> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RecordKeyBuilder

> RecordKeyBuilder — Kinetica Rust API

[gpudb\_api](https://docs.kinetica.com/content/api/rust/index.md)::<wbr />[record\_key\_builder](https://docs.kinetica.com/content/api/rust/record_key_builder/index.md)
[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L470-L476)&#x20;

<pre>`pub struct RecordKeyBuilder {    pub shard_indices: Vec<usize>,    pub shard_types: Vec<ShardColumnType>,    pub buffer_size: usize,    pub shard_column_names: Vec<String>,}`</pre>
Fields
`shard_indices: Vec<usize>``shard_types: Vec<ShardColumnType>``buffer_size: usize``shard_column_names: Vec<String>`

Column names for shard key columns (for fast lookup)

## Implementations

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L478-L773)
impl [RecordKeyBuilder](https://docs.kinetica.com/content/api/rust/record_key_builder/struct.RecordKeyBuilder.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L483-L513)
pub fn [new](#method.new)(table\_type: &[KineticaType](https://docs.kinetica.com/content/api/rust/record_key_builder/struct.KineticaType.md)) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<Self, [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

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](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L516-L526)
pub fn [from\_type](#method.from_type)(record\_type: &[Type](https://docs.kinetica.com/content/api/rust/generic_record/struct.Type.md)) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<Self, [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Builds the key builder for records of `record_type`.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L529-L531)
pub fn [has\_key](#method.has_key)(\&self) -> [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)

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

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L544-L571)
pub fn [build\_typed](#method.build_typed)( \&self, shard\_values: &\[(&[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), [ShardKeyValue](https://docs.kinetica.com/content/api/rust/bulk_inserter_common/enum.ShardKeyValue.md)\<'\_>)], ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<[RecordKey](https://docs.kinetica.com/content/api/rust/record_key/struct.RecordKey.md)>, [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

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](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L581-L604)
pub fn [build\_from\_map](#method.build_from_map)( \&self, routing\_map: &[HashMap](https://doc.rust-lang.org/1.98.1/std/collections/hash/map/struct.HashMap.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, ) -> [Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<[RecordKey](https://docs.kinetica.com/content/api/rust/record_key/struct.RecordKey.md)>

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`](https://docs.kinetica.com/content/api/rust/record_key_builder/struct.RecordKeyBuilder#method.build) for a look-up, where an unusable value is an error.Returns `None` if the table has no shard key.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L615-L636)
pub fn [build](#method.build)( \&self, key\_values: &\[[ShardKeyValue](https://docs.kinetica.com/content/api/rust/bulk_inserter_common/enum.ShardKeyValue.md)\<'\_>], ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<[RecordKey](https://docs.kinetica.com/content/api/rust/record_key/struct.RecordKey.md)>, [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

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`](https://docs.kinetica.com/content/api/rust/record_key_builder/struct.RecordKeyBuilder#method.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](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/record_key_builder.rs#L666-L772)
pub fn [build\_expression](#method.build_expression)( \&self, key\_values: &\[[ShardKeyValue](https://docs.kinetica.com/content/api/rust/bulk_inserter_common/enum.ShardKeyValue.md)\<'\_>], ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>, [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

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

<ul>
  <li>`None` when the table has no key.</li>
  <li>The number of values must equal the number of key columns exactly.</li>
  <li>Terms are `<column> = <value>`, joined by `" and "`, and a null value is `is_null(<column>)`.</li>
  <li>The text types (`char*`, `date`, `datetime`, `decimal`, `ipv4`, `string`, `time`, `uuid`) take text, written in double quotes with every embedded double quote doubled.</li>
  <li>`ulong` takes any value, written out as text, but only if that is the text of an unsigned long.</li>
  <li>`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.</li>
  <li>`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`.</li>
</ul>

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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.