if (currBlock >= reader.getDataBlockIndexReader().getRootBlockCount()) {
new CacheConfig(fs.getConf()), fs.getConf()); BlockIndexReader bir = reader.getDataBlockIndexReader(); int blockCount = bir.getRootBlockCount(); reader.close();
@Override public void close(boolean evictOnClose) throws IOException { if (evictOnClose && cacheConf.isBlockCacheEnabled()) { int numEvicted = 0; for (int i = 0; i < dataBlockIndexReader.getRootBlockCount(); i++) { if (cacheConf.getBlockCache().evictBlock( new BlockCacheKey(name, dataBlockIndexReader.getRootBlockOffset(i), DataBlockEncoding.NONE, BlockType.DATA))) { numEvicted++; } } LOG.debug("On close of file " + name + " evicted " + numEvicted + " block(s) of " + dataBlockIndexReader.getRootBlockCount() + " total blocks"); } if (this.closeIStream && this.istream != null) { this.istream.close(); this.istream = null; } getSchemaMetrics().flushMetrics(); }
int blockCount = bir.getRootBlockCount();
int blockCount = bir.getRootBlockCount();
throw new IOException("Block index not loaded"); if (block < 0 || block >= dataBlockIndexReader.getRootBlockCount()) { throw new IOException("Requested block is out of range: " + block + ", max: " + dataBlockIndexReader.getRootBlockCount()); long nextOffset; if (block == dataBlockIndexReader.getRootBlockCount() - 1) { nextOffset = (metaBlockIndexReader.getRootBlockCount() == 0) ? this.trailer.getFileInfoOffset() : metaBlockIndexReader.getRootBlockOffset(0);
long offset = metaBlockIndexReader.getRootBlockOffset(block); long nextOffset; if (block == metaBlockIndexReader.getRootBlockCount() - 1) { nextOffset = trailer.getFileInfoOffset(); } else {
new CacheConfig(fs.getConf()), fs.getConf()); BlockIndexReader bir = reader.getDataBlockIndexReader(); int blockCount = bir.getRootBlockCount(); reader.close();
protected void testSeekToInternals(TagUsage tagUsage) throws IOException { Path p = makeNewFile(tagUsage); FileSystem fs = TEST_UTIL.getTestFileSystem(); Configuration conf = TEST_UTIL.getConfiguration(); HFile.Reader reader = HFile.createReader(fs, p, new CacheConfig(conf), true, conf); reader.loadFileInfo(); assertEquals(2, reader.getDataBlockIndexReader().getRootBlockCount()); HFileScanner scanner = reader.getScanner(false, true); // lies before the start of the file. assertEquals(-1, scanner.seekTo(toKV("a", tagUsage))); assertEquals(1, scanner.seekTo(toKV("d", tagUsage))); assertEquals("c", toRowStr(scanner.getCell())); // Across a block boundary now. // 'h' does not exist so we will get a '1' back for not found. assertEquals(0, scanner.seekTo(toKV("i", tagUsage))); assertEquals("i", toRowStr(scanner.getCell())); assertEquals(1, scanner.seekTo(toKV("l", tagUsage))); assertEquals("k", toRowStr(scanner.getCell())); reader.close(); deleteTestDir(fs); }
protected void testSeekToInternals(TagUsage tagUsage) throws IOException { Path p = makeNewFile(tagUsage); FileSystem fs = TEST_UTIL.getTestFileSystem(); Configuration conf = TEST_UTIL.getConfiguration(); HFile.Reader reader = HFile.createReader(fs, p, new CacheConfig(conf), true, conf); reader.loadFileInfo(); assertEquals(2, reader.getDataBlockIndexReader().getRootBlockCount()); HFileScanner scanner = reader.getScanner(false, true); // lies before the start of the file. assertEquals(-1, scanner.seekTo(toKV("a", tagUsage))); assertEquals(1, scanner.seekTo(toKV("d", tagUsage))); assertEquals("c", toRowStr(scanner.getCell())); // Across a block boundary now. // 'h' does not exist so we will get a '1' back for not found. assertEquals(0, scanner.seekTo(toKV("i", tagUsage))); assertEquals("i", toRowStr(scanner.getCell())); assertEquals(1, scanner.seekTo(toKV("l", tagUsage))); assertEquals("k", toRowStr(scanner.getCell())); reader.close(); deleteTestDir(fs); }