You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2016/07/22 01:15:57 UTC
[1/7] hbase git commit: HBASE-11144 Filter to support scanning
multiple row key ranges (Jiajia Li)
Repository: hbase
Updated Branches:
refs/heads/0.98 33d64e021 -> 10e06ca61
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
new file mode 100644
index 0000000..c2d25de
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
@@ -0,0 +1,465 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.filter;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(MediumTests.class)
+public class TestMultiRowRangeFilter {
+
+ private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ private final Log LOG = LogFactory.getLog(this.getClass());
+ private byte[] family = Bytes.toBytes("family");
+ private byte[] qf = Bytes.toBytes("qf");
+ private byte[] value = Bytes.toBytes("val");
+ private byte[] tableName;
+ private int numRows = 100;
+
+ /**
+ * @throws Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ TEST_UTIL.startMiniCluster();
+ }
+
+ /**
+ * @throws Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ @Test
+ public void testMergeAndSortWithEmptyStartRow() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(15), true, Bytes.toBytes(40), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(40), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithEmptyStopRow() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(15), true, Bytes.toBytes(""), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(70), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(""), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithEmptyStartRowAndStopRow() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(""), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(70), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(""), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testMultiRowRangeWithoutRange() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ new MultiRowRangeFilter(ranges);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testMultiRowRangeWithInvalidRange() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ // the start row larger than the stop row
+ ranges.add(new RowRange(Bytes.toBytes(80), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(70), false));
+ new MultiRowRangeFilter(ranges);
+ }
+
+ @Test
+ public void testMergeAndSortWithoutOverlap() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ expectedRanges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ expectedRanges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithOverlap() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(15), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(30), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(50), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(70), false));
+ ranges.add(new RowRange(Bytes.toBytes(90), true, Bytes.toBytes(100), false));
+ ranges.add(new RowRange(Bytes.toBytes(95), true, Bytes.toBytes(100), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(70), false));
+ expectedRanges.add(new RowRange(Bytes.toBytes(90), true, Bytes.toBytes(100), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithStartRowInclusive() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(""), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(""), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithRowExclusive() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(20), false, Bytes.toBytes(""), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ expectedRanges.add(new RowRange(Bytes.toBytes(20), false, Bytes.toBytes(""), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ @Test
+ public void testMergeAndSortWithRowInclusive() throws IOException {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), true));
+ ranges.add(new RowRange(Bytes.toBytes(20), false, Bytes.toBytes(""), false));
+ List<RowRange> actualRanges = MultiRowRangeFilter.sortAndMerge(ranges);
+ List<RowRange> expectedRanges = new ArrayList<RowRange>();
+ expectedRanges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(""), false));
+ assertRangesEqual(expectedRanges, actualRanges);
+ }
+
+ public void assertRangesEqual(List<RowRange> expected, List<RowRange> actual) {
+ assertEquals(expected.size(), actual.size());
+ for(int i = 0; i < expected.size(); i++) {
+ Assert.assertTrue(Bytes.equals(expected.get(i).getStartRow(), actual.get(i).getStartRow()));
+ Assert.assertTrue(expected.get(i).isStartRowInclusive() ==
+ actual.get(i).isStartRowInclusive());
+ Assert.assertTrue(Bytes.equals(expected.get(i).getStopRow(), actual.get(i).getStopRow()));
+ Assert.assertTrue(expected.get(i).isStopRowInclusive() ==
+ actual.get(i).isStopRowInclusive());
+ }
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithRangeOverlap() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithRangeOverlap");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(15), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(65), true, Bytes.toBytes(75), false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, null, false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(80), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(40), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(""), ht);
+
+ assertEquals(results1.size() + results2.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithoutRangeOverlap() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithoutRangeOverlap");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(20), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(30), Bytes.toBytes(40), ht);
+ List<Cell> results3 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(70), ht);
+
+ assertEquals(results1.size() + results2.size() + results3.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithEmptyStartRow() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithEmptyStartRow");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(10), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ List<Cell> results1 = getScanResult(Bytes.toBytes(""), Bytes.toBytes(10), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(30), Bytes.toBytes(40), ht);
+ assertEquals(results1.size() + results2.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithEmptyStopRow() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithEmptyStopRow");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(""), false));
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(""), ht);
+ assertEquals(results1.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithInclusive() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithInclusive");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(65), true, Bytes.toBytes(75), false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, null, false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(80), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(40), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(""), ht);
+
+ assertEquals(results1.size() + results2.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeFilterWithExclusive() throws IOException {
+ tableName = Bytes.toBytes("testMultiRowRangeFilterWithExclusive");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(20), false, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(65), true, Bytes.toBytes(75), false));
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges);
+ scan.setFilter(filter);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(40), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(65), Bytes.toBytes(75), ht);
+
+ assertEquals((results1.size() - 1) + results2.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeWithFilterListAndOperator() throws IOException {
+ tableName = Bytes.toBytes("TestMultiRowRangeFilterWithFilterListAndOperator");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges1 = new ArrayList<RowRange>();
+ ranges1.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges1.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ ranges1.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+
+ MultiRowRangeFilter filter1 = new MultiRowRangeFilter(ranges1);
+
+ List<RowRange> ranges2 = new ArrayList<RowRange>();
+ ranges2.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(40), false));
+ ranges2.add(new RowRange(Bytes.toBytes(80), true, Bytes.toBytes(90), false));
+
+ MultiRowRangeFilter filter2 = new MultiRowRangeFilter(ranges2);
+
+ FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
+ filterList.addFilter(filter1);
+ filterList.addFilter(filter2);
+ scan.setFilter(filterList);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(30), Bytes.toBytes(40), ht);
+
+ assertEquals(results1.size(), resultsSize);
+
+ ht.close();
+ }
+
+ @Test
+ public void testMultiRowRangeWithFilterListOrOperator() throws IOException {
+ tableName = Bytes.toBytes("TestMultiRowRangeFilterWithFilterListOrOperator");
+ HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+ generateRows(numRows, ht, family, qf, value);
+
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+
+ List<RowRange> ranges1 = new ArrayList<RowRange>();
+ ranges1.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ ranges1.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges1.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+
+ MultiRowRangeFilter filter1 = new MultiRowRangeFilter(ranges1);
+
+ List<RowRange> ranges2 = new ArrayList<RowRange>();
+ ranges2.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(40), false));
+ ranges2.add(new RowRange(Bytes.toBytes(80), true, Bytes.toBytes(90), false));
+
+ MultiRowRangeFilter filter2 = new MultiRowRangeFilter(ranges2);
+
+ FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);
+ filterList.addFilter(filter1);
+ filterList.addFilter(filter2);
+ scan.setFilter(filterList);
+ int resultsSize = getResultsSize(ht, scan);
+ LOG.info("found " + resultsSize + " results");
+ List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(40), ht);
+ List<Cell> results2 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(70), ht);
+ List<Cell> results3 = getScanResult(Bytes.toBytes(80), Bytes.toBytes(90), ht);
+
+ assertEquals(results1.size() + results2.size() + results3.size(),resultsSize);
+
+ ht.close();
+ }
+
+ private void generateRows(int numberOfRows, HTable ht, byte[] family, byte[] qf, byte[] value)
+ throws IOException {
+ for (int i = 0; i < numberOfRows; i++) {
+ byte[] row = Bytes.toBytes(i);
+ Put p = new Put(row);
+ p.add(family, qf, value);
+ ht.put(p);
+ }
+ TEST_UTIL.flush();
+ }
+
+ private List<Cell> getScanResult(byte[] startRow, byte[] stopRow, HTable ht) throws IOException {
+ Scan scan = new Scan();
+ scan.setMaxVersions();
+ if(!Bytes.toString(startRow).isEmpty()) {
+ scan.setStartRow(startRow);
+ }
+ if(!Bytes.toString(stopRow).isEmpty()) {
+ scan.setStopRow(stopRow);
+ }
+ ResultScanner scanner = ht.getScanner(scan);
+ List<Cell> kvList = new ArrayList<Cell>();
+ Result r;
+ while ((r = scanner.next()) != null) {
+ for (Cell kv : r.listCells()) {
+ kvList.add(kv);
+ }
+ }
+ return kvList;
+ }
+
+ private int getResultsSize(HTable ht, Scan scan) throws IOException {
+ ResultScanner scanner = ht.getScanner(scan);
+ List<Cell> results = new ArrayList<Cell>();
+ Result r;
+ while ((r = scanner.next()) != null) {
+ for (Cell kv : r.listCells()) {
+ results.add(kv);
+ }
+ }
+ return results.size();
+ }
+}
\ No newline at end of file
[6/7] hbase git commit: HBASE-15115 Fix findbugs complaints in
hbase-client
Posted by ap...@apache.org.
HBASE-15115 Fix findbugs complaints in hbase-client
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e5d0d485
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e5d0d485
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e5d0d485
Branch: refs/heads/0.98
Commit: e5d0d4858070974a1d4b8a1110ad5f174a0faf68
Parents: 3ca0780
Author: stack <st...@apache.org>
Authored: Fri Jan 15 10:25:49 2016 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 17:56:05 2016 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/client/MetricsConnection.java | 2 +-
.../hadoop/hbase/client/RetriesExhaustedException.java | 3 +--
.../java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java | 8 ++------
.../java/org/apache/hadoop/hbase/filter/LongComparator.java | 2 --
.../org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java | 2 ++
5 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/e5d0d485/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
index f73356a..919895e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
@@ -103,7 +103,7 @@ public class MetricsConnection implements StatisticTrackable {
}
@VisibleForTesting
- protected final class CallTracker {
+ protected static final class CallTracker {
private final String name;
@VisibleForTesting final Timer callTimer;
@VisibleForTesting final Histogram reqHist;
http://git-wip-us.apache.org/repos/asf/hbase/blob/e5d0d485/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
index d4f1057..0c62cff 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
@@ -84,8 +84,7 @@ public class RetriesExhaustedException extends IOException {
public RetriesExhaustedException(final int numTries,
final List<ThrowableWithExtraContext> exceptions) {
super(getMessage(numTries, exceptions),
- (exceptions != null && !exceptions.isEmpty() ?
- exceptions.get(exceptions.size() - 1).t : null));
+ exceptions.isEmpty()? null: exceptions.get(exceptions.size() - 1).t);
}
private static String getMessage(String callableVitals, int numTries,
http://git-wip-us.apache.org/repos/asf/hbase/blob/e5d0d485/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 a1245cd..cd8f908 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
@@ -194,12 +194,8 @@ public class FuzzyRowFilter extends FilterBase {
@Override
public int compare(Pair<byte[], Pair<byte[], byte[]>> o1,
Pair<byte[], Pair<byte[], byte[]>> o2) {
- int compare = Bytes.compareTo(o1.getFirst(), o2.getFirst());
- if (!isReversed()) {
- return compare;
- } else {
- return -compare;
- }
+ return isReversed()? Bytes.compareTo(o2.getFirst(), o1.getFirst()):
+ Bytes.compareTo(o1.getFirst(), o2.getFirst());
}
});
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/e5d0d485/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/LongComparator.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/LongComparator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/LongComparator.java
index f05675a..5c8a3cb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/LongComparator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/LongComparator.java
@@ -79,8 +79,6 @@ public class LongComparator extends ByteArrayComparable {
*/
boolean areSerializedFieldsEqual(LongComparator other) {
if (other == this) return true;
- if (!(other instanceof LongComparator)) return false;
-
return super.areSerializedFieldsEqual(other);
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/e5d0d485/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
index 4bcf430..e556d5e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -499,6 +499,8 @@ public class MultiRowRangeFilter extends FilterBase {
}
@Override
+ @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="EQ_COMPARETO_USE_OBJECT_EQUALS",
+ justification="This compareTo is not of this Object, but of referenced RowRange")
public int compareTo(RowRange other) {
return Bytes.compareTo(this.startRow, other.startRow);
}
[5/7] hbase git commit: HBASE-13594 MultiRowRangeFilter shouldn't
call HBaseZeroCopyByteString.wrap() directly
Posted by ap...@apache.org.
HBASE-13594 MultiRowRangeFilter shouldn't call HBaseZeroCopyByteString.wrap() directly
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f3fa22a3
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f3fa22a3
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f3fa22a3
Branch: refs/heads/0.98
Commit: f3fa22a385f22be418b969ee19ce2b0e30537861
Parents: abe1168
Author: tedyu <yu...@gmail.com>
Authored: Wed Apr 29 10:35:45 2015 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 17:54:19 2016 -0700
----------------------------------------------------------------------
.../apache/hadoop/hbase/filter/MultiRowRangeFilter.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/f3fa22a3/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
index 1ac9693..24c8135 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -22,16 +22,16 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.protobuf.generated.FilterProtos;
+import org.apache.hadoop.hbase.util.ByteStringer;
import org.apache.hadoop.hbase.util.Bytes;
-import com.google.protobuf.HBaseZeroCopyByteString;
import com.google.protobuf.InvalidProtocolBufferException;
/**
@@ -146,10 +146,10 @@ public class MultiRowRangeFilter extends FilterBase {
if (range != null) {
FilterProtos.RowRange.Builder rangebuilder = FilterProtos.RowRange.newBuilder();
if (range.startRow != null)
- rangebuilder.setStartRow(HBaseZeroCopyByteString.wrap(range.startRow));
+ rangebuilder.setStartRow(ByteStringer.wrap(range.startRow));
rangebuilder.setStartRowInclusive(range.startRowInclusive);
if (range.stopRow != null)
- rangebuilder.setStopRow(HBaseZeroCopyByteString.wrap(range.stopRow));
+ rangebuilder.setStopRow(ByteStringer.wrap(range.stopRow));
rangebuilder.setStopRowInclusive(range.stopRowInclusive);
range.isScan = Bytes.equals(range.startRow, range.stopRow) ? 1 : 0;
builder.addRowRangeList(rangebuilder.build());
[2/7] hbase git commit: HBASE-11144 Filter to support scanning
multiple row key ranges (Jiajia Li)
Posted by ap...@apache.org.
HBASE-11144 Filter to support scanning multiple row key ranges (Jiajia Li)
Conflicts:
hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b2d883dd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b2d883dd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b2d883dd
Branch: refs/heads/0.98
Commit: b2d883ddcf47833786d7ee0eeaa52bee60c00de5
Parents: 33d64e0
Author: tedyu <yu...@gmail.com>
Authored: Tue Jan 13 07:04:49 2015 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 17:49:22 2016 -0700
----------------------------------------------------------------------
.../hbase/filter/MultiRowRangeFilter.java | 508 ++++++
.../hbase/protobuf/generated/FilterProtos.java | 1449 +++++++++++++++++-
hbase-protocol/src/main/protobuf/Filter.proto | 11 +
.../hadoop/hbase/rest/model/ScannerModel.java | 20 +-
.../hbase/filter/TestFilterSerialization.java | 15 +
.../hbase/filter/TestMultiRowRangeFilter.java | 465 ++++++
6 files changed, 2465 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
new file mode 100644
index 0000000..bd880a0
--- /dev/null
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -0,0 +1,508 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.filter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.classification.InterfaceStability;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.protobuf.generated.FilterProtos;
+import org.apache.hadoop.hbase.util.Bytes;
+
+import com.google.protobuf.HBaseZeroCopyByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+
+/**
+ * Filter to support scan multiple row key ranges. It can construct the row key ranges from the
+ * passed list which can be accessed by each region server.
+ *
+ * HBase is quite efficient when scanning only one small row key range. If user needs to specify
+ * multiple row key ranges in one scan, the typical solutions are: 1. through FilterList which is a
+ * list of row key Filters, 2. using the SQL layer over HBase to join with two table, such as hive,
+ * phoenix etc. However, both solutions are inefficient. Both of them can't utilize the range info
+ * to perform fast forwarding during scan which is quite time consuming. If the number of ranges
+ * are quite big (e.g. millions), join is a proper solution though it is slow. However, there are
+ * cases that user wants to specify a small number of ranges to scan (e.g. <1000 ranges). Both
+ * solutions can't provide satisfactory performance in such case. MultiRowRangeFilter is to support
+ * such usec ase (scan multiple row key ranges), which can construct the row key ranges from user
+ * specified list and perform fast-forwarding during scan. Thus, the scan will be quite efficient.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public class MultiRowRangeFilter extends FilterBase {
+
+ private List<RowRange> rangeList;
+
+ private static final int ROW_BEFORE_FIRST_RANGE = -1;
+ private boolean EXCLUSIVE = false;
+ private boolean done = false;
+ private boolean initialized = false;
+ private int index;
+ private RowRange range;
+ private ReturnCode currentReturnCode;
+
+ /**
+ * @param list A list of <code>RowRange</code>
+ * @throws java.io.IOException
+ * throw an exception if the range list is not in an natural order or any
+ * <code>RowRange</code> is invalid
+ */
+ public MultiRowRangeFilter(List<RowRange> list) throws IOException {
+ this.rangeList = sortAndMerge(list);
+ }
+
+ @Override
+ public boolean filterAllRemaining() {
+ return done;
+ }
+
+ public List<RowRange> getRowRanges() {
+ return this.rangeList;
+ }
+
+ @Override
+ public boolean filterRowKey(byte[] buffer, int offset, int length) {
+ // If it is the first time of running, calculate the current range index for
+ // the row key. If index is out of bound which happens when the start row
+ // user sets is after the largest stop row of the ranges, stop the scan.
+ // If row key is after the current range, find the next range and update index.
+ if (!initialized || !range.contains(buffer, offset, length)) {
+ byte[] rowkey = new byte[length];
+ System.arraycopy(buffer, offset, rowkey, 0, length);
+ index = getNextRangeIndex(rowkey);
+ if (index >= rangeList.size()) {
+ done = true;
+ currentReturnCode = ReturnCode.NEXT_ROW;
+ return false;
+ }
+ if(index != ROW_BEFORE_FIRST_RANGE) {
+ range = rangeList.get(index);
+ } else {
+ range = rangeList.get(0);
+ }
+ if(EXCLUSIVE) {
+ EXCLUSIVE = false;
+ currentReturnCode = ReturnCode.NEXT_ROW;
+ return false;
+ }
+ if (!initialized) {
+ if(index != ROW_BEFORE_FIRST_RANGE) {
+ currentReturnCode = ReturnCode.INCLUDE;
+ } else {
+ currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
+ }
+ initialized = true;
+ } else {
+ currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
+ }
+ } else {
+ currentReturnCode = ReturnCode.INCLUDE;
+ }
+ return false;
+ }
+
+ @Override
+ public ReturnCode filterKeyValue(Cell ignored) {
+ return currentReturnCode;
+ }
+
+ @Override
+ public Cell getNextCellHint(Cell currentKV) {
+ // skip to the next range's start row
+ return KeyValueUtil.createFirstOnRow(range.startRow);
+ }
+
+ /**
+ * @return The filter serialized using pb
+ */
+ public byte[] toByteArray() {
+ FilterProtos.MultiRowRangeFilter.Builder builder = FilterProtos.MultiRowRangeFilter
+ .newBuilder();
+ for (RowRange range : rangeList) {
+ if (range != null) {
+ FilterProtos.RowRange.Builder rangebuilder = FilterProtos.RowRange.newBuilder();
+ if (range.startRow != null)
+ rangebuilder.setStartRow(HBaseZeroCopyByteString.wrap(range.startRow));
+ rangebuilder.setStartRowInclusive(range.startRowInclusive);
+ if (range.stopRow != null)
+ rangebuilder.setStopRow(HBaseZeroCopyByteString.wrap(range.stopRow));
+ rangebuilder.setStopRowInclusive(range.stopRowInclusive);
+ range.isScan = Bytes.equals(range.startRow, range.stopRow) ? 1 : 0;
+ builder.addRowRangeList(rangebuilder.build());
+ }
+ }
+ return builder.build().toByteArray();
+ }
+
+ /**
+ * @param pbBytes A pb serialized instance
+ * @return An instance of MultiRowRangeFilter
+ * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
+ */
+ public static MultiRowRangeFilter parseFrom(final byte[] pbBytes)
+ throws DeserializationException {
+ FilterProtos.MultiRowRangeFilter proto;
+ try {
+ proto = FilterProtos.MultiRowRangeFilter.parseFrom(pbBytes);
+ } catch (InvalidProtocolBufferException e) {
+ throw new DeserializationException(e);
+ }
+ int length = proto.getRowRangeListCount();
+ List<FilterProtos.RowRange> rangeProtos = proto.getRowRangeListList();
+ List<RowRange> rangeList = new ArrayList<RowRange>(length);
+ for (FilterProtos.RowRange rangeProto : rangeProtos) {
+ RowRange range = new RowRange(rangeProto.hasStartRow() ? rangeProto.getStartRow()
+ .toByteArray() : null, rangeProto.getStartRowInclusive(), rangeProto.hasStopRow() ?
+ rangeProto.getStopRow().toByteArray() : null, rangeProto.getStopRowInclusive());
+ rangeList.add(range);
+ }
+ try {
+ return new MultiRowRangeFilter(rangeList);
+ } catch (IOException e) {
+ throw new DeserializationException("Fail to instantiate the MultiRowRangeFilter", e);
+ }
+ }
+
+ /**
+ * @param o the filter to compare
+ * @return true if and only if the fields of the filter that are serialized are equal to the
+ * corresponding fields in other. Used for testing.
+ */
+ boolean areSerializedFieldsEqual(Filter o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof MultiRowRangeFilter))
+ return false;
+
+ MultiRowRangeFilter other = (MultiRowRangeFilter) o;
+ if (this.rangeList.size() != other.rangeList.size())
+ return false;
+ for (int i = 0; i < rangeList.size(); ++i) {
+ RowRange thisRange = this.rangeList.get(i);
+ RowRange otherRange = other.rangeList.get(i);
+ if (!(Bytes.equals(thisRange.startRow, otherRange.startRow) && Bytes.equals(
+ thisRange.stopRow, otherRange.stopRow) && (thisRange.startRowInclusive ==
+ otherRange.startRowInclusive) && (thisRange.stopRowInclusive ==
+ otherRange.stopRowInclusive))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * calculate the position where the row key in the ranges list.
+ *
+ * @param rowKey the row key to calculate
+ * @return index the position of the row key
+ */
+ private int getNextRangeIndex(byte[] rowKey) {
+ RowRange temp = new RowRange(rowKey, true, null, true);
+ int index = Collections.binarySearch(rangeList, temp);
+ if (index < 0) {
+ int insertionPosition = -index - 1;
+ // check if the row key in the range before the insertion position
+ if (insertionPosition != 0 && rangeList.get(insertionPosition - 1).contains(rowKey)) {
+ return insertionPosition - 1;
+ }
+ // check if the row key is before the first range
+ if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) {
+ return ROW_BEFORE_FIRST_RANGE;
+ }
+ return insertionPosition;
+ }
+ // the row key equals one of the start keys, and the the range exclude the start key
+ if(rangeList.get(index).startRowInclusive == false) {
+ EXCLUSIVE = true;
+ }
+ return index;
+ }
+
+ /**
+ * sort the ranges and if the ranges with overlap, then merge them.
+ *
+ * @param ranges the list of ranges to sort and merge.
+ * @return the ranges after sort and merge.
+ */
+ public static List<RowRange> sortAndMerge(List<RowRange> ranges) {
+ if (ranges.size() == 0) {
+ throw new IllegalArgumentException("No ranges found.");
+ }
+ List<RowRange> invalidRanges = new ArrayList<RowRange>();
+ List<RowRange> newRanges = new ArrayList<RowRange>(ranges.size());
+ Collections.sort(ranges);
+ if(ranges.get(0).isValid()) {
+ if (ranges.size() == 1) {
+ newRanges.add(ranges.get(0));
+ }
+ } else {
+ invalidRanges.add(ranges.get(0));
+ }
+
+ byte[] lastStartRow = ranges.get(0).startRow;
+ boolean lastStartRowInclusive = ranges.get(0).startRowInclusive;
+ byte[] lastStopRow = ranges.get(0).stopRow;
+ boolean lastStopRowInclusive = ranges.get(0).stopRowInclusive;
+ int i = 1;
+ for (; i < ranges.size(); i++) {
+ RowRange range = ranges.get(i);
+ if (!range.isValid()) {
+ invalidRanges.add(range);
+ }
+ if(Bytes.equals(lastStopRow, HConstants.EMPTY_BYTE_ARRAY)) {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ break;
+ }
+ // with overlap in the ranges
+ if ((Bytes.compareTo(lastStopRow, range.startRow) > 0) ||
+ (Bytes.compareTo(lastStopRow, range.startRow) == 0 && !(lastStopRowInclusive == false &&
+ range.isStartRowInclusive() == false))) {
+ if(Bytes.equals(range.stopRow, HConstants.EMPTY_BYTE_ARRAY)) {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, range.stopRow,
+ range.stopRowInclusive));
+ break;
+ }
+ // if first range contains second range, ignore the second range
+ if (Bytes.compareTo(lastStopRow, range.stopRow) >= 0) {
+ if((Bytes.compareTo(lastStopRow, range.stopRow) == 0)) {
+ if(lastStopRowInclusive == true || range.stopRowInclusive == true) {
+ lastStopRowInclusive = true;
+ }
+ }
+ if ((i + 1) == ranges.size()) {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ }
+ } else {
+ lastStopRow = range.stopRow;
+ lastStopRowInclusive = range.stopRowInclusive;
+ if ((i + 1) < ranges.size()) {
+ i++;
+ range = ranges.get(i);
+ if (!range.isValid()) {
+ invalidRanges.add(range);
+ }
+ } else {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ break;
+ }
+ while ((Bytes.compareTo(lastStopRow, range.startRow) > 0) ||
+ (Bytes.compareTo(lastStopRow, range.startRow) == 0 &&
+ (lastStopRowInclusive == true || range.startRowInclusive==true))) {
+ if(Bytes.equals(range.stopRow, HConstants.EMPTY_BYTE_ARRAY)) {
+ break;
+ }
+ // if this first range contain second range, ignore the second range
+ if (Bytes.compareTo(lastStopRow, range.stopRow) >= 0) {
+ if(lastStopRowInclusive == true || range.stopRowInclusive == true) {
+ lastStopRowInclusive = true;
+ }
+ i++;
+ if (i < ranges.size()) {
+ range = ranges.get(i);
+ if (!range.isValid()) {
+ invalidRanges.add(range);
+ }
+ } else {
+ break;
+ }
+ } else {
+ lastStopRow = range.stopRow;
+ lastStopRowInclusive = range.stopRowInclusive;
+ i++;
+ if (i < ranges.size()) {
+ range = ranges.get(i);
+ if (!range.isValid()) {
+ invalidRanges.add(range);
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ if(Bytes.equals(range.stopRow, HConstants.EMPTY_BYTE_ARRAY)) {
+ if((Bytes.compareTo(lastStopRow, range.startRow) < 0) ||
+ (Bytes.compareTo(lastStopRow, range.startRow) == 0 &&
+ lastStopRowInclusive == false && range.startRowInclusive == false)) {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ newRanges.add(range);
+ } else {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, range.stopRow,
+ range.stopRowInclusive));
+ break;
+ }
+ }
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ if ((i + 1) == ranges.size()) {
+ newRanges.add(range);
+ }
+ lastStartRow = range.startRow;
+ lastStartRowInclusive = range.startRowInclusive;
+ lastStopRow = range.stopRow;
+ lastStopRowInclusive = range.stopRowInclusive;
+ }
+ } else {
+ newRanges.add(new RowRange(lastStartRow, lastStartRowInclusive, lastStopRow,
+ lastStopRowInclusive));
+ if ((i + 1) == ranges.size()) {
+ newRanges.add(range);
+ }
+ lastStartRow = range.startRow;
+ lastStartRowInclusive = range.startRowInclusive;
+ lastStopRow = range.stopRow;
+ lastStopRowInclusive = range.stopRowInclusive;
+ }
+ }
+ // check the remaining ranges
+ for(int j=i; j < ranges.size(); j++) {
+ if(!ranges.get(j).isValid()) {
+ invalidRanges.add(ranges.get(j));
+ }
+ }
+ // if invalid range exists, throw the exception
+ if (invalidRanges.size() != 0) {
+ throwExceptionForInvalidRanges(invalidRanges, true);
+ }
+ // If no valid ranges found, throw the exception
+ if(newRanges.size() == 0) {
+ throw new IllegalArgumentException("No valid ranges found.");
+ }
+ return newRanges;
+ }
+
+ private static void throwExceptionForInvalidRanges(List<RowRange> invalidRanges,
+ boolean details) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(invalidRanges.size()).append(" invaild ranges.\n");
+ if (details) {
+ for (RowRange range : invalidRanges) {
+ sb.append(
+ "Invalid range: start row => " + Bytes.toString(range.startRow) + ", stop row => "
+ + Bytes.toString(range.stopRow)).append('\n');
+ }
+ }
+ throw new IllegalArgumentException(sb.toString());
+ }
+
+ @InterfaceAudience.Public
+ @InterfaceStability.Evolving
+ public static class RowRange implements Comparable<RowRange> {
+ private byte[] startRow;
+ private boolean startRowInclusive = true;
+ private byte[] stopRow;
+ private boolean stopRowInclusive = false;
+ private int isScan = 0;
+
+ public RowRange() {
+ }
+ /**
+ * If the startRow is empty or null, set it to HConstants.EMPTY_BYTE_ARRAY, means begin at the
+ * start row of the table. If the stopRow is empty or null, set it to
+ * HConstants.EMPTY_BYTE_ARRAY, means end of the last row of table.
+ */
+ public RowRange(String startRow, boolean startRowInclusive, String stopRow,
+ boolean stopRowInclusive) {
+ this((startRow == null || startRow.isEmpty()) ? HConstants.EMPTY_BYTE_ARRAY :
+ Bytes.toBytes(startRow), startRowInclusive,
+ (stopRow == null || stopRow.isEmpty()) ? HConstants.EMPTY_BYTE_ARRAY :
+ Bytes.toBytes(stopRow), stopRowInclusive);
+ }
+
+ public RowRange(byte[] startRow, boolean startRowInclusive, byte[] stopRow,
+ boolean stopRowInclusive) {
+ this.startRow = (startRow == null) ? HConstants.EMPTY_BYTE_ARRAY : startRow;
+ this.startRowInclusive = startRowInclusive;
+ this.stopRow = (stopRow == null) ? HConstants.EMPTY_BYTE_ARRAY :stopRow;
+ this.stopRowInclusive = stopRowInclusive;
+ isScan = Bytes.equals(startRow, stopRow) ? 1 : 0;
+ }
+
+ public byte[] getStartRow() {
+ return startRow;
+ }
+
+ public byte[] getStopRow() {
+ return stopRow;
+ }
+
+ /**
+ * @return if start row is inclusive.
+ */
+ public boolean isStartRowInclusive() {
+ return startRowInclusive;
+ }
+
+ /**
+ * @return if stop row is inclusive.
+ */
+ public boolean isStopRowInclusive() {
+ return stopRowInclusive;
+ }
+
+ public boolean contains(byte[] row) {
+ return contains(row, 0, row.length);
+ }
+
+ public boolean contains(byte[] buffer, int offset, int length) {
+ if(startRowInclusive) {
+ if(stopRowInclusive) {
+ return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >= 0
+ && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
+ Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <= isScan);
+ } else {
+ return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >= 0
+ && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
+ Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) < isScan);
+ }
+ } else {
+ if(stopRowInclusive) {
+ return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) > 0
+ && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
+ Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <= isScan);
+ } else {
+ return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) > 0
+ && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
+ Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) < isScan);
+ }
+ }
+ }
+
+ @Override
+ public int compareTo(RowRange other) {
+ return Bytes.compareTo(this.startRow, other.startRow);
+ }
+
+ public boolean isValid() {
+ return Bytes.equals(startRow, HConstants.EMPTY_BYTE_ARRAY)
+ || Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY)
+ || Bytes.compareTo(startRow, stopRow) < 0
+ || (Bytes.compareTo(startRow, stopRow) == 0 && stopRowInclusive == true);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java
index 2ce084c..2f210a5 100644
--- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java
+++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/FilterProtos.java
@@ -15974,6 +15974,1425 @@ public final class FilterProtos {
// @@protoc_insertion_point(class_scope:FilterAllFilter)
}
+ public interface RowRangeOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional bytes start_row = 1;
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ boolean hasStartRow();
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ com.google.protobuf.ByteString getStartRow();
+
+ // optional bool start_row_inclusive = 2;
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ boolean hasStartRowInclusive();
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ boolean getStartRowInclusive();
+
+ // optional bytes stop_row = 3;
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ boolean hasStopRow();
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ com.google.protobuf.ByteString getStopRow();
+
+ // optional bool stop_row_inclusive = 4;
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ boolean hasStopRowInclusive();
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ boolean getStopRowInclusive();
+ }
+ /**
+ * Protobuf type {@code RowRange}
+ */
+ public static final class RowRange extends
+ com.google.protobuf.GeneratedMessage
+ implements RowRangeOrBuilder {
+ // Use RowRange.newBuilder() to construct.
+ private RowRange(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ this.unknownFields = builder.getUnknownFields();
+ }
+ private RowRange(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private static final RowRange defaultInstance;
+ public static RowRange getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public RowRange getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ private final com.google.protobuf.UnknownFieldSet unknownFields;
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private RowRange(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ initFields();
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ startRow_ = input.readBytes();
+ break;
+ }
+ case 16: {
+ bitField0_ |= 0x00000002;
+ startRowInclusive_ = input.readBool();
+ break;
+ }
+ case 26: {
+ bitField0_ |= 0x00000004;
+ stopRow_ = input.readBytes();
+ break;
+ }
+ case 32: {
+ bitField0_ |= 0x00000008;
+ stopRowInclusive_ = input.readBool();
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_RowRange_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_RowRange_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.class, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder.class);
+ }
+
+ public static com.google.protobuf.Parser<RowRange> PARSER =
+ new com.google.protobuf.AbstractParser<RowRange>() {
+ public RowRange parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new RowRange(input, extensionRegistry);
+ }
+ };
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<RowRange> getParserForType() {
+ return PARSER;
+ }
+
+ private int bitField0_;
+ // optional bytes start_row = 1;
+ public static final int START_ROW_FIELD_NUMBER = 1;
+ private com.google.protobuf.ByteString startRow_;
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public boolean hasStartRow() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public com.google.protobuf.ByteString getStartRow() {
+ return startRow_;
+ }
+
+ // optional bool start_row_inclusive = 2;
+ public static final int START_ROW_INCLUSIVE_FIELD_NUMBER = 2;
+ private boolean startRowInclusive_;
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public boolean hasStartRowInclusive() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public boolean getStartRowInclusive() {
+ return startRowInclusive_;
+ }
+
+ // optional bytes stop_row = 3;
+ public static final int STOP_ROW_FIELD_NUMBER = 3;
+ private com.google.protobuf.ByteString stopRow_;
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public boolean hasStopRow() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public com.google.protobuf.ByteString getStopRow() {
+ return stopRow_;
+ }
+
+ // optional bool stop_row_inclusive = 4;
+ public static final int STOP_ROW_INCLUSIVE_FIELD_NUMBER = 4;
+ private boolean stopRowInclusive_;
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public boolean hasStopRowInclusive() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public boolean getStopRowInclusive() {
+ return stopRowInclusive_;
+ }
+
+ private void initFields() {
+ startRow_ = com.google.protobuf.ByteString.EMPTY;
+ startRowInclusive_ = false;
+ stopRow_ = com.google.protobuf.ByteString.EMPTY;
+ stopRowInclusive_ = false;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, startRow_);
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBool(2, startRowInclusive_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeBytes(3, stopRow_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ output.writeBool(4, stopRowInclusive_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, startRow_);
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(2, startRowInclusive_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(3, stopRow_);
+ }
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(4, stopRowInclusive_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange)) {
+ return super.equals(obj);
+ }
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange other = (org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange) obj;
+
+ boolean result = true;
+ result = result && (hasStartRow() == other.hasStartRow());
+ if (hasStartRow()) {
+ result = result && getStartRow()
+ .equals(other.getStartRow());
+ }
+ result = result && (hasStartRowInclusive() == other.hasStartRowInclusive());
+ if (hasStartRowInclusive()) {
+ result = result && (getStartRowInclusive()
+ == other.getStartRowInclusive());
+ }
+ result = result && (hasStopRow() == other.hasStopRow());
+ if (hasStopRow()) {
+ result = result && getStopRow()
+ .equals(other.getStopRow());
+ }
+ result = result && (hasStopRowInclusive() == other.hasStopRowInclusive());
+ if (hasStopRowInclusive()) {
+ result = result && (getStopRowInclusive()
+ == other.getStopRowInclusive());
+ }
+ result = result &&
+ getUnknownFields().equals(other.getUnknownFields());
+ return result;
+ }
+
+ private int memoizedHashCode = 0;
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptorForType().hashCode();
+ if (hasStartRow()) {
+ hash = (37 * hash) + START_ROW_FIELD_NUMBER;
+ hash = (53 * hash) + getStartRow().hashCode();
+ }
+ if (hasStartRowInclusive()) {
+ hash = (37 * hash) + START_ROW_INCLUSIVE_FIELD_NUMBER;
+ hash = (53 * hash) + hashBoolean(getStartRowInclusive());
+ }
+ if (hasStopRow()) {
+ hash = (37 * hash) + STOP_ROW_FIELD_NUMBER;
+ hash = (53 * hash) + getStopRow().hashCode();
+ }
+ if (hasStopRowInclusive()) {
+ hash = (37 * hash) + STOP_ROW_INCLUSIVE_FIELD_NUMBER;
+ hash = (53 * hash) + hashBoolean(getStopRowInclusive());
+ }
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code RowRange}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_RowRange_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_RowRange_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.class, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder.class);
+ }
+
+ // Construct using org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ startRow_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ startRowInclusive_ = false;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ stopRow_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ stopRowInclusive_ = false;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_RowRange_descriptor;
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange getDefaultInstanceForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.getDefaultInstance();
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange build() {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange buildPartial() {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange result = new org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.startRow_ = startRow_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.startRowInclusive_ = startRowInclusive_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.stopRow_ = stopRow_;
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.stopRowInclusive_ = stopRowInclusive_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange) {
+ return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange other) {
+ if (other == org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.getDefaultInstance()) return this;
+ if (other.hasStartRow()) {
+ setStartRow(other.getStartRow());
+ }
+ if (other.hasStartRowInclusive()) {
+ setStartRowInclusive(other.getStartRowInclusive());
+ }
+ if (other.hasStopRow()) {
+ setStopRow(other.getStopRow());
+ }
+ if (other.hasStopRowInclusive()) {
+ setStopRowInclusive(other.getStopRowInclusive());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ // optional bytes start_row = 1;
+ private com.google.protobuf.ByteString startRow_ = com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public boolean hasStartRow() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public com.google.protobuf.ByteString getStartRow() {
+ return startRow_;
+ }
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public Builder setStartRow(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ startRow_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bytes start_row = 1;</code>
+ */
+ public Builder clearStartRow() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ startRow_ = getDefaultInstance().getStartRow();
+ onChanged();
+ return this;
+ }
+
+ // optional bool start_row_inclusive = 2;
+ private boolean startRowInclusive_ ;
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public boolean hasStartRowInclusive() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public boolean getStartRowInclusive() {
+ return startRowInclusive_;
+ }
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public Builder setStartRowInclusive(boolean value) {
+ bitField0_ |= 0x00000002;
+ startRowInclusive_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool start_row_inclusive = 2;</code>
+ */
+ public Builder clearStartRowInclusive() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ startRowInclusive_ = false;
+ onChanged();
+ return this;
+ }
+
+ // optional bytes stop_row = 3;
+ private com.google.protobuf.ByteString stopRow_ = com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public boolean hasStopRow() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public com.google.protobuf.ByteString getStopRow() {
+ return stopRow_;
+ }
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public Builder setStopRow(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000004;
+ stopRow_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bytes stop_row = 3;</code>
+ */
+ public Builder clearStopRow() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ stopRow_ = getDefaultInstance().getStopRow();
+ onChanged();
+ return this;
+ }
+
+ // optional bool stop_row_inclusive = 4;
+ private boolean stopRowInclusive_ ;
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public boolean hasStopRowInclusive() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public boolean getStopRowInclusive() {
+ return stopRowInclusive_;
+ }
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public Builder setStopRowInclusive(boolean value) {
+ bitField0_ |= 0x00000008;
+ stopRowInclusive_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool stop_row_inclusive = 4;</code>
+ */
+ public Builder clearStopRowInclusive() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ stopRowInclusive_ = false;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:RowRange)
+ }
+
+ static {
+ defaultInstance = new RowRange(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:RowRange)
+ }
+
+ public interface MultiRowRangeFilterOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // repeated .RowRange row_range_list = 1;
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange>
+ getRowRangeListList();
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange getRowRangeList(int index);
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ int getRowRangeListCount();
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ java.util.List<? extends org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder>
+ getRowRangeListOrBuilderList();
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder getRowRangeListOrBuilder(
+ int index);
+ }
+ /**
+ * Protobuf type {@code MultiRowRangeFilter}
+ */
+ public static final class MultiRowRangeFilter extends
+ com.google.protobuf.GeneratedMessage
+ implements MultiRowRangeFilterOrBuilder {
+ // Use MultiRowRangeFilter.newBuilder() to construct.
+ private MultiRowRangeFilter(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ super(builder);
+ this.unknownFields = builder.getUnknownFields();
+ }
+ private MultiRowRangeFilter(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+ private static final MultiRowRangeFilter defaultInstance;
+ public static MultiRowRangeFilter getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public MultiRowRangeFilter getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ private final com.google.protobuf.UnknownFieldSet unknownFields;
+ @java.lang.Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private MultiRowRangeFilter(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ initFields();
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
+ rowRangeList_ = new java.util.ArrayList<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange>();
+ mutable_bitField0_ |= 0x00000001;
+ }
+ rowRangeList_.add(input.readMessage(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.PARSER, extensionRegistry));
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e.getMessage()).setUnfinishedMessage(this);
+ } finally {
+ if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
+ rowRangeList_ = java.util.Collections.unmodifiableList(rowRangeList_);
+ }
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_MultiRowRangeFilter_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_MultiRowRangeFilter_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.class, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.Builder.class);
+ }
+
+ public static com.google.protobuf.Parser<MultiRowRangeFilter> PARSER =
+ new com.google.protobuf.AbstractParser<MultiRowRangeFilter>() {
+ public MultiRowRangeFilter parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new MultiRowRangeFilter(input, extensionRegistry);
+ }
+ };
+
+ @java.lang.Override
+ public com.google.protobuf.Parser<MultiRowRangeFilter> getParserForType() {
+ return PARSER;
+ }
+
+ // repeated .RowRange row_range_list = 1;
+ public static final int ROW_RANGE_LIST_FIELD_NUMBER = 1;
+ private java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange> rowRangeList_;
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange> getRowRangeListList() {
+ return rowRangeList_;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public java.util.List<? extends org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder>
+ getRowRangeListOrBuilderList() {
+ return rowRangeList_;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public int getRowRangeListCount() {
+ return rowRangeList_.size();
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange getRowRangeList(int index) {
+ return rowRangeList_.get(index);
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder getRowRangeListOrBuilder(
+ int index) {
+ return rowRangeList_.get(index);
+ }
+
+ private void initFields() {
+ rowRangeList_ = java.util.Collections.emptyList();
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ for (int i = 0; i < rowRangeList_.size(); i++) {
+ output.writeMessage(1, rowRangeList_.get(i));
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ for (int i = 0; i < rowRangeList_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(1, rowRangeList_.get(i));
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter)) {
+ return super.equals(obj);
+ }
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter other = (org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter) obj;
+
+ boolean result = true;
+ result = result && getRowRangeListList()
+ .equals(other.getRowRangeListList());
+ result = result &&
+ getUnknownFields().equals(other.getUnknownFields());
+ return result;
+ }
+
+ private int memoizedHashCode = 0;
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptorForType().hashCode();
+ if (getRowRangeListCount() > 0) {
+ hash = (37 * hash) + ROW_RANGE_LIST_FIELD_NUMBER;
+ hash = (53 * hash) + getRowRangeListList().hashCode();
+ }
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseDelimitedFrom(input, extensionRegistry);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input);
+ }
+ public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return PARSER.parseFrom(input, extensionRegistry);
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code MultiRowRangeFilter}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilterOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_MultiRowRangeFilter_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_MultiRowRangeFilter_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.class, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.Builder.class);
+ }
+
+ // Construct using org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ getRowRangeListFieldBuilder();
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ if (rowRangeListBuilder_ == null) {
+ rowRangeList_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ } else {
+ rowRangeListBuilder_.clear();
+ }
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.internal_static_MultiRowRangeFilter_descriptor;
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter getDefaultInstanceForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.getDefaultInstance();
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter build() {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter buildPartial() {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter result = new org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter(this);
+ int from_bitField0_ = bitField0_;
+ if (rowRangeListBuilder_ == null) {
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ rowRangeList_ = java.util.Collections.unmodifiableList(rowRangeList_);
+ bitField0_ = (bitField0_ & ~0x00000001);
+ }
+ result.rowRangeList_ = rowRangeList_;
+ } else {
+ result.rowRangeList_ = rowRangeListBuilder_.build();
+ }
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter) {
+ return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter other) {
+ if (other == org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter.getDefaultInstance()) return this;
+ if (rowRangeListBuilder_ == null) {
+ if (!other.rowRangeList_.isEmpty()) {
+ if (rowRangeList_.isEmpty()) {
+ rowRangeList_ = other.rowRangeList_;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ } else {
+ ensureRowRangeListIsMutable();
+ rowRangeList_.addAll(other.rowRangeList_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.rowRangeList_.isEmpty()) {
+ if (rowRangeListBuilder_.isEmpty()) {
+ rowRangeListBuilder_.dispose();
+ rowRangeListBuilder_ = null;
+ rowRangeList_ = other.rowRangeList_;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ rowRangeListBuilder_ =
+ com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+ getRowRangeListFieldBuilder() : null;
+ } else {
+ rowRangeListBuilder_.addAllMessages(other.rowRangeList_);
+ }
+ }
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.FilterProtos.MultiRowRangeFilter) e.getUnfinishedMessage();
+ throw e;
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ // repeated .RowRange row_range_list = 1;
+ private java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange> rowRangeList_ =
+ java.util.Collections.emptyList();
+ private void ensureRowRangeListIsMutable() {
+ if (!((bitField0_ & 0x00000001) == 0x00000001)) {
+ rowRangeList_ = new java.util.ArrayList<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange>(rowRangeList_);
+ bitField0_ |= 0x00000001;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder> rowRangeListBuilder_;
+
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange> getRowRangeListList() {
+ if (rowRangeListBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(rowRangeList_);
+ } else {
+ return rowRangeListBuilder_.getMessageList();
+ }
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public int getRowRangeListCount() {
+ if (rowRangeListBuilder_ == null) {
+ return rowRangeList_.size();
+ } else {
+ return rowRangeListBuilder_.getCount();
+ }
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange getRowRangeList(int index) {
+ if (rowRangeListBuilder_ == null) {
+ return rowRangeList_.get(index);
+ } else {
+ return rowRangeListBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder setRowRangeList(
+ int index, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange value) {
+ if (rowRangeListBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRowRangeListIsMutable();
+ rowRangeList_.set(index, value);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder setRowRangeList(
+ int index, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder builderForValue) {
+ if (rowRangeListBuilder_ == null) {
+ ensureRowRangeListIsMutable();
+ rowRangeList_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ rowRangeListBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder addRowRangeList(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange value) {
+ if (rowRangeListBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRowRangeListIsMutable();
+ rowRangeList_.add(value);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder addRowRangeList(
+ int index, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange value) {
+ if (rowRangeListBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRowRangeListIsMutable();
+ rowRangeList_.add(index, value);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder addRowRangeList(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder builderForValue) {
+ if (rowRangeListBuilder_ == null) {
+ ensureRowRangeListIsMutable();
+ rowRangeList_.add(builderForValue.build());
+ onChanged();
+ } else {
+ rowRangeListBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder addRowRangeList(
+ int index, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder builderForValue) {
+ if (rowRangeListBuilder_ == null) {
+ ensureRowRangeListIsMutable();
+ rowRangeList_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ rowRangeListBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder addAllRowRangeList(
+ java.lang.Iterable<? extends org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange> values) {
+ if (rowRangeListBuilder_ == null) {
+ ensureRowRangeListIsMutable();
+ super.addAll(values, rowRangeList_);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder clearRowRangeList() {
+ if (rowRangeListBuilder_ == null) {
+ rowRangeList_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public Builder removeRowRangeList(int index) {
+ if (rowRangeListBuilder_ == null) {
+ ensureRowRangeListIsMutable();
+ rowRangeList_.remove(index);
+ onChanged();
+ } else {
+ rowRangeListBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder getRowRangeListBuilder(
+ int index) {
+ return getRowRangeListFieldBuilder().getBuilder(index);
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder getRowRangeListOrBuilder(
+ int index) {
+ if (rowRangeListBuilder_ == null) {
+ return rowRangeList_.get(index); } else {
+ return rowRangeListBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public java.util.List<? extends org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder>
+ getRowRangeListOrBuilderList() {
+ if (rowRangeListBuilder_ != null) {
+ return rowRangeListBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(rowRangeList_);
+ }
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder addRowRangeListBuilder() {
+ return getRowRangeListFieldBuilder().addBuilder(
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder addRowRangeListBuilder(
+ int index) {
+ return getRowRangeListFieldBuilder().addBuilder(
+ index, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .RowRange row_range_list = 1;</code>
+ */
+ public java.util.List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder>
+ getRowRangeListBuilderList() {
+ return getRowRangeListFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilder<
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder>
+ getRowRangeListFieldBuilder() {
+ if (rowRangeListBuilder_ == null) {
+ rowRangeListBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+ org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRange.Builder, org.apache.hadoop.hbase.protobuf.generated.FilterProtos.RowRangeOrBuilder>(
+ rowRangeList_,
+ ((bitField0_ & 0x00000001) == 0x00000001),
+ getParentForChildren(),
+ isClean());
+ rowRangeList_ = null;
+ }
+ return rowRangeListBuilder_;
+ }
+
+ // @@protoc_insertion_point(builder_scope:MultiRowRangeFilter)
+ }
+
+ static {
+ defaultInstance = new MultiRowRangeFilter(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:MultiRowRangeFilter)
+ }
+
private static com.google.protobuf.Descriptors.Descriptor
internal_static_Filter_descriptor;
private static
@@ -16114,6 +17533,16 @@ public final class FilterProtos {
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_FilterAllFilter_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_RowRange_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_RowRange_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_MultiRowRangeFilter_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_MultiRowRangeFilter_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
@@ -16169,8 +17598,12 @@ public final class FilterProtos {
"(\010\"5\n\013ValueFilter\022&\n\016compare_filter\030\001 \002(" +
"\0132\016.CompareFilter\"+\n\020WhileMatchFilter\022\027\n" +
"\006filter\030\001 \002(\0132\007.Filter\"\021\n\017FilterAllFilte" +
- "rBB\n*org.apache.hadoop.hbase.protobuf.ge" +
- "neratedB\014FilterProtosH\001\210\001\001\240\001\001"
+ "r\"h\n\010RowRange\022\021\n\tstart_row\030\001 \001(\014\022\033\n\023star" +
+ "t_row_inclusive\030\002 \001(\010\022\020\n\010stop_row\030\003 \001(\014\022" +
+ "\032\n\022stop_row_inclusive\030\004 \001(\010\"8\n\023MultiRowR" +
+ "angeFilter\022!\n\016row_range_list\030\001 \003(\0132\t.Row",
+ "RangeBB\n*org.apache.hadoop.hbase.protobu" +
+ "f.generatedB\014FilterProtosH\001\210\001\001\240\001\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -16345,6 +17778,18 @@ public final class FilterProtos {
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_FilterAllFilter_descriptor,
new java.lang.String[] { });
+ internal_static_RowRange_descriptor =
+ getDescriptor().getMessageTypes().get(28);
+ internal_static_RowRange_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_RowRange_descriptor,
+ new java.lang.String[] { "StartRow", "StartRowInclusive", "StopRow", "StopRowInclusive", });
+ internal_static_MultiRowRangeFilter_descriptor =
+ getDescriptor().getMessageTypes().get(29);
+ internal_static_MultiRowRangeFilter_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_MultiRowRangeFilter_descriptor,
+ new java.lang.String[] { "RowRangeList", });
return null;
}
};
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-protocol/src/main/protobuf/Filter.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/protobuf/Filter.proto b/hbase-protocol/src/main/protobuf/Filter.proto
index b17f855..7fc7344 100644
--- a/hbase-protocol/src/main/protobuf/Filter.proto
+++ b/hbase-protocol/src/main/protobuf/Filter.proto
@@ -156,4 +156,15 @@ message WhileMatchFilter {
required Filter filter = 1;
}
message FilterAllFilter {
+}
+
+message RowRange {
+ optional bytes start_row = 1;
+ optional bool start_row_inclusive = 2;
+ optional bytes stop_row = 3;
+ optional bool stop_row_inclusive =4;
+}
+
+message MultiRowRangeFilter {
+ repeated RowRange row_range_list = 1;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
index f9eaa22..bb8c001 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
@@ -32,8 +32,8 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.BinaryPrefixComparator;
@@ -52,6 +52,8 @@ import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
import org.apache.hadoop.hbase.filter.InclusiveStopFilter;
import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
+import org.apache.hadoop.hbase.filter.MultiRowRangeFilter;
+import org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange;
import org.apache.hadoop.hbase.filter.MultipleColumnPrefixFilter;
import org.apache.hadoop.hbase.filter.NullComparator;
import org.apache.hadoop.hbase.filter.PageFilter;
@@ -213,6 +215,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
@XmlAttribute public Boolean dropDependentColumn;
@XmlAttribute public Float chance;
@XmlElement public List<String> prefixes;
+ @XmlElement private List<RowRange> ranges;
@XmlElement public List<Long> timestamps;
static enum FilterType {
@@ -227,6 +230,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
InclusiveStopFilter,
KeyOnlyFilter,
MultipleColumnPrefixFilter,
+ MultiRowRangeFilter,
PageFilter,
PrefixFilter,
QualifierFilter,
@@ -294,6 +298,13 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
this.prefixes.add(Base64.encodeBytes(prefix));
}
break;
+ case MultiRowRangeFilter:
+ this.ranges = new ArrayList<RowRange>();
+ for(RowRange range : ((MultiRowRangeFilter)filter).getRowRanges()) {
+ this.ranges.add(new RowRange(range.getStartRow(), range.isStartRowInclusive(),
+ range.getStopRow(), range.isStopRowInclusive()));
+ }
+ break;
case PageFilter:
this.value = Long.toString(((PageFilter)filter).getPageSize());
break;
@@ -395,6 +406,13 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
}
filter = new MultipleColumnPrefixFilter(values);
} break;
+ case MultiRowRangeFilter: {
+ try {
+ filter = new MultiRowRangeFilter(ranges);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ } break;
case PageFilter:
filter = new PageFilter(Long.valueOf(value));
break;
http://git-wip-us.apache.org/repos/asf/hbase/blob/b2d883dd/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java
index 163b7d1..5576296 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterSerialization.java
@@ -21,10 +21,13 @@ package org.apache.hadoop.hbase.filter;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;
import java.util.TreeSet;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
@@ -319,4 +322,16 @@ public class TestFilterSerialization {
ProtobufUtil.toFilter(ProtobufUtil.toFilter(whileMatchFilter))));
}
+ @Test
+ public void testMultiRowRangeFilter() throws Exception {
+ List<RowRange> ranges = new ArrayList<RowRange>();
+ ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false));
+ ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false));
+ ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false));
+
+ MultiRowRangeFilter multiRowRangeFilter =
+ new MultiRowRangeFilter(ranges);
+ assertTrue(multiRowRangeFilter.areSerializedFieldsEqual(
+ ProtobufUtil.toFilter(ProtobufUtil.toFilter(multiRowRangeFilter))));
+ }
}
[4/7] hbase git commit: HBASE-14206 MultiRowRangeFilter returns
records whose rowKeys are out of allowed ranges (Anton Nazaruk)
Posted by ap...@apache.org.
HBASE-14206 MultiRowRangeFilter returns records whose rowKeys are out of allowed ranges (Anton Nazaruk)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3ca07805
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3ca07805
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3ca07805
Branch: refs/heads/0.98
Commit: 3ca07805e19cdeb16cb1828d276d833f5e907b98
Parents: f3fa22a
Author: tedyu <yu...@gmail.com>
Authored: Tue Aug 11 10:01:55 2015 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 17:54:19 2016 -0700
----------------------------------------------------------------------
.../hadoop/hbase/filter/MultiRowRangeFilter.java | 3 +++
.../hbase/filter/TestMultiRowRangeFilter.java | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ca07805/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
index 24c8135..4bcf430 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -233,6 +233,9 @@ public class MultiRowRangeFilter extends FilterBase {
if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) {
return ROW_BEFORE_FIRST_RANGE;
}
+ if (!initialized) {
+ initialized = true;
+ }
return insertionPosition;
}
// the row key equals one of the start keys, and the the range exclude the start key
http://git-wip-us.apache.org/repos/asf/hbase/blob/3ca07805/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
index 7ecc29c..041c930 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
@@ -70,6 +70,24 @@ public class TestMultiRowRangeFilter {
}
@Test
+ public void testRanges() throws IOException {
+ byte[] key1Start = new byte[] {-3};
+ byte[] key1End = new byte[] {-2};
+
+ byte[] key2Start = new byte[] {5};
+ byte[] key2End = new byte[] {6};
+
+ byte[] badKey = new byte[] {-10};
+
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
+ new MultiRowRangeFilter.RowRange(key1Start, true, key1End, false),
+ new MultiRowRangeFilter.RowRange(key2Start, true, key2End, false)
+ ));
+ filter.filterRowKey(badKey, 0, 1);
+ assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null));
+ }
+
+ @Test
public void testOutOfOrderScannerNextException() throws Exception {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
new MultiRowRangeFilter.RowRange(Bytes.toBytes("b"), true, Bytes.toBytes("c"), true),
[7/7] hbase git commit: HBASE-16108 RowCounter should support
multiple key ranges (Konstantin Ryakhovskiy)
Posted by ap...@apache.org.
HBASE-16108 RowCounter should support multiple key ranges (Konstantin Ryakhovskiy)
Conflicts:
hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/10e06ca6
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/10e06ca6
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/10e06ca6
Branch: refs/heads/0.98
Commit: 10e06ca618e5ef809ea88d04e553d534e2327ec9
Parents: e5d0d48
Author: tedyu <yu...@gmail.com>
Authored: Fri Jul 1 09:32:43 2016 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 18:04:29 2016 -0700
----------------------------------------------------------------------
.../hadoop/hbase/mapreduce/RowCounter.java | 88 ++++++----
.../hadoop/hbase/mapreduce/TestRowCounter.java | 165 ++++++++++++++++---
2 files changed, 198 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/10e06ca6/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
index 82e5f6e..3d4bf2d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java
@@ -19,8 +19,8 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.List;
+import java.util.ArrayList;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.hbase.HConstants;
@@ -30,8 +30,9 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.filter.FilterBase;
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
-import org.apache.hadoop.hbase.filter.FirstKeyValueMatchingQualifiersFilter;
+import org.apache.hadoop.hbase.filter.MultiRowRangeFilter;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapreduce.Job;
@@ -88,8 +89,7 @@ public class RowCounter {
public static Job createSubmittableJob(Configuration conf, String[] args)
throws IOException {
String tableName = args[0];
- String startKey = null;
- String endKey = null;
+ List<MultiRowRangeFilter.RowRange> rowRangeList = null;
long startTime = 0;
long endTime = 0;
@@ -102,14 +102,12 @@ public class RowCounter {
// First argument is table name, starting from second
for (int i = 1; i < args.length; i++) {
if (args[i].startsWith(rangeSwitch)) {
- String[] startEnd = args[i].substring(rangeSwitch.length()).split(",", 2);
- if (startEnd.length != 2 || startEnd[1].contains(",")) {
- printUsage("Please specify range in such format as \"--range=a,b\" " +
- "or, with only one boundary, \"--range=,b\" or \"--range=a,\"");
+ try {
+ rowRangeList = parseRowRangeParameter(args[i], rangeSwitch);
+ } catch (IllegalArgumentException e) {
return null;
}
- startKey = startEnd[0];
- endKey = startEnd[1];
+ continue;
}
if (startTime < endTime) {
printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);
@@ -134,14 +132,7 @@ public class RowCounter {
job.setJarByClass(RowCounter.class);
Scan scan = new Scan();
scan.setCacheBlocks(false);
- Set<byte []> qualifiers = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
- if (startKey != null && !startKey.equals("")) {
- scan.setStartRow(Bytes.toBytes(startKey));
- }
- if (endKey != null && !endKey.equals("")) {
- scan.setStopRow(Bytes.toBytes(endKey));
- }
- scan.setFilter(new FirstKeyOnlyFilter());
+ setScanFilter(scan, rowRangeList);
if (sb.length() > 0) {
for (String columnName : sb.toString().trim().split(" ")) {
String family = StringUtils.substringBefore(columnName, ":");
@@ -155,14 +146,6 @@ public class RowCounter {
}
}
}
- // specified column may or may not be part of first key value for the row.
- // Hence do not use FirstKeyOnlyFilter if scan has columns, instead use
- // FirstKeyValueMatchingQualifiersFilter.
- if (qualifiers.size() == 0) {
- scan.setFilter(new FirstKeyOnlyFilter());
- } else {
- scan.setFilter(new FirstKeyValueMatchingQualifiersFilter(qualifiers));
- }
scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);
job.setOutputFormatClass(NullOutputFormat.class);
TableMapReduceUtil.initTableMapperJob(tableName, scan,
@@ -171,6 +154,55 @@ public class RowCounter {
return job;
}
+ private static List<MultiRowRangeFilter.RowRange> parseRowRangeParameter(
+ String arg, String rangeSwitch) {
+ final String[] ranges = arg.substring(rangeSwitch.length()).split(";");
+ final List<MultiRowRangeFilter.RowRange> rangeList =
+ new ArrayList<MultiRowRangeFilter.RowRange>();
+ for (String range : ranges) {
+ String[] startEnd = range.split(",", 2);
+ if (startEnd.length != 2 || startEnd[1].contains(",")) {
+ printUsage("Please specify range in such format as \"--range=a,b\" " +
+ "or, with only one boundary, \"--range=,b\" or \"--range=a,\"");
+ throw new IllegalArgumentException("Wrong range specification: " + range);
+ }
+ String startKey = startEnd[0];
+ String endKey = startEnd[1];
+ rangeList.add(new MultiRowRangeFilter.RowRange(
+ Bytes.toBytesBinary(startKey), true,
+ Bytes.toBytesBinary(endKey), false));
+ }
+ return rangeList;
+ }
+
+ /**
+ * Sets filter {@link FilterBase} to the {@link Scan} instance.
+ * If provided rowRangeList contains more than one element,
+ * method sets filter which is instance of {@link MultiRowRangeFilter}.
+ * Otherwise, method sets filter which is instance of {@link FirstKeyOnlyFilter}.
+ * If rowRangeList contains exactly one element, startRow and stopRow are set to the scan.
+ * @param scan
+ * @param rowRangeList
+ */
+ private static void setScanFilter(Scan scan, List<MultiRowRangeFilter.RowRange> rowRangeList) {
+ final int size = rowRangeList == null ? 0 : rowRangeList.size();
+ if (size <= 1) {
+ scan.setFilter(new FirstKeyOnlyFilter());
+ }
+ if (size == 1) {
+ MultiRowRangeFilter.RowRange range = rowRangeList.get(0);
+ scan.setStartRow(range.getStartRow()); //inclusive
+ scan.setStopRow(range.getStopRow()); //exclusive
+ } else if (size > 1) {
+ try {
+ scan.setFilter(new MultiRowRangeFilter(rowRangeList));
+ } catch (IOException e) {
+ //the IOException should never be thrown. see HBASE-16145
+ throw new RuntimeException("Cannot instantiate MultiRowRangeFilter");
+ }
+ }
+ }
+
/*
* @param errorMessage Can attach a message when error occurs.
*/
@@ -185,7 +217,7 @@ public class RowCounter {
private static void printUsage() {
System.err.println("Usage: RowCounter [options] <tablename> " +
"[--starttime=[start] --endtime=[end] " +
- "[--range=[startKey],[endKey]] [<column1> <column2>...]");
+ "[--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]");
System.err.println("For performance consider the following options:\n"
+ "-Dhbase.client.scanner.caching=100\n"
+ "-Dmapred.map.tasks.speculative.execution=false");
http://git-wip-us.apache.org/repos/asf/hbase/blob/10e06ca6/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
index 7b5af6e..2a6a048 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
@@ -69,9 +69,8 @@ public class TestRowCounter {
throws Exception {
TEST_UTIL.startMiniCluster();
TEST_UTIL.startMiniMapReduceCluster();
- HTable table = TEST_UTIL.createTable(Bytes.toBytes(TABLE_NAME),
- Bytes.toBytes(COL_FAM));
- writeRows(table);
+ HTable table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME), Bytes.toBytes(COL_FAM));
+ writeRows(table, TOTAL_ROWS, ROWS_WITH_ONE_COL);
table.close();
}
@@ -137,6 +136,100 @@ public class TestRowCounter {
}
/**
+ * Test a case when a range is specified with single range of start-end keys
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowSingleRange() throws Exception {
+ String[] args = new String[] {
+ TABLE_NAME, "--range=row1,row3"
+ };
+ runRowCount(args, 2);
+ }
+
+ /**
+ * Test a case when a range is specified with single range with end key only
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowSingleRangeUpperBound() throws Exception {
+ String[] args = new String[] {
+ TABLE_NAME, "--range=,row3"
+ };
+ runRowCount(args, 3);
+ }
+
+ /**
+ * Test a case when a range is specified with two ranges where one range is with end key only
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowMultiRangeUpperBound() throws Exception {
+ String[] args = new String[] {
+ TABLE_NAME, "--range=,row3;row5,row7"
+ };
+ runRowCount(args, 5);
+ }
+ /**
+ * Test a case when a range is specified with multiple ranges of start-end keys
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowMultiRange() throws Exception {
+ String[] args = new String[] {
+ TABLE_NAME, "--range=row1,row3;row5,row8"
+ };
+ runRowCount(args, 5);
+ }
+
+ /**
+ * Test a case when a range is specified with multiple ranges of start-end keys;
+ * one range is filled, another two are not
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowMultiEmptyRange() throws Exception {
+ String[] args = new String[] {
+ TABLE_NAME, "--range=row1,row3;;"
+ };
+ runRowCount(args, 2);
+ }
+
+ @Test
+ public void testRowCounter10kRowRange() throws Exception {
+ String tableName = TABLE_NAME + "10k";
+ HTable table = TEST_UTIL.createTable(TableName.valueOf(tableName), Bytes.toBytes(COL_FAM));
+ try {
+ writeRows(table, 10000, 0);
+ } finally {
+ table.close();
+ }
+ String[] args = new String[] {
+ tableName, "--range=row9872,row9875"
+ };
+ runRowCount(args, 3);
+ }
+
+ /**
+ * test case for HBASE-15287
+ * @throws Exception
+ */
+ @Test
+ public void testRowCounterRowRangeBinary() throws Exception {
+ String tableName = TABLE_NAME + "Binary";
+ HTable table = TEST_UTIL.createTable(TableName.valueOf(tableName), Bytes.toBytes(COL_FAM));
+ try {
+ writeRows(table, 10, 0, true);
+ } finally {
+ table.close();
+ }
+ String[] args = new String[] {
+ tableName, "--range=\\x00row5,\\x00row8"
+ };
+ runRowCount(args, 3);
+ }
+
+ /**
* Test a case when the timerange is specified with --starttime and --endtime options
*
* @throws Exception
@@ -144,6 +237,7 @@ public class TestRowCounter {
@Test
public void testRowCounterTimeRange()
throws Exception {
+ final String tableName = TABLE_NAME + "TimeRange";
final byte[] family = Bytes.toBytes(COL_FAM);
final byte[] col1 = Bytes.toBytes(COL1);
Put put1 = new Put(Bytes.toBytes("row_timerange_" + 1));
@@ -153,32 +247,35 @@ public class TestRowCounter {
long ts;
// clean up content of TABLE_NAME
- HTable table = TEST_UTIL.truncateTable(TableName.valueOf(TABLE_NAME));
- ts = System.currentTimeMillis();
- put1.add(family, col1, ts, Bytes.toBytes("val1"));
- table.put(put1);
- Thread.sleep(100);
-
- ts = System.currentTimeMillis();
- put2.add(family, col1, ts, Bytes.toBytes("val2"));
- put3.add(family, col1, ts, Bytes.toBytes("val3"));
- table.put(put2);
- table.put(put3);
- table.close();
- String[] args = new String[] {TABLE_NAME, COL_FAM + ":" + COL1, "--starttime=" + 0,
+ HTable table = TEST_UTIL.createTable(TableName.valueOf(tableName), Bytes.toBytes(COL_FAM));
+ try {
+ ts = System.currentTimeMillis();
+ put1.add(family, col1, ts, Bytes.toBytes("val1"));
+ table.put(put1);
+ Thread.sleep(100);
+ ts = System.currentTimeMillis();
+ put2.add(family, col1, ts, Bytes.toBytes("val2"));
+ put3.add(family, col1, ts, Bytes.toBytes("val3"));
+ table.put(put2);
+ table.put(put3);
+ } finally {
+ table.close();
+ }
+
+ String[] args = new String[] {tableName, COL_FAM + ":" + COL1, "--starttime=" + 0,
"--endtime=" + ts};
runRowCount(args, 1);
- args = new String[] {TABLE_NAME, COL_FAM + ":" + COL1, "--starttime=" + 0,
+ args = new String[] {tableName, COL_FAM + ":" + COL1, "--starttime=" + 0,
"--endtime=" + (ts - 10)};
runRowCount(args, 1);
- args = new String[] {TABLE_NAME, COL_FAM + ":" + COL1, "--starttime=" + ts,
+ args = new String[] {tableName, COL_FAM + ":" + COL1, "--starttime=" + ts,
"--endtime=" + (ts + 1000)};
runRowCount(args, 2);
- args = new String[] {TABLE_NAME, COL_FAM + ":" + COL1, "--starttime=" + (ts - 30 * 1000),
+ args = new String[] {tableName, COL_FAM + ":" + COL1, "--starttime=" + (ts - 30 * 1000),
"--endtime=" + (ts + 30 * 1000),};
runRowCount(args, 3);
}
@@ -196,20 +293,32 @@ public class TestRowCounter {
Configuration conf = opts.getConfiguration();
args = opts.getRemainingArgs();
Job job = RowCounter.createSubmittableJob(conf, args);
+ long start = System.currentTimeMillis();
job.waitForCompletion(true);
+ long duration = System.currentTimeMillis() - start;
+ LOG.debug("row count duration (ms): " + duration);
assertTrue(job.isSuccessful());
Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);
assertEquals(expectedCount, counter.getValue());
}
+ private static void writeRows(HTable table, int totalRows, int rowsWithOneCol)
+ throws IOException {
+ writeRows(table, totalRows, rowsWithOneCol, false);
+ }
+
/**
* Writes TOTAL_ROWS number of distinct rows in to the table. Few rows have
* two columns, Few have one.
- *
* @param table
+ * @param totalRows total number of rows to be added to the table
+ * @param rowsWithOneCol number of rows with one column to be added to the table
+ * @param writeBinary whether row prefix has to have \x00 in the beginning
* @throws IOException
*/
- private static void writeRows(HTable table) throws IOException {
+ private static void writeRows(HTable table, int totalRows, int rowsWithOneCol, boolean writeBinary)
+ throws IOException {
+ final String rowPrefix = writeBinary ? "\\x00row" : "row";
final byte[] family = Bytes.toBytes(COL_FAM);
final byte[] value = Bytes.toBytes("abcd");
final byte[] col1 = Bytes.toBytes(COL1);
@@ -218,8 +327,8 @@ public class TestRowCounter {
ArrayList<Put> rowsUpdate = new ArrayList<Put>();
// write few rows with two columns
int i = 0;
- for (; i < TOTAL_ROWS - ROWS_WITH_ONE_COL; i++) {
- byte[] row = Bytes.toBytes("row" + i);
+ for (; i < totalRows - rowsWithOneCol; i++) {
+ byte[] row = Bytes.toBytesBinary(rowPrefix + i);
Put put = new Put(row);
put.add(family, col1, value);
put.add(family, col2, value);
@@ -228,8 +337,8 @@ public class TestRowCounter {
}
// write few rows with only one column
- for (; i < TOTAL_ROWS; i++) {
- byte[] row = Bytes.toBytes("row" + i);
+ for (; i < totalRows; i++) {
+ byte[] row = Bytes.toBytesBinary(rowPrefix + i);
Put put = new Put(row);
put.add(family, col2, value);
rowsUpdate.add(put);
@@ -261,7 +370,8 @@ public class TestRowCounter {
assertTrue(data.toString().contains("Wrong number of parameters:"));
assertTrue(data.toString().contains("Usage: RowCounter [options] <tablename> " +
"[--starttime=[start] --endtime=[end] " +
- "[--range=[startKey],[endKey]] " +
+ "[--range=[startKey],[endKey]" +
+ "[;[startKey],[endKey]...]] " +
"[<column1> <column2>...]"));
assertTrue(data.toString().contains("-Dhbase.client.scanner.caching=100"));
assertTrue(data.toString().contains("-Dmapred.map.tasks.speculative.execution=false"));
@@ -279,7 +389,8 @@ public class TestRowCounter {
" \"--range=,b\" or \"--range=a,\""));
assertTrue(data.toString().contains("Usage: RowCounter [options] <tablename> " +
"[--starttime=[start] --endtime=[end] " +
- "[--range=[startKey],[endKey]] " +
+ "[--range=[startKey],[endKey]" +
+ "[;[startKey],[endKey]...]] " +
"[<column1> <column2>...]"));
}
[3/7] hbase git commit: HBASE-13704 Hbase throws
OutOfOrderScannerNextException when MultiRowRangeFilter is used (Aleksandr
Maksymenko)
Posted by ap...@apache.org.
HBASE-13704 Hbase throws OutOfOrderScannerNextException when MultiRowRangeFilter is used (Aleksandr Maksymenko)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/abe1168d
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/abe1168d
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/abe1168d
Branch: refs/heads/0.98
Commit: abe1168ddff7e0e08921480fdf0b3aecaef63034
Parents: b2d883d
Author: tedyu <yu...@gmail.com>
Authored: Tue May 19 20:21:08 2015 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Thu Jul 21 17:50:46 2016 -0700
----------------------------------------------------------------------
.../hadoop/hbase/filter/MultiRowRangeFilter.java | 6 ++++--
.../hbase/filter/TestMultiRowRangeFilter.java | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/abe1168d/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
index bd880a0..1ac9693 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -102,7 +102,7 @@ public class MultiRowRangeFilter extends FilterBase {
} else {
range = rangeList.get(0);
}
- if(EXCLUSIVE) {
+ if (EXCLUSIVE) {
EXCLUSIVE = false;
currentReturnCode = ReturnCode.NEXT_ROW;
return false;
@@ -115,7 +115,9 @@ public class MultiRowRangeFilter extends FilterBase {
}
initialized = true;
} else {
- currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
+ if (range.contains(buffer, offset, length)) {
+ currentReturnCode = ReturnCode.INCLUDE;
+ } else currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
}
} else {
currentReturnCode = ReturnCode.INCLUDE;
http://git-wip-us.apache.org/repos/asf/hbase/blob/abe1168d/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
index c2d25de..7ecc29c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -69,6 +70,24 @@ public class TestMultiRowRangeFilter {
}
@Test
+ public void testOutOfOrderScannerNextException() throws Exception {
+ MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
+ new MultiRowRangeFilter.RowRange(Bytes.toBytes("b"), true, Bytes.toBytes("c"), true),
+ new MultiRowRangeFilter.RowRange(Bytes.toBytes("d"), true, Bytes.toBytes("e"), true)
+ ));
+ filter.filterRowKey(Bytes.toBytes("a"), 0, 1);
+ assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null));
+ filter.filterRowKey(Bytes.toBytes("b"), 0, 1);
+ assertEquals(Filter.ReturnCode.INCLUDE, filter.filterKeyValue(null));
+ filter.filterRowKey(Bytes.toBytes("c"), 0, 1);
+ assertEquals(Filter.ReturnCode.INCLUDE, filter.filterKeyValue(null));
+ filter.filterRowKey(Bytes.toBytes("d"), 0, 1);
+ assertEquals(Filter.ReturnCode.INCLUDE, filter.filterKeyValue(null));
+ filter.filterRowKey(Bytes.toBytes("e"), 0, 1);
+ assertEquals(Filter.ReturnCode.INCLUDE, filter.filterKeyValue(null));
+ }
+
+ @Test
public void testMergeAndSortWithEmptyStartRow() throws IOException {
List<RowRange> ranges = new ArrayList<RowRange>();
ranges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(20), false));