Class CollectionRmdTimestamp<DELETED_ELEMENT_TYPE>

java.lang.Object
com.linkedin.venice.schema.rmd.v1.CollectionRmdTimestamp<DELETED_ELEMENT_TYPE>

@NotThreadSafe public class CollectionRmdTimestamp<DELETED_ELEMENT_TYPE> extends Object
This class centralizes the logic of creating a collection replication metadata schema and providing a POJO representation upon a collection replication metadata generic record. Its purpose is to abstract details of collection replication metadata schema and its generic record away for users.
  • Field Details

    • TOP_LEVEL_TS_FIELD_POS

      public static final int TOP_LEVEL_TS_FIELD_POS
      See Also:
    • TOP_LEVEL_TS_FIELD_NAME

      public static final String TOP_LEVEL_TS_FIELD_NAME
      See Also:
    • TOP_LEVEL_COLO_ID_FIELD_POS

      public static final int TOP_LEVEL_COLO_ID_FIELD_POS
      See Also:
    • TOP_LEVEL_COLO_ID_FIELD_NAME

      public static final String TOP_LEVEL_COLO_ID_FIELD_NAME
      See Also:
    • PUT_ONLY_PART_LENGTH_FIELD_POS

      public static final int PUT_ONLY_PART_LENGTH_FIELD_POS
      See Also:
    • PUT_ONLY_PART_LENGTH_FIELD_NAME

      public static final String PUT_ONLY_PART_LENGTH_FIELD_NAME
      See Also:
    • ACTIVE_ELEM_TS_FIELD_POS

      public static final int ACTIVE_ELEM_TS_FIELD_POS
      Client readable elements that haven't been deleted yet.
      See Also:
    • ACTIVE_ELEM_TS_FIELD_NAME

      public static final String ACTIVE_ELEM_TS_FIELD_NAME
      See Also:
    • DELETED_ELEM_FIELD_POS

      public static final int DELETED_ELEM_FIELD_POS
      See Also:
    • DELETED_ELEM_FIELD_NAME

      public static final String DELETED_ELEM_FIELD_NAME
      See Also:
    • DELETED_ELEM_TS_FIELD_POS

      public static final int DELETED_ELEM_TS_FIELD_POS
      See Also:
    • DELETED_ELEM_TS_FIELD_NAME

      public static final String DELETED_ELEM_TS_FIELD_NAME
      See Also:
    • COLLECTION_TS_ARRAY_SCHEMA

      public static final org.apache.avro.Schema COLLECTION_TS_ARRAY_SCHEMA
  • Constructor Details

    • CollectionRmdTimestamp

      public CollectionRmdTimestamp(CollectionRmdTimestamp other)
    • CollectionRmdTimestamp

      public CollectionRmdTimestamp(org.apache.avro.generic.GenericRecord collectionRmdRecord)
  • Method Details

    • getTopLevelFieldTimestamp

      public long getTopLevelFieldTimestamp()
    • getTopLevelColoID

      public int getTopLevelColoID()
    • getPutOnlyPartLength

      public int getPutOnlyPartLength()
    • isInPutOnlyState

      public boolean isInPutOnlyState()
    • getActiveElementTimestamps

      public List<Long> getActiveElementTimestamps()
    • removeActiveTimestampsLowerOrEqualTo

      public int removeActiveTimestampsLowerOrEqualTo(long minTimestamp)
      Parameters:
      minTimestamp - Remove all active timestamps that are smaller or equal to minTimestamp.
      Returns:
      number of active timestamps removed from the beginning (index 0).
    • removeDeletionInfoWithTimestampsLowerOrEqualTo

      public void removeDeletionInfoWithTimestampsLowerOrEqualTo(long minTimestamp)
    • getDeletedElementTimestamps

      public List<Long> getDeletedElementTimestamps()
    • getDeletedElements

      public List<DELETED_ELEMENT_TYPE> getDeletedElements()
    • setTopLevelFieldTimestamp

      public void setTopLevelFieldTimestamp(long topLevelFieldTimestamp)
    • setTopLevelColoID

      public void setTopLevelColoID(int topLevelColoID)
    • setPutOnlyPartLength

      public void setPutOnlyPartLength(int putOnlyPartLength)
    • setActiveElementTimestamps

      public void setActiveElementTimestamps(List<Long> collectionActiveTimestamps)
    • setDeletedElementsAndTimestamps

      public void setDeletedElementsAndTimestamps(List<DELETED_ELEMENT_TYPE> deletedElements, List<Long> deletedTimestamps)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createCollectionTimeStampSchema

      public static org.apache.avro.Schema createCollectionTimeStampSchema(String metadataRecordName, String namespace, org.apache.avro.Schema elemSchema)
      Create a RECORD that keeps track of collection field's update metadata. There are 4 sub-fields here. TOP_LEVEL_TS_FIELD_NAME The top level timestamp. This field is updated when the whole collections is replaced/removed (via partial update) ACTIVE_ELEM_TS_FIELD_NAME A timestamp array that holds the timestamps for each elements in the collection. DELETED_ELEM_FIELD_NAME A tombstone array that holds deleted elements. If this collection is an ARRAY, the array will hold elements the same type as the original array. If this collection is a MAP, the array will hold string elements (keys in the original map). DELETED_ELEM_TS_FIELD_NAME A timestamp array that holds the timestamps for each deleted element in the tombstone array
       Example value schema:
       {
         "type" : "record",
         "name" : "testRecord",
         "namespace" : "avro.example",
         "fields" : [ {
           "name" : "intArray",
           "type" : {
             "type" : "array",
             "items" : "int"
           },
           "default" : [ ]
         } ]
       }
      
       Corresponding TS schema
       {
         "type" : "record",
         "name" : "ARRAY_CollectionTimestampMetadata_1",
         "doc" : "structure that maintains all of the necessary metadata to perform deterministic conflict resolution on collection fields.",
         "fields" : [ {
           "name" : "topLevelFieldTimestamp",
           "type" : "long",
           "doc" : "Timestamp of the last partial update attempting to set every element of this collection.",
           "default" : 0
         },{
           "name" : "topLevelColoID",
           "type" : "int",
           "doc" : "ID of the colo from which the last successfully applied partial update was sent.",
           "default" : -1
         },{
           "name" : "putOnlyPartLength",
           "type" : "int",
           "doc" : "Length of the put-only part of the collection which starts from index 0.",
           "default" : 0
         },
         {
           "name" : "activeElementsTimestamps",
           "type" : {
             "type" : "array",
             "items" : "long"
           },
           "doc" : "Timestamps of each active element in the user's collection. This is a parallel array with the user's collection.",
           "default" : [ ]
         }, {
           "name" : "deletedElementsIdentities",
           "type" : {
             "type" : "array",
             "items" : "int"
           },
           "doc" : "The tomestone array of deleted elements. This is a parallel array with deletedElementsTimestamps",
           "default" : [ ]
         }, {
           "name" : "deletedElementsTimestamps",
           "type" : {
             "type" : "array",
             "items" : "long"
           },
           "doc" : "Timestamps of each deleted element. This is a parallel array with deletedElementsIdentity.",
           "default" : [ ]
         }
       }