Ditto 4.8.0-rc.2
Loading...
Searching...
No Matches
ditto::QueryResultItem Class Reference

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

#include <QueryResult.hpp>

Public Member Functions

std::shared_ptr< ValueMap > value () const
 Returns the content as a materialized value map.
 
bool is_materialized () const
 Returns true if value is currently held materialized in memory, otherwise returns false.
 
void materialize ()
 Loads the CBOR representation of the item's content, decodes it as a dictionary so it can be accessed via value(). Keeps the nlohman::json in memory until dematerialize() is called. No-op if value is already materialized.
 
void dematerialize ()
 Releases the materialized value from memory. No-op if item is not materialized.
 
std::vector< uint8_t > cbor_data () const
 Returns the content of the item as CBOR data.
 
std::string json_string () const
 Returns the content of the item as a JSON string.
 

Detailed Description

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

Member Function Documentation

◆ cbor_data()

std::vector< uint8_t > ditto::QueryResultItem::cbor_data ( ) const

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.

◆ dematerialize()

void ditto::QueryResultItem::dematerialize ( )

Releases the materialized value from memory. No-op if item is not materialized.

C++ note: this mutates the object and is thus not thread-safe.

◆ is_materialized()

bool ditto::QueryResultItem::is_materialized ( ) const

Returns true if value is currently held materialized in memory, otherwise returns false.

See Also

◆ json_string()

std::string ditto::QueryResultItem::json_string ( ) const

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.

◆ materialize()

void ditto::QueryResultItem::materialize ( )

Loads the CBOR representation of the item's content, decodes it as a dictionary so it can be accessed via value(). Keeps the nlohman::json in memory until dematerialize() is called. No-op if value is already materialized.

C++ note: this mutates the object and is thus not thread-safe.

◆ value()

std::shared_ptr< ValueMap > ditto::QueryResultItem::value ( ) const

Returns the content as a materialized value map.

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.

‍Note: This property is very similar to Document.value().

C++ note: this mutates the object, but in a synchronized thread-safe fashion.