josephxsxn

Hive Bloom Filters

Jul 12th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.33 KB | None | 0 0
  1. set hive.tez.exec.print.summary=true;
  2. set hive.execution.engine=tez;
  3. create table stats_test_2 (line string) stored as orc;
  4. insert into table stats_test_2 values ('testval1'),('testval2');
  5. insert into table stats_test_2 values ('testval3'),('testval4');
  6. ALTER TABLE stats_test_2 SET TBLPROPERTIES('orc.create.index'='true','orc.bloom.filter.columns'='line','orc.bloom.filter.fpp'='0.05');
  7. Analyze table stats_test_2 COMPUTE STATISTICS FOR COLUMNS;
  8. select count(*), line from stats_test_2 where line='testval1' group by line;
  9.  
  10.  
  11. ALTER TABLE stats_test_2 SET TBLPROPERTIES('orc.create.index'='true','orc.bloom.filter.columns'=col,col2','orc.bloom.filter.fpp'='0.05');
  12.  
  13. --Analyze DOES NOT create bloom filters! They are only created at INSERT
  14. insert overwrite table $name select * from $table sort by line;
  15.  
  16. Then orcfile dump and look for the bloom filter entry in the stripe –
  17.  
  18. /usr/hdp/2.5.3.0-37/hive/bin/hive --orcfiledump /apps/hive/warehouse/jniemie8.db/stats_test_2/000000_0
  19. Processing data file /apps/hive/warehouse/jniemie8.db/stats_test_2/000000_0 [length: 406]
  20. Structure for /apps/hive/warehouse/jniemie8.db/stats_test_2/000000_0
  21. File Version: 0.12 with HIVE_13083
  22. 2017-07-12 10:41:49,382 INFO  [main] orc.ReaderImpl: Reading ORC rows from /apps/hive/warehouse/jniemie8.db/stats_test_2/000000_0 with {include: null, offset: 0, length: 9223372036854775807}
  23. 2017-07-12 10:41:49,384 INFO  [main] orc.RecordReaderImpl: Reader schema not provided -- using file schema struct<_col0:string>
  24. Rows: 2
  25. Compression: ZLIB
  26. Compression size: 262144
  27. Type: struct<_col0:string>
  28.  
  29. Stripe Statistics:
  30.  Stripe 1:
  31.    Column 0: count: 2 hasNull: false
  32.    Column 1: count: 2 hasNull: false min: testval3 max: testval4 sum: 16
  33.  
  34. File Statistics:
  35.  Column 0: count: 2 hasNull: false
  36.  Column 1: count: 2 hasNull: false min: testval3 max: testval4 sum: 16
  37.  
  38. Stripes:
  39.  Stripe: offset: 3 data: 22 rows: 2 tail: 60 index: 185
  40.    Stream: column 0 section ROW_INDEX start: 3 length 11
  41.    Stream: column 1 section ROW_INDEX start: 14 length 35
  42.    Stream: column 1 section BLOOM_FILTER start: 49 length 139
  43.    Stream: column 1 section DATA start: 188 length 16
  44.    Stream: column 1 section LENGTH start: 204 length 6
  45.    Encoding column 0: DIRECT
  46.    Encoding column 1: DIRECT_V2
  47.  
  48. File length: 406 bytes
  49. Padding length: 0 bytes
  50. Padding ratio: 0%
Add Comment
Please, Sign In to add comment