/** * @param c * @param kv Presume first on row: i.e. empty column, maximum timestamp and * a type of Type.Maximum * @param ttl Time to live in ms for this Store * @param metaregion True if this is hbase:meta or -ROOT- region. */ GetClosestRowBeforeTracker(final KVComparator c, final KeyValue kv, final long ttl, final boolean metaregion) { super(); this.metaregion = metaregion; this.targetkey = kv; // If we are in a metaregion, then our table name is the prefix on the // targetkey. this.rowoffset = kv.getRowOffset(); int l = -1; if (metaregion) { l = KeyValue.getDelimiter(kv.getRowArray(), rowoffset, kv.getRowLength(), HConstants.DELIMITER) - this.rowoffset; } this.tablenamePlusDelimiterLength = metaregion? l + 1: -1; this.now = System.currentTimeMillis(); this.oldestUnexpiredTs = now - ttl; this.kvcomparator = c; KeyValue.RowOnlyComparator rc = new KeyValue.RowOnlyComparator(this.kvcomparator); this.deletes = new TreeMap<KeyValue, NavigableSet<KeyValue>>(rc); }
/** * @param conf * @param family Name of this store's column family * @param minVersions Store's MIN_VERSIONS setting * @param maxVersions Store's VERSIONS setting * @param ttl Store's TTL (in ms) * @param timeToPurgeDeletes duration in ms after which a delete marker can * be purged during a major compaction. * @param keepDeletedCells Store's keepDeletedCells setting * @param comparator The store's comparator */ public ScanInfo(final Configuration conf, final byte[] family, final int minVersions, final int maxVersions, final long ttl, final KeepDeletedCells keepDeletedCells, final long timeToPurgeDeletes, final KVComparator comparator) { this.family = family; this.minVersions = minVersions; this.maxVersions = maxVersions; this.ttl = ttl; this.keepDeletedCells = keepDeletedCells; this.timeToPurgeDeletes = timeToPurgeDeletes; this.comparator = comparator; this.tableMaxRowSize = conf.getLong(HConstants.TABLE_MAX_ROWSIZE_KEY, HConstants.TABLE_MAX_ROWSIZE_DEFAULT); this.usePread = conf.getBoolean("hbase.storescanner.use.pread", false); long perHeartbeat = conf.getLong(StoreScanner.HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK, StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK); this.cellsPerTimeoutCheck = perHeartbeat > 0 ? perHeartbeat : StoreScanner.DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK; this.parallelSeekEnabled = conf.getBoolean(StoreScanner.STORESCANNER_PARALLEL_SEEK_ENABLE, false); this.conf = conf; }
public void setComparatorClass(Class<? extends KVComparator> klass) { // Is the comparator instantiable? try { KVComparator comp = klass.newInstance(); // HFile V2 legacy comparator class names. if (KeyValue.COMPARATOR.getClass().equals(klass)) { comparatorClassName = KeyValue.COMPARATOR.getLegacyKeyComparatorName(); } else if (KeyValue.META_COMPARATOR.getClass().equals(klass)) { comparatorClassName = KeyValue.META_COMPARATOR.getLegacyKeyComparatorName(); } else if (KeyValue.RAW_COMPARATOR.getClass().equals(klass)) { comparatorClassName = KeyValue.RAW_COMPARATOR.getLegacyKeyComparatorName(); } else { // if the name wasn't one of the legacy names, maybe its a legit new kind of comparator. comparatorClassName = klass.getName(); } } catch (Exception e) { throw new RuntimeException("Comparator class " + klass.getName() + " is not instantiable", e); } }
@SuppressWarnings("unchecked") private static Class<? extends KVComparator> getComparatorClass( String comparatorClassName) throws IOException { try { // HFile V2 legacy comparator class names. if (comparatorClassName.equals(KeyValue.COMPARATOR.getLegacyKeyComparatorName())) { comparatorClassName = KeyValue.COMPARATOR.getClass().getName(); } else if (comparatorClassName.equals(KeyValue.META_COMPARATOR.getLegacyKeyComparatorName())) { comparatorClassName = KeyValue.META_COMPARATOR.getClass().getName(); } else if (comparatorClassName.equals(KeyValue.RAW_COMPARATOR.getLegacyKeyComparatorName())) { comparatorClassName = KeyValue.RAW_COMPARATOR.getClass().getName(); } // if the name wasn't one of the legacy names, maybe its a legit new kind of comparator. return (Class<? extends KVComparator>) Class.forName(comparatorClassName); } catch (ClassNotFoundException ex) { throw new IOException(ex); } }
public AbstractHFileWriter(CacheConfig cacheConf, FSDataOutputStream outputStream, Path path, KVComparator comparator, HFileContext fileContext) { this.outputStream = outputStream; this.path = path; this.name = path != null ? path.getName() : outputStream.toString(); this.hFileContext = fileContext; DataBlockEncoding encoding = hFileContext.getDataBlockEncoding(); if (encoding != DataBlockEncoding.NONE) { this.blockEncoder = new HFileDataBlockEncoderImpl(encoding); } else { this.blockEncoder = NoOpDataBlockEncoder.INSTANCE; } this.comparator = comparator != null ? comparator : KeyValue.COMPARATOR; closeOutputStream = path != null; this.cacheConf = cacheConf; }
/** * Search for one key using the secondary index in a non-root block. In case * of success, positions the provided buffer at the entry of interest, where * the file offset and the on-disk-size can be read. * * @param nonRootBlock * a non-root block without header. Initial position does not * matter. * @param key * the byte array containing the key * @return the index position where the given key was found, otherwise * return -1 in the case the given key is before the first key. * */ static int locateNonRootIndexEntry(ByteBuffer nonRootBlock, Cell key, KVComparator comparator) { int entryIndex = binarySearchNonRootIndex(key, nonRootBlock, comparator); if (entryIndex != -1) { int numEntries = nonRootBlock.getInt(0); // The end of secondary index and the beginning of entries themselves. int entriesOffset = Bytes.SIZEOF_INT * (numEntries + 2); // The offset of the entry we are interested in relative to the end of // the secondary index. int entryRelOffset = nonRootBlock.getInt(Bytes.SIZEOF_INT * (1 + entryIndex)); nonRootBlock.position(entriesOffset + entryRelOffset); } return entryIndex; }
/** * @param c * @param kv Presume first on row: i.e. empty column, maximum timestamp and * a type of Type.Maximum * @param ttl Time to live in ms for this Store * @param metaregion True if this is .META. or -ROOT- region. */ GetClosestRowBeforeTracker(final KVComparator c, final KeyValue kv, final long ttl, final boolean metaregion) { super(); this.metaregion = metaregion; this.targetkey = kv; // If we are in a metaregion, then our table name is the prefix on the // targetkey. this.rowoffset = kv.getRowOffset(); int l = -1; if (metaregion) { l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(), HRegionInfo.DELIMITER) - this.rowoffset; } this.tablenamePlusDelimiterLength = metaregion? l + 1: -1; this.oldestts = System.currentTimeMillis() - ttl; this.kvcomparator = c; KeyValue.RowComparator rc = new KeyValue.RowComparator(this.kvcomparator); this.deletes = new TreeMap<KeyValue, NavigableSet<KeyValue>>(rc); }
/** * Search for one key using the secondary index in a non-root block. In case * of success, positions the provided buffer at the entry of interest, where * the file offset and the on-disk-size can be read. * * @param nonRootBlock a non-root block without header. Initial position * does not matter. * @param key the byte array containing the key * @param keyOffset the offset of the key in its byte array * @param keyLength the length of the key * @return the index position where the given key was found, * otherwise return -1 in the case the given key is before the first key. * */ static int locateNonRootIndexEntry(ByteBuffer nonRootBlock, byte[] key, int keyOffset, int keyLength, KVComparator comparator) { int entryIndex = binarySearchNonRootIndex(key, keyOffset, keyLength, nonRootBlock, comparator); if (entryIndex != -1) { int numEntries = nonRootBlock.getInt(0); // The end of secondary index and the beginning of entries themselves. int entriesOffset = Bytes.SIZEOF_INT * (numEntries + 2); // The offset of the entry we are interested in relative to the end of // the secondary index. int entryRelOffset = nonRootBlock.getInt(Bytes.SIZEOF_INT * (1 + entryIndex)); nonRootBlock.position(entriesOffset + entryRelOffset); } return entryIndex; }
/** * @param c * @param kv Presume first on row: i.e. empty column, maximum timestamp and * a type of Type.Maximum * @param ttl Time to live in ms for this Store * @param metaregion True if this is hbase:meta or -ROOT- region. */ GetClosestRowBeforeTracker(final KVComparator c, final KeyValue kv, final long ttl, final boolean metaregion) { super(); this.metaregion = metaregion; this.targetkey = kv; // If we are in a metaregion, then our table name is the prefix on the // targetkey. this.rowoffset = kv.getRowOffset(); int l = -1; if (metaregion) { l = KeyValue.getDelimiter(kv.getBuffer(), rowoffset, kv.getRowLength(), HConstants.DELIMITER) - this.rowoffset; } this.tablenamePlusDelimiterLength = metaregion? l + 1: -1; this.oldestts = System.currentTimeMillis() - ttl; this.kvcomparator = c; KeyValue.RowOnlyComparator rc = new KeyValue.RowOnlyComparator(this.kvcomparator); this.deletes = new TreeMap<KeyValue, NavigableSet<KeyValue>>(rc); }
/** * @param chunkByteSizeHint * each chunk's size in bytes. The real chunk size might be different * as required by the fold factor. * @param errorRate * target false positive rate * @param hashType * hash function type to use * @param maxFold * maximum degree of folding allowed */ public CompoundBloomFilterWriter(int chunkByteSizeHint, float errorRate, int hashType, int maxFold, boolean cacheOnWrite, KVComparator comparator) { chunkByteSize = ByteBloomFilter.computeFoldableByteSize( chunkByteSizeHint * 8L, maxFold); this.errorRate = errorRate; this.hashType = hashType; this.maxFold = maxFold; this.cacheOnWrite = cacheOnWrite; this.comparator = comparator; }
private void createComponentsOnce( Configuration conf, Store store, KVComparator kvComparator) throws IOException { assert compactor == null && compactionPolicy == null && storeFileManager == null && storeFlusher == null; createComponents(conf, store, kvComparator); assert compactor != null && compactionPolicy != null && storeFileManager != null && storeFlusher != null; }
/** * Create the StoreEngine configured for the given Store. * @param store The store. An unfortunate dependency needed due to it * being passed to coprocessors via the compactor. * @param conf Store configuration. * @param kvComparator KVComparator for storeFileManager. * @return StoreEngine to use. */ public static StoreEngine<?, ?, ?, ?> create( Store store, Configuration conf, KVComparator kvComparator) throws IOException { String className = conf.get(STORE_ENGINE_CLASS_KEY, DEFAULT_STORE_ENGINE_CLASS.getName()); try { StoreEngine<?,?,?,?> se = ReflectionUtils.instantiateWithCustomCtor( className, new Class[] { }, new Object[] { }); se.createComponentsOnce(conf, store, kvComparator); return se; } catch (Exception e) { throw new IOException("Unable to load configured store engine '" + className + "'", e); } }
/** * Gets the approximate mid-point of this file that is optimal for use in splitting it. * * @param comparator Comparator used to compare KVs. * @return The split point row, or null if splitting is not possible, or reader is null. */ @SuppressWarnings("deprecation") byte[] getFileSplitPoint(KVComparator comparator) throws IOException { if (this.reader == null) { LOG.warn("Storefile " + this + " Reader is null; cannot get split point"); return null; } // Get first, last, and mid keys. Midkey is the key that starts block // in middle of hfile. Has column and timestamp. Need to return just // the row we want to split on as midkey. byte[] midkey = this.reader.midkey(); if (midkey != null) { KeyValue mk = KeyValue.createKeyValueFromKey(midkey, 0, midkey.length); byte[] fk = this.reader.getFirstKey(); KeyValue firstKey = KeyValue.createKeyValueFromKey(fk, 0, fk.length); byte[] lk = this.reader.getLastKey(); KeyValue lastKey = KeyValue.createKeyValueFromKey(lk, 0, lk.length); // if the midkey is the same as the first or last keys, we cannot (ever) split this region. if (comparator.compareRows(mk, firstKey) == 0 || comparator.compareRows(mk, lastKey) == 0) { if (LOG.isDebugEnabled()) { LOG.debug("cannot split because midkey is the same as first or last row"); } return null; } return mk.getRow(); } return null; }
/** * Creates an HFile.Writer that also write helpful meta data. * * @param fs file system to write to * @param path file name to create * @param conf user configuration * @param comparator key comparator * @param bloomType bloom filter setting * @param maxKeys the expected maximum number of keys to be added. Was used for Bloom filter * size in {@link HFile} format version 1. * @param favoredNodes * @param fileContext - The HFile context * @throws IOException problem writing to FS */ private Writer(FileSystem fs, Path path, final Configuration conf, CacheConfig cacheConf, final KVComparator comparator, BloomType bloomType, long maxKeys, InetSocketAddress[] favoredNodes, HFileContext fileContext) throws IOException { writer = HFile.getWriterFactory(conf, cacheConf).withPath(fs, path).withComparator(comparator) .withFavoredNodes(favoredNodes).withFileContext(fileContext).create(); this.kvComparator = comparator; generalBloomFilterWriter = BloomFilterFactory .createGeneralBloomAtWrite(conf, cacheConf, bloomType, (int) Math.min(maxKeys, Integer.MAX_VALUE), writer); if (generalBloomFilterWriter != null) { this.bloomType = bloomType; if (LOG.isTraceEnabled()) LOG.trace( "Bloom filter type for " + path + ": " + this.bloomType + ", " + generalBloomFilterWriter.getClass().getSimpleName()); } else { // Not using Bloom filters. this.bloomType = BloomType.NONE; } // initialize delete family Bloom filter when there is NO RowCol Bloom // filter if (this.bloomType != BloomType.ROWCOL) { this.deleteFamilyBloomFilterWriter = BloomFilterFactory .createDeleteBloomAtWrite(conf, cacheConf, (int) Math.min(maxKeys, Integer.MAX_VALUE), writer); } else { deleteFamilyBloomFilterWriter = null; } if (deleteFamilyBloomFilterWriter != null) { if (LOG.isTraceEnabled()) LOG.trace( "Delete Family Bloom filter type for " + path + ": " + deleteFamilyBloomFilterWriter .getClass().getSimpleName()); } }
public DefaultStoreFileManager(KVComparator kvComparator, Configuration conf, CompactionConfiguration comConf) { this.kvComparator = kvComparator; this.comConf = comConf; this.blockingFileCount = conf.getInt(HStore.BLOCKING_STOREFILES_KEY, HStore.DEFAULT_BLOCKING_STOREFILE_COUNT); }
@Override protected void checkScanOrder(Cell prevKV, Cell kv, KeyValue.KVComparator comparator) throws IOException { // Check that the heap gives us KVs in an increasing order for same row and // decreasing order for different rows. assert prevKV == null || comparator == null || comparator.compareRows(kv, prevKV) < 0 || (comparator.matchingRows(kv, prevKV) && comparator.compare(kv, prevKV) >= 0) : "Key " + prevKV + " followed by a " + "error order key " + kv + " in cf " + store + " in reversed scan"; }
/** * Initializes multi-writer before usage. * @param sourceScanner Optional store scanner to obtain the information about read progress. * @param factory Factory used to produce individual file writers. * @param comparator Comparator used to compare rows. */ public void init(StoreScanner sourceScanner, WriterFactory factory, KVComparator comparator) throws IOException { this.writerFactory = factory; this.sourceScanner = sourceScanner; this.comparator = comparator; }
public StripeStoreFileManager( KVComparator kvComparator, Configuration conf, StripeStoreConfig config) { this.kvComparator = kvComparator; this.config = config; this.blockingFileCount = conf.getInt( HStore.BLOCKING_STOREFILES_KEY, HStore.DEFAULT_BLOCKING_STOREFILE_COUNT); }
@Override protected void createComponents( Configuration conf, Store store, KVComparator comparator) throws IOException { this.config = new StripeStoreConfig(conf, store); this.compactionPolicy = new StripeCompactionPolicy(conf, store, config); this.storeFileManager = new StripeStoreFileManager(comparator, conf, this.config); this.storeFlusher = new StripeStoreFlusher( conf, store, this.compactionPolicy, this.storeFileManager); this.compactor = new StripeCompactor(conf, store); }
/** Constructor that takes a path, creates and closes the output stream. */ public HFileWriterV3(Configuration conf, CacheConfig cacheConf, FileSystem fs, Path path, FSDataOutputStream ostream, final KVComparator comparator, final HFileContext fileContext) throws IOException { super(conf, cacheConf, fs, path, ostream, comparator, fileContext); if (LOG.isTraceEnabled()) { LOG.trace("Writer" + (path != null ? " for " + path : "") + " initialized with cacheConf: " + cacheConf + " comparator: " + comparator.getClass().getSimpleName() + " fileContext: " + fileContext); } }
@Override public Writer createWriter(FileSystem fs, Path path, FSDataOutputStream ostream, KVComparator comparator, HFileContext context) throws IOException { context.setIncludesTags(false);// HFile V2 does not deal with tags at all! return new HFileWriterV2(conf, cacheConf, fs, path, ostream, comparator, context); }
/** Constructor that takes a path, creates and closes the output stream. */ public HFileWriterV2(Configuration conf, CacheConfig cacheConf, FileSystem fs, Path path, FSDataOutputStream ostream, final KVComparator comparator, final HFileContext context) throws IOException { super(cacheConf, ostream == null ? createOutputStream(conf, fs, path, null) : ostream, path, comparator, context); finishInit(conf); }
@Override public int compareKey(KVComparator comparator, Cell key) { return comparator.compareOnlyKeyPortion( key, new KeyValue.KeyOnlyKeyValue(blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position() + KEY_VALUE_LEN_SIZE, currKeyLen)); }
private static StripeStoreFileManager createManager( ArrayList<StoreFile> sfs, Configuration conf) throws Exception { StripeStoreConfig config = new StripeStoreConfig( conf, Mockito.mock(StoreConfigInformation.class)); StripeStoreFileManager result = new StripeStoreFileManager(new KVComparator(), conf, config); result.loadFiles(sfs); return result; }
@Test public void testCustomParts() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.set(DefaultStoreEngine.DEFAULT_COMPACTOR_CLASS_KEY, DummyCompactor.class.getName()); conf.set(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY, DummyCompactionPolicy.class.getName()); conf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY, DummyStoreFlusher.class.getName()); Store mockStore = Mockito.mock(Store.class); StoreEngine<?, ?, ?, ?> se = StoreEngine.create(mockStore, conf, new KVComparator()); Assert.assertTrue(se instanceof DefaultStoreEngine); Assert.assertTrue(se.getCompactionPolicy() instanceof DummyCompactionPolicy); Assert.assertTrue(se.getStoreFlusher() instanceof DummyStoreFlusher); Assert.assertTrue(se.getCompactor() instanceof DummyCompactor); }
/** * Is this the correct handling of an illegal comparator? How to prevent that from getting all * the way to this point. */ @Override public EncodedSeeker createSeeker(KVComparator comparator, HFileBlockDecodingContext decodingCtx) { if (comparator instanceof RawBytesComparator){ throw new IllegalArgumentException("comparator must be KeyValue.KeyComparator"); } else if (comparator instanceof MetaComparator){ throw new IllegalArgumentException("DataBlockEncoding.PREFIX_TREE not compatible with hbase:meta " +"table"); } return new PrefixTreeSeeker(decodingCtx.getHFileContext().isIncludesMvcc()); }
/** * Get the appropriate row comparator for this table. * * @return The comparator. * @deprecated The comparator is an internal property of the table. Should * not have been exposed here */ @InterfaceAudience.Private @Deprecated public KVComparator getRowComparator() { if(TableName.META_TABLE_NAME.equals(this)) { return KeyValue.META_COMPARATOR; } return KeyValue.COMPARATOR; }
@Override public EncodedSeeker createSeeker(KVComparator comparator, final HFileBlockDecodingContext decodingCtx) { return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) { @Override protected void decodeNext() { current.keyLength = currentBuffer.getInt(); current.valueLength = currentBuffer.getInt(); current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, 0, current.keyLength); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesTags()) { // Read short as unsigned, high byte first current.tagsLength = ((currentBuffer.get() & 0xff) << 8) ^ (currentBuffer.get() & 0xff); ByteBufferUtils.skip(currentBuffer, current.tagsLength); } if (includesMvcc()) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); } @Override protected void decodeFirst() { ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT); current.lastCommonPrefix = 0; decodeNext(); } }; }
public BufferedEncodedSeeker(KVComparator comparator, HFileBlockDecodingContext decodingCtx) { this.comparator = comparator; this.samePrefixComparator = comparator; this.decodingCtx = decodingCtx; if (decodingCtx.getHFileContext().isCompressTags()) { try { tagCompressionContext = new TagCompressionContext(LRUDictionary.class, Byte.MAX_VALUE); } catch (Exception e) { throw new RuntimeException("Failed to initialize TagCompressionContext", e); } } }
@Override public EncodedSeeker createSeeker(KVComparator comparator, final HFileBlockDecodingContext decodingCtx) { return new BufferedEncodedSeeker<SeekerState>(comparator, decodingCtx) { @Override protected void decodeNext() { current.keyLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.valueLength = ByteBufferUtils.readCompressedInt(currentBuffer); current.lastCommonPrefix = ByteBufferUtils.readCompressedInt(currentBuffer); current.keyLength += current.lastCommonPrefix; current.ensureSpaceForKey(); currentBuffer.get(current.keyBuffer, current.lastCommonPrefix, current.keyLength - current.lastCommonPrefix); current.valueOffset = currentBuffer.position(); ByteBufferUtils.skip(currentBuffer, current.valueLength); if (includesTags()) { decodeTags(); } if (includesMvcc()) { current.memstoreTS = ByteBufferUtils.readVLong(currentBuffer); } else { current.memstoreTS = 0; } current.nextKvOffset = currentBuffer.position(); } @Override protected void decodeFirst() { ByteBufferUtils.skip(currentBuffer, Bytes.SIZEOF_INT); decodeNext(); } }; }
public void testMoreComparisons() throws Exception { long now = System.currentTimeMillis(); // Meta compares KeyValue aaa = new KeyValue( Bytes.toBytes("TestScanMultipleVersions,row_0500,1236020145502"), now); KeyValue bbb = new KeyValue( Bytes.toBytes("TestScanMultipleVersions,,99999999999999"), now); KVComparator c = new KeyValue.MetaComparator(); assertTrue(c.compare(bbb, aaa) < 0); KeyValue aaaa = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,,1236023996656"), Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1236024396271L, (byte[])null); assertTrue(c.compare(aaaa, bbb) < 0); KeyValue x = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,row_0500,1236034574162"), Bytes.toBytes("info"), Bytes.toBytes(""), 9223372036854775807L, (byte[])null); KeyValue y = new KeyValue(Bytes.toBytes("TestScanMultipleVersions,row_0500,1236034574162"), Bytes.toBytes("info"), Bytes.toBytes("regioninfo"), 1236034574912L, (byte[])null); assertTrue(c.compare(x, y) < 0); comparisons(new KeyValue.MetaComparator()); comparisons(new KeyValue.KVComparator()); metacomparisons(new KeyValue.MetaComparator()); }
private void comparisons(final KeyValue.KVComparator c) { long now = System.currentTimeMillis(); assertTrue(c.compare(new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now), new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now)) == 0); assertTrue(c.compare(new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now), new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,2"), now)) < 0); assertTrue(c.compare(new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,2"), now), new KeyValue( Bytes.toBytes(TableName.META_TABLE_NAME.getNameAsString()+",,1"), now)) > 0); }
private void assertKVLess(KeyValue.KVComparator c, KeyValue less, KeyValue greater) { int cmp = c.compare(less,greater); assertTrue(cmp < 0); cmp = c.compare(greater,less); assertTrue(cmp > 0); }
private void assertKVLessWithoutRow(KeyValue.KVComparator c, int common, KeyValue less, KeyValue greater) { int cmp = c.compareIgnoringPrefix(common, less.getBuffer(), less.getOffset() + KeyValue.ROW_OFFSET, less.getKeyLength(), greater.getBuffer(), greater.getOffset() + KeyValue.ROW_OFFSET, greater.getKeyLength()); assertTrue(cmp < 0); cmp = c.compareIgnoringPrefix(common, greater.getBuffer(), greater.getOffset() + KeyValue.ROW_OFFSET, greater.getKeyLength(), less.getBuffer(), less.getOffset() + KeyValue.ROW_OFFSET, less.getKeyLength()); assertTrue(cmp > 0); }