Search in sources :

Example 1 with MultiPageGraphResultSet

use of com.datastax.dse.driver.internal.core.graph.MultiPageGraphResultSet in project java-driver by datastax.

the class GraphPagingIT method should_cancel_result_set.

@Test
public void should_cancel_result_set() {
    // given
    DriverExecutionProfile profile = enableGraphPaging().withInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, 1).withInt(DseDriverOption.GRAPH_CONTINUOUS_PAGING_PAGE_SIZE, 10);
    // when
    GraphStatement statement = ScriptGraphStatement.newInstance("g.V().hasLabel('person').values('name')").setGraphName(SESSION_RULE.getGraphName()).setTraversalSource("g").setExecutionProfile(profile);
    MultiPageGraphResultSet results = (MultiPageGraphResultSet) SESSION_RULE.session().execute(statement);
    assertThat(((MultiPageGraphResultSet.RowIterator) results.iterator()).isCancelled()).isFalse();
    assertThat(((CountingIterator) results.iterator()).remaining()).isEqualTo(10);
    results.cancel();
    assertThat(((MultiPageGraphResultSet.RowIterator) results.iterator()).isCancelled()).isTrue();
    assertThat(((CountingIterator) results.iterator()).remaining()).isEqualTo(10);
    for (int i = 0; i < 10; i++) {
        results.one();
    }
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) MultiPageGraphResultSet(com.datastax.dse.driver.internal.core.graph.MultiPageGraphResultSet) CountingIterator(com.datastax.oss.driver.internal.core.util.CountingIterator) Test(org.junit.Test)

Aggregations

MultiPageGraphResultSet (com.datastax.dse.driver.internal.core.graph.MultiPageGraphResultSet)1 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)1 CountingIterator (com.datastax.oss.driver.internal.core.util.CountingIterator)1 Test (org.junit.Test)1