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
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).
Builds the key builder for records of record_type.
Whether the table has a key, shard or primary, to build keys from.
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]).
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.
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.
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.
Nonewhen 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 isis_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. ulongtakes any value, written out as text, but only if that is the text of an unsigned long.int,int8andint16take anInt,Int8orInt16,longandtimestampaLongorTimestamp,floataFloatanddoubleaDouble, written always with a fraction, and inEnotation below10^-3and from10^7on (1.0,1.0E10). Anint8orint16value is not range checked.booleantakes any value: aBooleanas1or0, a number as1unless it is 0 once cut to ani32(a long to its low 32 bits, a float or double truncated toward zero), and text as1.
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.