Search in sources :

Example 26 with RowRange

use of org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange in project hbase by apache.

the class TestMultiRowRangeFilter method testRowKeyPrefixWithMergablePrefix.

@Test
public void testRowKeyPrefixWithMergablePrefix() throws IOException {
    byte[] prefix1 = { (byte) 0x12, (byte) 0x23, (byte) 0xFF, (byte) 0xFE };
    byte[] prefix2 = { (byte) 0x12, (byte) 0x23, (byte) 0xFF, (byte) 0xFF };
    byte[][] rowKeyPrefixes = new byte[2][];
    rowKeyPrefixes[0] = prefix1;
    rowKeyPrefixes[1] = prefix2;
    MultiRowRangeFilter filter = new MultiRowRangeFilter(rowKeyPrefixes);
    List<RowRange> actualRanges = filter.getRowRanges();
    List<RowRange> expectedRanges = new ArrayList<>();
    final byte[] expectedStop = { (byte) 0x12, (byte) 0x24 };
    expectedRanges.add(new RowRange(prefix1, true, expectedStop, false));
    assertRangesEqual(expectedRanges, actualRanges);
}
Also used : RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 27 with RowRange

use of org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange in project hbase by apache.

the class TestMultiRowRangeFilter method testMultiRowRangeFilterWithoutRangeOverlap.

@Test
public void testMultiRowRangeFilterWithoutRangeOverlap() throws IOException {
    tableName = TableName.valueOf(name.getMethodName());
    Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
    generateRows(numRows, ht, family, qf, value);
    Scan scan = new Scan();
    scan.readAllVersions();
    List<RowRange> ranges = new ArrayList<>();
    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();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 28 with RowRange

use of org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange in project hbase by apache.

the class TestMultiRowRangeFilter method testMultiRowRangeWithFilterListAndOperator.

@Test
public void testMultiRowRangeWithFilterListAndOperator() throws IOException {
    tableName = TableName.valueOf(name.getMethodName());
    Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
    generateRows(numRows, ht, family, qf, value);
    Scan scan = new Scan();
    scan.readAllVersions();
    List<RowRange> ranges1 = new ArrayList<>();
    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<>();
    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();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 29 with RowRange

use of org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange in project hbase by apache.

the class TestMultiRowRangeFilter method testMultiRowRangeWithFilterListOrOperator.

@Test
public void testMultiRowRangeWithFilterListOrOperator() throws IOException {
    tableName = TableName.valueOf(name.getMethodName());
    Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
    generateRows(numRows, ht, family, qf, value);
    Scan scan = new Scan();
    scan.readAllVersions();
    List<RowRange> ranges1 = new ArrayList<>();
    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<>();
    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();
}
Also used : Table(org.apache.hadoop.hbase.client.Table) RowRange(org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Aggregations

RowRange (org.apache.hadoop.hbase.filter.MultiRowRangeFilter.RowRange)29 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)27 Cell (org.apache.hadoop.hbase.Cell)13 Scan (org.apache.hadoop.hbase.client.Scan)13 Table (org.apache.hadoop.hbase.client.Table)13 Put (org.apache.hadoop.hbase.client.Put)3 DirectedType (uk.gov.gchq.gaffer.data.element.id.DirectedType)2 SeedMatching (uk.gov.gchq.gaffer.operation.SeedMatching)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Pair (uk.gov.gchq.gaffer.commonutil.pair.Pair)1 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)1 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)1 SeededGraphFilters (uk.gov.gchq.gaffer.operation.graph.SeededGraphFilters)1 IncludeIncomingOutgoingType (uk.gov.gchq.gaffer.operation.graph.SeededGraphFilters.IncludeIncomingOutgoingType)1