Skip to content

Commit

Permalink
feat: update filter to accept an exact timestamp for better accessibi…
Browse files Browse the repository at this point in the history
…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 e25758b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Expand Up @@ -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. */
Expand Down
Expand Up @@ -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 =
Expand Down

0 comments on commit e25758b

Please sign in to comment.