org.apache.hadoop.hbase.filter.ColumnPrefixFilter Java Examples

The following examples show how to use org.apache.hadoop.hbase.filter.ColumnPrefixFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuotaTableUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a scanner for all namespace snapshot entries of the given namespace
 * @param namespace name of the namespace whose snapshot entries are to be scanned
 */
static Scan createScanForNamespaceSnapshotSizes(String namespace) {
  Scan s = new Scan();
  if (namespace == null || namespace.isEmpty()) {
    // Read all namespaces, just look at the row prefix
    s.setRowPrefixFilter(QUOTA_NAMESPACE_ROW_KEY_PREFIX);
  } else {
    // Fetch the exact row for the table
    byte[] rowkey = getNamespaceRowKey(namespace);
    // Fetch just this one row
    s.withStartRow(rowkey).withStopRow(rowkey, true);
  }

  // Just the usage family and only the snapshot size qualifiers
  return s.addFamily(QUOTA_FAMILY_USAGE)
      .setFilter(new ColumnPrefixFilter(QUOTA_SNAPSHOT_SIZE_QUALIFIER));
}
 
Example #2
Source File: QuotaTableUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
static Scan createScanForSpaceSnapshotSizes(TableName table) {
  Scan s = new Scan();
  if (null == table) {
    // Read all tables, just look at the row prefix
    s.setRowPrefixFilter(QUOTA_TABLE_ROW_KEY_PREFIX);
  } else {
    // Fetch the exact row for the table
    byte[] rowkey = getTableRowKey(table);
    // Fetch just this one row
    s.withStartRow(rowkey).withStopRow(rowkey, true);
  }

  // Just the usage family and only the snapshot size qualifiers
  return s.addFamily(QUOTA_FAMILY_USAGE).setFilter(
      new ColumnPrefixFilter(QUOTA_SNAPSHOT_SIZE_QUALIFIER));
}
 
Example #3
Source File: HBaseScanOperatorTest.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
public Scan operationScan()
{
  Scan scan = new Scan();
  Filter f = new ColumnPrefixFilter(Bytes.toBytes("col-0"));
  scan.setFilter(f);
  return scan;
}
 
Example #4
Source File: TestPartialResultsFromClientSide.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Test partial Result re-assembly in the presence of different filters. The Results from the
 * partial scanner should match the Results returned from a scanner that receives all of the
 * results in one RPC to the server. The partial scanner is tested with a variety of different
 * result sizes (all of which are less than the size necessary to fetch an entire row)
 * @throws Exception
 */
@Test
public void testPartialResultsWithColumnFilter() throws Exception {
  testPartialResultsWithColumnFilter(new FirstKeyOnlyFilter());
  testPartialResultsWithColumnFilter(new ColumnPrefixFilter(Bytes.toBytes("testQualifier5")));
  testPartialResultsWithColumnFilter(new ColumnRangeFilter(Bytes.toBytes("testQualifer1"), true,
      Bytes.toBytes("testQualifier7"), true));

  Set<byte[]> qualifiers = new LinkedHashSet<>();
  qualifiers.add(Bytes.toBytes("testQualifier5"));
  testPartialResultsWithColumnFilter(new FirstKeyValueMatchingQualifiersFilter(qualifiers));
}
 
Example #5
Source File: TestFilters.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@Test(timeOut = 60_000)
public void testGetWithColumnPrefixFilter(ITestContext context) throws Exception {
    testGet(context, new ColumnPrefixFilter(prefix));
}
 
Example #6
Source File: TestFilters.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@Test(timeOut = 60_000)
public void testScanWithColumnPrefixFilter(ITestContext context) throws Exception {
    testScan(context, new ColumnPrefixFilter(prefix));
}
 
Example #7
Source File: TestHBaseStorageFiltering.java    From spork with Apache License 2.0 4 votes vote down vote up
private void assertPrefixFilter(Filter filter, String prefix) {
    assertTrue("Filter is not a ColumnPrefixFilter: " + filter.getClass().getSimpleName(),
            filter instanceof ColumnPrefixFilter);
    ColumnPrefixFilter familyFilter = (ColumnPrefixFilter)filter;
    assertEquals("Unexpected prefix", prefix, Bytes.toString(familyFilter.getPrefix()));
}