Skip to main content
pub struct RecordKeyBuilder 
    pub shard_indices: Vec<usize>,
    pub shard_types: Vec<ShardColumnType>,
    pub buffer_size: usize,
    pub shard_column_names: Vec<String>,

Fields

shard_indices: Vec<usize>shard_types: Vec<ShardColumnType>buffer_size: usizeshard_column_names: Vec<String>

Column names for shard key columns (for fast lookup)

Implementations

Source

pub fn new(table_type: &KineticaType) -> Result<Self, KineticaError>

Builds the key builder for a table of type table_type.

Fails when a key column has a type that cannot be a key (json, wkt, array, vector or bytes).

Source

pub fn from_type(record_type: &Type) -> Result<Self, KineticaError>

Builds the key builder for records of record_type.

Source

pub fn has_key(&self) -> bool

Whether the table has a key, shard or primary, to build keys from.

Source

pub fn build_typed( &self, shard_values: &[(&str, ShardKeyValue<’_>)], ) -> Result<Option<RecordKey>, KineticaError>

Build record key from typed shard key values (optimized path - no string parsing).

This method uses pre-typed values from ShardKeyExtractor to avoid string parsing overhead for numeric types.

Performance Note: For best performance, return shard key values in the same order as the table’s shard columns. This enables O(1) lookup instead of O(n) search.

Returns None if the table has no shard key, and fails if a value is not of a type its column accepts (see [add_shard_value]).

Source

pub fn build_from_map( &self, routing_map: &HashMap<String, String>, ) -> Option<RecordKey>

Builds a record key from a column-name → value map, for an ingest.

Lenient: a value that will not parse as its column’s type encodes as a null rather than failing, because a record may carry a placeholder for a column the server initialises. Use Self::build for a look-up, where an unusable value is an error.

Returns None if the table has no shard key.

Source

pub fn build( &self, key_values: &[ShardKeyValue<’_>], ) -> Result<Option<RecordKey>, KineticaError>

Builds the record key of the given key values, one per key column in key order, for a look-up.

Shares [add_shard_value] with Self::build_typed, so a look-up is routed to the rank the matching record was ingested to. None when the table has no key. Fails for a count that is not the number of key columns, a value its column’s type does not accept, and a UUID that does not read as one, which an ingest would write as zero: nothing will substitute a usable value for one given expressly to be looked up.

Source

pub fn build_expression( &self, key_values: &[ShardKeyValue<’_>], ) -> Result<Option<String>, KineticaError>

Builds a filter expression associating the given key values, one per key column in key order, with the table’s key columns.

  • None when the table has no key.
  • The number of values must equal the number of key columns exactly.
  • Terms are <column> = <value>, joined by ” and ”, and a null value is is_null(<column>).
  • The text types (char*, date, datetime, decimal, ipv4, string, time, uuid) take text, written in double quotes with every embedded double quote doubled.
  • ulong takes any value, written out as text, but only if that is the text of an unsigned long.
  • int, int8 and int16 take an Int, Int8 or Int16, long and timestamp a Long or Timestamp, float a Float and double a Double, written always with a fraction, and in E notation below 10^-3 and from 10^7 on (1.0, 1.0E10). An int8 or int16 value is not range checked.
  • boolean takes any value: a Boolean as 1 or 0, a number as 1 unless it is 0 once cut to an i32 (a long to its low 32 bits, a float or double truncated toward zero), and text as 1.

A value of another type fails.

Known risk: column names are written as they are, not quoted. A key column whose name needs quoting in an expression — a reserved word, or one with special characters — yields a filter the server rejects. The names come from the table’s own schema rather than from the caller, so this is not a way to inject into the filter.