GetAdapter implements ReadOperationAdapter<Get> { @Override public void adapt(Get operation, ReadHooks readHooks, Query query) { Scan operationAsScan = new Scan(addKeyOnlyFilter(operation)); scanAdapter.throwIfUnsupportedScan(operationAsScan); query .filter(scanAdapter.buildFilter(operationAsScan, readHooks)) .rowKey(ByteString.copyFrom(operation.getRow())); } GetAdapter(ScanAdapter scanAdapter); static Get setCheckExistenceOnly(Get get); @Override void adapt(Get operation, ReadHooks readHooks, Query query); Filters.Filter buildFilter(Get operation);  }
@Test public void rowKeyIsSetInRequest() throws IOException { Get get = makeValidGet(dataHelper.randomData(PREFIX_DATA)); getAdapter.adapt(get, throwingReadHooks, query); ByteString adaptedRowKey = query.toProto(requestContext).getRows().getRowKeys(0); Assert.assertEquals( new String(get.getRow(), StandardCharsets.UTF_8), adaptedRowKey.toStringUtf8()); }
@Test public void maxVersionsIsSet() throws IOException { Get get = makeValidGet(dataHelper.randomData(PREFIX_DATA)); get.setMaxVersions(10); getAdapter.adapt(get, throwingReadHooks, query); Assert.assertEquals( FILTERS.limit().cellsPerColumn(10).toProto(), query.toProto(requestContext).getFilter()); }
@Test public void columnFamilyIsSet() throws IOException { Get get = makeValidGet(dataHelper.randomData(PREFIX_DATA)); get.addFamily(Bytes.toBytes(FAMILY_ID)); getAdapter.adapt(get, throwingReadHooks, query); Assert.assertEquals( FILTERS.family().exactMatch(FAMILY_ID).toProto(), query.toProto(requestContext).getFilter()); }
@Test public void columnQualifierIsSet() throws IOException { Get get = makeValidGet(dataHelper.randomData(PREFIX_DATA)); get.addColumn(Bytes.toBytes(FAMILY_ID), Bytes.toBytes(QUALIFIER_ID)); getAdapter.adapt(get, throwingReadHooks, query); Assert.assertEquals( FILTERS .chain() .filter(FILTERS.family().regex(FAMILY_ID)) .filter(FILTERS.qualifier().regex(QUALIFIER_ID)) .toProto(), query.toProto(requestContext).getFilter()); }
@Test public void multipleQualifiersAreSet() throws IOException { Get get = makeValidGet(dataHelper.randomData(PREFIX_DATA)); get.addColumn(Bytes.toBytes(FAMILY_ID), Bytes.toBytes(QUALIFIER_ID)); get.addColumn(Bytes.toBytes(FAMILY_ID), Bytes.toBytes("q2")); getAdapter.adapt(get, throwingReadHooks, query); Assert.assertEquals( FILTERS .chain() .filter(FILTERS.family().regex(FAMILY_ID)) .filter( FILTERS .interleave() .filter(FILTERS.qualifier().regex(QUALIFIER_ID)) .filter(FILTERS.qualifier().regex("q2"))) .toProto(), query.toProto(requestContext).getFilter()); }