Skip to content

Commit

Permalink
feat: Added FILTERS.timestamp().exact() to better accessibility
Browse files Browse the repository at this point in the history
This change enable user to directly provide precise timestamp to query with.
  • Loading branch information
rahulKQL committed Nov 18, 2019
1 parent 1834fc1 commit 8732523
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 8732523

Please sign in to comment.