Interface DittoQueryResultItem
- All Superinterfaces:
AutoCloseable,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 TypeMethodDescriptionvoidclose()Clean up result and release resources.voidReleases the materialized value from memory.byte[]Returns the content of the item as CBOR data.@NonNull StringReturns the content of the item as a JSON string.getValue()Returns the content as a materialized dictionary.booleanReturnstrueif value is currently held materialized in memory, otherwise returnsfalse.Loads the CBOR representation of the item's content, decodes it into aMapso it can be accessed viagetValue().
-
Method Details
-
getValue
Returns the content as a materialized dictionary.
The item's value is
materialize()-ed on first access and subsequently on each access after performingdematerialize(). Once materialized, the value is kept in memory until explicitlydematerialize()-ed or the item goes out of scope. -
isMaterialized
boolean isMaterialized()Returnstrueif value is currently held materialized in memory, otherwise returnsfalse.- See Also:
-
materialize
Loads the CBOR representation of the item's content, decodes it into aMapso it can be accessed viagetValue(). Keeps the Map in memory untildematerialize()is called. No-op ifvalueis already materialized.- Returns:
- A
Mapof 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
Clean up result and release resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-