Interface ChangeStreamRecordAdapter.ChangeStreamRecordBuilder<ChangeStreamRecordT>

  • Enclosing interface:
    ChangeStreamRecordAdapter<ChangeStreamRecordT>

    public static interface ChangeStreamRecordAdapter.ChangeStreamRecordBuilder<ChangeStreamRecordT>
    A SAX style change stream record factory. It is responsible for creating one of the three types of change stream record: heartbeat, close stream, and a change stream mutation.

    State management is handled external to the implementation of this class:

      Case 1: Heartbeat
    1. Exactly 1 onHeartbeat.
      Case 2: CloseStream
    1. Exactly 1 onCloseStream.
      Case 3: ChangeStreamMutation. A change stream mutation consists of one or more mods, where the SetCells might be chunked. There are 3 different types of mods that a ReadChangeStream response can have:
    1. DeleteFamily -> Exactly 1 deleteFamily
    2. DeleteCell -> Exactly 1 deleteCell
    3. SetCell -> Exactly 1 startCell, At least 1 CellValue, Exactly 1 finishCell.

    The whole flow of constructing a ChangeStreamMutation is:

    1. Exactly 1 startUserMutation or startGcMutation.
    2. At least 1 DeleteFamily/DeleteCell/SetCell mods.
    3. Exactly 1 finishChangeStreamMutation.

    Note: For a non-chunked SetCell, only 1 CellValue will be called. For a chunked SetCell, more than 1 CellValues will be called.

    Note: DeleteRow's won't appear in data changes since they'll be converted to multiple DeleteFamily's.

    • Method Detail

      • startUserMutation

        void startUserMutation​(@Nonnull
                               com.google.protobuf.ByteString rowKey,
                               @Nonnull
                               String sourceClusterId,
                               org.threeten.bp.Instant commitTimestamp,
                               int tieBreaker)
        Called to start a new user initiated ChangeStreamMutation. This will be called at most once. If called, the current change stream record must not include any close stream message or heartbeat.
      • startGcMutation

        void startGcMutation​(@Nonnull
                             com.google.protobuf.ByteString rowKey,
                             org.threeten.bp.Instant commitTimestamp,
                             int tieBreaker)
        Called to start a new Garbage Collection ChangeStreamMutation. This will be called at most once. If called, the current change stream record must not include any close stream message or heartbeat.
      • deleteFamily

        void deleteFamily​(@Nonnull
                          String familyName)
        Called to add a DeleteFamily mod.
      • startCell

        void startCell​(String family,
                       com.google.protobuf.ByteString qualifier,
                       long timestampMicros)
        Called to start a SetCell.
          In case of a non-chunked cell, the following order is guaranteed:
        1. Exactly 1 startCell.
        2. Exactly 1 cellValue.
        3. Exactly 1 finishCell.
          In case of a chunked cell, the following order is guaranteed:
        1. Exactly 1 startCell.
        2. At least 2 cellValue.
        3. Exactly 1 finishCell.
      • cellValue

        void cellValue​(com.google.protobuf.ByteString value)
        Called once per non-chunked cell, or at least twice per chunked cell to concatenate the cell value.
      • finishCell

        void finishCell()
        Called once per cell to signal the end of the value (unless reset).
      • finishChangeStreamMutation

        ChangeStreamRecordT finishChangeStreamMutation​(@Nonnull
                                                       String token,
                                                       org.threeten.bp.Instant estimatedLowWatermark)
        Called once per stream record to signal that all mods have been processed (unless reset).
      • reset

        void reset()
        Called when the current in progress change stream record should be dropped