GPUdb C++ API  Version 7.2.2.4
gpudb::UpdateRecordsRequest< T > Struct Template Reference

A set of parameters for GPUdb::updateRecords. More...

#include <gpudb/protocol/update_records.h>

Public Member Functions

 UpdateRecordsRequest ()
 Constructs an UpdateRecordsRequest object with default parameters. More...
 
 UpdateRecordsRequest (const std::string &tableName_, const std::vector< std::string > &expressions_, const std::vector< std::map< std::string, boost::optional< std::string > > > &newValuesMaps_, const std::vector< T > &data_, const std::map< std::string, std::string > &options_)
 Constructs an UpdateRecordsRequest object with the specified parameters. More...
 

Public Attributes

std::string tableName
 Name of table to be updated, in [ schema_name. ]table_name format, using standard name resolution rules. More...
 
std::vector< std::string > expressions
 A list of the actual predicates, one for each update; format should follow the guidelines here. More...
 
std::vector< std::map< std::string, boost::optional< std::string > > > newValuesMaps
 List of new values for the matching records. More...
 
std::vector< T > data
 An optional list of new binary-avro encoded records to insert, one for each update. More...
 
std::map< std::string, std::string > options
 Optional parameters. More...
 

Detailed Description

template<typename T>
struct gpudb::UpdateRecordsRequest< T >

A set of parameters for GPUdb::updateRecords.

Runs multiple predicate-based updates in a single call. With the list of given expressions, any matching record's column values will be updated as provided in newValuesMaps. There is also an optional 'upsert' capability where if a particular predicate doesn't match any existing record, then a new record can be inserted.

Note that this operation can only be run on an original table and not on a result view.

This operation can update primary key values. By default only 'pure primary key' predicates are allowed when updating primary key values. If the primary key for a table is the column 'attr1', then the operation will only accept predicates of the form: "attr1 == 'foo'" if the attr1 column is being updated. For a composite primary key (e.g. columns 'attr1' and 'attr2') then this operation will only accept predicates of the form: "(attr1 == 'foo') and (attr2 == 'bar')". Meaning, all primary key columns must appear in an equality predicate in the expressions. Furthermore each 'pure primary key' predicate must be unique within a given request. These restrictions can be removed by utilizing some available options through options.

The update_on_existing_pk option specifies the record primary key collision policy for tables with a primary key, while ignore_existing_pk specifies the record primary key collision error-suppression policy when those collisions result in the update being rejected. Both are ignored on tables with no primary key.

Template Parameters
TThe type of object being processed.

Definition at line 937 of file update_records.h.

Constructor & Destructor Documentation

◆ UpdateRecordsRequest() [1/2]

template<typename T >
gpudb::UpdateRecordsRequest< T >::UpdateRecordsRequest ( )
inline

Constructs an UpdateRecordsRequest object with default parameters.

Definition at line 942 of file update_records.h.

◆ UpdateRecordsRequest() [2/2]

template<typename T >
gpudb::UpdateRecordsRequest< T >::UpdateRecordsRequest ( const std::string &  tableName_,
const std::vector< std::string > &  expressions_,
const std::vector< std::map< std::string, boost::optional< std::string > > > &  newValuesMaps_,
const std::vector< T > &  data_,
const std::map< std::string, std::string > &  options_ 
)
inline

Constructs an UpdateRecordsRequest object with the specified parameters.

Parameters
[in]tableName_Name of table to be updated, in [schema_name.]table_name format, using standard name resolution rules. Must be a currently existing table and not a view.
[in]expressions_A list of the actual predicates, one for each update; format should follow the guidelines here.
[in]newValuesMaps_List of new values for the matching records. Each element is a map with (key, value) pairs where the keys are the names of the columns whose values are to be updated; the values are the new values. The number of elements in the list should match the length of expressions_.
[in]data_An optional list of new binary-avro encoded records to insert, one for each update. If one of expressions_ does not yield a matching record to be updated, then the corresponding element from this list will be added to the table. The default value is an empty vector.
[in]options_Optional parameters.
  • update_records_global_expression: An optional global expression to reduce the search space of the predicates listed in expressions_. The default value is ''.
  • update_records_bypass_safety_checks: When set to true, all predicates are available for primary key updates. Keep in mind that it is possible to destroy data in this case, since a single predicate may match multiple objects (potentially all of records of a table), and then updating all of those records to have the same primary key will, due to the primary key uniqueness constraints, effectively delete all but one of those updated records. Supported values: The default value is update_records_false.
  • update_records_update_on_existing_pk: Specifies the record collision policy for updating a table with a primary key. There are two ways that a record collision can occur. The first is an "update collision", which happens when the update changes the value of the updated record's primary key, and that new primary key already exists as the primary key of another record in the table. The second is an "insert collision", which occurs when a given filter in expressions_ finds no records to update, and the alternate insert record given in data_ (or recordsToInsertStr) contains a primary key matching that of an existing record in the table. If update_on_existing_pk is set to true, "update collisions" will result in the existing record collided into being removed and the record updated with values specified in newValuesMaps_ taking its place; "insert collisions" will result in the collided-into record being updated with the values in data_/recordsToInsertStr (if given). If set to false, the existing collided-into record will remain unchanged, while the update will be rejected and the error handled as determined by ignore_existing_pk. If the specified table does not have a primary key, then this option has no effect. Supported values:
    • update_records_true: Overwrite the collided-into record when updating a record's primary key or inserting an alternate record causes a primary key collision between the record being updated/inserted and another existing record in the table
    • update_records_false: Reject updates which cause primary key collisions between the record being updated/inserted and an existing record in the table
    The default value is update_records_false.
  • update_records_ignore_existing_pk: Specifies the record collision error-suppression policy for updating a table with a primary key, only used when primary key record collisions are rejected (update_on_existing_pk is false). If set to true, any record update that is rejected for resulting in a primary key collision with an existing table record will be ignored with no error generated. If false, the rejection of any update for resulting in a primary key collision will cause an error to be reported. If the specified table does not have a primary key or if update_on_existing_pk is true, then this option has no effect. Supported values:
    • update_records_true: Ignore updates that result in primary key collisions with existing records
    • update_records_false: Treat as errors any updates that result in primary key collisions with existing records
    The default value is update_records_false.
  • update_records_update_partition: Force qualifying records to be deleted and reinserted so their partition membership will be reevaluated. Supported values: The default value is update_records_false.
  • update_records_truncate_strings: If set to true, any strings which are too long for their charN string fields will be truncated to fit. Supported values: The default value is update_records_false.
  • update_records_use_expressions_in_new_values_maps: When set to true, all new values in newValuesMaps_ are considered as expression values. When set to false, all new values in newValuesMaps_ are considered as constants. NOTE: When true, string constants will need to be quoted to avoid being evaluated as expressions. Supported values: The default value is update_records_false.
  • update_records_record_id: ID of a single record to be updated (returned in the call to GPUdb::insertRecords or GPUdb::getRecordsFromCollection).
The default value is an empty map.

Definition at line 1202 of file update_records.h.

Member Data Documentation

◆ data

template<typename T >
std::vector<T> gpudb::UpdateRecordsRequest< T >::data

An optional list of new binary-avro encoded records to insert, one for each update.

If one of expressions does not yield a matching record to be updated, then the corresponding element from this list will be added to the table. The default value is an empty vector.

Definition at line 1243 of file update_records.h.

◆ expressions

template<typename T >
std::vector<std::string> gpudb::UpdateRecordsRequest< T >::expressions

A list of the actual predicates, one for each update; format should follow the guidelines here.

Definition at line 1225 of file update_records.h.

◆ newValuesMaps

template<typename T >
std::vector<std::map<std::string, boost::optional<std::string> > > gpudb::UpdateRecordsRequest< T >::newValuesMaps

List of new values for the matching records.

Each element is a map with (key, value) pairs where the keys are the names of the columns whose values are to be updated; the values are the new values. The number of elements in the list should match the length of expressions.

Definition at line 1234 of file update_records.h.

◆ options

template<typename T >
std::map<std::string, std::string> gpudb::UpdateRecordsRequest< T >::options

Optional parameters.

The default value is an empty map.

Definition at line 1400 of file update_records.h.

◆ tableName

template<typename T >
std::string gpudb::UpdateRecordsRequest< T >::tableName

Name of table to be updated, in [ schema_name. ]table_name format, using standard name resolution rules.

Must be a currently existing table and not a view.

Definition at line 1218 of file update_records.h.


The documentation for this struct was generated from the following file: