Skip to content
Permalink
Browse files
feat: update filter to accept an exact timestamp for better accessibi…
…lity (#92)

This change introduces `FILTERS.timestamp().exact()`, which enable user to directly provide exact timestamp to query Bigtable.
  • Loading branch information
rahulKQL authored and igorbernstein2 committed Nov 18, 2019
1 parent 1834fc1 commit e25758b3164618ac16d57fffe6ba0e4175229960
@@ -516,6 +516,15 @@ private TimestampFilter() {}
public TimestampRangeFilter range() {
return new TimestampRangeFilter();
}

/**
* Matches cells with exact given timestamp.
*
* @return a {@link TimestampRangeFilter} with start/end closed timestamp.
*/
public TimestampRangeFilter exact(Long exactTimestamp) {
return new TimestampRangeFilter().startClosed(exactTimestamp).endClosed(exactTimestamp);
}
}

/** Matches only cells with microsecond timestamps within the given range. */
@@ -350,6 +350,21 @@ public void timestampRange() {
assertThat(actualFilter).isEqualTo(expectedFilter);
}

@Test
public void timestampAtExactTime() {
RowFilter actualFilter = FILTERS.timestamp().exact(20_000L).toProto();

RowFilter expectedFilter =
RowFilter.newBuilder()
.setTimestampRangeFilter(
TimestampRange.newBuilder()
.setStartTimestampMicros(20_000L)
.setEndTimestampMicros(20_000L + 1))
.build();

assertThat(actualFilter).isEqualTo(expectedFilter);
}

@Test
public void timestampOpenClosedFakeRange() {
RowFilter actualFilter =

0 comments on commit e25758b

Please sign in to comment.