Class UpdateBuilderImpl
java.lang.Object
com.linkedin.venice.writer.update.UpdateBuilderImpl
- All Implemented Interfaces:
UpdateBuilder
-
Constructor Summary
-
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.
-
Constructor Details
-
UpdateBuilderImpl
public UpdateBuilderImpl(org.apache.avro.Schema updateSchema) - Parameters:
updateSchema
- Update schema that is derived from the value Record schema.
-
-
Method Details
-
setNewFieldValue
Description copied from interface:UpdateBuilder
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.- Specified by:
setNewFieldValue
in interfaceUpdateBuilder
- Parameters:
fieldName
- field namenewFieldValue
- new value that is going to be set to this field.
-
setElementsToAddToListField
Description copied from interface:UpdateBuilder
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.- Specified by:
setElementsToAddToListField
in interfaceUpdateBuilder
- Parameters:
listFieldName
- name of a list field.elementsToAdd
- Elements that are going to be added to this list field.
-
setElementsToRemoveFromListField
public UpdateBuilder setElementsToRemoveFromListField(String listFieldName, List<?> elementsToRemove) Description copied from interface:UpdateBuilder
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.- Specified by:
setElementsToRemoveFromListField
in interfaceUpdateBuilder
- Parameters:
listFieldName
- Name of a list field.elementsToRemove
- Elements that are going to be removed from this list field.
-
setEntriesToAddToMapField
Description copied from interface:UpdateBuilder
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.- Specified by:
setEntriesToAddToMapField
in interfaceUpdateBuilder
- Parameters:
mapFieldName
- Name of a map field.entriesToAdd
- Entries that are going to be added to this map field.
-
setKeysToRemoveFromMapField
Description copied from interface:UpdateBuilder
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.- Specified by:
setKeysToRemoveFromMapField
in interfaceUpdateBuilder
- Parameters:
mapFieldName
- Name of a map field.keysToRemove
- Keys of k-v entries that are going to be removed from this map field.
-
build
public org.apache.avro.generic.GenericRecord build()Description copied from interface:UpdateBuilder
Build aGenericRecord
that is ready to be sent as an Update request.- Specified by:
build
in interfaceUpdateBuilder
- Returns:
- A
GenericRecord
that is ready to be sent to Venice.
-