From c6f6fde72e18560119868c6d9a39f0ebd1ffce78 Mon Sep 17 00:00:00 2001 From: Mike Drob Date: Thu, 2 Nov 2017 16:16:43 -0500 Subject: [PATCH] HBASE-19160 expose some CellUtil and CellComparator at not-private --- .../org/apache/hadoop/hbase/CellComparator.java | 7 +++++ .../java/org/apache/hadoop/hbase/CellUtil.java | 36 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) 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 a0f2fa492c..94ffdd4f40 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 @@ -28,6 +28,13 @@ import org.apache.yetus.audience.InterfaceStability; @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) @InterfaceStability.Evolving public interface CellComparator extends Comparator { + /** + * A comparator for ordering cells in user-space tables. Useful when writing cells in sorted + * order as necessary for bulk import. + */ + default CellComparator getInstance() { + return CellComparatorImpl.COMPARATOR; + } /** * Lexographically compares two cells. The key part of the cell is taken for comparison which diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java index 8a5bb2cdd4..4a6b0d287b 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java @@ -1485,4 +1485,40 @@ public final class CellUtil { if (diff != 0) return diff; return compareQualifiers(left, right, rqoffset, rqlength); } + + /** + * Create a Cell that is smaller than all other possible Cells for the given Cell's row. + * @param cell A cell to extract the row from + * @return First possible Cell on passed Cell's row. + */ + public static Cell createFirstOnRow(final Cell cell) { + return PrivateCellUtil.createFirstOnRow(cell); + } + + /** + * Create a Cell that is smaller than all other possible Cells for the given row. + * @param row A rowkey + * @return First possible Cell on passed Cell's row. + */ + public static Cell createFirstOnRow(final byte[] row) { + return PrivateCellUtil.createFirstOnRow(row); + } + + /** + * Create a Cell that is larger than all other possible Cells for the given Cell's row. + * @param cell A cell to extract the row from + * @return Last possible Cell on passed Cell's row. + */ + public static Cell createLastOnRow(final Cell cell) { + return PrivateCellUtil.createLastOnRow(cell); + } + + /** + * Create a Cell that is larger than all other possible Cells for the given row. + * @param row A rowkey + * @return Last possible Cell on passed Cell's row. + */ + public static Cell createLastOnRow(final byte[] row) { + return PrivateCellUtil.createLastOnRow(row); + } } -- 2.14.1