Search in sources :

Example 1 with ReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.ReadHooks in project java-bigtable-hbase by googleapis.

the class HBaseRequestAdapter method adapt.

/**
 * adapt.
 *
 * @param scan a {@link Scan} object.
 * @return a {@link Query} object.
 */
public Query adapt(Scan scan) {
    ReadHooks readHooks = new DefaultReadHooks();
    Query query = Query.create(getTableId());
    Adapters.SCAN_ADAPTER.adapt(scan, readHooks, query);
    readHooks.applyPreSendHook(query);
    return query;
}
Also used : ReadHooks(com.google.cloud.bigtable.hbase.adapters.read.ReadHooks) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Query(com.google.cloud.bigtable.data.v2.models.Query) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)

Example 2 with ReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.ReadHooks in project java-bigtable-hbase by googleapis.

the class HBaseRequestAdapter method adapt.

/**
 * adapt.
 *
 * @param get a {@link Get} object.
 * @return a {@link Query} object.
 */
public Query adapt(Get get) {
    ReadHooks readHooks = new DefaultReadHooks();
    Query query = Query.create(getTableId());
    Adapters.GET_ADAPTER.adapt(get, readHooks, query);
    readHooks.applyPreSendHook(query);
    return query;
}
Also used : ReadHooks(com.google.cloud.bigtable.hbase.adapters.read.ReadHooks) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Query(com.google.cloud.bigtable.data.v2.models.Query) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)

Example 3 with ReadHooks

use of com.google.cloud.bigtable.hbase.adapters.read.ReadHooks in project java-bigtable-hbase by googleapis.

the class TestPageFilterAdapter method pageFilterIsAppliedToReadRowsRequest.

@Test
public void pageFilterIsAppliedToReadRowsRequest() throws IOException {
    final String TABLE_ID = "tableId";
    final RequestContext requestContext = RequestContext.create("ProjectId", "InstanceId", "AppProfile");
    ReadHooks hooks = new DefaultReadHooks();
    FilterAdapterContext context = new FilterAdapterContext(new Scan(), hooks);
    PageFilter pageFilter = new PageFilter(20);
    Filters.Filter adaptedFilter = pageFilterAdapter.adapt(context, pageFilter);
    Assert.assertNull("PageFilterAdapter should not return a Filters.Filter.", adaptedFilter);
    Query query = Query.create(TABLE_ID).limit(100);
    hooks.applyPreSendHook(query);
    Assert.assertEquals(20, query.toProto(requestContext).getRowsLimit());
}
Also used : Filters(com.google.cloud.bigtable.data.v2.models.Filters) ReadHooks(com.google.cloud.bigtable.hbase.adapters.read.ReadHooks) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Query(com.google.cloud.bigtable.data.v2.models.Query) Scan(org.apache.hadoop.hbase.client.Scan) PageFilter(org.apache.hadoop.hbase.filter.PageFilter) RequestContext(com.google.cloud.bigtable.data.v2.internal.RequestContext) DefaultReadHooks(com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks) Test(org.junit.Test)

Aggregations

Query (com.google.cloud.bigtable.data.v2.models.Query)3 DefaultReadHooks (com.google.cloud.bigtable.hbase.adapters.read.DefaultReadHooks)3 ReadHooks (com.google.cloud.bigtable.hbase.adapters.read.ReadHooks)3 RequestContext (com.google.cloud.bigtable.data.v2.internal.RequestContext)1 Filters (com.google.cloud.bigtable.data.v2.models.Filters)1 Scan (org.apache.hadoop.hbase.client.Scan)1 PageFilter (org.apache.hadoop.hbase.filter.PageFilter)1 Test (org.junit.Test)1