Class RawUpdateRecordsRequest
- java.lang.Object
-
- com.gpudb.protocol.RawUpdateRecordsRequest
-
- All Implemented Interfaces:
org.apache.avro.generic.GenericContainer,org.apache.avro.generic.IndexedRecord
public class RawUpdateRecordsRequest extends Object implements org.apache.avro.generic.IndexedRecord
A set of parameters forGPUdb.updateRecordsRaw.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_PKoption specifies the record primary key collision policy for tables with a primary key, whileIGNORE_EXISTING_PKspecifies 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRawUpdateRecordsRequest.OptionsA set of string constants for theRawUpdateRecordsRequestparameteroptions.static classRawUpdateRecordsRequest.RecordEncodingA set of string constants for theRawUpdateRecordsRequestparameterrecordEncoding.
-
Constructor Summary
Constructors Constructor Description RawUpdateRecordsRequest()Constructs a RawUpdateRecordsRequest object with default parameters.RawUpdateRecordsRequest(String tableName, List<String> expressions, List<Map<String,String>> newValuesMaps, List<ByteBuffer> recordsToInsert, List<String> recordsToInsertStr, String recordEncoding, Map<String,String> options)Constructs a RawUpdateRecordsRequest object with the specified parameters.RawUpdateRecordsRequest(String tableName, List<String> expressions, List<Map<String,String>> newValuesMaps, List<ByteBuffer> recordsToInsert, Map<String,String> options)Constructs a RawUpdateRecordsRequest object with the specified parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Objectget(int index)This method supports the Avro framework and is not intended to be called directly by the user.static org.apache.avro.SchemagetClassSchema()This method supports the Avro framework and is not intended to be called directly by the user.List<String>getExpressions()A list of the actual predicates, one for each update; format should follow the guidelineshere.List<Map<String,String>>getNewValuesMaps()List of new values for the matching records.Map<String,String>getOptions()Optional parameters.StringgetRecordEncoding()Identifies which ofrecordsToInsertandrecordsToInsertStrshould be used.List<ByteBuffer>getRecordsToInsert()An *optional* list of new binary-avro encoded records to insert, one for each update.List<String>getRecordsToInsertStr()An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects.org.apache.avro.SchemagetSchema()This method supports the Avro framework and is not intended to be called directly by the user.StringgetTableName()Name of table to be updated, in [schema_name.]table_name format, using standard name resolution rules.inthashCode()voidput(int index, Object value)This method supports the Avro framework and is not intended to be called directly by the user.RawUpdateRecordsRequestsetExpressions(List<String> expressions)A list of the actual predicates, one for each update; format should follow the guidelineshere.RawUpdateRecordsRequestsetNewValuesMaps(List<Map<String,String>> newValuesMaps)List of new values for the matching records.RawUpdateRecordsRequestsetOptions(Map<String,String> options)Optional parameters.RawUpdateRecordsRequestsetRecordEncoding(String recordEncoding)Identifies which ofrecordsToInsertandrecordsToInsertStrshould be used.RawUpdateRecordsRequestsetRecordsToInsert(List<ByteBuffer> recordsToInsert)An *optional* list of new binary-avro encoded records to insert, one for each update.RawUpdateRecordsRequestsetRecordsToInsertStr(List<String> recordsToInsertStr)An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects.RawUpdateRecordsRequestsetTableName(String tableName)Name of table to be updated, in [schema_name.]table_name format, using standard name resolution rules.StringtoString()
-
-
-
Constructor Detail
-
RawUpdateRecordsRequest
public RawUpdateRecordsRequest()
Constructs a RawUpdateRecordsRequest object with default parameters.
-
RawUpdateRecordsRequest
public RawUpdateRecordsRequest(String tableName, List<String> expressions, List<Map<String,String>> newValuesMaps, List<ByteBuffer> recordsToInsert, Map<String,String> options)
Constructs a RawUpdateRecordsRequest object with the specified parameters.- Parameters:
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.expressions- A list of the actual predicates, one for each update; format should follow the guidelineshere.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 ofexpressions.recordsToInsert- An *optional* list of new binary-avro encoded records to insert, one for each update. If one ofexpressionsdoes 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 emptyList.options- Optional parameters.GLOBAL_EXPRESSION: An optional global expression to reduce the search space of the predicates listed inexpressions. The default value is ''.BYPASS_SAFETY_CHECKS: When set toTRUE, 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 isFALSE.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 inexpressionsfinds no records to update, and the alternate insert record given inrecordsToInsert(orrecordsToInsertStr) contains a primary key matching that of an existing record in the table. IfUPDATE_ON_EXISTING_PKis set toTRUE, "update collisions" will result in the existing record collided into being removed and the record updated with values specified innewValuesMapstaking its place; "insert collisions" will result in the collided-into record being updated with the values inrecordsToInsert/recordsToInsertStr(if given). If set toFALSE, the existing collided-into record will remain unchanged, while the update will be rejected and the error handled as determined byIGNORE_EXISTING_PK. If the specified table does not have a primary key, then this option has no effect. Supported values: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 tableFALSE: Reject updates which cause primary key collisions between the record being updated/inserted and an existing record in the table
FALSE.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_PKisFALSE). If set toTRUE, 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. IfFALSE, 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 ifUPDATE_ON_EXISTING_PKisTRUE, then this option has no effect. Supported values:TRUE: Ignore updates that result in primary key collisions with existing recordsFALSE: Treat as errors any updates that result in primary key collisions with existing records
FALSE.UPDATE_PARTITION: Force qualifying records to be deleted and reinserted so their partition membership will be reevaluated. Supported values: The default value isFALSE.TRUNCATE_STRINGS: If set toTRUE, any strings which are too long for their charN string fields will be truncated to fit. Supported values: The default value isFALSE.USE_EXPRESSIONS_IN_NEW_VALUES_MAPS: When set toTRUE, all new values innewValuesMapsare considered as expression values. When set toFALSE, all new values innewValuesMapsare considered as constants. NOTE: WhenTRUE, string constants will need to be quoted to avoid being evaluated as expressions. Supported values: The default value isFALSE.RECORD_ID: ID of a single record to be updated (returned in the call toGPUdb.insertRecordsRaworGPUdb.getRecordsFromCollectionRaw).
Map.
-
RawUpdateRecordsRequest
public RawUpdateRecordsRequest(String tableName, List<String> expressions, List<Map<String,String>> newValuesMaps, List<ByteBuffer> recordsToInsert, List<String> recordsToInsertStr, String recordEncoding, Map<String,String> options)
Constructs a RawUpdateRecordsRequest object with the specified parameters.- Parameters:
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.expressions- A list of the actual predicates, one for each update; format should follow the guidelineshere.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 ofexpressions.recordsToInsert- An *optional* list of new binary-avro encoded records to insert, one for each update. If one ofexpressionsdoes 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 emptyList.recordsToInsertStr- An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects. The default value is an emptyList.recordEncoding- Identifies which ofrecordsToInsertandrecordsToInsertStrshould be used. Supported values: The default value isBINARY.options- Optional parameters.GLOBAL_EXPRESSION: An optional global expression to reduce the search space of the predicates listed inexpressions. The default value is ''.BYPASS_SAFETY_CHECKS: When set toTRUE, 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 isFALSE.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 inexpressionsfinds no records to update, and the alternate insert record given inrecordsToInsert(orrecordsToInsertStr) contains a primary key matching that of an existing record in the table. IfUPDATE_ON_EXISTING_PKis set toTRUE, "update collisions" will result in the existing record collided into being removed and the record updated with values specified innewValuesMapstaking its place; "insert collisions" will result in the collided-into record being updated with the values inrecordsToInsert/recordsToInsertStr(if given). If set toFALSE, the existing collided-into record will remain unchanged, while the update will be rejected and the error handled as determined byIGNORE_EXISTING_PK. If the specified table does not have a primary key, then this option has no effect. Supported values: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 tableFALSE: Reject updates which cause primary key collisions between the record being updated/inserted and an existing record in the table
FALSE.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_PKisFALSE). If set toTRUE, 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. IfFALSE, 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 ifUPDATE_ON_EXISTING_PKisTRUE, then this option has no effect. Supported values:TRUE: Ignore updates that result in primary key collisions with existing recordsFALSE: Treat as errors any updates that result in primary key collisions with existing records
FALSE.UPDATE_PARTITION: Force qualifying records to be deleted and reinserted so their partition membership will be reevaluated. Supported values: The default value isFALSE.TRUNCATE_STRINGS: If set toTRUE, any strings which are too long for their charN string fields will be truncated to fit. Supported values: The default value isFALSE.USE_EXPRESSIONS_IN_NEW_VALUES_MAPS: When set toTRUE, all new values innewValuesMapsare considered as expression values. When set toFALSE, all new values innewValuesMapsare considered as constants. NOTE: WhenTRUE, string constants will need to be quoted to avoid being evaluated as expressions. Supported values: The default value isFALSE.RECORD_ID: ID of a single record to be updated (returned in the call toGPUdb.insertRecordsRaworGPUdb.getRecordsFromCollectionRaw).
Map.
-
-
Method Detail
-
getClassSchema
public static org.apache.avro.Schema getClassSchema()
This method supports the Avro framework and is not intended to be called directly by the user.- Returns:
- The schema for the class.
-
getTableName
public String getTableName()
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.- Returns:
- The current value of
tableName.
-
setTableName
public RawUpdateRecordsRequest setTableName(String 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.- Parameters:
tableName- The new value fortableName.- Returns:
thisto mimic the builder pattern.
-
getExpressions
public List<String> getExpressions()
A list of the actual predicates, one for each update; format should follow the guidelineshere.- Returns:
- The current value of
expressions.
-
setExpressions
public RawUpdateRecordsRequest setExpressions(List<String> expressions)
A list of the actual predicates, one for each update; format should follow the guidelineshere.- Parameters:
expressions- The new value forexpressions.- Returns:
thisto mimic the builder pattern.
-
getNewValuesMaps
public List<Map<String,String>> getNewValuesMaps()
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 ofexpressions.- Returns:
- The current value of
newValuesMaps.
-
setNewValuesMaps
public RawUpdateRecordsRequest setNewValuesMaps(List<Map<String,String>> 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 ofexpressions.- Parameters:
newValuesMaps- The new value fornewValuesMaps.- Returns:
thisto mimic the builder pattern.
-
getRecordsToInsert
public List<ByteBuffer> getRecordsToInsert()
An *optional* list of new binary-avro encoded records to insert, one for each update. If one ofexpressionsdoes 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 emptyList.- Returns:
- The current value of
recordsToInsert.
-
setRecordsToInsert
public RawUpdateRecordsRequest setRecordsToInsert(List<ByteBuffer> recordsToInsert)
An *optional* list of new binary-avro encoded records to insert, one for each update. If one ofexpressionsdoes 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 emptyList.- Parameters:
recordsToInsert- The new value forrecordsToInsert.- Returns:
thisto mimic the builder pattern.
-
getRecordsToInsertStr
public List<String> getRecordsToInsertStr()
An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects. The default value is an emptyList.- Returns:
- The current value of
recordsToInsertStr.
-
setRecordsToInsertStr
public RawUpdateRecordsRequest setRecordsToInsertStr(List<String> recordsToInsertStr)
An optional list of JSON encoded objects to insert, one for each update, to be added if the particular update did not match any objects. The default value is an emptyList.- Parameters:
recordsToInsertStr- The new value forrecordsToInsertStr.- Returns:
thisto mimic the builder pattern.
-
getRecordEncoding
public String getRecordEncoding()
Identifies which ofrecordsToInsertandrecordsToInsertStrshould be used. Supported values: The default value isBINARY.- Returns:
- The current value of
recordEncoding.
-
setRecordEncoding
public RawUpdateRecordsRequest setRecordEncoding(String recordEncoding)
Identifies which ofrecordsToInsertandrecordsToInsertStrshould be used. Supported values: The default value isBINARY.- Parameters:
recordEncoding- The new value forrecordEncoding.- Returns:
thisto mimic the builder pattern.
-
getOptions
public Map<String,String> getOptions()
Optional parameters.GLOBAL_EXPRESSION: An optional global expression to reduce the search space of the predicates listed inexpressions. The default value is ''.BYPASS_SAFETY_CHECKS: When set toTRUE, 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 isFALSE.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 inexpressionsfinds no records to update, and the alternate insert record given inrecordsToInsert(orrecordsToInsertStr) contains a primary key matching that of an existing record in the table. IfUPDATE_ON_EXISTING_PKis set toTRUE, "update collisions" will result in the existing record collided into being removed and the record updated with values specified innewValuesMapstaking its place; "insert collisions" will result in the collided-into record being updated with the values inrecordsToInsert/recordsToInsertStr(if given). If set toFALSE, the existing collided-into record will remain unchanged, while the update will be rejected and the error handled as determined byIGNORE_EXISTING_PK. If the specified table does not have a primary key, then this option has no effect. Supported values: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 tableFALSE: Reject updates which cause primary key collisions between the record being updated/inserted and an existing record in the table
FALSE.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_PKisFALSE). If set toTRUE, 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. IfFALSE, 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 ifUPDATE_ON_EXISTING_PKisTRUE, then this option has no effect. Supported values:TRUE: Ignore updates that result in primary key collisions with existing recordsFALSE: Treat as errors any updates that result in primary key collisions with existing records
FALSE.UPDATE_PARTITION: Force qualifying records to be deleted and reinserted so their partition membership will be reevaluated. Supported values: The default value isFALSE.TRUNCATE_STRINGS: If set toTRUE, any strings which are too long for their charN string fields will be truncated to fit. Supported values: The default value isFALSE.USE_EXPRESSIONS_IN_NEW_VALUES_MAPS: When set toTRUE, all new values innewValuesMapsare considered as expression values. When set toFALSE, all new values innewValuesMapsare considered as constants. NOTE: WhenTRUE, string constants will need to be quoted to avoid being evaluated as expressions. Supported values: The default value isFALSE.RECORD_ID: ID of a single record to be updated (returned in the call toGPUdb.insertRecordsRaworGPUdb.getRecordsFromCollectionRaw).
Map.- Returns:
- The current value of
options.
-
setOptions
public RawUpdateRecordsRequest setOptions(Map<String,String> options)
Optional parameters.GLOBAL_EXPRESSION: An optional global expression to reduce the search space of the predicates listed inexpressions. The default value is ''.BYPASS_SAFETY_CHECKS: When set toTRUE, 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 isFALSE.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 inexpressionsfinds no records to update, and the alternate insert record given inrecordsToInsert(orrecordsToInsertStr) contains a primary key matching that of an existing record in the table. IfUPDATE_ON_EXISTING_PKis set toTRUE, "update collisions" will result in the existing record collided into being removed and the record updated with values specified innewValuesMapstaking its place; "insert collisions" will result in the collided-into record being updated with the values inrecordsToInsert/recordsToInsertStr(if given). If set toFALSE, the existing collided-into record will remain unchanged, while the update will be rejected and the error handled as determined byIGNORE_EXISTING_PK. If the specified table does not have a primary key, then this option has no effect. Supported values: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 tableFALSE: Reject updates which cause primary key collisions between the record being updated/inserted and an existing record in the table
FALSE.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_PKisFALSE). If set toTRUE, 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. IfFALSE, 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 ifUPDATE_ON_EXISTING_PKisTRUE, then this option has no effect. Supported values:TRUE: Ignore updates that result in primary key collisions with existing recordsFALSE: Treat as errors any updates that result in primary key collisions with existing records
FALSE.UPDATE_PARTITION: Force qualifying records to be deleted and reinserted so their partition membership will be reevaluated. Supported values: The default value isFALSE.TRUNCATE_STRINGS: If set toTRUE, any strings which are too long for their charN string fields will be truncated to fit. Supported values: The default value isFALSE.USE_EXPRESSIONS_IN_NEW_VALUES_MAPS: When set toTRUE, all new values innewValuesMapsare considered as expression values. When set toFALSE, all new values innewValuesMapsare considered as constants. NOTE: WhenTRUE, string constants will need to be quoted to avoid being evaluated as expressions. Supported values: The default value isFALSE.RECORD_ID: ID of a single record to be updated (returned in the call toGPUdb.insertRecordsRaworGPUdb.getRecordsFromCollectionRaw).
Map.- Parameters:
options- The new value foroptions.- Returns:
thisto mimic the builder pattern.
-
getSchema
public org.apache.avro.Schema getSchema()
This method supports the Avro framework and is not intended to be called directly by the user.- Specified by:
getSchemain interfaceorg.apache.avro.generic.GenericContainer- Returns:
- The schema object describing this class.
-
get
public Object get(int index)
This method supports the Avro framework and is not intended to be called directly by the user.- Specified by:
getin interfaceorg.apache.avro.generic.IndexedRecord- Parameters:
index- the position of the field to get- Returns:
- value of the field with the given index.
- Throws:
IndexOutOfBoundsException
-
put
public void put(int index, Object value)This method supports the Avro framework and is not intended to be called directly by the user.- Specified by:
putin interfaceorg.apache.avro.generic.IndexedRecord- Parameters:
index- the position of the field to setvalue- the value to set- Throws:
IndexOutOfBoundsException
-
-