Interface UpdateBuilder
-
- All Known Implementing Classes:
UpdateBuilderImpl
@Experimental public interface UpdateBuilder
This class applies the builder pattern to build a partial update record. Note that to-be-updated value must be of typeSchema.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.apache.avro.generic.GenericRecord
build()
Build aGenericRecord
that is ready to be sent as an Update request.UpdateBuilder
setElementsToAddToListField(java.lang.String listFieldName, java.util.List<?> elementsToAdd)
Set elements to be added to a List/Array field.UpdateBuilder
setElementsToRemoveFromListField(java.lang.String listFieldName, java.util.List<?> elementsToRemove)
Set elements to be removed from a List/Array field.UpdateBuilder
setEntriesToAddToMapField(java.lang.String mapFieldName, java.util.Map<java.lang.String,?> entriesToAdd)
Set k-v entries to be added to a Map field.UpdateBuilder
setKeysToRemoveFromMapField(java.lang.String mapFieldName, java.util.List<java.lang.String> keysToRemove)
Set keys to be added to a Map field.UpdateBuilder
setNewFieldValue(java.lang.String fieldName, java.lang.Object newFieldValue)
Set a new value to a field.
-
-
-
Method Detail
-
setNewFieldValue
UpdateBuilder setNewFieldValue(java.lang.String fieldName, java.lang.Object newFieldValue)
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
UpdateBuilder setElementsToAddToListField(java.lang.String listFieldName, java.util.List<?> elementsToAdd)
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
UpdateBuilder setElementsToRemoveFromListField(java.lang.String listFieldName, java.util.List<?> elementsToRemove)
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
UpdateBuilder setEntriesToAddToMapField(java.lang.String mapFieldName, java.util.Map<java.lang.String,?> entriesToAdd)
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
UpdateBuilder setKeysToRemoveFromMapField(java.lang.String mapFieldName, java.util.List<java.lang.String> keysToRemove)
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.
-
-