pub struct RecordRetriever<R = GenericRecord> /* private fields */ Object that permits efficient retrieval of records from GPUdb, with support for multi-head access.
RecordRetriever instances are thread safe and may be used from any number of tasks simultaneously. Records are returned as R: GenericRecords by default, or any type serde can deserialize (see RetrievedRecord).
Implementations
Creates a retriever of the records of table_name, which are of record_type, returning them as GenericRecords.
The worker list is derived from the connection’s own worker addresses, and records are retrieved with no options.
pub async fn with_retriever_options( kinetica: Arc<Kinetica>, table_name: &str, record_type: Arc<Type>, options: RecordRetrieverOptions, ) -> Result<Self, KineticaError>
Creates a retriever passing options to its retrievals.
pub async fn with_workers( kinetica: Arc<Kinetica>, table_name: &str, record_type: Arc<Type>, workers: Option<WorkerList>, ) -> Result<Self, KineticaError>
Creates a retriever with the given worker list.
None derives the list from the connection’s own worker addresses, which is the default; an empty list (WorkerList::empty) declines multi-head for this retriever.
pub async fn with_options( kinetica: Arc<Kinetica>, table_name: &str, record_type: Arc<Type>, workers: Option<WorkerList>, options: Option<HashMap<String, String>>, ) -> Result<Self, KineticaError>
Creates a retriever with the given worker list and options.
impl<T: DeserializeOwned + Send + ‘static> RecordRetriever<T>
Creates a retriever returning records decoded as T, from the Avro schema of record_type. workers and options are as for RecordRetriever::with_options.
impl<R: RetrievedRecord> RecordRetriever<R>
Gets the connection from which records will be retrieved.
pub fn table_name(&self) -> &str
Gets the name of the table from which records will be retrieved.
pub fn is_using_head_rank(&self) -> bool
Returns whether this RecordRetriever is using the head rank for simple record fetching (not utilizing the server’s key lookup feature).
pub fn is_doing_worker_lookup(&self) -> bool
Returns whether this RecordRetriever is using worker ranks for key lookups.
Gets the options currently used for the retriever methods.
pub fn set_options(&self, options: HashMap<String, String>)
Sets the options to be used for the retriever methods.
pub async fn get_by_key( &self, key_values: &[ShardKeyValue<’_>], expression: Option<&str>, ) -> Result<GetRecordsResponse<R>, KineticaError>
Retrieves records with the given key values and filter expression.
This method operates in four modes, depending on the parameters passed:
- key values only: attempts a direct-to-rank lookup for records matching the given key values
- key values and expression: attempts a direct-to-rank lookup for records matching the given key values, filtering them by the given expression
- expression only: requests, via the head rank, all records in the table matching the given filter expression
- neither: retrieves all records from the table via the head rank
key_values- The key values to use for the lookup, one per key column in key order, or none; these must correspond to either the explicit or implicit shard key for sharded tables or the primary key of replicated tables. Each must be of a type its column takes (seeRecordKeyBuilder::build_expression).expression- A filter expression that will be applied to the data requested by the key values; if no key values are specified this filter will be applied to all of the data in the target table
The requested records, decoded.
pub async fn get_by_key_with_offset( &self, key_values: &[ShardKeyValue<’_>], expression: Option<&str>, offset: i64, ) -> Result<GetRecordsResponse<R>, KineticaError>
Retrieves records with the given key values and filter expression, starting from an offset.
key_values- The key values to use for the lookup, or noneexpression- A filter expressionoffset- Offset of the record(s) within the result set to return
The requested records, decoded.
pub async fn get_columns_by_key( &self, columns: Vec<String>, key_values: &[ShardKeyValue<’_>], expression: Option<&str>, ) -> Result<GetRecordsByColumnResponse, KineticaError>
Retrieves specific columns with the given key values and filter expression.
columns- The requested columns (which can include expressions). May use “*” for all columns.key_values- The key values to use for the lookup, or noneexpression- A filter expression
The requested records, typed by the response.
pub async fn get_columns_by_key_with_offset( &self, columns: Vec<String>, key_values: &[ShardKeyValue<’_>], expression: Option<&str>, offset: i64, ) -> Result<GetRecordsByColumnResponse, KineticaError>
Retrieves specific columns with the given key values and filter expression, starting from an offset.
columns- The requested columnskey_values- The key values to use for the lookup, or noneexpression- A filter expressionoffset- Offset of the record(s) within the result set to return
The requested records, typed by the response.