Search in sources :

Example 1 with RangeQuery

use of org.apache.kafka.streams.query.RangeQuery in project ksql by confluentinc.

the class KsMaterializedTableIQv2Test method shouldRangeQueryWithCorrectParams_noBounds.

@Test
public void shouldRangeQueryWithCorrectParams_noBounds() {
    // Given:
    when(kafkaStreams.query(any())).thenReturn(getIteratorResult());
    // When:
    table.get(PARTITION, null, null);
    // Then:
    verify(kafkaStreams).query(queryTypeCaptor.capture());
    StateQueryRequest request = queryTypeCaptor.getValue();
    assertThat(request.getQuery(), instanceOf(RangeQuery.class));
    RangeQuery rangeQuery = (RangeQuery) request.getQuery();
    assertThat(rangeQuery.getLowerBound(), is(Optional.empty()));
    assertThat(rangeQuery.getUpperBound(), is(Optional.empty()));
}
Also used : RangeQuery(org.apache.kafka.streams.query.RangeQuery) StateQueryRequest(org.apache.kafka.streams.query.StateQueryRequest) Test(org.junit.Test)

Example 2 with RangeQuery

use of org.apache.kafka.streams.query.RangeQuery in project ksql by confluentinc.

the class KsMaterializedTableIQv2Test method shouldRangeQueryWithCorrectParams_bothBounds.

@Test
public void shouldRangeQueryWithCorrectParams_bothBounds() {
    // Given:
    when(kafkaStreams.query(any())).thenReturn(getIteratorResult());
    // When:
    table.get(PARTITION, A_KEY, A_KEY2);
    // Then:
    verify(kafkaStreams).query(queryTypeCaptor.capture());
    StateQueryRequest request = queryTypeCaptor.getValue();
    assertThat(request.getQuery(), instanceOf(RangeQuery.class));
    RangeQuery rangeQuery = (RangeQuery) request.getQuery();
    assertThat(rangeQuery.getLowerBound(), is(Optional.of(A_KEY)));
    assertThat(rangeQuery.getUpperBound(), is(Optional.of(A_KEY2)));
}
Also used : RangeQuery(org.apache.kafka.streams.query.RangeQuery) StateQueryRequest(org.apache.kafka.streams.query.StateQueryRequest) Test(org.junit.Test)

Example 3 with RangeQuery

use of org.apache.kafka.streams.query.RangeQuery in project ksql by confluentinc.

the class KsMaterializedTableIQv2Test method shouldRangeQueryWithCorrectParams_upperBound.

@Test
public void shouldRangeQueryWithCorrectParams_upperBound() {
    // Given:
    when(kafkaStreams.query(any())).thenReturn(getIteratorResult());
    // When:
    table.get(PARTITION, null, A_KEY2);
    // Then:
    verify(kafkaStreams).query(queryTypeCaptor.capture());
    StateQueryRequest request = queryTypeCaptor.getValue();
    assertThat(request.getQuery(), instanceOf(RangeQuery.class));
    RangeQuery rangeQuery = (RangeQuery) request.getQuery();
    assertThat(rangeQuery.getLowerBound(), is(Optional.empty()));
    assertThat(rangeQuery.getUpperBound(), is(Optional.of(A_KEY2)));
}
Also used : RangeQuery(org.apache.kafka.streams.query.RangeQuery) StateQueryRequest(org.apache.kafka.streams.query.StateQueryRequest) Test(org.junit.Test)

Example 4 with RangeQuery

use of org.apache.kafka.streams.query.RangeQuery in project ksql by confluentinc.

the class KsMaterializedTableIQv2Test method shouldRangeQueryWithCorrectParams_lowerBound.

@Test
public void shouldRangeQueryWithCorrectParams_lowerBound() {
    // Given:
    when(kafkaStreams.query(any())).thenReturn(getIteratorResult());
    // When:
    table.get(PARTITION, A_KEY, null);
    // Then:
    verify(kafkaStreams).query(queryTypeCaptor.capture());
    StateQueryRequest request = queryTypeCaptor.getValue();
    assertThat(request.getQuery(), instanceOf(RangeQuery.class));
    RangeQuery rangeQuery = (RangeQuery) request.getQuery();
    assertThat(rangeQuery.getLowerBound(), is(Optional.of(A_KEY)));
    assertThat(rangeQuery.getUpperBound(), is(Optional.empty()));
}
Also used : RangeQuery(org.apache.kafka.streams.query.RangeQuery) StateQueryRequest(org.apache.kafka.streams.query.StateQueryRequest) Test(org.junit.Test)

Example 5 with RangeQuery

use of org.apache.kafka.streams.query.RangeQuery in project ksql by confluentinc.

the class KsMaterializedTableIQv2Test method shouldRangeQueryWithCorrectParams_fullTableScan.

@Test
public void shouldRangeQueryWithCorrectParams_fullTableScan() {
    // Given:
    when(kafkaStreams.query(any())).thenReturn(getIteratorResult());
    // When:
    table.get(PARTITION);
    // Then:
    verify(kafkaStreams).query(queryTypeCaptor.capture());
    StateQueryRequest request = queryTypeCaptor.getValue();
    assertThat(request.getQuery(), instanceOf(RangeQuery.class));
    RangeQuery rangeQuery = (RangeQuery) request.getQuery();
    assertThat(rangeQuery.getLowerBound(), is(Optional.empty()));
    assertThat(rangeQuery.getUpperBound(), is(Optional.empty()));
}
Also used : RangeQuery(org.apache.kafka.streams.query.RangeQuery) StateQueryRequest(org.apache.kafka.streams.query.StateQueryRequest) Test(org.junit.Test)

Aggregations

RangeQuery (org.apache.kafka.streams.query.RangeQuery)7 StateQueryRequest (org.apache.kafka.streams.query.StateQueryRequest)7 Test (org.junit.Test)5 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Streams (com.google.common.collect.Streams)2 GenericKey (io.confluent.ksql.GenericKey)2 GenericRow (io.confluent.ksql.GenericRow)2 MaterializationException (io.confluent.ksql.execution.streams.materialization.MaterializationException)2 MaterializedTable (io.confluent.ksql.execution.streams.materialization.MaterializedTable)2 Row (io.confluent.ksql.execution.streams.materialization.Row)2 StreamsMaterializedTable (io.confluent.ksql.execution.streams.materialization.StreamsMaterializedTable)2 IteratorUtil (io.confluent.ksql.util.IteratorUtil)2 Collections (java.util.Collections)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 FailureReason (org.apache.kafka.streams.query.FailureReason)2 KeyQuery (org.apache.kafka.streams.query.KeyQuery)2 Position (org.apache.kafka.streams.query.Position)2 PositionBound (org.apache.kafka.streams.query.PositionBound)2