Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FILTERS.timestamp().exact() for better access & read ability. #92

Merged
merged 1 commit into from Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why + 1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimestampRange#endTimestampMicros denotes upper bound for timestamp range. If we pass the same value then no rows will return.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end range cap is exclusive, so for a single number, the range is [x, x+1)

.build();

assertThat(actualFilter).isEqualTo(expectedFilter);
}

@Test
public void timestampOpenClosedFakeRange() {
RowFilter actualFilter =
Expand Down