{"id":163578,"date":"2020-10-02T14:33:53","date_gmt":"2020-10-02T06:33:53","guid":{"rendered":"http:\/\/4563.org\/?p=163578"},"modified":"2020-10-02T14:33:53","modified_gmt":"2020-10-02T06:33:53","slug":"%e5%9c%a8%e5%ae%b9%e5%99%a8%e9%87%8c-parse-%e5%a4%a7%e4%bd%93%e7%a7%af%e7%9a%84-json-%e6%96%87%e4%bb%b6%e5%88%b0-postgres-%e6%9c%89%e4%bb%80%e4%b9%88%e5%a5%bd%e5%8a%9e%e6%b3%95%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=163578","title":{"rendered":"\u5728\u5bb9\u5668\u91cc Parse \u5927\u4f53\u79ef\u7684 JSON \u6587\u4ef6\u5230 Postgres \u6709\u4ec0\u4e48\u597d\u529e\u6cd5\u5417\uff1f\u4e3b\u8981\u662f\u5185\u5b58\u5360\u7528\u8fd8\u6709\u6548\u7387\u95ee\u9898\u3002"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5728\u5bb9\u5668\u91cc Parse \u5927\u4f53\u79ef\u7684 JSON \u6587\u4ef6\u5230 Postgres \u6709\u4ec0\u4e48\u597d\u529e\u6cd5\u5417\uff1f\u4e3b\u8981\u662f\u5185\u5b58\u5360\u7528\u8fd8\u6709\u6548\u7387\u95ee\u9898\u3002               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nuistzhou <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>10+G \u7684 JSON \u6587\u4ef6\uff0c\u5927\u6982\u6709\u51e0\u5343\u4e07\u6761\u8bb0\u5f55\uff0c\u6bcf\u6761\u8bb0\u5f55\u7684 fields \u6216\u591a\u6216\u5c11\u4e0d\u592a\u4e00\u6837\uff0c\u73b0\u5728\u6211\u60f3\u628a\u8fd9\u4e2a json \u5f04\u5230 Postgres \u91cc\uff0c\u800c\u4e14\u53ea\u60f3\u8981\u5176\u4e2d\u7684 2 \u4e2a\u516c\u5171 fields \uff08\u6240\u6709\u7684\u8bb0\u5f55\u90fd\u6709\u8fd9\u4e24\u4e2a\u5c5e\u6027\uff09\u3002\u5bf9\u4e86\uff0c\u5bb9\u5668\u6211\u53ea\u7ed9\u4e86 2G \u5185\u5b58\uff0c\u9664\u53bb\u8fd0\u884c\u7684\u7a0b\u5e8f\uff0c\u53ef\u80fd\u53ea\u5269 700MB+\u7684\u7a7a\u4f59\u5185\u5b58\u4e86\u3002<\/p>\n<p>\u73b0\u5728\u7684 2 \u4e2a\u60f3\u6cd5\u662f\uff1a<\/p>\n<p>1 \u3001\u7528 Pandas \u7684 read_json()\u7684 chunksize \u6765\u628a json \u8bfb\u53d6\u6210\u6d41\u6587\u4ef6\uff0c\u7136\u540e\u4e00\u4e2a chunk \u63a5\u4e00\u4e2a chunk \u5730\u8bfb\u53d6\u5230\u5185\u5b58\uff0c\u7136\u540e\u5199\u5230\u6570\u636e\u5e93\u91cc\u3002 \u4f46\u662f\u6211\u5728\u5bb9\u5668\u91cc\u5b9e\u73b0\u65f6\uff0c\u6bcf\u6b21\u90fd\u662f python \u8fdb\u7a0b\u88ab kill \u4e86\uff0c\u53ef\u80fd\u662f\u5185\u5b58\u95ee\u9898\uff0c\u4f46\u6211\u7684 chunksize \u586b 10 \u4e5f\u4e00\u6837\u5931\u8d25\uff0c10 \u884c\u6570\u636e\u4e5f\u4e0d\u5927\u5440\uff0c\u767e\u601d\u4e0d\u5f97\u5176\u89e3\u3002<\/p>\n<p>2 \u3001\u60f3\u7528 Bash \u7684 jq \u6765\u5904\u7406\uff0c\u4f46\u662f\u6ca1\u6709\u7ecf\u9a8c\uff0c\u4e0d\u77e5\u9053\u662f\u5426\u53ef\u884c\uff0c\u4ee5\u53ca\u5728\u5bb9\u5668\u4e0a\u6267\u884c\u7684\u6548\u7387\u8fd8\u6709\u5185\u5b58\u5360\u7528\u95ee\u9898\u3002<\/p>\n<p>\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u5927\u4f6c\u80fd\u6307\u70b9\u4e00\u4e0b\uff0c\u6bd4\u5982\u6709\u6ca1\u6709\u66f4\u597d\u7684\u6d41\u5904\u7406\u529e\u6cd5\uff0c\u8c22\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3570811\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pabupa <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u867d\u7136 chunk \u5f88\u5c0f\uff0c\u4f46\u662f\u6700\u7ec8\u7ed3\u679c\u80af\u5b9a\u6bd4\u5185\u5b58\u5927\u3002<\/p>\n<p>\u6240\u4ee5\uff1a<\/p>\n<p>1\uff0c\u53bb\u6389\u6587\u4ef6\u4e2d\u7684\u6700\u5916\u5c42\u5305\u88f9\u5b57\u7b26\uff0c\u53ea\u5269\u4e0b`{key:val,&#8230;}&#8230;`<br \/>2\uff0c\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5b57\u7b26\uff0c\u76f4\u5230`}`\u4e3a\u6b62\uff0c\u7136\u540e\u5c1d\u8bd5\u89e3\u6790 buffer \u3002\u89e3\u6790\u6210\u529f\uff0c\u5219\u7ee7\u7eed\u4e0b\u4e00\u4e2a document \uff1b\u89e3\u6790\u4e0d\u6210\u529f\uff0c\u5c31\u7ee7\u7eed\u627e\u4e0b\u4e00\u4e2a`}`\uff0c\u66f4\u65b0 buffer \u3002<br \/>3\uff0c \u6bcf\u6210\u529f\u89e3\u6790 N \u4e2a\u5c31\u5199\u4e00\u6b21\u6570\u636e\u5e93\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3570812\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : nuistzhou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @pabupa \u8c22\u8c22\uff01\u867d\u7136\u6211\u5df2\u7ecf\u641e\u5b9a\u4e86\uff0c\u4f46\u53d1\u73b0\u5199 9 \u767e\u4e07\u6570\u636e\u90fd\u8981\u51e0\u4e2a\u5c0f\u65f6\uff0c\u592a\u6050\u6016\u4e86\uff0c\u90a3\u6211\u53e6\u4e00\u4e2a 8 \u5343\u4e07\u6761\u7684\u6587\u4ef6\u5c82\u4e0d\u662f\u8981\u75af\u4e86\u3002\u5728\u8003\u8651\u7528 spark \u4e4b\u7c7b\u7684\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5bb9\u5668\u91cc Parse \u5927\u4f53\u79ef\u7684 J&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/163578"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=163578"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/163578\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163578"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}