ramkrish86 commented on a change in pull request #2747:
URL: https://github.com/apache/hbase/pull/2747#discussion_r541903064



##########
File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
##########
@@ -51,35 +53,38 @@
    */
   public static final CellComparatorImpl COMPARATOR = new CellComparatorImpl();
 
+  private static final ContiguousCellFormatComparator contiguousCellComparator 
=
+      new ContiguousCellFormatComparator(COMPARATOR);
+
   @Override
   public final int compare(final Cell a, final Cell b) {
     return compare(a, b, false);
   }
 
   @Override
   public int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
-
     int diff = 0;
-    // "Peel off" the most common path.
-    if (a instanceof ByteBufferKeyValue && b instanceof ByteBufferKeyValue) {
-      diff = BBKVComparator.compare((ByteBufferKeyValue)a, 
(ByteBufferKeyValue)b, ignoreSequenceid);
-      if (diff != 0) {
-        return diff;
-      }
+    // "Peeling off" the most common cases where the Cells backed by KV format 
either onheap or
+    // offheap
+    if (a instanceof ContiguousCellFormat && b instanceof ContiguousCellFormat

Review comment:
       `We have too many if/else's in the path. if BB, if tags, if sequenceid, 
if offheap.... if unsafe. If ByteBufferExtendedCell...`
   
   Previously we had all these branches for BytebufferExtendedcell and left 
being normal cell and right being normal cell etc. But we were not having the 
optimization of knowing the internals. Now this branching is fixed and the 
branches are only at this place and internally no branches. Previously the 
compareRows() had 4 branches, compareFamilies() had 4 branches, 
comparequalifiers() had 4 branches and then the tags and sequenceId. This 
reduces those branches. I strongly favour this lesser branching but more 
duplicate code 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to