Search in sources :

Example 11 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project phoenix by apache.

the class PhoenixRuntimeIT method getUserTableAndViewsFilter.

private static Filter getUserTableAndViewsFilter() {
    SingleColumnValueFilter tableFilter = new SingleColumnValueFilter(TABLE_FAMILY_BYTES, PhoenixDatabaseMetaData.TABLE_TYPE_BYTES, CompareOp.EQUAL, Bytes.toBytes(PTableType.TABLE.getSerializedValue()));
    tableFilter.setFilterIfMissing(true);
    SingleColumnValueFilter viewFilter = new SingleColumnValueFilter(TABLE_FAMILY_BYTES, PhoenixDatabaseMetaData.TABLE_TYPE_BYTES, CompareOp.EQUAL, Bytes.toBytes(PTableType.VIEW.getSerializedValue()));
    viewFilter.setFilterIfMissing(true);
    FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ONE, Arrays.asList(new Filter[] { tableFilter, viewFilter }));
    return filter;
}
Also used : SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) FirstKeyOnlyFilter(org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter) Filter(org.apache.hadoop.hbase.filter.Filter) SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList)

Example 12 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project phoenix by apache.

the class MetaDataEndpointImpl method findChildViews_4_11.

private TableViewFinder findChildViews_4_11(Region region, byte[] tenantId, byte[] schemaName, byte[] tableName) throws IOException {
    Scan scan = new Scan();
    byte[] startRow = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
    byte[] stopRow = ByteUtil.nextKey(startRow);
    scan.setStartRow(startRow);
    scan.setStopRow(stopRow);
    SingleColumnValueFilter linkFilter = new SingleColumnValueFilter(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES, CompareOp.EQUAL, CHILD_TABLE_BYTES);
    linkFilter.setFilterIfMissing(true);
    scan.setFilter(linkFilter);
    scan.addColumn(TABLE_FAMILY_BYTES, LINK_TYPE_BYTES);
    scan.addColumn(TABLE_FAMILY_BYTES, PARENT_TENANT_ID_BYTES);
    // Original region-only scanner modified due to PHOENIX-1208
    // RegionScanner scanner = region.getScanner(scan);
    // The following *should* work, but doesn't due to HBASE-11837
    // TableName systemCatalogTableName = region.getTableDesc().getTableName();
    // HTableInterface hTable = env.getTable(systemCatalogTableName);
    // These deprecated calls work around the issue
    HTableInterface hTable = ServerUtil.getHTableForCoprocessorScan(env, region.getTableDesc().getTableName().getName());
    try {
        boolean allViewsInCurrentRegion = true;
        int numOfChildViews = 0;
        List<ViewInfo> viewInfoList = Lists.newArrayList();
        ResultScanner scanner = hTable.getScanner(scan);
        try {
            for (Result result = scanner.next(); (result != null); result = scanner.next()) {
                numOfChildViews++;
                ImmutableBytesWritable ptr = new ImmutableBytesWritable();
                ResultTuple resultTuple = new ResultTuple(result);
                resultTuple.getKey(ptr);
                byte[] key = ptr.copyBytes();
                if (checkTableKeyInRegion(key, region) != null) {
                    allViewsInCurrentRegion = false;
                }
                byte[][] rowViewKeyMetaData = new byte[5][];
                getVarChars(result.getRow(), 5, rowViewKeyMetaData);
                byte[] viewTenantId = rowViewKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX];
                byte[] viewSchemaName = SchemaUtil.getSchemaNameFromFullName(rowViewKeyMetaData[PhoenixDatabaseMetaData.FAMILY_NAME_INDEX]).getBytes();
                byte[] viewName = SchemaUtil.getTableNameFromFullName(rowViewKeyMetaData[PhoenixDatabaseMetaData.FAMILY_NAME_INDEX]).getBytes();
                viewInfoList.add(new ViewInfo(viewTenantId, viewSchemaName, viewName));
            }
            TableViewFinder tableViewFinderResult = new TableViewFinder(viewInfoList);
            if (numOfChildViews > 0 && !allViewsInCurrentRegion) {
                tableViewFinderResult.setAllViewsNotInSingleRegion();
            }
            return tableViewFinderResult;
        } finally {
            scanner.close();
        }
    } finally {
        hTable.close();
    }
}
Also used : SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable) ResultTuple(org.apache.phoenix.schema.tuple.ResultTuple) HTableInterface(org.apache.hadoop.hbase.client.HTableInterface) PTinyint(org.apache.phoenix.schema.types.PTinyint) PSmallint(org.apache.phoenix.schema.types.PSmallint) Result(org.apache.hadoop.hbase.client.Result) Scan(org.apache.hadoop.hbase.client.Scan)

Example 13 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project cdap by caskdata.

the class HBase11QueueConsumer method createStateFilter.

/**
   * Creates a HBase filter that will filter out rows with state column state = PROCESSED (ignoring transaction).
   */
private Filter createStateFilter() {
    byte[] processedMask = new byte[Ints.BYTES * 2 + 1];
    processedMask[processedMask.length - 1] = ConsumerEntryState.PROCESSED.getState();
    return new SingleColumnValueFilter(QueueEntryRow.COLUMN_FAMILY, stateColumnName, CompareFilter.CompareOp.NOT_EQUAL, new BitComparator(processedMask, BitComparator.BitwiseOp.AND));
}
Also used : SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) BitComparator(org.apache.hadoop.hbase.filter.BitComparator)

Example 14 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project cdap by caskdata.

the class HBase12CDH570QueueConsumer method createStateFilter.

/**
   * Creates a HBase filter that will filter out rows with state column state = PROCESSED (ignoring transaction).
   */
private Filter createStateFilter() {
    byte[] processedMask = new byte[Ints.BYTES * 2 + 1];
    processedMask[processedMask.length - 1] = ConsumerEntryState.PROCESSED.getState();
    return new SingleColumnValueFilter(QueueEntryRow.COLUMN_FAMILY, stateColumnName, CompareFilter.CompareOp.NOT_EQUAL, new BitComparator(processedMask, BitComparator.BitwiseOp.AND));
}
Also used : SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) BitComparator(org.apache.hadoop.hbase.filter.BitComparator)

Example 15 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project cdap by caskdata.

the class HBase10QueueConsumer method createStateFilter.

/**
   * Creates a HBase filter that will filter out rows with state column state = PROCESSED (ignoring transaction).
   */
private Filter createStateFilter() {
    byte[] processedMask = new byte[Ints.BYTES * 2 + 1];
    processedMask[processedMask.length - 1] = ConsumerEntryState.PROCESSED.getState();
    return new SingleColumnValueFilter(QueueEntryRow.COLUMN_FAMILY, stateColumnName, CompareFilter.CompareOp.NOT_EQUAL, new BitComparator(processedMask, BitComparator.BitwiseOp.AND));
}
Also used : SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) BitComparator(org.apache.hadoop.hbase.filter.BitComparator)

Aggregations

SingleColumnValueFilter (org.apache.hadoop.hbase.filter.SingleColumnValueFilter)31 Scan (org.apache.hadoop.hbase.client.Scan)12 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)10 Filter (org.apache.hadoop.hbase.filter.Filter)9 FilterList (org.apache.hadoop.hbase.filter.FilterList)8 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)7 BitComparator (org.apache.hadoop.hbase.filter.BitComparator)7 Result (org.apache.hadoop.hbase.client.Result)6 RowFilter (org.apache.hadoop.hbase.filter.RowFilter)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 CompareOp (org.apache.hadoop.hbase.filter.CompareFilter.CompareOp)4 FirstKeyOnlyFilter (org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter)4 Put (org.apache.hadoop.hbase.client.Put)3 ByteArrayComparable (org.apache.hadoop.hbase.filter.ByteArrayComparable)3 PrefixFilter (org.apache.hadoop.hbase.filter.PrefixFilter)3 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 Cell (org.apache.hadoop.hbase.Cell)2 TableName (org.apache.hadoop.hbase.TableName)2