{"id":266,"date":"2024-11-23T09:50:56","date_gmt":"2024-11-23T01:50:56","guid":{"rendered":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/hive-%e5%bc%80%e5%90%af%e4%ba%8b%e5%8a%a1acid-%e8%bf%90%e8%a1%8c%e5%88%a0%e5%92%8c%e6%94%b9%e6%93%8d%e4%bd%9c\/"},"modified":"2024-11-23T09:50:56","modified_gmt":"2024-11-23T01:50:56","slug":"hive-%e5%bc%80%e5%90%af%e4%ba%8b%e5%8a%a1acid-%e8%bf%90%e8%a1%8c%e5%88%a0%e5%92%8c%e6%94%b9%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/hive-%e5%bc%80%e5%90%af%e4%ba%8b%e5%8a%a1acid-%e8%bf%90%e8%a1%8c%e5%88%a0%e5%92%8c%e6%94%b9%e6%93%8d%e4%bd%9c\/","title":{"rendered":"Hive \u5f00\u542f\u4e8b\u52a1ACID  \u8fd0\u884c\u5220\u548c\u6539\u64cd\u4f5c"},"content":{"rendered":"<h1>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Hive \u5f00\u542f\u4e8b\u52a1ACID\u00a0 \u8fd0\u884c\u5220\u548c\u6539\u64cd\u4f5c<br \/>\n<\/h1>\n<p><\/p>\n<h2>\u4e8b\u52a1\u8868\u7684\u9002\u7528\u573a\u666f<br \/>\n<\/h2>\n<p>\u5bf9\u4e8e\u6570\u4ed3\u4e2d\u7684\u884c\u7ea7\u6570\u636e\u66f4\u65b0\u5220\u9664\u9700\u6c42\u6bd4\u8f83\u9891\u7e41\u7684\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e8b\u52a1\u8868\u3002<\/p>\n<p>\u4f46\u5e73\u5e38\u7684hive\u8868\u5e76\u4e0d\u5efa\u8bae\u4f7f\u7528\u4e8b\u52a1\u8868\u3002\u56e0\u4e3a\u4e8b\u52a1\u8868\u7684\u9650\u5236\u5f88\u591a\uff0c\u52a0\u4e0a\u7531\u4e8ehive\u8868\u7684\u7279\u6027\uff0c\u4e5f\u5f88\u96be\u6ee1\u8db3\u9ad8\u5e76\u53d1\u7684\u573a\u666f\u3002\u53e6\u5916\uff0c\u5982\u679c\u4e8b\u52a1\u8868\u592a\u591a\uff0c\u5e76\u4e14\u5b58\u5728\u5927\u91cf\u7684\u66f4\u65b0\u64cd\u4f5c\uff0cmetastore\u540e\u53f0\u542f\u52a8\u7684\u5408\u5e76\u7ebf\u7a0b\u4f1a\u5b9a\u671f\u7684\u63d0\u4ea4MapReduce Job\uff0c\u4e5f\u4f1a\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u589e\u91cd\u96c6\u7fa4\u7684\u8d1f\u62c5\u3002<\/p>\n<p><b>\u7ed3\u8bba\uff1a \u9664\u975e\u6709\u975e\u5e38\u8feb\u5207\u7684\u884c\u7ea7\u66f4\u65b0\u9700\u6c42\uff0c\u53c8\u53ea\u80fd\u7528hive\u8868\u6765\u505a\uff0c\u624d\u9700\u8981\u53bb\u8003\u8651\u4e8b\u52a1\u8868\u3002<\/b><\/p>\n<h3><b>\u6ce8\u610f\u4e8b\u9879<\/b><\/h3>\n<p><b>\u4e0d\u652f\u6301 BEGIN\u3001COMMIT\u3001ROLLBACK \u7b49\u8bed\u53e5\uff0c\u6240\u6709\u7684\u8bed\u53e5\u90fd\u662f\u81ea\u52a8\u63d0\u4ea4<\/b><\/p>\n<p><b>\u4ec5\u652f\u6301ORC\u683c\u5f0f<\/b><\/p>\n<h2>\u8bbe\u7f6e\u5f00\u542f\u4e8b\u52a1<\/h2>\n<h3>1\u3001\u914d\u7f6eHive\u652f\u6301\u4e8b\u52a1\uff08Hive 2.0\u7248\uff09<br \/>\n<\/h3>\n<p><property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.support.concurrency<\/name><\/p>\n<p>\u00a0 \u00a0 <value>true<\/value><\/p>\n<\/p>\n<p><property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.exec.dynamic.partition.mode<\/name><\/p>\n<p>\u00a0 \u00a0 <value>nonstrict<\/value><\/p>\n<\/p>\n<p><property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.txn.manager<\/name><\/p>\n<p>\u00a0 \u00a0 <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager<\/value><\/p>\n<\/p>\n<p><property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.compactor.initiator.on<\/name><\/p>\n<p>\u00a0 \u00a0 <value>true<\/value><\/p>\n<\/p>\n<p><property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.compactor.worker.threads<\/name><\/p>\n<p>\u00a0 \u00a0 <value>1<\/value><\/p>\n<\/p>\n<p>\u00a0 <property><\/property><\/p>\n<p>\u00a0 \u00a0 <name>hive.enforce.bucketing<\/name><\/p>\n<p>\u00a0 \u00a0 <value>true<\/value><\/p>\n<p>\u00a0 <\/p>\n<h3>2\u3001\u6d4b\u8bd5<\/h3>\n<p><\/p>\n<p>&#8211;\u4e8b\u52a1\u8868\u00a0 \u80fd\u66f4\u65b0\u7684 \u5fc5\u987b\u662f\u5206\u6876\u7684\uff08\u53ef\u4ee5\u5206\u533a\uff09 \u5b58\u50a8\u4e3aorc \u7684\u8868\u5e76\u5728\u5c5e\u6027\u4e2d\u8fd0\u884c\u4e8b\u52a1\u624d\u53ef\u4ee5<\/p>\n<p>&#8212; \u5206\u533a\u5206\u6876\u8868<\/p>\n<p>CREATE\u00a0 TABLE t2 (id INT, name STRING) PARTITIONED BY (country STRING, state STRING)<\/p>\n<p>CLUSTERED BY (id) INTO 8 BUCKETS<\/p>\n<p>STORED AS ORC TBLPROPERTIES (&#8216;transactional&#8217;=&#8217;true&#8217;);<\/p>\n<p><\/p>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 700px; max-height: 91px;\">\n<div class=\"image-view\" data-width=\"848\" data-height=\"91\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-0ecbc8e0073230ac6924f8b8f0e5a02b.png\"><\/div>\n<\/div>\n<div class=\"image-caption\"><\/div>\n<\/div>\n<p>insert into t2 partition(country=&#8217;cn&#8217;,state=&#8217;sd&#8217;)\u00a0 values(1,&#8217;ceshi&#8217;);<\/p>\n<p><\/p>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 520px; max-height: 145px;\">\n<div class=\"image-view\" data-width=\"520\" data-height=\"145\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-d4b713ddb599333848b70a23273873e0.png\"><\/div>\n<\/div>\n<div class=\"image-caption\"><\/div>\n<\/div>\n<p>update t2<\/p>\n<p>set name=&#8217;good&#8217;<\/p>\n<p>where id=1;<\/p>\n<p><\/p>\n<div class=\"image-package\">\n<div class=\"image-container\" style=\"max-width: 500px; max-height: 145px;\">\n<div class=\"image-view\" data-width=\"500\" data-height=\"145\"><img decoding=\"async\" src=\"https:\/\/obagg.com\/wp-content\/uploads\/2024\/11\/frc-c046cf7fc08331d482cea6c94721d4de.png\"><\/div>\n<\/div>\n<div class=\"image-caption\"><\/div>\n<\/div>\n<p>delete from t2 where id =1;<\/p>\n<p>Please credit: <a href=\"https:\/\/obagg.com\">OBA Blog<\/a> &raquo; <a href=\"https:\/\/obagg.com\/index.php\/2024\/11\/23\/hive-%e5%bc%80%e5%90%af%e4%ba%8b%e5%8a%a1acid-%e8%bf%90%e8%a1%8c%e5%88%a0%e5%92%8c%e6%94%b9%e6%93%8d%e4%bd%9c\/\">Hive \u5f00\u542f\u4e8b\u52a1ACID  \u8fd0\u884c\u5220\u548c\u6539\u64cd\u4f5c<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Hive \u5f00\u542f\u4e8b\u52a1ACID\u00a0 \u8fd0\u884c\u5220\u548c\u6539\u64cd\u4f5c \u4e8b\u52a1\u8868\u7684\u9002\u7528\u573a\u666f \u5bf9\u4e8e\u6570\u4ed3\u4e2d\u7684\u884c\u7ea7\u6570\u636e\u66f4\u65b0\u5220\u9664\u9700\u6c42\u6bd4\u8f83\u9891\u7e41\u7684\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e8b\u52a1\u8868\u3002 \u4f46\u5e73\u5e38\u7684hive\u8868\u5e76\u4e0d\u5efa\u8bae\u4f7f\u7528\u4e8b\u52a1\u8868\u3002\u56e0\u4e3a\u4e8b\u52a1\u8868\u7684\u9650\u5236\u5f88\u591a\uff0c\u52a0\u4e0a\u7531\u4e8ehive\u8868\u7684\u7279\u6027\uff0c\u4e5f\u5f88\u96be\u6ee1\u8db3\u9ad8\u5e76\u53d1\u7684\u573a\u666f\u3002\u53e6\u5916\uff0c\u5982\u679c\u4e8b\u52a1\u8868\u592a\u591a\uff0c\u5e76\u4e14\u5b58\u5728\u5927\u91cf\u7684\u66f4\u65b0\u64cd\u4f5c\uff0cmetastore\u540e\u53f0\u542f\u52a8\u7684\u5408\u5e76\u7ebf\u7a0b\u4f1a\u5b9a\u671f\u7684\u63d0\u4ea4MapReduce Job\uff0c\u4e5f\u4f1a\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u589e\u91cd\u96c6\u7fa4\u7684\u8d1f\u62c5\u3002 \u7ed3\u8bba\uff1a \u9664\u975e\u6709\u975e\u5e38\u8feb\u5207\u7684\u884c\u7ea7\u66f4\u65b0\u9700\u6c42\uff0c\u53c8\u53ea\u80fd\u7528hive\u8868\u6765\u505a\uff0c\u624d\u9700\u8981\u53bb\u8003\u8651\u4e8b\u52a1\u8868\u3002 \u6ce8\u610f\u4e8b\u9879 \u4e0d\u652f\u6301 BEGIN\u3001COMMIT\u3001ROLLBACK \u7b49\u8bed\u53e5\uff0c\u6240\u6709\u7684\u8bed\u53e5\u90fd\u662f\u81ea\u52a8\u63d0\u4ea4 \u4ec5\u652f\u6301ORC\u683c\u5f0f \u8bbe\u7f6e\u5f00\u542f\u4e8b\u52a1 1\u3001\u914d\u7f6eHive\u652f\u6301\u4e8b\u52a1\uff08Hive 2.0\u7248\uff09 \u00a0 \u00a0 hive.support.concurrency \u00a0 \u00a0 true \u00a0 \u00a0 hive.exec.dynamic.partition.mode \u00a0 \u00a0 nonstrict \u00a0 \u00a0 hive.txn.manager \u00a0 \u00a0 org.apache.hadoop.hive.ql.lockmgr.DbTxnManager \u00a0 \u00a0 hive.compactor.initiator.on \u00a0 \u00a0 true \u00a0 \u00a0 hive.compactor.worker.threads \u00a0 \u00a0 1 \u00a0 \u00a0 \u00a0 hive.enforce.bucketing \u00a0 \u00a0 true \u00a0 2\u3001\u6d4b\u8bd5 &#8211;\u4e8b\u52a1\u8868\u00a0 \u80fd\u66f4\u65b0\u7684 \u5fc5\u987b\u662f\u5206\u6876\u7684\uff08\u53ef\u4ee5\u5206\u533a\uff09 \u5b58\u50a8\u4e3aorc \u7684\u8868\u5e76\u5728\u5c5e\u6027\u4e2d\u8fd0\u884c\u4e8b\u52a1\u624d\u53ef\u4ee5 &#8212; \u5206\u533a\u5206\u6876\u8868 CREATE\u00a0 TABLE t2 (id INT, name STRING) PARTITIONED BY (country STRING, state STRING) CLUSTERED BY (id) INTO 8 BUCKETS STORED AS ORC TBLPROPERTIES (&#8216;transactional&#8217;=&#8217;true&#8217;); insert into t2 partition(country=&#8217;cn&#8217;,state=&#8217;sd&#8217;)\u00a0 values(1,&#8217;ceshi&#8217;); update t2 set name=&#8217;good&#8217; where id=1; delete from t2 where id =1; Please credit: OBA Blog &raquo; Hive \u5f00\u542f\u4e8b\u52a1ACID \u8fd0\u884c\u5220\u548c\u6539\u64cd\u4f5c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-share"],"_links":{"self":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/comments?post=266"}],"version-history":[{"count":0,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/266\/revisions"}],"wp:attachment":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/media?parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/categories?post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/tags?post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}