Interface DittoQueryResultItem

All Superinterfaces:
AutoCloseable, Closeable

public interface DittoQueryResultItem extends Closeable

Represents a single match of a DQL query, similar to a "row" in SQL terms. It's a reference type serving as a "cursor", allowing for efficient access of the underlying data in various formats.

The getValue() getter will lazily materialize and keep the value in memory until it goes out of scope. To reduce the memory footprint, structure your code such that items can be processed as a stream, i.e. one by one (or in batches) and dematerialize() them right after use.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clean up result and release resources.
    void
    Releases the materialized value from memory.
    byte[]
    Returns the content of the item as CBOR data.
    @NonNull String
    Returns the content of the item as a JSON string.
    @NonNull Map<@NonNull String,@Nullable ?>
    Returns the content as a materialized dictionary.
    boolean
    Returns true if value is currently held materialized in memory, otherwise returns false.
    @Nullable Map<@NonNull String,@Nullable ?>
    Loads the CBOR representation of the item's content, decodes it into a Map so it can be accessed via getValue().
  • Method Details

    • getValue

      @NonNull Map<@NonNull String,@Nullable ?> getValue()

      Returns the content as a materialized dictionary.

      The item's value is materialize()-ed on first access and subsequently on each access after performing dematerialize(). Once materialized, the value is kept in memory until explicitly dematerialize()-ed or the item goes out of scope.

    • isMaterialized

      boolean isMaterialized()
      Returns true if value is currently held materialized in memory, otherwise returns false.
      See Also:
    • materialize

      @Nullable Map<@NonNull String,@Nullable ?> materialize() throws DittoError
      Loads the CBOR representation of the item's content, decodes it into a Map so it can be accessed via getValue(). Keeps the Map in memory until dematerialize() is called. No-op if value is already materialized.
      Returns:
      A Map of data for the item.
      Throws:
      DittoError - If there is a problem with retrieving the data.
    • dematerialize

      void dematerialize()
      Releases the materialized value from memory. No-op if item is not materialized.
    • getCborData

      byte[] getCborData()

      Returns the content of the item as CBOR data.

      Important: The returned CBOR data is not cached, make sure to call this method once and keep it for as long as needed.

    • getJsonString

      @NonNull String getJsonString()

      Returns the content of the item as a JSON string.

      Important: The returned JSON string is not cached, make sure to call this method once and keep it for as long as needed.

    • close

      void close() throws IOException
      Clean up result and release resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException