Class QueryIterableResult

java.lang.Object
oracle.nosql.driver.ops.Result
oracle.nosql.driver.ops.QueryIterableResult
All Implemented Interfaces:
AutoCloseable, Iterable<MapValue>

public class QueryIterableResult extends Result implements Iterable<MapValue>, AutoCloseable
QueryIterableResult represents an Iterable over all the query results.

The shape of the values is based on the schema implied by the query. For example a query such as "SELECT * FROM ..." that returns an intact row will return values that conform to the schema of the table. Projections return instances that conform to the schema implied by the statement. UPDATE queries either return values based on a RETURNING clause or, by default, the number of rows affected by the statement.

Example:

 NoSQLHandle handle = ...;

 try (QueryRequest qreq = new QueryRequest()
          .setStatement("select * from foo") ) {

     for (MapValue row : handle.queryIterable(qreq)) {
         // do something with row
     }
 }
 
Note: The read/write KB/Units, rate limit delay and retry stats are summed up from the beginning of the iteration.
See Also:
  • Method Details

    • iterator

      public Iterator<MapValue> iterator()
      Returns an iterator over all results of a query. Each call is treated as a separate query. The first server call is done at the time of the first hasNext()/next() call. Note: Objects returned by this method can only be used safely by one thread at a time unless synchronized externally.
      Specified by:
      iterator in interface Iterable<MapValue>
      Returns:
      the iterator
    • getReadKB

      public int getReadKB()
      Returns the read throughput consumed by all iterators of this operation, in KBytes. This is the actual amount of data read by this operation. The number of read units consumed is returned by getReadUnits() which may be a larger number if the operation used Consistency.ABSOLUTE
      Returns:
      the read KBytes consumed
    • getWriteKB

      public int getWriteKB()
      Returns the write throughput consumed by all iterators of this operation, in KBytes.
      Returns:
      the write KBytes consumed
    • getReadUnits

      public int getReadUnits()
      Returns the read throughput consumed by all iterators of this operation, in read units. This number may be larger than that returned by getReadKB() if the operation used Consistency.ABSOLUTE
      Returns:
      the read units consumed
    • getWriteUnits

      public int getWriteUnits()
      Returns the write throughput consumed by all iterators of this operation, in write units.
      Returns:
      the write units consumed
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable