You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2017/10/24 03:44:45 UTC
[05/50] [abbrv] hbase git commit: HBSE-18945 Make a IA.LimitedPrivate
interface for CellComparator (Ram)
HBSE-18945 Make a IA.LimitedPrivate interface for CellComparator (Ram)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/70f4c5da
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/70f4c5da
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/70f4c5da
Branch: refs/heads/HBASE-18410
Commit: 70f4c5da475a221b28e3516a23f35fc6098d4044
Parents: 9f61f8b
Author: Ramkrishna <ra...@intel.com>
Authored: Tue Oct 17 23:17:07 2017 +0530
Committer: Ramkrishna <ra...@intel.com>
Committed: Tue Oct 17 23:17:07 2017 +0530
----------------------------------------------------------------------
.../hbase/backup/impl/BackupSystemTable.java | 15 +-
.../hadoop/hbase/client/ConnectionUtils.java | 5 +-
.../org/apache/hadoop/hbase/client/Put.java | 1 -
.../org/apache/hadoop/hbase/client/Result.java | 11 +-
.../hbase/filter/ColumnPaginationFilter.java | 3 +-
.../hadoop/hbase/filter/ColumnRangeFilter.java | 5 +-
.../hadoop/hbase/filter/CompareFilter.java | 18 +-
.../apache/hadoop/hbase/filter/FilterList.java | 6 +-
.../hadoop/hbase/filter/FuzzyRowFilter.java | 4 +-
.../hbase/filter/InclusiveStopFilter.java | 4 +-
.../hbase/filter/SingleColumnValueFilter.java | 3 +-
.../hbase/client/TestClientNoCluster.java | 4 +-
.../hadoop/hbase/client/TestOperation.java | 10 +-
.../hadoop/hbase/filter/TestComparators.java | 38 +-
.../hbase/shaded/protobuf/TestProtobufUtil.java | 4 +-
.../org/apache/hadoop/hbase/CellComparator.java | 653 ++-----------------
.../apache/hadoop/hbase/CellComparatorImpl.java | 381 +++++++++++
.../java/org/apache/hadoop/hbase/CellUtil.java | 306 ++++++++-
.../java/org/apache/hadoop/hbase/KeyValue.java | 21 +-
.../io/encoding/BufferedDataBlockEncoder.java | 5 +-
.../hbase/io/encoding/DataBlockEncoder.java | 3 +-
.../hbase/io/encoding/RowIndexCodecV1.java | 3 +-
.../hbase/io/encoding/RowIndexEncoderV1.java | 3 +-
.../hbase/io/encoding/RowIndexSeekerV1.java | 4 +-
.../apache/hadoop/hbase/TestCellComparator.java | 28 +-
.../org/apache/hadoop/hbase/TestKeyValue.java | 48 +-
.../hadoop/hbase/util/RedundantKVGenerator.java | 6 +-
.../mapreduce/IntegrationTestImportTsv.java | 6 +-
.../hadoop/hbase/mapreduce/CellSortReducer.java | 4 +-
.../hbase/mapreduce/HFileOutputFormat2.java | 6 +-
.../apache/hadoop/hbase/mapreduce/Import.java | 4 +-
.../hadoop/hbase/mapreduce/PutSortReducer.java | 4 +-
.../hadoop/hbase/mapreduce/SyncTable.java | 9 +-
.../hadoop/hbase/mapreduce/TextSortReducer.java | 4 +-
.../hbase/codec/prefixtree/PrefixTreeCodec.java | 2 +-
.../decode/PrefixTreeArrayScanner.java | 3 +-
.../codec/prefixtree/decode/PrefixTreeCell.java | 3 +-
.../row/data/TestRowDataNumberStrings.java | 4 +-
.../hadoop/hbase/io/HalfStoreFileReader.java | 13 +-
.../hadoop/hbase/io/hfile/FixedFileTrailer.java | 15 +-
.../org/apache/hadoop/hbase/io/hfile/HFile.java | 3 +-
.../hadoop/hbase/io/hfile/HFileBlockIndex.java | 3 +-
.../hbase/io/hfile/HFilePrettyPrinter.java | 10 +-
.../hadoop/hbase/io/hfile/HFileReaderImpl.java | 14 +-
.../hadoop/hbase/io/hfile/HFileWriterImpl.java | 11 +-
.../org/apache/hadoop/hbase/mob/MobUtils.java | 4 +-
.../compactions/PartitionedMobCompactor.java | 4 +-
.../regionserver/CellArrayImmutableSegment.java | 1 +
.../regionserver/CellChunkImmutableSegment.java | 3 +-
.../hbase/regionserver/DefaultMemStore.java | 3 +-
.../hadoop/hbase/regionserver/HRegion.java | 10 +-
.../hadoop/hbase/regionserver/HStore.java | 9 +-
.../hbase/regionserver/ImmutableSegment.java | 2 +-
.../apache/hadoop/hbase/regionserver/Store.java | 5 +-
.../hadoop/hbase/regionserver/StoreFile.java | 4 +-
.../hbase/regionserver/StoreFileReader.java | 5 +-
.../hbase/regionserver/StoreFileWriter.java | 5 +-
.../hadoop/hbase/regionserver/StoreScanner.java | 3 +-
.../querymatcher/DeleteTracker.java | 7 +
.../querymatcher/ExplicitColumnTracker.java | 5 +-
.../querymatcher/NewVersionBehaviorTracker.java | 13 +-
.../querymatcher/ScanDeleteTracker.java | 12 +-
.../querymatcher/ScanQueryMatcher.java | 22 +-
.../querymatcher/ScanWildcardColumnTracker.java | 4 +-
.../hbase/regionserver/wal/FSWALEntry.java | 4 +-
.../visibility/VisibilityController.java | 2 +-
.../VisibilityNewVersionBehaivorTracker.java | 9 +-
.../visibility/VisibilityScanDeleteTracker.java | 7 +-
.../hadoop/hbase/util/BloomFilterFactory.java | 4 +-
.../hbase/util/CollectionBackedScanner.java | 5 +-
.../hadoop/hbase/util/CompressionTest.java | 4 +-
.../hadoop/hbase/util/RowBloomContext.java | 1 +
.../hadoop/hbase/HBaseTestingUtility.java | 2 +-
.../hbase/HFilePerformanceEvaluation.java | 2 +-
.../apache/hadoop/hbase/MetaMockingUtil.java | 2 +-
...estAvoidCellReferencesIntoShippedBlocks.java | 4 +-
.../apache/hadoop/hbase/client/TestResult.java | 18 +-
.../hbase/filter/TestDependentColumnFilter.java | 4 +-
.../apache/hadoop/hbase/filter/TestFilter.java | 10 +-
.../hadoop/hbase/filter/TestFilterList.java | 39 +-
.../TestSingleColumnValueExcludeFilter.java | 6 +-
.../hbase/io/TestHalfStoreFileReader.java | 4 +-
.../io/encoding/TestDataBlockEncoders.java | 11 +-
.../io/encoding/TestPrefixTreeEncoding.java | 16 +-
.../encoding/TestSeekToBlockWithEncoders.java | 4 +-
.../hadoop/hbase/io/hfile/TestCacheOnWrite.java | 4 +-
.../hbase/io/hfile/TestFixedFileTrailer.java | 6 +-
.../apache/hadoop/hbase/io/hfile/TestHFile.java | 70 +-
.../hadoop/hbase/io/hfile/TestHFileBlock.java | 4 +-
.../hbase/io/hfile/TestHFileBlockIndex.java | 14 +-
.../hadoop/hbase/io/hfile/TestHFileSeek.java | 4 +-
.../hbase/io/hfile/TestHFileWriterV3.java | 3 +-
.../hadoop/hbase/io/hfile/TestPrefetch.java | 4 +-
.../hadoop/hbase/io/hfile/TestReseekTo.java | 4 +-
.../hadoop/hbase/io/hfile/TestSeekTo.java | 4 +-
.../TestPartitionedMobCompactor.java | 4 +-
.../hadoop/hbase/protobuf/TestProtobufUtil.java | 4 +-
.../hbase/regionserver/KeyValueScanFixture.java | 6 +-
.../hbase/regionserver/TestCellFlatSet.java | 8 +-
.../hbase/regionserver/TestCellSkipListSet.java | 4 +-
.../regionserver/TestCompactingMemStore.java | 10 +-
.../TestCompactingToCellFlatMapMemStore.java | 4 +-
.../regionserver/TestCompoundBloomFilter.java | 4 +-
.../hbase/regionserver/TestDefaultMemStore.java | 12 +-
.../regionserver/TestDefaultStoreEngine.java | 4 +-
.../hbase/regionserver/TestHMobStore.java | 14 +-
.../hadoop/hbase/regionserver/TestHStore.java | 9 +-
.../hbase/regionserver/TestHStoreFile.java | 6 +-
.../hbase/regionserver/TestKeyValueHeap.java | 12 +-
.../regionserver/TestKeyValueScanFixture.java | 4 +-
.../regionserver/TestMobStoreCompaction.java | 4 +-
.../regionserver/TestMultiColumnScanner.java | 4 +-
.../hbase/regionserver/TestRecoveredEdits.java | 6 +-
.../regionserver/TestReversibleScanners.java | 6 +-
.../TestScannerHeartbeatMessages.java | 15 +-
.../regionserver/TestSeekOptimizations.java | 9 +-
.../hbase/regionserver/TestStoreScanner.java | 21 +-
.../regionserver/TestStripeStoreEngine.java | 4 +-
.../TestStripeStoreFileManager.java | 4 +-
.../compactions/TestDateTieredCompactor.java | 6 +-
.../compactions/TestStripeCompactionPolicy.java | 4 +-
.../compactions/TestStripeCompactor.java | 6 +-
.../AbstractTestScanQueryMatcher.java | 6 +-
.../TestNewVersionBehaviorTracker.java | 22 +-
.../querymatcher/TestScanDeleteTracker.java | 3 +-
.../TestReplicationWALEntryFilters.java | 4 +-
.../hadoop/hbase/spark/HBaseContext.scala | 2 +-
127 files changed, 1278 insertions(+), 1059 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
----------------------------------------------------------------------
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
index aaa50b1..de3ccc7 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java
@@ -37,7 +37,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -255,7 +254,7 @@ public final class BackupSystemTable implements Closeable {
res.advance();
byte[] row = CellUtil.cloneRow(res.listCells().get(0));
for (Cell cell : res.listCells()) {
- if (CellComparator.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
+ if (CellUtil.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
BackupSystemTable.PATH_COL.length) == 0) {
map.put(row, Bytes.toString(CellUtil.cloneValue(cell)));
}
@@ -284,13 +283,13 @@ public final class BackupSystemTable implements Closeable {
byte[] fam = null;
String path = null;
for (Cell cell : res.listCells()) {
- if (CellComparator.compareQualifiers(cell, BackupSystemTable.TBL_COL, 0,
+ if (CellUtil.compareQualifiers(cell, BackupSystemTable.TBL_COL, 0,
BackupSystemTable.TBL_COL.length) == 0) {
tbl = TableName.valueOf(CellUtil.cloneValue(cell));
- } else if (CellComparator.compareQualifiers(cell, BackupSystemTable.FAM_COL, 0,
+ } else if (CellUtil.compareQualifiers(cell, BackupSystemTable.FAM_COL, 0,
BackupSystemTable.FAM_COL.length) == 0) {
fam = CellUtil.cloneValue(cell);
- } else if (CellComparator.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
+ } else if (CellUtil.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
BackupSystemTable.PATH_COL.length) == 0) {
path = Bytes.toString(CellUtil.cloneValue(cell));
}
@@ -436,13 +435,13 @@ public final class BackupSystemTable implements Closeable {
rows.add(row);
String rowStr = Bytes.toString(row);
region = BackupSystemTable.getRegionNameFromOrigBulkLoadRow(rowStr);
- if (CellComparator.compareQualifiers(cell, BackupSystemTable.FAM_COL, 0,
+ if (CellUtil.compareQualifiers(cell, BackupSystemTable.FAM_COL, 0,
BackupSystemTable.FAM_COL.length) == 0) {
fam = Bytes.toString(CellUtil.cloneValue(cell));
- } else if (CellComparator.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
+ } else if (CellUtil.compareQualifiers(cell, BackupSystemTable.PATH_COL, 0,
BackupSystemTable.PATH_COL.length) == 0) {
path = Bytes.toString(CellUtil.cloneValue(cell));
- } else if (CellComparator.compareQualifiers(cell, BackupSystemTable.STATE_COL, 0,
+ } else if (CellUtil.compareQualifiers(cell, BackupSystemTable.STATE_COL, 0,
BackupSystemTable.STATE_COL.length) == 0) {
byte[] state = CellUtil.cloneValue(cell);
if (Bytes.equals(BackupSystemTable.BL_PREPARE, state)) {
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
index 1ff64d5..9c7fd34 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
@@ -39,7 +39,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -315,7 +315,8 @@ public final class ConnectionUtils {
return result;
}
Cell[] rawCells = result.rawCells();
- int index = Arrays.binarySearch(rawCells, keepCellsAfter, CellComparator::compareWithoutRow);
+ int index =
+ Arrays.binarySearch(rawCells, keepCellsAfter, CellComparatorImpl.COMPARATOR::compareWithoutRow);
if (index < 0) {
index = -index - 1;
} else {
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
index 8848404..9ee6555 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
@@ -29,7 +29,6 @@ import java.util.TreeMap;
import java.util.UUID;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 906caac..c238aee 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -35,6 +35,7 @@ import java.util.TreeMap;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
@@ -212,14 +213,14 @@ public class Result implements CellScannable, CellScanner {
* Return the array of Cells backing this Result instance.
*
* The array is sorted from smallest -> largest using the
- * {@link CellComparator#COMPARATOR}.
+ * {@link CellComparator}.
*
* The array only contains what your Get or Scan specifies and no more.
* For example if you request column "A" 1 version you will have at most 1
* Cell in the array. If you request column "A" with 2 version you will
* have at most 2 Cells, with the first one being the newer timestamp and
* the second being the older timestamp (this is the sort order defined by
- * {@link CellComparator#COMPARATOR}). If columns don't exist, they won't be
+ * {@link CellComparator}). If columns don't exist, they won't be
* present in the result. Therefore if you ask for 1 version all columns,
* it is safe to iterate over this array and expect to see 1 Cell for
* each column and no more.
@@ -245,7 +246,7 @@ public class Result implements CellScannable, CellScanner {
/**
* Return the Cells for the specific column. The Cells are sorted in
- * the {@link CellComparator#COMPARATOR} order. That implies the first entry in
+ * the {@link CellComparator} order. That implies the first entry in
* the list is the most recent column. If the query (Scan or Get) only
* requested 1 version the list will contain at most 1 entry. If the column
* did not exist in the result set (either the column does not exist
@@ -302,7 +303,7 @@ public class Result implements CellScannable, CellScanner {
qualifierNotNull, 0, qualifierNotNull.length);
// pos === ( -(insertion point) - 1)
- int pos = Arrays.binarySearch(kvs, searchTerm, CellComparator.COMPARATOR);
+ int pos = Arrays.binarySearch(kvs, searchTerm, CellComparatorImpl.COMPARATOR);
// never will exact match
if (pos < 0) {
pos = (pos+1) * -1;
@@ -347,7 +348,7 @@ public class Result implements CellScannable, CellScanner {
qualifier, qoffset, qlength);
// pos === ( -(insertion point) - 1)
- int pos = Arrays.binarySearch(kvs, searchTerm, CellComparator.COMPARATOR);
+ int pos = Arrays.binarySearch(kvs, searchTerm, CellComparatorImpl.COMPARATOR);
// never will exact match
if (pos < 0) {
pos = (pos+1) * -1;
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
index 1565ddd..5faf85d 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
@@ -120,7 +119,7 @@ public class ColumnPaginationFilter extends FilterBase {
int cmp = 0;
// Only compare if no KV's have been seen so far.
if (count == 0) {
- cmp = CellComparator.compareQualifiers(v, this.columnOffset, 0, this.columnOffset.length);
+ cmp = CellUtil.compareQualifiers(v, this.columnOffset, 0, this.columnOffset.length);
}
if (cmp < 0) {
return ReturnCode.SEEK_NEXT_USING_HINT;
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
index 425600c..87057a9 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
@@ -126,7 +125,7 @@ public class ColumnRangeFilter extends FilterBase {
int cmpMin = 1;
if (this.minColumn != null) {
- cmpMin = CellComparator.compareQualifiers(kv, this.minColumn, 0, this.minColumn.length);
+ cmpMin = CellUtil.compareQualifiers(kv, this.minColumn, 0, this.minColumn.length);
}
if (cmpMin < 0) {
@@ -141,7 +140,7 @@ public class ColumnRangeFilter extends FilterBase {
return ReturnCode.INCLUDE;
}
- int cmpMax = CellComparator.compareQualifiers(kv, this.maxColumn, 0, this.maxColumn.length);
+ int cmpMax = CellUtil.compareQualifiers(kv, this.maxColumn, 0, this.maxColumn.length);
if (this.maxColumnInclusive && cmpMax <= 0 ||
!this.maxColumnInclusive && cmpMax < 0) {
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
index c305ffc..8145f01 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
@@ -23,7 +23,7 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
@@ -137,7 +137,7 @@ public abstract class CompareFilter extends FilterBase {
if (compareOp == CompareOp.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareRow(cell, comparator);
+ int compareResult = CellUtil.compareRow(cell, comparator);
return compare(compareOp, compareResult);
}
@@ -146,7 +146,7 @@ public abstract class CompareFilter extends FilterBase {
if (op == CompareOperator.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareRow(cell, comparator);
+ int compareResult = CellUtil.compareRow(cell, comparator);
return compare(op, compareResult);
}
@@ -160,7 +160,7 @@ public abstract class CompareFilter extends FilterBase {
if (compareOp == CompareOp.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareFamily(cell, comparator);
+ int compareResult = CellUtil.compareFamily(cell, comparator);
return compare(compareOp, compareResult);
}
@@ -169,7 +169,7 @@ public abstract class CompareFilter extends FilterBase {
if (op == CompareOperator.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareFamily(cell, comparator);
+ int compareResult = CellUtil.compareFamily(cell, comparator);
return compare(op, compareResult);
}
@@ -184,7 +184,7 @@ public abstract class CompareFilter extends FilterBase {
if (compareOp == CompareOp.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareQualifier(cell, comparator);
+ int compareResult = CellUtil.compareQualifier(cell, comparator);
return compare(compareOp, compareResult);
}
@@ -194,7 +194,7 @@ public abstract class CompareFilter extends FilterBase {
if (op == CompareOperator.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareQualifier(cell, comparator);
+ int compareResult = CellUtil.compareQualifier(cell, comparator);
return compare(op, compareResult);
}
@@ -209,7 +209,7 @@ public abstract class CompareFilter extends FilterBase {
if (compareOp == CompareOp.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareValue(cell, comparator);
+ int compareResult = CellUtil.compareValue(cell, comparator);
return compare(compareOp, compareResult);
}
@@ -218,7 +218,7 @@ public abstract class CompareFilter extends FilterBase {
if (op == CompareOperator.NO_OP) {
return true;
}
- int compareResult = CellComparator.compareValue(cell, comparator);
+ int compareResult = CellUtil.compareValue(cell, comparator);
return compare(op, compareResult);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
index e6791ab..2f11472 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
@@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
@@ -500,7 +500,7 @@ final public class FilterList extends FilterBase {
keyHint = curKeyHint;
continue;
}
- if (CellComparator.COMPARATOR.compare(keyHint, curKeyHint) < 0) {
+ if (CellComparatorImpl.COMPARATOR.compare(keyHint, curKeyHint) < 0) {
keyHint = curKeyHint;
}
}
@@ -523,7 +523,7 @@ final public class FilterList extends FilterBase {
keyHint = curKeyHint;
continue;
}
- if (CellComparator.COMPARATOR.compare(keyHint, curKeyHint) > 0) {
+ if (CellComparatorImpl.COMPARATOR.compare(keyHint, curKeyHint) > 0) {
keyHint = curKeyHint;
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
index 24d4fab..244e8fb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.PriorityQueue;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
@@ -235,7 +235,7 @@ public class FuzzyRowFilter extends FilterBase {
boolean lessThan(Cell currentCell, byte[] nextRowKey) {
int compareResult =
- CellComparator.COMPARATOR.compareRows(currentCell, nextRowKey, 0, nextRowKey.length);
+ CellComparatorImpl.COMPARATOR.compareRows(currentCell, nextRowKey, 0, nextRowKey.length);
return (!isReversed() && compareResult < 0) || (isReversed() && compareResult > 0);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
index 3c94c2c..c467d17 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
@@ -22,7 +22,7 @@ package org.apache.hadoop.hbase.filter;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException;
@@ -60,7 +60,7 @@ public class InclusiveStopFilter extends FilterBase {
public boolean filterRowKey(Cell firstRowCell) {
// if stopRowKey is <= buffer, then true, filter row.
if (filterAllRemaining()) return true;
- int cmp = CellComparator.COMPARATOR.compareRows(firstRowCell, stopRowKey, 0, stopRowKey.length);
+ int cmp = CellComparatorImpl.COMPARATOR.compareRows(firstRowCell, stopRowKey, 0, stopRowKey.length);
done = reversed ? cmp < 0 : cmp > 0;
return done;
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
index a86b257..468af8c 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.ArrayList;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.yetus.audience.InterfaceAudience;
@@ -268,7 +267,7 @@ public class SingleColumnValueFilter extends FilterBase {
}
private boolean filterColumnValue(final Cell cell) {
- int compareResult = CellComparator.compareValue(cell, this.comparator);
+ int compareResult = CellUtil.compareValue(cell, this.comparator);
return CompareFilter.compare(this.op, compareResult);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
index 0925974..0f11156 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
@@ -32,7 +32,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.logging.Log;
@@ -677,7 +677,7 @@ public class TestClientNoCluster extends Configured implements Tool {
* Comparator for meta row keys.
*/
private static class MetaRowsComparator implements Comparator<byte []> {
- private final CellComparator delegate = CellComparator.META_COMPARATOR;
+ private final CellComparatorImpl delegate = CellComparatorImpl.META_COMPARATOR;
@Override
public int compare(byte[] left, byte[] right) {
return delegate.compareRows(new KeyValue.KeyOnlyKeyValue(left), right, 0, right.length);
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
index fa9c4ad..800de6d 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestOperation.java
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -388,7 +388,7 @@ public class TestOperation {
Assert.assertEquals(1984L, c.get(0).getTimestamp());
Assert.assertArrayEquals(VALUE, CellUtil.cloneValue(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimeStamp());
- Assert.assertEquals(0, CellComparator.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
+ Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
p = new Put(ROW);
p.addColumn(FAMILY, ByteBuffer.wrap(QUALIFIER), 2013L, null);
@@ -397,7 +397,7 @@ public class TestOperation {
Assert.assertEquals(2013L, c.get(0).getTimestamp());
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimeStamp());
- Assert.assertEquals(0, CellComparator.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
+ Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
p = new Put(ByteBuffer.wrap(ROW));
p.addColumn(FAMILY, ByteBuffer.wrap(QUALIFIER), 2001L, null);
@@ -407,7 +407,7 @@ public class TestOperation {
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertArrayEquals(ROW, CellUtil.cloneRow(c.get(0)));
Assert.assertEquals(HConstants.LATEST_TIMESTAMP, p.getTimeStamp());
- Assert.assertEquals(0, CellComparator.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
+ Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
p = new Put(ByteBuffer.wrap(ROW), 1970L);
p.addColumn(FAMILY, ByteBuffer.wrap(QUALIFIER), 2001L, null);
@@ -417,7 +417,7 @@ public class TestOperation {
Assert.assertArrayEquals(new byte[]{}, CellUtil.cloneValue(c.get(0)));
Assert.assertArrayEquals(ROW, CellUtil.cloneRow(c.get(0)));
Assert.assertEquals(1970L, p.getTimeStamp());
- Assert.assertEquals(0, CellComparator.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
+ Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(c.get(0), new KeyValue(c.get(0))));
}
@Test
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
index 0c69ece..f640c5e 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/filter/TestComparators.java
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -53,44 +53,44 @@ public class TestComparators {
ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer());
Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
ByteArrayComparable comparable = new BinaryComparator(r1);
- assertEquals(0, CellComparator.compareRow(bbCell, comparable));
- assertEquals(0, CellComparator.compareRow(kv, comparable));
+ assertEquals(0, CellUtil.compareRow(bbCell, comparable));
+ assertEquals(0, CellUtil.compareRow(kv, comparable));
kv = new KeyValue(r0, f, q1, v1);
buffer = ByteBuffer.wrap(kv.getBuffer());
bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
- assertTrue(CellComparator.compareRow(bbCell, comparable) > 0);
- assertTrue(CellComparator.compareRow(kv, comparable) > 0);
+ assertTrue(CellUtil.compareRow(bbCell, comparable) > 0);
+ assertTrue(CellUtil.compareRow(kv, comparable) > 0);
kv = new KeyValue(r2, f, q1, v1);
buffer = ByteBuffer.wrap(kv.getBuffer());
bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
- assertTrue(CellComparator.compareRow(bbCell, comparable) < 0);
- assertTrue(CellComparator.compareRow(kv, comparable) < 0);
+ assertTrue(CellUtil.compareRow(bbCell, comparable) < 0);
+ assertTrue(CellUtil.compareRow(kv, comparable) < 0);
// Qualifier compare
comparable = new BinaryPrefixComparator(Bytes.toBytes("qual"));
- assertEquals(0, CellComparator.compareQualifier(bbCell, comparable));
- assertEquals(0, CellComparator.compareQualifier(kv, comparable));
+ assertEquals(0, CellUtil.compareQualifier(bbCell, comparable));
+ assertEquals(0, CellUtil.compareQualifier(kv, comparable));
kv = new KeyValue(r2, f, q2, v1);
buffer = ByteBuffer.wrap(kv.getBuffer());
bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
- assertEquals(0, CellComparator.compareQualifier(bbCell, comparable));
- assertEquals(0, CellComparator.compareQualifier(kv, comparable));
+ assertEquals(0, CellUtil.compareQualifier(bbCell, comparable));
+ assertEquals(0, CellUtil.compareQualifier(kv, comparable));
kv = new KeyValue(r2, f, q3, v1);
buffer = ByteBuffer.wrap(kv.getBuffer());
bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
- assertTrue(CellComparator.compareQualifier(bbCell, comparable) < 0);
- assertTrue(CellComparator.compareQualifier(kv, comparable) < 0);
+ assertTrue(CellUtil.compareQualifier(bbCell, comparable) < 0);
+ assertTrue(CellUtil.compareQualifier(kv, comparable) < 0);
// Value compare
comparable = new LongComparator(l1);
- assertEquals(0, CellComparator.compareValue(bbCell, comparable));
- assertEquals(0, CellComparator.compareValue(kv, comparable));
+ assertEquals(0, CellUtil.compareValue(bbCell, comparable));
+ assertEquals(0, CellUtil.compareValue(kv, comparable));
kv = new KeyValue(r1, f, q1, v2);
buffer = ByteBuffer.wrap(kv.getBuffer());
bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
- assertTrue(CellComparator.compareValue(bbCell, comparable) < 0);
- assertTrue(CellComparator.compareValue(kv, comparable) < 0);
+ assertTrue(CellUtil.compareValue(bbCell, comparable) < 0);
+ assertTrue(CellUtil.compareValue(kv, comparable) < 0);
// Family compare
comparable = new SubstringComparator("cf");
- assertEquals(0, CellComparator.compareFamily(bbCell, comparable));
- assertEquals(0, CellComparator.compareFamily(kv, comparable));
+ assertEquals(0, CellUtil.compareFamily(bbCell, comparable));
+ assertEquals(0, CellUtil.compareFamily(kv, comparable));
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
index 469c3ea..91b02e6 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
@@ -26,7 +26,7 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
-import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Append;
@@ -261,7 +261,7 @@ public class TestProtobufUtil {
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(dbb, kv1.getLength(), kv2.getLength());
CellProtos.Cell cell = ProtobufUtil.toCell(offheapKV);
Cell newOffheapKV = ProtobufUtil.toCell(ExtendedCellBuilderFactory.create(CellBuilderType.SHALLOW_COPY), cell);
- assertTrue(CellComparator.COMPARATOR.compare(offheapKV, newOffheapKV) == 0);
+ assertTrue(CellComparatorImpl.COMPARATOR.compare(offheapKV, newOffheapKV) == 0);
}
/**
http://git-wip-us.apache.org/repos/asf/hbase/blob/70f4c5da/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
index 567b10c..a0f2fa4 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
@@ -15,630 +15,101 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.hadoop.hbase;
-import java.io.Serializable;
import java.util.Comparator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.KeyValue.Type;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
-import org.apache.hadoop.hbase.filter.ByteArrayComparable;
-import org.apache.hadoop.hbase.util.ByteBufferUtils;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import org.apache.hadoop.hbase.shaded.com.google.common.primitives.Longs;
-
/**
- * Compare two HBase cells. Do not use this method comparing <code>-ROOT-</code> or
- * <code>hbase:meta</code> cells. Cells from these tables need a specialized comparator, one that
- * takes account of the special formatting of the row where we have commas to delimit table from
- * regionname, from row. See KeyValue for how it has a special comparator to do hbase:meta cells
- * and yet another for -ROOT-.
- * While using this comparator for {{@link #compareRows(Cell, Cell)} et al, the hbase:meta cells
- * format should be taken into consideration, for which the instance of this comparator
- * should be used. In all other cases the static APIs in this comparator would be enough
+ * Comparator for comparing cells and has some specialized methods that allows comparing individual
+ * cell components like row, family, qualifier and timestamp
*/
-@edu.umd.cs.findbugs.annotations.SuppressWarnings(
- value="UNKNOWN",
- justification="Findbugs doesn't like the way we are negating the result of a compare in below")
-@InterfaceAudience.Private
+@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
@InterfaceStability.Evolving
-public class CellComparator implements Comparator<Cell>, Serializable {
- static final Log LOG = LogFactory.getLog(CellComparator.class);
- private static final long serialVersionUID = -8760041766259623329L;
+public interface CellComparator extends Comparator<Cell> {
/**
- * Comparator for plain key/values; i.e. non-catalog table key/values. Works on Key portion
- * of KeyValue only.
- */
- public static final CellComparator COMPARATOR = new CellComparator();
- /**
- * A {@link CellComparator} for <code>hbase:meta</code> catalog table
- * {@link KeyValue}s.
+ * Lexographically compares two cells. The key part of the cell is taken for comparison which
+ * includes row, family, qualifier, timestamp and type
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public static final CellComparator META_COMPARATOR = new MetaCellComparator();
-
@Override
- public int compare(Cell a, Cell b) {
- return compare(a, b, false);
- }
+ int compare(Cell leftCell, Cell rightCell);
/**
- * Compares only the key portion of a cell. It does not include the sequence id/mvcc of the
- * cell
- * @param left
- * @param right
- * @return an int greater than 0 if left > than right
- * lesser than 0 if left < than right
- * equal to 0 if left is equal to right
+ * Lexographically compares the rows of two cells.
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public final int compareKeyIgnoresMvcc(Cell left, Cell right) {
- return compare(left, right, true);
- }
-
- /**
- * Used when a cell needs to be compared with a key byte[] such as cases of
- * finding the index from the index block, bloom keys from the bloom blocks
- * This byte[] is expected to be serialized in the KeyValue serialization format
- * If the KeyValue (Cell's) serialization format changes this method cannot be used.
- * @param left the cell to be compared
- * @param key the serialized key part of a KeyValue
- * @param offset the offset in the key byte[]
- * @param length the length of the key byte[]
- * @return an int greater than 0 if left is greater than right
- * lesser than 0 if left is lesser than right
- * equal to 0 if left is equal to right
- */
- public final int compare(Cell left, byte[] key, int offset, int length) {
- // row
- short rrowlength = Bytes.toShort(key, offset);
- int c = compareRows(left, key, offset + Bytes.SIZEOF_SHORT, rrowlength);
- if (c != 0) return c;
-
- // Compare the rest of the two KVs without making any assumptions about
- // the common prefix. This function will not compare rows anyway, so we
- // don't need to tell it that the common prefix includes the row.
- return compareWithoutRow(left, key, offset, length, rrowlength);
- }
-
- /**
- * Compare cells.
- * @param a
- * @param b
- * @param ignoreSequenceid True if we are to compare the key portion only and ignore
- * the sequenceid. Set to false to compare key and consider sequenceid.
- * @return 0 if equal, -1 if a < b, and +1 if a > b.
- */
- private final int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
- // row
- int c = compareRows(a, b);
- if (c != 0) return c;
-
- c = compareWithoutRow(a, b);
- if(c != 0) return c;
-
- if (!ignoreSequenceid) {
- // Negate following comparisons so later edits show up first
- // mvccVersion: later sorts first
- return Longs.compare(b.getSequenceId(), a.getSequenceId());
- } else {
- return c;
- }
- }
-
- /**
- * Compares the family and qualifier part of the cell
- * @param left the left cell
- * @param right the right cell
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
- */
- public final static int compareColumns(final Cell left, final Cell right) {
- int diff = compareFamilies(left, right);
- if (diff != 0) {
- return diff;
- }
- return compareQualifiers(left, right);
- }
-
- private final static int compareColumns(Cell left, byte[] right, int rfoffset, int rflength,
- int rqoffset, int rqlength) {
- int diff = compareFamilies(left, right, rfoffset, rflength);
- if (diff != 0)
- return diff;
- return compareQualifiers(left, right, rqoffset, rqlength);
- }
-
- /**
- * Compare the families of left and right cell
- * @param left
- * @param right
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
- */
- public final static int compareFamilies(Cell left, Cell right) {
- if (left instanceof ByteBufferCell && right instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getFamilyByteBuffer(),
- ((ByteBufferCell) left).getFamilyPosition(), left.getFamilyLength(),
- ((ByteBufferCell) right).getFamilyByteBuffer(),
- ((ByteBufferCell) right).getFamilyPosition(), right.getFamilyLength());
- }
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getFamilyByteBuffer(),
- ((ByteBufferCell) left).getFamilyPosition(), left.getFamilyLength(),
- right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
- }
- if (right instanceof ByteBufferCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(
- left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- ((ByteBufferCell)right).getFamilyByteBuffer(),
- ((ByteBufferCell)right).getFamilyPosition(), right.getFamilyLength());
- }
- return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
- }
-
- private final static int compareFamilies(Cell left, byte[] right, int roffset, int rlength) {
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getFamilyByteBuffer(),
- ((ByteBufferCell) left).getFamilyPosition(), left.getFamilyLength(), right,
- roffset, rlength);
- }
- return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- right, roffset, rlength);
- }
-
- /**
- * Compare the qualifiers part of the left and right cells.
- * @param left
- * @param right
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
- */
- public final static int compareQualifiers(Cell left, Cell right) {
- if (left instanceof ByteBufferCell && right instanceof ByteBufferCell) {
- return ByteBufferUtils
- .compareTo(((ByteBufferCell) left).getQualifierByteBuffer(),
- ((ByteBufferCell) left).getQualifierPosition(),
- left.getQualifierLength(), ((ByteBufferCell) right).getQualifierByteBuffer(),
- ((ByteBufferCell) right).getQualifierPosition(),
- right.getQualifierLength());
- }
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getQualifierByteBuffer(),
- ((ByteBufferCell) left).getQualifierPosition(), left.getQualifierLength(),
- right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());
- }
- if (right instanceof ByteBufferCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getQualifierArray(),
- left.getQualifierOffset(), left.getQualifierLength(),
- ((ByteBufferCell)right).getQualifierByteBuffer(),
- ((ByteBufferCell)right).getQualifierPosition(), right.getQualifierLength());
- }
- return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
- right.getQualifierLength());
- }
-
- public final static int compareQualifiers(Cell left, byte[] right, int rOffset, int rLength) {
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getQualifierByteBuffer(),
- ((ByteBufferCell) left).getQualifierPosition(), left.getQualifierLength(),
- right, rOffset, rLength);
- }
- return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), right, rOffset, rLength);
- }
-
- /**
- * Compare columnFamily, qualifier, timestamp, and key type (everything
- * except the row). This method is used both in the normal comparator and
- * the "same-prefix" comparator. Note that we are assuming that row portions
- * of both KVs have already been parsed and found identical, and we don't
- * validate that assumption here.
- * @param commonPrefix
- * the length of the common prefix of the two key-values being
- * compared, including row length and row
- */
- private final int compareWithoutRow(Cell left,
- byte[] right, int roffset, int rlength, short rowlength) {
- /***
- * KeyValue Format and commonLength:
- * |_keyLen_|_valLen_|_rowLen_|_rowKey_|_famiLen_|_fami_|_Quali_|....
- * ------------------|-------commonLength--------|--------------
- */
- int commonLength = KeyValue.ROW_LENGTH_SIZE + KeyValue.FAMILY_LENGTH_SIZE + rowlength;
-
- // commonLength + TIMESTAMP_TYPE_SIZE
- int commonLengthWithTSAndType = KeyValue.TIMESTAMP_TYPE_SIZE + commonLength;
- // ColumnFamily + Qualifier length.
- int lcolumnlength = left.getFamilyLength() + left.getQualifierLength();
- int rcolumnlength = rlength - commonLengthWithTSAndType;
-
- byte ltype = left.getTypeByte();
- byte rtype = right[roffset + (rlength - 1)];
-
- // If the column is not specified, the "minimum" key type appears the
- // latest in the sorted order, regardless of the timestamp. This is used
- // for specifying the last key/value in a given row, because there is no
- // "lexicographically last column" (it would be infinitely long). The
- // "maximum" key type does not need this behavior.
- if (lcolumnlength == 0 && ltype == Type.Minimum.getCode()) {
- // left is "bigger", i.e. it appears later in the sorted order
- return 1;
- }
- if (rcolumnlength == 0 && rtype == Type.Minimum.getCode()) {
- return -1;
- }
-
- int rfamilyoffset = commonLength + roffset;
-
- // Column family length.
- int lfamilylength = left.getFamilyLength();
- int rfamilylength = right[rfamilyoffset - 1];
- // If left family size is not equal to right family size, we need not
- // compare the qualifiers.
- boolean sameFamilySize = (lfamilylength == rfamilylength);
- if (!sameFamilySize) {
- // comparing column family is enough.
- return compareFamilies(left, right, rfamilyoffset, rfamilylength);
- }
- // Compare family & qualifier together.
- // Families are same. Compare on qualifiers.
- int comparison = compareColumns(left, right, rfamilyoffset, rfamilylength, rfamilyoffset
- + rfamilylength, (rcolumnlength - rfamilylength));
- if (comparison != 0) {
- return comparison;
- }
-
- // //
- // Next compare timestamps.
- long rtimestamp = Bytes.toLong(right, roffset + (rlength - KeyValue.TIMESTAMP_TYPE_SIZE));
- int compare = compareTimestamps(left.getTimestamp(), rtimestamp);
- if (compare != 0) {
- return compare;
- }
-
- // Compare types. Let the delete types sort ahead of puts; i.e. types
- // of higher numbers sort before those of lesser numbers. Maximum (255)
- // appears ahead of everything, and minimum (0) appears after
- // everything.
- return (0xff & rtype) - (0xff & ltype);
- }
-
- /**
- * Compares the rows of the left and right cell.
- * For the hbase:meta case this method is overridden such that it can handle hbase:meta cells.
- * The caller should ensure using the appropriate comparator for hbase:meta.
- * @param left
- * @param right
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
- */
- public int compareRows(final Cell left, final Cell right) {
- // left and right can be exactly the same at the beginning of a row
- if (left == right) {
- return 0;
- }
- if (left instanceof ByteBufferCell && right instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getRowByteBuffer(),
- ((ByteBufferCell) left).getRowPosition(), left.getRowLength(),
- ((ByteBufferCell) right).getRowByteBuffer(),
- ((ByteBufferCell) right).getRowPosition(), right.getRowLength());
- }
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getRowByteBuffer(),
- ((ByteBufferCell) left).getRowPosition(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
- }
- if (right instanceof ByteBufferCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- ((ByteBufferCell)right).getRowByteBuffer(),
- ((ByteBufferCell)right).getRowPosition(), right.getRowLength());
- }
- return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
- }
+ int compareRows(Cell leftCell, Cell rightCell);
/**
* Compares the row part of the cell with a simple plain byte[] like the
- * stopRow in Scan. This should be used with context where for hbase:meta
- * cells the {{@link #META_COMPARATOR} should be used
- *
- * @param left
- * the cell to be compared
- * @param right
- * the kv serialized byte[] to be compared with
- * @param roffset
- * the offset in the byte[]
- * @param rlength
- * the length in the byte[]
- * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger
- * than byte[], -1 otherwise
- */
- public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
- if (left instanceof ByteBufferCell) {
- return ByteBufferUtils.compareTo(((ByteBufferCell) left).getRowByteBuffer(),
- ((ByteBufferCell) left).getRowPosition(), left.getRowLength(), right,
- roffset, rlength);
- }
- return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
- roffset, rlength);
- }
-
- public static int compareWithoutRow(final Cell left, final Cell right) {
- // If the column is not specified, the "minimum" key type appears the
- // latest in the sorted order, regardless of the timestamp. This is used
- // for specifying the last key/value in a given row, because there is no
- // "lexicographically last column" (it would be infinitely long). The
- // "maximum" key type does not need this behavior.
- // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this.
- int lFamLength = left.getFamilyLength();
- int rFamLength = right.getFamilyLength();
- int lQualLength = left.getQualifierLength();
- int rQualLength = right.getQualifierLength();
- if (lFamLength + lQualLength == 0
- && left.getTypeByte() == Type.Minimum.getCode()) {
- // left is "bigger", i.e. it appears later in the sorted order
- return 1;
- }
- if (rFamLength + rQualLength == 0
- && right.getTypeByte() == Type.Minimum.getCode()) {
- return -1;
- }
- if (lFamLength != rFamLength) {
- // comparing column family is enough.
- return compareFamilies(left, right);
- }
- // Compare cf:qualifier
- int diff = compareColumns(left, right);
- if (diff != 0) return diff;
-
- diff = compareTimestamps(left, right);
- if (diff != 0) return diff;
-
- // Compare types. Let the delete types sort ahead of puts; i.e. types
- // of higher numbers sort before those of lesser numbers. Maximum (255)
- // appears ahead of everything, and minimum (0) appears after
- // everything.
- return (0xff & right.getTypeByte()) - (0xff & left.getTypeByte());
- }
-
- /**
- * Compares cell's timestamps in DESCENDING order.
- * The below older timestamps sorting ahead of newer timestamps looks
- * wrong but it is intentional. This way, newer timestamps are first
- * found when we iterate over a memstore and newer versions are the
- * first we trip over when reading from a store file.
- * @return 1 if left's timestamp < right's timestamp
- * -1 if left's timestamp > right's timestamp
- * 0 if both timestamps are equal
- */
- public static int compareTimestamps(final Cell left, final Cell right) {
- return compareTimestamps(left.getTimestamp(), right.getTimestamp());
- }
-
- /**
- * Used to compare two cells based on the column hint provided. This is specifically
- * used when we need to optimize the seeks based on the next indexed key. This is an
- * advanced usage API specifically needed for some optimizations.
- * @param nextIndexedCell the next indexed cell
- * @param currentCell the cell to be compared
- * @param foff the family offset of the currentCell
- * @param flen the family length of the currentCell
- * @param colHint the column hint provided - could be null
- * @param coff the offset of the column hint if provided, if not offset of the currentCell's
- * qualifier
- * @param clen the length of the column hint if provided, if not length of the currentCell's
- * qualifier
- * @param ts the timestamp to be seeked
- * @param type the type to be seeked
- * @return an int based on the given column hint
- * TODO : To be moved out of here because this is a special API used in scan
- * optimization.
- */
- // compare a key against row/fam/qual/ts/type
- public final int compareKeyBasedOnColHint(Cell nextIndexedCell, Cell currentCell, int foff,
- int flen, byte[] colHint, int coff, int clen, long ts, byte type) {
- int compare = compareRows(nextIndexedCell, currentCell);
- if (compare != 0) {
- return compare;
- }
- // If the column is not specified, the "minimum" key type appears the
- // latest in the sorted order, regardless of the timestamp. This is used
- // for specifying the last key/value in a given row, because there is no
- // "lexicographically last column" (it would be infinitely long). The
- // "maximum" key type does not need this behavior.
- if (nextIndexedCell.getFamilyLength() + nextIndexedCell.getQualifierLength() == 0
- && nextIndexedCell.getTypeByte() == Type.Minimum.getCode()) {
- // left is "bigger", i.e. it appears later in the sorted order
- return 1;
- }
- if (flen + clen == 0 && type == Type.Minimum.getCode()) {
- return -1;
- }
-
- compare = compareFamilies(nextIndexedCell, currentCell);
- if (compare != 0) {
- return compare;
- }
- if (colHint == null) {
- compare = compareQualifiers(nextIndexedCell, currentCell);
- } else {
- compare = compareQualifiers(nextIndexedCell, colHint, coff, clen);
- }
- if (compare != 0) {
- return compare;
- }
- // Next compare timestamps.
- compare = compareTimestamps(nextIndexedCell.getTimestamp(), ts);
- if (compare != 0) {
- return compare;
- }
-
- // Compare types. Let the delete types sort ahead of puts; i.e. types
- // of higher numbers sort before those of lesser numbers. Maximum (255)
- // appears ahead of everything, and minimum (0) appears after
- // everything.
- return (0xff & type) - (0xff & nextIndexedCell.getTypeByte());
- }
-
- /**
- * Compares timestamps in DESCENDING order.
- * The below older timestamps sorting ahead of newer timestamps looks
- * wrong but it is intentional. This way, newer timestamps are first
- * found when we iterate over a memstore and newer versions are the
- * first we trip over when reading from a store file.
- * @return 1 if left timestamp < right timestamp
- * -1 if left timestamp > right timestamp
- * 0 if both timestamps are equal
+ * stopRow in Scan.
+ * @param cell the cell
+ * @param bytes the byte[] representing the row to be compared with
+ * @param offset the offset of the byte[]
+ * @param length the length of the byte[]
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public static int compareTimestamps(final long ltimestamp, final long rtimestamp) {
- if (ltimestamp < rtimestamp) {
- return 1;
- } else if (ltimestamp > rtimestamp) {
- return -1;
- }
- return 0;
- }
+ int compareRows(Cell cell, byte[] bytes, int offset, int length);
/**
- * Compare cell's row against given comparator
- * @param cell
- * @param comparator
- * @return result comparing cell's row
+ * Lexographically compares the two cells excluding the row part. It compares family, qualifier,
+ * timestamp and the type
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public static int compareRow(Cell cell, ByteArrayComparable comparator) {
- if (cell instanceof ByteBufferCell) {
- return comparator.compareTo(((ByteBufferCell) cell).getRowByteBuffer(),
- ((ByteBufferCell) cell).getRowPosition(), cell.getRowLength());
- }
- return comparator.compareTo(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
- }
+ int compareWithoutRow(Cell leftCell, Cell rightCell);
/**
- * Compare cell's column family against given comparator
- * @param cell
- * @param comparator
- * @return result comparing cell's column family
+ * Lexographically compares the families of the two cells
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public static int compareFamily(Cell cell, ByteArrayComparable comparator) {
- if (cell instanceof ByteBufferCell) {
- return comparator.compareTo(((ByteBufferCell) cell).getFamilyByteBuffer(),
- ((ByteBufferCell) cell).getFamilyPosition(), cell.getFamilyLength());
- }
- return comparator.compareTo(cell.getFamilyArray(), cell.getFamilyOffset(),
- cell.getFamilyLength());
- }
+ int compareFamilies(Cell leftCell, Cell rightCell);
/**
- * Compare cell's qualifier against given comparator
- * @param cell
- * @param comparator
- * @return result comparing cell's qualifier
+ * Lexographically compares the qualifiers of the two cells
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both
+ * cells are equal
*/
- public static int compareQualifier(Cell cell, ByteArrayComparable comparator) {
- if (cell instanceof ByteBufferCell) {
- return comparator.compareTo(((ByteBufferCell) cell).getQualifierByteBuffer(),
- ((ByteBufferCell) cell).getQualifierPosition(), cell.getQualifierLength());
- }
- return comparator.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(),
- cell.getQualifierLength());
- }
+ int compareQualifiers(Cell leftCell, Cell rightCell);
/**
- * Compare cell's value against given comparator
- * @param cell
- * @param comparator
- * @return result comparing cell's value
+ * Compares cell's timestamps in DESCENDING order. The below older timestamps sorting ahead of
+ * newer timestamps looks wrong but it is intentional. This way, newer timestamps are first found
+ * when we iterate over a memstore and newer versions are the first we trip over when reading from
+ * a store file.
+ * @param leftCell the left hand side cell
+ * @param rightCell the right hand side cell
+ * @return 1 if left's timestamp < right's timestamp -1 if left's timestamp > right's
+ * timestamp 0 if both timestamps are equal
*/
- public static int compareValue(Cell cell, ByteArrayComparable comparator) {
- if (cell instanceof ByteBufferCell) {
- return comparator.compareTo(((ByteBufferCell) cell).getValueByteBuffer(),
- ((ByteBufferCell) cell).getValuePosition(), cell.getValueLength());
- }
- return comparator.compareTo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
- }
+ int compareTimestamps(Cell leftCell, Cell rightCell);
/**
- * A {@link CellComparator} for <code>hbase:meta</code> catalog table
- * {@link KeyValue}s.
+ * Compares cell's timestamps in DESCENDING order. The below older timestamps sorting ahead of
+ * newer timestamps looks wrong but it is intentional. This way, newer timestamps are first found
+ * when we iterate over a memstore and newer versions are the first we trip over when reading from
+ * a store file.
+ * @param leftCellts the left cell's timestamp
+ * @param rightCellts the right cell's timestamp
+ * @return 1 if left's timestamp < right's timestamp -1 if left's timestamp > right's
+ * timestamp 0 if both timestamps are equal
*/
- public static class MetaCellComparator extends CellComparator {
-
- @Override
- public int compareRows(final Cell left, final Cell right) {
- return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
- right.getRowArray(), right.getRowOffset(), right.getRowLength());
- }
-
- @Override
- public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
- return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
- roffset, rlength);
- }
-
- private int compareRows(byte[] left, int loffset, int llength, byte[] right, int roffset,
- int rlength) {
- int leftDelimiter = Bytes.searchDelimiterIndex(left, loffset, llength, HConstants.DELIMITER);
- int rightDelimiter = Bytes
- .searchDelimiterIndex(right, roffset, rlength, HConstants.DELIMITER);
- // Compare up to the delimiter
- int lpart = (leftDelimiter < 0 ? llength : leftDelimiter - loffset);
- int rpart = (rightDelimiter < 0 ? rlength : rightDelimiter - roffset);
- int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);
- if (result != 0) {
- return result;
- } else {
- if (leftDelimiter < 0 && rightDelimiter >= 0) {
- return -1;
- } else if (rightDelimiter < 0 && leftDelimiter >= 0) {
- return 1;
- } else if (leftDelimiter < 0 && rightDelimiter < 0) {
- return 0;
- }
- }
- // Compare middle bit of the row.
- // Move past delimiter
- leftDelimiter++;
- rightDelimiter++;
- int leftFarDelimiter = Bytes.searchDelimiterIndexInReverse(left, leftDelimiter, llength
- - (leftDelimiter - loffset), HConstants.DELIMITER);
- int rightFarDelimiter = Bytes.searchDelimiterIndexInReverse(right, rightDelimiter, rlength
- - (rightDelimiter - roffset), HConstants.DELIMITER);
- // Now compare middlesection of row.
- lpart = (leftFarDelimiter < 0 ? llength + loffset : leftFarDelimiter) - leftDelimiter;
- rpart = (rightFarDelimiter < 0 ? rlength + roffset : rightFarDelimiter) - rightDelimiter;
- result = Bytes.compareTo(left, leftDelimiter, lpart, right, rightDelimiter, rpart);
- if (result != 0) {
- return result;
- } else {
- if (leftDelimiter < 0 && rightDelimiter >= 0) {
- return -1;
- } else if (rightDelimiter < 0 && leftDelimiter >= 0) {
- return 1;
- } else if (leftDelimiter < 0 && rightDelimiter < 0) {
- return 0;
- }
- }
- // Compare last part of row, the rowid.
- leftFarDelimiter++;
- rightFarDelimiter++;
- result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset),
- right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));
- return result;
- }
- }
+ int compareTimestamps(long leftCellts, long rightCellts);
}