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 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 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​(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 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​(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 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​(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 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​(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 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.