CellComparator createComparator() throws IOException { expectAtLeastMajorVersion(2); return createComparator(comparatorClassName); }
comparator = FixedFileTrailer.createComparator(Bytes.toString(comparatorClassName));
@Test public void testCreateComparator() throws IOException { FixedFileTrailer t = new FixedFileTrailer(version, HFileReaderImpl.PBUF_TRAILER_MINOR_VERSION); try { assertEquals(CellComparatorImpl.class, t.createComparator(KeyValue.COMPARATOR.getLegacyKeyComparatorName()).getClass()); assertEquals(CellComparatorImpl.class, t.createComparator(KeyValue.COMPARATOR.getClass().getName()).getClass()); assertEquals(CellComparatorImpl.class, t.createComparator(CellComparator.class.getName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(KeyValue.META_COMPARATOR.getClass().getName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator( CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass()); assertNull(t.createComparator(Bytes.BYTES_RAWCOMPARATOR.getClass().getName())); assertNull(t.createComparator("org.apache.hadoop.hbase.KeyValue$RawBytesComparator")); } catch (IOException e) { fail("Unexpected exception while testing FixedFileTrailer#createComparator()"); } // Test an invalid comparatorClassName expectedEx.expect(IOException.class); t.createComparator(""); }
private void checkLoadedTrailer(int version, FixedFileTrailer expected, FixedFileTrailer loaded) throws IOException { assertEquals(version, loaded.getMajorVersion()); assertEquals(expected.getDataIndexCount(), loaded.getDataIndexCount()); assertEquals(Math.min(expected.getEntryCount(), version == 1 ? Integer.MAX_VALUE : Long.MAX_VALUE), loaded.getEntryCount()); if (version == 1) { assertEquals(expected.getFileInfoOffset(), loaded.getFileInfoOffset()); } if (version == 2) { assertEquals(expected.getLastDataBlockOffset(), loaded.getLastDataBlockOffset()); assertEquals(expected.getNumDataIndexLevels(), loaded.getNumDataIndexLevels()); assertEquals(expected.createComparator().getClass().getName(), loaded.createComparator().getClass().getName()); assertEquals(expected.getFirstDataBlockOffset(), loaded.getFirstDataBlockOffset()); assertTrue( expected.createComparator() instanceof CellComparatorImpl); assertEquals(expected.getUncompressedDataIndexSize(), loaded.getUncompressedDataIndexSize()); } assertEquals(expected.getLoadOnOpenDataOffset(), loaded.getLoadOnOpenDataOffset()); assertEquals(expected.getMetaIndexCount(), loaded.getMetaIndexCount()); assertEquals(expected.getTotalUncompressedBytes(), loaded.getTotalUncompressedBytes()); }
new HFileBlock.FSReaderImpl(fsdis, fileSize, meta); CellComparator comparator = trailer.createComparator(); HFileBlockIndex.BlockIndexReader dataBlockIndexReader = new HFileBlockIndex.CellBasedKeyBlockIndexReader(comparator,
comparator = trailer.createComparator(); dataBlockIndexReader = new HFileBlockIndex.CellBasedKeyBlockIndexReader(comparator, trailer.getNumDataIndexLevels(), this);
RawComparator<byte[]> createComparator() throws IOException { expectAtLeastMajorVersion(2); return createComparator(comparatorClassName); }
KVComparator createComparator() throws IOException { expectAtLeastMajorVersion(2); return createComparator(comparatorClassName); }
/** * De-serialization for compound Bloom filter metadata. Must be consistent * with what {@link CompoundBloomFilterWriter} does. * * @param meta serialized Bloom filter metadata without any magic blocks * @throws IOException */ public CompoundBloomFilter(DataInput meta, HFile.Reader reader) throws IOException { this.reader = reader; totalByteSize = meta.readLong(); hashCount = meta.readInt(); hashType = meta.readInt(); totalKeyCount = meta.readLong(); totalMaxKeys = meta.readLong(); numChunks = meta.readInt(); comparator = FixedFileTrailer.createComparator( Bytes.toString(Bytes.readByteArray(meta))); hash = Hash.getInstance(hashType); if (hash == null) { throw new IllegalArgumentException("Invalid hash type: " + hashType); } index = new HFileBlockIndex.BlockIndexReader(comparator, 1); index.readRootIndex(meta, numChunks); }
/** * De-serialization for compound Bloom filter metadata. Must be consistent * with what {@link CompoundBloomFilterWriter} does. * * @param meta serialized Bloom filter metadata without any magic blocks * @throws IOException */ public CompoundBloomFilter(DataInput meta, HFile.Reader reader) throws IOException { this.reader = reader; totalByteSize = meta.readLong(); hashCount = meta.readInt(); hashType = meta.readInt(); totalKeyCount = meta.readLong(); totalMaxKeys = meta.readLong(); numChunks = meta.readInt(); comparator = FixedFileTrailer.createComparator( Bytes.toString(Bytes.readByteArray(meta))); hash = Hash.getInstance(hashType); if (hash == null) { throw new IllegalArgumentException("Invalid hash type: " + hashType); } index = new HFileBlockIndex.BlockIndexReader(comparator, 1); index.readRootIndex(meta, numChunks); }
@Test public void testCreateComparator() throws IOException { FixedFileTrailer t = new FixedFileTrailer(version, HFileReaderImpl.PBUF_TRAILER_MINOR_VERSION); try { assertEquals(CellComparatorImpl.class, t.createComparator(KeyValue.COMPARATOR.getLegacyKeyComparatorName()).getClass()); assertEquals(CellComparatorImpl.class, t.createComparator(KeyValue.COMPARATOR.getClass().getName()).getClass()); assertEquals(CellComparatorImpl.class, t.createComparator(CellComparator.class.getName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator(KeyValue.META_COMPARATOR.getClass().getName()).getClass()); assertEquals(CellComparatorImpl.MetaCellComparator.class, t.createComparator( CellComparatorImpl.MetaCellComparator.META_COMPARATOR.getClass().getName()).getClass()); assertNull(t.createComparator(Bytes.BYTES_RAWCOMPARATOR.getClass().getName())); assertNull(t.createComparator("org.apache.hadoop.hbase.KeyValue$RawBytesComparator")); } catch (IOException e) { fail("Unexpected exception while testing FixedFileTrailer#createComparator()"); } // Test an invalid comparatorClassName expectedEx.expect(IOException.class); t.createComparator(""); }
private void checkLoadedTrailer(int version, FixedFileTrailer expected, FixedFileTrailer loaded) throws IOException { assertEquals(version, loaded.getMajorVersion()); assertEquals(expected.getDataIndexCount(), loaded.getDataIndexCount()); assertEquals(Math.min(expected.getEntryCount(), version == 1 ? Integer.MAX_VALUE : Long.MAX_VALUE), loaded.getEntryCount()); if (version == 1) { assertEquals(expected.getFileInfoOffset(), loaded.getFileInfoOffset()); } if (version == 2) { assertEquals(expected.getLastDataBlockOffset(), loaded.getLastDataBlockOffset()); assertEquals(expected.getNumDataIndexLevels(), loaded.getNumDataIndexLevels()); assertEquals(expected.createComparator().getClass().getName(), loaded.createComparator().getClass().getName()); assertEquals(expected.getFirstDataBlockOffset(), loaded.getFirstDataBlockOffset()); assertTrue( expected.createComparator() instanceof CellComparatorImpl); assertEquals(expected.getUncompressedDataIndexSize(), loaded.getUncompressedDataIndexSize()); } assertEquals(expected.getLoadOnOpenDataOffset(), loaded.getLoadOnOpenDataOffset()); assertEquals(expected.getMetaIndexCount(), loaded.getMetaIndexCount()); assertEquals(expected.getTotalUncompressedBytes(), loaded.getTotalUncompressedBytes()); }
new HFileBlock.FSReaderImpl(fsdis, fileSize, meta); CellComparator comparator = trailer.createComparator(); HFileBlockIndex.BlockIndexReader dataBlockIndexReader = new HFileBlockIndex.CellBasedKeyBlockIndexReader(comparator,
comparator = trailer.createComparator(); dataBlockIndexReader = new HFileBlockIndex.BlockIndexReader(comparator, trailer.getNumDataIndexLevels(), this);
comparator = trailer.createComparator(); dataBlockIndexReader = new HFileBlockIndex.BlockIndexReader(comparator, trailer.getNumDataIndexLevels(), this);