All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datastax.dse.driver.api.core.graph.GraphResultSet Maven / Gradle / Ivy

/*
 * Copyright DataStax, Inc.
 *
 * This software can be used solely with DataStax Enterprise. Please consult the license at
 * http://www.datastax.com/terms/datastax-dse-driver-license-terms
 */
package com.datastax.dse.driver.api.core.graph;

import com.datastax.oss.driver.shaded.guava.common.collect.Iterables;
import com.datastax.oss.driver.shaded.guava.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * The result of a synchronous Graph query.
 *
 * 

This object is a container for {@link GraphNode} objects that will contain the data returned * by Graph queries. * *

Note that this object can only be iterated once: items are "consumed" as they are read, * subsequent calls to {@code iterator()} will return the same iterator instance. * *

The default implementation returned by the driver is not thread-safe. It can only be * iterated by the thread that invoked {@code dseSession.execute}. * * @see GraphNode * @see GraphSession#execute(GraphStatement) */ public interface GraphResultSet extends Iterable { /** * Returns the next node, or {@code null} if the result set is exhausted. * *

This is convenient for queries that are known to return exactly one row, for example count * queries. */ @Nullable default GraphNode one() { Iterator graphNodeIterator = iterator(); return graphNodeIterator.hasNext() ? graphNodeIterator.next() : null; } /** * Returns all the remaining nodes as a list; not recommended for paginated queries that return * a large number of nodes. * *

At this time (DSE 6.0.0), graph queries are not paginated and the server sends all the * results at once. */ @NonNull default List all() { if (!iterator().hasNext()) { return Collections.emptyList(); } List graphNodeList = Lists.newArrayList(); Iterables.addAll(graphNodeList, this); return graphNodeList; } /** * Cancels the query and asks the server to stop sending results. * *

At this time (DSE 6.0.0), graph queries are not paginated and the server sends all the * results at once; therefore this method has no effect. */ void cancel(); /** * The execution information for the query that have been performed to assemble this result set. */ @NonNull GraphExecutionInfo getExecutionInfo(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy