Class DittoQueryResult

java.lang.Object
com.ditto.java.DittoQueryResult
All Implemented Interfaces:
AutoCloseable

public final class DittoQueryResult extends Object implements AutoCloseable

Represents the results returned when executing a DQL (Ditto Query Language) query.

Each query result contains a list of DittoQueryResultItem instances, one for each document matching the query. For mutating queries, the result also includes the IDs of documents that were modified locally.

This class implements AutoCloseable to manage resources. Always close the result when done, preferably using try-with-resources statements.

See Also:
API Note:
More info such as metrics, affected document IDs, etc. will be provided in the near future.
  • Method Details

    • getItems

      public @NonNull List<? extends DittoQueryResultItem> getItems()

      Returns the individual items matching the DQL query.

      Each item represents a document that matched the query criteria.

      Returns:
      a list of DittoQueryResultItem instances, one for each matching document.
    • getMutatedDocumentIds

      public @NonNull Set<? extends DittoCborSerializable> getMutatedDocumentIds()

      Returns the IDs of documents that were mutated locally by a mutating DQL query.

      This method returns the IDs of documents that were modified locally when executing mutating DQL queries (INSERT, UPDATE, DELETE, etc.). The set will be empty if no documents were mutated.

      Note: A DittoStoreObserver can only be registered with a SELECT query, which is non-mutating. Therefore, query results passed to a DittoStoreObserver will always return an empty set.

      Important: The returned document IDs are not cached. Call this method once and keep the return value for as long as needed to avoid unnecessary recomputation.

      Returns:
      a set of DittoCborSerializable document IDs that were mutated locally.
    • close

      public void close() throws DittoException

      Closes this query result and releases associated resources.

      This method should be called when the query result is no longer needed to free resources. Use try-with-resources statements for automatic cleanup.

      Specified by:
      close in interface AutoCloseable
      Throws:
      DittoException - if an error occurs during cleanup.
    • isClosed

      public boolean isClosed()