use of com.google.bigtable.v2.TimestampRange in project java-bigtable by googleapis.
the class RowMutationTest method toProtoTest.
@Test
public void toProtoTest() {
long timestampMin = System.currentTimeMillis() * 1_000;
RowMutation rowMutation = RowMutation.create("fake-table", "fake-key").setCell("fake-family", "fake-qualifier", "fake-value");
MutateRowRequest actualRowMutation = rowMutation.toProto(REQUEST_CONTEXT);
com.google.common.collect.Range<Long> timestampRange = com.google.common.collect.Range.closed(timestampMin, System.currentTimeMillis() * 1_000);
assertThat(actualRowMutation.getTableName()).isEqualTo(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, "fake-table"));
assertThat(actualRowMutation.getAppProfileId()).isEqualTo(APP_PROFILE_ID);
assertThat(actualRowMutation.getMutationsList()).hasSize(1);
assertThat(actualRowMutation.getMutations(0).getSetCell().getValue()).isEqualTo(ByteString.copyFromUtf8("fake-value"));
assertThat(actualRowMutation.getMutations(0).getSetCell().getTimestampMicros()).isIn(timestampRange);
}
use of com.google.bigtable.v2.TimestampRange in project java-bigtable by googleapis.
the class FiltersTest method timestampRange.
@Test
public void timestampRange() {
RowFilter actualFilter = FILTERS.timestamp().range().startClosed(1_000L).endOpen(30_000L).toProto();
RowFilter expectedFilter = RowFilter.newBuilder().setTimestampRangeFilter(TimestampRange.newBuilder().setStartTimestampMicros(1_000L).setEndTimestampMicros(30_000L)).build();
assertThat(actualFilter).isEqualTo(expectedFilter);
}
use of com.google.bigtable.v2.TimestampRange in project simple-bigtable by spotify.
the class CellsReadImplTest method testEndTimestampMicros.
@Test
public void testEndTimestampMicros() throws Exception {
final TimestampRange timestampRange = TimestampRange.newBuilder().setEndTimestampMicros(12345).build();
final CellsWithinColumnRead.ReadImpl read = (CellsWithinColumnRead.ReadImpl) cellsRead.endTimestampMicros(timestampRange.getEndTimestampMicros());
final ReadRowsRequest.Builder readRequest = read.readRequest();
verifyReadRequest(readRequest);
assertEquals(4, readRequest.getFilter().getChain().getFiltersCount());
assertEquals(timestampRange, readRequest.getFilter().getChain().getFilters(3).getTimestampRangeFilter());
assertEquals(RowFilter.getDefaultInstance(), readRequest.getFilter().toBuilder().clearChain().build());
}
use of com.google.bigtable.v2.TimestampRange in project simple-bigtable by spotify.
the class CellsReadImplTest method testStartTimestampMicros.
@Test
public void testStartTimestampMicros() throws Exception {
final TimestampRange timestampRange = TimestampRange.newBuilder().setStartTimestampMicros(12345).build();
final CellsWithinColumnRead.ReadImpl read = (CellsWithinColumnRead.ReadImpl) cellsRead.startTimestampMicros(timestampRange.getStartTimestampMicros());
final ReadRowsRequest.Builder readRequest = read.readRequest();
verifyReadRequest(readRequest);
assertEquals(4, readRequest.getFilter().getChain().getFiltersCount());
assertEquals(timestampRange, readRequest.getFilter().getChain().getFilters(3).getTimestampRangeFilter());
assertEquals(RowFilter.getDefaultInstance(), readRequest.getFilter().toBuilder().clearChain().build());
}
use of com.google.bigtable.v2.TimestampRange in project simple-bigtable by spotify.
the class CellsReadImplTest method testMultipleFilters.
@Test
public void testMultipleFilters() throws Exception {
final TimestampRange startTimestampRange = TimestampRange.newBuilder().setStartTimestampMicros(12345).build();
final TimestampRange endTimestampRange = TimestampRange.newBuilder().setEndTimestampMicros(12345).build();
final CellsWithinColumnRead.ReadImpl read = (CellsWithinColumnRead.ReadImpl) cellsRead.limit(10).startTimestampMicros(startTimestampRange.getStartTimestampMicros()).endTimestampMicros(endTimestampRange.getEndTimestampMicros()).valueRegex(ByteString.copyFromUtf8("regex"));
final ReadRowsRequest.Builder readRequest = read.readRequest();
verifyReadRequest(readRequest);
assertEquals(7, readRequest.getFilter().getChain().getFiltersCount());
assertEquals(10, readRequest.getFilter().getChain().getFilters(3).getCellsPerColumnLimitFilter());
assertEquals(startTimestampRange, readRequest.getFilter().getChain().getFilters(4).getTimestampRangeFilter());
assertEquals(endTimestampRange, readRequest.getFilter().getChain().getFilters(5).getTimestampRangeFilter());
assertEquals("regex", readRequest.getFilter().getChain().getFilters(6).getValueRegexFilter().toStringUtf8());
assertEquals(RowFilter.getDefaultInstance(), readRequest.getFilter().toBuilder().clearChain().build());
}
Aggregations