use of io.confluent.ksql.execution.streams.materialization.WindowedRow in project ksql by confluentinc.
the class KsMaterializedSessionTableIQv2Test method shouldReturnValueIfSessionEndsBetweenBounds.
@Test
public void shouldReturnValueIfSessionEndsBetweenBounds() {
// Given:
final Instant wstart = LOWER_INSTANT.minusMillis(5);
final Instant wend = UPPER_INSTANT.minusMillis(1);
givenSingleSession(wstart, wend);
// When:
final KsMaterializedQueryResult<WindowedRow> result = table.get(A_KEY, PARTITION, Range.all(), WINDOW_END_BOUNDS);
// Then:
final Iterator<WindowedRow> rowIterator = result.getRowIterator();
assertThat(rowIterator.hasNext(), is(true));
assertThat(rowIterator.next(), is(WindowedRow.of(SCHEMA, sessionKey(wstart, wend), A_VALUE, wend.toEpochMilli())));
assertThat(result.getPosition(), not(Optional.empty()));
assertThat(result.getPosition().get(), is(POSITION));
}
use of io.confluent.ksql.execution.streams.materialization.WindowedRow in project ksql by confluentinc.
the class KsMaterializedSessionTableIQv2Test method shouldReturnValueIfSessionEndsAtUpperBoundIfUpperBoundClosed.
@Test
public void shouldReturnValueIfSessionEndsAtUpperBoundIfUpperBoundClosed() {
// Given:
final Range<Instant> endBounds = Range.closed(LOWER_INSTANT, UPPER_INSTANT);
final Instant wstart = UPPER_INSTANT.minusMillis(1);
givenSingleSession(wstart, UPPER_INSTANT);
// When:
final KsMaterializedQueryResult<WindowedRow> result = table.get(A_KEY, PARTITION, Range.all(), endBounds);
// Then:
final Iterator<WindowedRow> rowIterator = result.getRowIterator();
assertThat(rowIterator.hasNext(), is(true));
assertThat(rowIterator.next(), is(WindowedRow.of(SCHEMA, sessionKey(wstart, UPPER_INSTANT), A_VALUE, UPPER_INSTANT.toEpochMilli())));
assertThat(result.getPosition(), not(Optional.empty()));
assertThat(result.getPosition().get(), is(POSITION));
}
use of io.confluent.ksql.execution.streams.materialization.WindowedRow in project ksql by confluentinc.
the class KsMaterializedSessionTableIQv2Test method shouldReturnValueIfSessionEndsAtLowerBoundIfLowerStartBoundClosed.
@Test
public void shouldReturnValueIfSessionEndsAtLowerBoundIfLowerStartBoundClosed() {
// Given:
final Range<Instant> endBounds = Range.closed(LOWER_INSTANT, UPPER_INSTANT);
final Instant wstart = LOWER_INSTANT.minusMillis(1);
givenSingleSession(wstart, LOWER_INSTANT);
// When:
final KsMaterializedQueryResult<WindowedRow> result = table.get(A_KEY, PARTITION, Range.all(), endBounds);
// Then:
final Iterator<WindowedRow> rowIterator = result.getRowIterator();
assertThat(rowIterator.hasNext(), is(true));
assertThat(rowIterator.next(), is(WindowedRow.of(SCHEMA, sessionKey(wstart, LOWER_INSTANT), A_VALUE, LOWER_INSTANT.toEpochMilli())));
assertThat(result.getPosition(), not(Optional.empty()));
assertThat(result.getPosition().get(), is(POSITION));
}
use of io.confluent.ksql.execution.streams.materialization.WindowedRow in project ksql by confluentinc.
the class KsMaterializedSessionTableIQv2Test method shouldReturnMultipleSessions.
@Test
public void shouldReturnMultipleSessions() {
// Given:
givenSingleSession(LOWER_INSTANT.minusMillis(1), LOWER_INSTANT.plusSeconds(1));
final Instant wend0 = LOWER_INSTANT;
givenSingleSession(LOWER_INSTANT, wend0);
final Instant wend1 = UPPER_INSTANT;
givenSingleSession(UPPER_INSTANT, wend1);
givenSingleSession(UPPER_INSTANT.plusMillis(1), UPPER_INSTANT.plusSeconds(1));
// When:
final KsMaterializedQueryResult<WindowedRow> result = table.get(A_KEY, PARTITION, WINDOW_START_BOUNDS, WINDOW_END_BOUNDS);
// Then:
final Iterator<WindowedRow> rowIterator = result.getRowIterator();
assertThat(rowIterator.hasNext(), is(true));
final List<WindowedRow> resultList = Lists.newArrayList(rowIterator);
assertThat(resultList, contains(WindowedRow.of(SCHEMA, sessionKey(LOWER_INSTANT, wend0), A_VALUE, wend0.toEpochMilli()), WindowedRow.of(SCHEMA, sessionKey(UPPER_INSTANT, wend1), A_VALUE, wend1.toEpochMilli())));
assertThat(result.getPosition(), not(Optional.empty()));
assertThat(result.getPosition().get(), is(POSITION));
}
use of io.confluent.ksql.execution.streams.materialization.WindowedRow in project ksql by confluentinc.
the class KsMaterializedSessionTableTest method shouldReturnValueIfSessionStartsAtUpperBoundIfUpperBoundClosed.
@Test
public void shouldReturnValueIfSessionStartsAtUpperBoundIfUpperBoundClosed() {
// Given:
final Range<Instant> startBounds = Range.closed(LOWER_INSTANT, UPPER_INSTANT);
final Instant wend = UPPER_INSTANT.plusMillis(1);
givenSingleSession(UPPER_INSTANT, wend);
// When:
final Iterator<WindowedRow> rowIterator = table.get(A_KEY, PARTITION, startBounds, Range.all()).rowIterator;
// Then:
assertThat(rowIterator.next(), is(WindowedRow.of(SCHEMA, sessionKey(UPPER_INSTANT, wend), A_VALUE, wend.toEpochMilli())));
}
Aggregations