Skip to main content
pub struct GenericRecord  /* private fields */ 

A generic record that can hold values for any Kinetica type.

It stores values in an array indexed by column position, and uses the associated Type for schema information.

Example

Dates and times

A date, time or datetime column holds text in Kinetica’s formats: yyyy-MM-dd, HH:mm:ss.SSS and yyyy-MM-dd HH:mm:ss.SSS. A record reads no other formats; format the value with chrono first:

Fractions of a second past the millisecond are dropped, not rounded. chrono refuses a day past the end of its month (2023-02-30) and the time 24:00. Zone names (America/New_York, EST) need a zone database, such as the chrono-tz crate. A fixed offset ignores daylight saving, so give the offset in effect if that is what is meant.

Implementations

Source

pub fn decode( record_type: &Arc<Type>, encoded: &[u8], ) -> Result<GenericRecord, KineticaError>

Decodes a record of record_type from its Avro binary form.

Source

pub fn decode_all<B: AsRef<[u8]>>( record_type: &Arc<Type>, encoded: &[B], ) -> Result<Vec<GenericRecord>, KineticaError>

Decodes records of record_type from their Avro binary forms.

Source

pub fn transpose( schema_string: &str, encoded_data: &[u8], record_type: &Arc<Type>, ) -> Result<Vec<GenericRecord>, KineticaError>

The records of a dynamic (column-wise) response, one per row, typed by record_type (see Type::from_dynamic_schema).

Source

pub fn new(record_type: Arc<Type>) -> Self

Create a new GenericRecord for the given type.

All values are initialized to Null.

Source

pub fn record_type(&self) -> &Arc<Type>

Get the type definition for this record.

Source

pub fn get(&self, index: usize) -> Option<&RecordValue>

Get a value by index.

Source

pub fn get_by_name(&self, name: &str) -> Option<&RecordValue>

Get a value by column name.

Source

pub fn set<V: Into<RecordValue>>( &mut self, index: usize, value: V, ) -> Result<(), KineticaError>

Sets the value at index. The value is not checked against the column’s type here; encoding the record does that. An index past the last column fails.

Source

pub fn set_by_name<V: Into<RecordValue>>( &mut self, name: &str, value: V, ) -> Result<(), KineticaError>

Sets the value of the column name. A name the type does not have fails with “Field ‘<name>’ does not exist.”

Source

pub fn set_null(&mut self, index: usize) -> Result<(), KineticaError>

Sets the value at index to null; see GenericRecord::set.

Source

pub fn set_null_by_name(&mut self, name: &str) -> Result<(), KineticaError>

Sets the value of the column name to null; see GenericRecord::set_by_name.

Source

pub fn get_int(&self, index: usize) -> Option<i32>

Get integer value by index.

Source

pub fn get_long(&self, index: usize) -> Option<i64>

Get long value by index. An int value is widened.

Source

pub fn get_float(&self, index: usize) -> Option<f32>

Get float value by index.

Source

pub fn get_double(&self, index: usize) -> Option<f64>

Get double value by index. A float value is widened.

Source

pub fn get_string(&self, index: usize) -> Option<&str>

Get string value by index.

Source

pub fn get_bytes(&self, index: usize) -> Option<&[u8]>

Get bytes value by index.

Source

pub fn get_bool(&self, index: usize) -> Option<bool>

Get boolean value by index.

Source

pub fn get_int_by_name(&self, name: &str) -> Option<i32>

Get integer value by name.

Source

pub fn get_long_by_name(&self, name: &str) -> Option<i64>

Get long value by name.

Source

pub fn get_float_by_name(&self, name: &str) -> Option<f32>

Get float value by name.

Source

pub fn get_double_by_name(&self, name: &str) -> Option<f64>

Get double value by name.

Source

pub fn get_string_by_name(&self, name: &str) -> Option<&str>

Get string value by name.

Source

pub fn get_bytes_by_name(&self, name: &str) -> Option<&[u8]>

Get bytes value by name.

Source

pub fn get_bool_by_name(&self, name: &str) -> Option<bool>

Get boolean value by name.

The elements of an array column, or the floats of a vector column. An array column’s value is JSON text, read as an array of its element type (see Column::array_type), each element None where it is null, with these coercions: a number from text, an integer from a fraction (truncated), a boolean from a number. Bytes elements arrive as text whose characters are the bytes, or as integers, which become their minimal big-endian bytes.

Source

pub fn get_vector(&self, index: usize) -> Result<Vec<f32>, KineticaError>

The floats of a vector column, read little-endian from its bytes. Fails with “Not a vector column” for a column without a vector(N) property.

Self::get_vector, by column name.

Source

pub fn get_json( &self, index: usize, ) -> Result<Map<String, Value>, KineticaError>

A JSON column’s object.

Self::get_json, by column name.

Source

pub fn set_array<V: Serialize>( &mut self, index: usize, value: &V, ) -> Result<(), KineticaError>

Puts an array column’s value. Text goes as it is, None as null, and anything else (a Vec<i32>, say) as its JSON text.

Source

pub fn set_array_by_name<V: Serialize>( &mut self, name: &str, value: &V, ) -> Result<(), KineticaError>

Self::set_array, by column name.

Source

pub fn set_json<V: Serialize>( &mut self, index: usize, value: &V, ) -> Result<(), KineticaError>

Puts a JSON column’s value. Text goes as it is, None as null, and anything else (a map, say) as its JSON text.

Source

pub fn set_json_by_name<V: Serialize>( &mut self, name: &str, value: &V, ) -> Result<(), KineticaError>

Self::set_json, by column name.

Source

pub fn set_bytes( &mut self, index: usize, value: Option<Vec<u8>>, ) -> Result<(), KineticaError>

Puts a bytes column’s value, or null.

Source

pub fn set_bytes_by_name( &mut self, name: &str, value: Option<Vec<u8>>, ) -> Result<(), KineticaError>

Self::set_bytes, by column name.

Source

pub fn set_vector( &mut self, index: usize, value: &[f32], ) -> Result<(), KineticaError>

Puts a vector column’s floats, little-endian. Fails with “Not a vector column” for a column without a vector(N) property, and with “Unmatched vector dimensions: found <n> but expected <n>” for another number of floats.

Source

pub fn set_vector_text( &mut self, index: usize, text: &str, ) -> Result<(), KineticaError>

Puts a vector column’s floats given as a JSON array: “Error reading vector string” where it is not one.

Source

pub fn set_vector_by_name( &mut self, name: &str, value: &[f32], ) -> Result<(), KineticaError>

Self::set_vector, by column name.

Source

pub fn set_decimal( &mut self, index: usize, value: impl Into<RecordValue>, ) -> Result<(), KineticaError>

Puts a decimal column’s value: text as it is, null as null, and a number at the column’s scale, failing where that would drop a digit, and for a NaN or infinity. Trailing zeros after the decimal point are stripped (“120.00” is “120.”). A whole number at scale 0 has no decimal point, so it keeps its value.

Source

pub fn set_decimal_by_name( &mut self, name: &str, value: impl Into<RecordValue>, ) -> Result<(), KineticaError>

Self::set_decimal, by column name.

Source

pub fn data_map(&self) -> Vec<(&str, &RecordValue)>

The record’s values by column name, in column order.

Trait Implementations

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source

fn fmt(&self, f: &mut Formatter<’_>) -> Result

Formats the value using the given formatter. Read more
Source

impl Display for GenericRecord

”name”:value,.., each name quoted and escaped, and each value as its text: a number bare (NaN and the infinities quoted), text and bytes quoted, and null as null.

Source

fn fmt(&self, f: &mut Formatter<’_>) -> Result

Formats the value using the given formatter. Read more
Source

impl Hash for GenericRecord

Consistent with GenericRecord’s equality: floats by their bits, every NaN alike.

Source

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source

fn avro_schema(&self) -> &‘static str

Returns the Avro schema as a JSON string for this record type.
Returns type properties including field types and attributes (e.g., primary_key).
Whether requests of this type are Snappy-compressed when the client has KineticaOptions::use_snappy enabled. Read more
Source

impl PartialEq for GenericRecord

The same type, and every value equal, floats by their bits with every NaN alike.

Source

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source

fn decode_records( record_type: &Arc<Type>, encoded: &[ByteBuf], ) -> Result<Vec<Self>, KineticaError>

Decodes records of record_type. A failure reads “Could not decode object: …”.
Source

impl Serialize for GenericRecord

Encodes the record for its Avro schema, field by field in column order, each value converted for its column:

  • a number goes into an int, long, float or double column whatever its own type, converted as as converts it (truncated, or rounded to the nearest);
  • a string goes only into a string column, and bytes only into bytes;
  • a nullable column is an Avro union, which takes a value only of the column’s own type, unconverted, or null.

A value the column cannot take fails the record with a message that begins with ENCODE_FAILURE_PREFIX.

Source

fn serialize<S>(&self, serializer: S) ->Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Returns the values of the columns the table is sharded on: its shard key columns, or its primary key columns when it has no shard key.