Search in sources :

Example 1 with ChainFilter

use of com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter in project java-bigtable-hbase by googleapis.

the class ColumnPaginationFilterAdapter method createChain.

/**
 * Create a filter chain that allows the latest values for each qualifier, those cells that pass
 * an option intermediate filter and are less than the limit per row.
 */
private Filter createChain(ColumnPaginationFilter filter, Filter intermediate) {
    ChainFilter chain = FILTERS.chain();
    chain.filter(FILTERS.limit().cellsPerColumn(1));
    if (intermediate != null) {
        chain.filter(intermediate);
    }
    chain.filter(FILTERS.limit().cellsPerRow(filter.getLimit()));
    return chain;
}
Also used : ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter)

Example 2 with ChainFilter

use of com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter in project java-bigtable-hbase by googleapis.

the class ScanAdapter method buildFilter.

/**
 * Given a {@link Scan}, build a {@link Filters.Filter} that include matching columns
 *
 * @param scan a {@link Scan} object.
 * @param hooks a {@link ReadHooks} object.
 * @return a {@link Filters.Filter} object.
 */
public Filters.Filter buildFilter(Scan scan, ReadHooks hooks) {
    ChainFilter chain = FILTERS.chain();
    Optional<Filters.Filter> familyFilter = createColumnFamilyFilter(scan);
    if (familyFilter.isPresent()) {
        chain.filter(familyFilter.get());
    }
    if (scan.getTimeRange() != null && !scan.getTimeRange().isAllTime()) {
        chain.filter(createTimeRangeFilter(scan.getTimeRange()));
    }
    if (scan.getMaxVersions() != Integer.MAX_VALUE) {
        chain.filter(createColumnLimitFilter(scan.getMaxVersions()));
    }
    Optional<Filters.Filter> userFilter = createUserFilter(scan, hooks);
    if (userFilter.isPresent()) {
        chain.filter(userFilter.get());
    }
    Optional<Filters.Filter> colFamilyTimeFilter = createColFamilyTimeRange(scan);
    if (colFamilyTimeFilter.isPresent()) {
        chain.filter(colFamilyTimeFilter.get());
    }
    return chain;
}
Also used : InterleaveFilter(com.google.cloud.bigtable.data.v2.models.Filters.InterleaveFilter) ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter) TimestampRangeFilter(com.google.cloud.bigtable.data.v2.models.Filters.TimestampRangeFilter) Filter(org.apache.hadoop.hbase.filter.Filter) ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter)

Example 3 with ChainFilter

use of com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter in project java-bigtable-hbase by googleapis.

the class SingleColumnValueFilterAdapter method getColumnSpecFilter.

@VisibleForTesting
static ChainFilter getColumnSpecFilter(byte[] family, byte[] qualifier, boolean latestVersionOnly) throws IOException {
    ByteString wrappedQual = quoteRegularExpression(qualifier);
    String wrappedFamily = quoteRegularExpression(family).toStringUtf8();
    ChainFilter builder = FILTERS.chain().filter(FILTERS.family().regex(wrappedFamily)).filter(FILTERS.qualifier().regex(wrappedQual));
    if (latestVersionOnly) {
        builder.filter(LATEST_ONLY_FILTER);
    }
    return builder;
}
Also used : ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) ChainFilter(com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ChainFilter (com.google.cloud.bigtable.data.v2.models.Filters.ChainFilter)3 InterleaveFilter (com.google.cloud.bigtable.data.v2.models.Filters.InterleaveFilter)1 TimestampRangeFilter (com.google.cloud.bigtable.data.v2.models.Filters.TimestampRangeFilter)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteString (com.google.protobuf.ByteString)1 Filter (org.apache.hadoop.hbase.filter.Filter)1