@InterfaceAudience.Private public class BBKVComparator extends Object implements Comparator
ByteBufferKeyValueis prevalent type (BBKV is base-type in hbase2). Takes a general comparator as fallback in case types are NOT the expected ByteBufferKeyValue.
This is a tricked-out Comparator at heart of hbase read and write. It is in the HOT path so we try all sorts of ugly stuff so we can go faster. See below in this javadoc comment for the list.
Apply this comparator narrowly so it is fed exclusively ByteBufferKeyValues as much as is possible so JIT can settle (e.g. make one per ConcurrentSkipListMap in HStore).
Exploits specially added methods in BBKV to save on deserializations of shorts, longs, etc: i.e. calculating the family length requires row length; pass it in rather than recalculate it, and so on.
This comparator does static dispatch to private final methods so hotspot is comfortable deciding inline.
Measurement has it that we almost have it so all inlines from memstore ConcurrentSkipListMap on down to the (unsafe) intrinisics that do byte compare and deserialize shorts and ints; needs a bit more work.
Does not take a Type to compare: i.e. it is not a Comparator<Cell> or CellComparator<Cell> or Comparator<ByteBufferKeyValue> because that adds another method to the hierarchy -- from compare(Object, Object) to dynamic compare(Cell, Cell) to static private compare -- and inlining doesn't happen if hierarchy is too deep (it is the case here).
Be careful making changes. Compare perf before and after and look at what hotspot ends up generating before committing change (jitwatch is helpful here). Changing this one class doubled write throughput (HBASE-20483).
|Modifier and Type||Field and Description|
|Modifier and Type||Method and Description|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.