Search in sources :

Example 6 with TimestampRange

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);
}
Also used : MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) Test(org.junit.Test)

Example 7 with 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);
}
Also used : RowFilter(com.google.bigtable.v2.RowFilter) Test(org.junit.Test)

Example 8 with TimestampRange

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());
}
Also used : CellsWithinColumnRead(com.spotify.bigtable.read.ReadCells.CellsWithinColumnRead) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) TimestampRange(com.google.bigtable.v2.TimestampRange) Test(org.junit.Test)

Example 9 with TimestampRange

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());
}
Also used : CellsWithinColumnRead(com.spotify.bigtable.read.ReadCells.CellsWithinColumnRead) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) TimestampRange(com.google.bigtable.v2.TimestampRange) Test(org.junit.Test)

Example 10 with TimestampRange

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());
}
Also used : CellsWithinColumnRead(com.spotify.bigtable.read.ReadCells.CellsWithinColumnRead) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) TimestampRange(com.google.bigtable.v2.TimestampRange) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 TimestampRange (com.google.bigtable.v2.TimestampRange)7 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)4 MutateRowRequest (com.google.bigtable.v2.MutateRowRequest)3 CellsWithinColumnRead (com.spotify.bigtable.read.ReadCells.CellsWithinColumnRead)3 Mutation (com.google.bigtable.v2.Mutation)2 RowMutation (com.google.cloud.bigtable.data.v2.models.RowMutation)2 Delete (org.apache.hadoop.hbase.client.Delete)2 MutateRowsRequest (com.google.bigtable.v2.MutateRowsRequest)1 MutationCase (com.google.bigtable.v2.Mutation.MutationCase)1 RowFilter (com.google.bigtable.v2.RowFilter)1 Filters (com.google.cloud.bigtable.data.v2.models.Filters)1 TimestampRangeFilter (com.google.cloud.bigtable.hbase.filter.TimestampRangeFilter)1 CellWithinCellsRead (com.spotify.bigtable.read.ReadCell.CellWithinCellsRead)1