System.out.println(blockIndexReader.toString()); assertEquals(-1, blockIndexReader.rootBlockContainingKey( toKV("a", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("c", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("d", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("e", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("g", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey(toKV("h", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("i", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("j", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("k", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("l", tagUsage))); reader.close();
/** * @param key Key to search. * @return Block number of the block containing the key or -1 if not in this * file. */ protected int blockContainingKey(final byte[] key, int offset, int length) { Preconditions.checkState(!dataBlockIndexReader.isEmpty(), "Block index not loaded"); return dataBlockIndexReader.rootBlockContainingKey(key, offset, length); }
int block = index.rootBlockContainingKey(key, keyOffset, keyLength); if (block < 0) { result = false; // This key is not in the file.
boolean pread, boolean isCompaction, DataBlockEncoding expectedDataBlockEncoding) throws IOException { int rootLevelIndex = rootBlockContainingKey(key); if (rootLevelIndex < 0 || rootLevelIndex >= blockOffsets.length) { return null;
boolean pread, boolean isCompaction) throws IOException { int rootLevelIndex = rootBlockContainingKey(key, keyOffset, keyLength); if (rootLevelIndex < 0 || rootLevelIndex >= blockOffsets.length) { return null;
int block = metaBlockIndexReader.rootBlockContainingKey(nameBytes, 0, nameBytes.length); if (block == -1)
int block = metaBlockIndexReader.rootBlockContainingKey(mbname, 0, mbname.length); if (block == -1)
int block = metaBlockIndexReader.rootBlockContainingKey(mbname, 0, mbname.length); if (block == -1)
int block = index.rootBlockContainingKey(key, keyOffset, keyLength); if (block < 0) {
System.out.println(blockIndexReader.toString()); assertEquals(-1, blockIndexReader.rootBlockContainingKey( toKV("a", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("c", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("d", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("e", tagUsage))); assertEquals(0, blockIndexReader.rootBlockContainingKey( toKV("g", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey(toKV("h", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("i", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("j", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("k", tagUsage))); assertEquals(1, blockIndexReader.rootBlockContainingKey( toKV("l", tagUsage))); reader.close();
@Override public boolean contains(byte[] key, int keyOffset, int keyLength, ByteBuff bloom) { int block = index.rootBlockContainingKey(key, keyOffset, keyLength); if (block < 0) { return false; // This key is not in the file. } boolean result; HFileBlock bloomBlock = getBloomBlock(block); try { ByteBuff bloomBuf = bloomBlock.getBufferReadOnly(); result = BloomFilterUtil.contains(key, keyOffset, keyLength, bloomBuf, bloomBlock.headerSize(), bloomBlock.getUncompressedSizeWithoutHeader(), hash, hashCount); } finally { // After the use return back the block if it was served from a cache. reader.returnBlock(bloomBlock); } if (numPositivesPerChunk != null && result) { // Update statistics. Only used in unit tests. ++numPositivesPerChunk[block]; } return result; }
@Override public boolean contains(Cell keyCell, ByteBuff bloom, BloomType type) { int block = index.rootBlockContainingKey(keyCell); if (block < 0) { return false; // This key is not in the file. } boolean result; HFileBlock bloomBlock = getBloomBlock(block); try { ByteBuff bloomBuf = bloomBlock.getBufferReadOnly(); result = BloomFilterUtil.contains(keyCell, bloomBuf, bloomBlock.headerSize(), bloomBlock.getUncompressedSizeWithoutHeader(), hash, hashCount, type); } finally { // After the use return back the block if it was served from a cache. reader.returnBlock(bloomBlock); } if (numPositivesPerChunk != null && result) { // Update statistics. Only used in unit tests. ++numPositivesPerChunk[block]; } return result; }
/** * Finds the root-level index block containing the given key. * * @param key * Key to find * @return Offset of block containing <code>key</code> (between 0 and the * number of blocks - 1) or -1 if this file does not contain the * request. */ // When we want to find the meta index block or bloom block for ROW bloom // type // Bytes.BYTES_RAWCOMPARATOR would be enough. For the ROW_COL bloom case we // need the CellComparator. public int rootBlockContainingKey(final byte[] key, int offset, int length) { return rootBlockContainingKey(key, offset, length, null); }