State API
quixstreams.state.base.state
State
Primary interface for working with key-value state data from StreamingDataFrame
State.get
Get the value for key if key is present in the state, else default
Arguments:
key: keydefault: default value to return if the key is not found
Returns:
value or None if the key is not found and default is not provided
State.get_bytes
Get the value for key if key is present in the state, else default
Arguments:
key: keydefault: default value to return if the key is not found
Returns:
value as bytes or None if the key is not found and default is not provided
State.set
Set value for the key, optionally with a per-write expiry.
Arguments:
key: keyvalue: valuettl: optional event-time TTL. When set, the entry expiresttlafter the current record's event-time and is filtered from subsequent reads.None(default) writes a sentinel stamp meaning "never expires", overwriting any prior TTL on the same key.
State.set_bytes
Set bytes value for the key, optionally with a per-write expiry.
Arguments:
key: keyvalue: value as bytesttl: see :meth:set.
State.delete
Delete value for the key.
This function always returns None, even if value is not found.
Arguments:
key: key
State.exists
Check if the key exists in state.
Arguments:
key: key
Returns:
True if key exists, False otherwise
TransactionState
TransactionState.__init__
Simple key-value state to be provided into StreamingDataFrame functions
Arguments:
transaction: instance ofPartitionTransactionprefix: serialized key prefix shared across callstimestamp: optional event-time of the current record (ms). Used by TTL-aware partitions to stamp values onset()withrecord.timestamp + ttland to filter expired entries onget(). The framework injects this on every record via theStreamingDataFramestateful wrapper.
TransactionState.get
Get the value for key if key is present in the state, else default
Arguments:
key: keydefault: default value to return if the key is not found
Returns:
value or None if the key is not found and default is not provided
TransactionState.get_bytes
Get the bytes value for key if key is present in the state, else default
Arguments:
key: keydefault: default value to return if the key is not found
Returns:
value or None if the key is not found and default is not provided
TransactionState.set
Set value for the key, optionally with a per-write expiry.
Arguments:
key: keyvalue: valuettl: optional event-time TTL. See :class:State.set.
TransactionState.set_bytes
Set bytes value for the key, optionally with a per-write expiry.
Arguments:
key: keyvalue: value as bytesttl: optional event-time TTL. See :class:State.set.
TransactionState.delete
Delete value for the key.
This function always returns None, even if value is not found.
Arguments:
key: key
TransactionState.exists
Check if the key exists in state.
Arguments:
key: key
Returns:
True if key exists, False otherwise
quixstreams.state.rocksdb.options
RocksDBOptions
RocksDB database options.
Arguments:
dumps: function to dump data to JSONloads: function to load data from JSONopen_max_retries: number of times to retry opening the database if it's locked by another process. To disable retrying, pass 0open_retry_backoff: number of seconds to wait between each retry.on_corrupted_recreate: when True, the corrupted DB will be destroyed if theuse_changelog_topics=Trueis also set on the Application. If this option is True, butuse_changelog_topics=False, the DB won't be destroyed. Note: risk of data loss! Make sure that the changelog topics are up-to-date before disabling it in production. Default -True.max_evictions_per_flush: cap on TTL-driven evictions performed during a singleflush()for stores with TTL enabled. Larger values increase per-flush latency but let the sweep keep up with higher steady-state expiration rates. Only meaningful for TTL-enabled stores; ignored otherwise. Default -10_000.
Please see rocksdict.Options for a complete description of other options.
RocksDBOptions.to_options
Convert parameters to rocksdict.Options
Returns:
instance of rocksdict.Options