private Path writeStoreFile(int t, BloomType bt, List<KeyValue> kvs) throws IOException { conf.setInt(BloomFilterFactory.IO_STOREFILE_BLOOM_BLOCK_SIZE, BLOOM_BLOCK_SIZES[t]); conf.setBoolean(CacheConfig.CACHE_BLOCKS_ON_WRITE_KEY, true); cacheConf = new CacheConfig(conf); HFileContext meta = new HFileContextBuilder().withBlockSize(BLOCK_SIZES[t]).build(); StoreFile.Writer w = new StoreFile.WriterBuilder(conf, cacheConf, fs) .withOutputDir(TEST_UTIL.getDataTestDir()) .withBloomType(bt) .withFileContext(meta) .build(); assertTrue(w.hasGeneralBloom()); assertTrue(w.getGeneralBloomWriter() instanceof CompoundBloomFilterWriter); CompoundBloomFilterWriter cbbf = (CompoundBloomFilterWriter) w.getGeneralBloomWriter(); int keyCount = 0; KeyValue prev = null; LOG.debug("Total keys/values to insert: " + kvs.size()); for (KeyValue kv : kvs) { w.append(kv); // Validate the key count in the Bloom filter. boolean newKey = true; if (prev != null) { newKey = !(bt == BloomType.ROW ? KeyValue.COMPARATOR.matchingRows(kv, prev) : KeyValue.COMPARATOR.matchingRowColumn(kv, prev)); } if (newKey) ++keyCount; assertEquals(keyCount, cbbf.getKeyCount()); prev = kv; } w.close(); return w.getPath(); }
private Path writeStoreFile(int t, BloomType bt, List<KeyValue> kvs) throws IOException { conf.setInt(BloomFilterFactory.IO_STOREFILE_BLOOM_BLOCK_SIZE, BLOOM_BLOCK_SIZES[t]); conf.setBoolean(CacheConfig.CACHE_BLOCKS_ON_WRITE_KEY, true); cacheConf = new CacheConfig(conf); StoreFile.Writer w = new StoreFile.WriterBuilder(conf, cacheConf, fs, BLOCK_SIZES[t]) .withOutputDir(TEST_UTIL.getDataTestDir()) .withBloomType(bt) .withChecksumType(HFile.DEFAULT_CHECKSUM_TYPE) .withBytesPerChecksum(HFile.DEFAULT_BYTES_PER_CHECKSUM) .build(); assertTrue(w.hasGeneralBloom()); assertTrue(w.getGeneralBloomWriter() instanceof CompoundBloomFilterWriter); CompoundBloomFilterWriter cbbf = (CompoundBloomFilterWriter) w.getGeneralBloomWriter(); int keyCount = 0; KeyValue prev = null; LOG.debug("Total keys/values to insert: " + kvs.size()); for (KeyValue kv : kvs) { w.append(kv); // Validate the key count in the Bloom filter. boolean newKey = true; if (prev != null) { newKey = !(bt == BloomType.ROW ? KeyValue.COMPARATOR.matchingRows(kv, prev) : KeyValue.COMPARATOR.matchingRowColumn(kv, prev)); } if (newKey) ++keyCount; assertEquals(keyCount, cbbf.getKeyCount()); prev = kv; } w.close(); return w.getPath(); }