T
- The type of object being processed.public class UpdateRecordsRequest<T> extends Object
GPUdb.updateRecords(UpdateRecordsRequest)
.
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 collection or 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
.
Modifier and Type | Class and Description |
---|---|
static class |
UpdateRecordsRequest.Options
Optional parameters.
|
Constructor and Description |
---|
UpdateRecordsRequest()
Constructs an UpdateRecordsRequest object with default parameters.
|
UpdateRecordsRequest(String tableName,
List<String> expressions,
List<Map<String,String>> newValuesMaps,
List<T> data,
Map<String,String> options)
Constructs an UpdateRecordsRequest object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
List<T> |
getData() |
List<String> |
getExpressions() |
List<Map<String,String>> |
getNewValuesMaps() |
Map<String,String> |
getOptions() |
String |
getTableName() |
int |
hashCode() |
UpdateRecordsRequest<T> |
setData(List<T> data) |
UpdateRecordsRequest<T> |
setExpressions(List<String> expressions) |
UpdateRecordsRequest<T> |
setNewValuesMaps(List<Map<String,String>> newValuesMaps) |
UpdateRecordsRequest<T> |
setOptions(Map<String,String> options) |
UpdateRecordsRequest<T> |
setTableName(String tableName) |
String |
toString() |
public UpdateRecordsRequest()
public UpdateRecordsRequest(String tableName, List<String> expressions, List<Map<String,String>> newValuesMaps, List<T> data, Map<String,String> options)
tableName
- Table to be updated. Must be a currently existing
table and not a collection or view.expressions
- A list of the actual predicates, one for each
update; format should follow the guidelines here
.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
.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.options
- Optional parameters.
GLOBAL_EXPRESSION
: An optional global expression to
reduce the search space of the predicates listed in
expressions
.
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 FALSE
.
UPDATE_ON_EXISTING_PK
: Can be used to customize
behavior when the updated primary key value already
exists, as described in GPUdb.insertRecords(InsertRecordsRequest)
.
Supported values:
The default value is FALSE
.
RECORD_ID
: ID of a single record to be updated
(returned in the call to GPUdb.insertRecords(InsertRecordsRequest)
or
GPUdb.getRecordsFromCollection(Object,
GetRecordsFromCollectionRequest)
).
public String getTableName()
public UpdateRecordsRequest<T> setTableName(String tableName)
tableName
- Table to be updated. Must be a currently existing
table and not a collection or view.this
to mimic the builder pattern.public List<String> getExpressions()
here
.public UpdateRecordsRequest<T> setExpressions(List<String> expressions)
expressions
- A list of the actual predicates, one for each
update; format should follow the guidelines here
.this
to mimic the builder pattern.public List<Map<String,String>> getNewValuesMaps()
expressions
.public UpdateRecordsRequest<T> setNewValuesMaps(List<Map<String,String>> newValuesMaps)
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
.this
to mimic the builder pattern.public List<T> getData()
expressions
does not
yield a matching record to be updated, then the corresponding
element from this list will be added to the table.public UpdateRecordsRequest<T> setData(List<T> data)
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.this
to mimic the builder pattern.public Map<String,String> getOptions()
GLOBAL_EXPRESSION
: An optional global expression to reduce the
search space of the predicates listed in expressions
.
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 FALSE
.
UPDATE_ON_EXISTING_PK
: Can be used to customize behavior when
the updated primary key value already exists, as described in
GPUdb.insertRecords(InsertRecordsRequest)
.
Supported values:
The default value is FALSE
.
RECORD_ID
: ID of a single record to be updated (returned in the
call to GPUdb.insertRecords(InsertRecordsRequest)
or GPUdb.getRecordsFromCollection(Object,
GetRecordsFromCollectionRequest)
).
public UpdateRecordsRequest<T> setOptions(Map<String,String> options)
options
- Optional parameters.
GLOBAL_EXPRESSION
: An optional global expression to
reduce the search space of the predicates listed in
expressions
.
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 FALSE
.
UPDATE_ON_EXISTING_PK
: Can be used to customize
behavior when the updated primary key value already
exists, as described in GPUdb.insertRecords(InsertRecordsRequest)
.
Supported values:
The default value is FALSE
.
RECORD_ID
: ID of a single record to be updated
(returned in the call to GPUdb.insertRecords(InsertRecordsRequest)
or
GPUdb.getRecordsFromCollection(Object,
GetRecordsFromCollectionRequest)
).
this
to mimic the builder pattern.Copyright © 2017. All rights reserved.