Interface UpdateBuilder
- All Known Implementing Classes:
UpdateBuilderImpl
This class applies the builder pattern to build a partial update record. Note that to-be-updated value
must be of type
Schema.Type.RECORD
.
It provides below ways to update a value record.
1. Set a new value to a field.
2. Add elements to a List/Array field.
3. Remove elements from a List/Array field.
4. Add entries to a Map field.
5. Remove entries by keys from a map field.-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.avro.generic.GenericRecord
build()
Build aGenericRecord
that is ready to be sent as an Update request.setElementsToAddToListField
(String listFieldName, List<?> elementsToAdd) Set elements to be added to a List/Array field.setElementsToRemoveFromListField
(String listFieldName, List<?> elementsToRemove) Set elements to be removed from a List/Array field.setEntriesToAddToMapField
(String mapFieldName, Map<String, ?> entriesToAdd) Set k-v entries to be added to a Map field.setKeysToRemoveFromMapField
(String mapFieldName, List<String> keysToRemove) Set keys to be added to a Map field.setNewFieldValue
(String fieldName, Object newFieldValue) Set a new value to a field.
-
Method Details
-
setNewFieldValue
Set a new value to a field. Note that setting value on the same field multiple times throws anIllegalStateException
. If this field is a List/Map field and other methods are used to add to or remove from this field, calling this method throws anIllegalStateException
as well.- Parameters:
fieldName
- field namenewFieldValue
- new value that is going to be set to this field.
-
setElementsToAddToListField
Set elements to be added to a List/Array field. Note that: 1. If a list field has already set new list value by invoking {@link this#setNewFieldValue}, calling this method on the same list field should throw anIllegalStateException
. 2. Calling this method multiple times on the same list field, only last invocation takes effect.- Parameters:
listFieldName
- name of a list field.elementsToAdd
- Elements that are going to be added to this list field.
-
setElementsToRemoveFromListField
Set elements to be removed from a List/Array field. Note that: 1. If a list field has already set new list value by invoking {@link this#setNewFieldValue}, calling this method on the same list field should throw anIllegalStateException
. 2. Calling this method multiple times on the same list field, only last invocation takes effect.- Parameters:
listFieldName
- Name of a list field.elementsToRemove
- Elements that are going to be removed from this list field.
-
setEntriesToAddToMapField
Set k-v entries to be added to a Map field. Note that: 1. If a map field has already set new list value by invoking {@link this#setNewFieldValue}, calling this method on the same map field should throw anIllegalStateException
. 2. Calling this method multiple times on the same map field, only last invocation takes effect.- Parameters:
mapFieldName
- Name of a map field.entriesToAdd
- Entries that are going to be added to this map field.
-
setKeysToRemoveFromMapField
Set keys to be added to a Map field. Note that: 1. If a map field has already set new list value by invoking {@link this#setNewFieldValue}, calling this method on the same map field should throw anIllegalStateException
. 2. Calling this method multiple times on the same map field, only last invocation takes effect.- Parameters:
mapFieldName
- Name of a map field.keysToRemove
- Keys of k-v entries that are going to be removed from this map field.
-
build
org.apache.avro.generic.GenericRecord build()Build aGenericRecord
that is ready to be sent as an Update request.- Returns:
- A
GenericRecord
that is ready to be sent to Venice.
-