日期:2014-05-16  浏览次数:20534 次

Hive-0.8.1索引的实验

先说一个0.7.1和0.8.1的Metastore不兼容

一。外部表的索引。

因为怕麻烦,就继续用之前的table02的数据,在new meta里也叫table02,不过改成了external表。最后的结论是Hive的索引也是支持外部表的。

建立索引,运行。还是6个mapper,不行。

二。建立内部表

CTAS from table02,建立一个内部表table03;

?

重点是,换了0.8.1,

<property>
? <name>hive.optimize.index.filter</name>
? <value>true</value>
? <description>Whether to enable automatic use of indexes</description>
</property>

建立了索引:

?

[sql] view plaincopyprint?
  1. hive>?create?index?table03_index?on?table?table03(id)??????????????????????
  2. ????>?as?'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'?????
  3. ????>?with?deferred?rebuild;???????????????????????????????????????????????
  4. OK??
  5. Time?taken:?2.221?seconds??
  6. hive>?show?tables;????????????
  7. OK??
  8. default__table02_compact_index__??
  9. default__table03_table03_index__??
  10. table02??
  11. table03??
  12. Time?taken:?1.073?seconds??
  13. hive>?dfs?-ls?/user/hive/warehouse/default__table03_table03_index__;????
  14. hive>?dfs?-ls?/user/hive/warehouse/default__table02_compact_index__;??
  15. Found?1?items??
  16. -rw-r--r--???1?allen?supergroup???74701985?2012-03-12?17:25?/user/hive/warehouse/default__table02_compact_index__/000000_0 ??
  17. hive>?alter?index?table03_index?on?table03?rebuild;??


现在重新query:

?

?

[sql] view plaincopyprint?
  1. hive>?select?*?from?table03?where?id=500000;???????????????????????????????
  2. Total?MapReduce?jobs?=?1??
  3. Launching?Job?1?