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 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 Details

    • setNewFieldValue

      UpdateBuilder setNewFieldValue(String fieldName, Object newFieldValue)
      Set a new value to a field. Note that setting value on the same field multiple times throws an IllegalStateException. 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 an IllegalStateException as well.
      Parameters:
      fieldName - field name
      newFieldValue - new value that is going to be set to this field.
    • setElementsToAddToListField

      UpdateBuilder setElementsToAddToListField(String listFieldName, 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 an IllegalStateException. 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(String listFieldName, 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 an IllegalStateException. 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(String mapFieldName, Map<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 an IllegalStateException. 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(String mapFieldName, List<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 an IllegalStateException. 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 a GenericRecord that is ready to be sent as an Update request.
      Returns:
      A GenericRecord that is ready to be sent to Venice.