Class PendingSegmentRecord

java.lang.Object
org.apache.druid.metadata.PendingSegmentRecord

public class PendingSegmentRecord extends Object
Representation of a record in the pending segments table.
Mapping of column in table to field:
  • id -> id (Unique identifier for pending segment)
  • sequence_name -> sequenceName (sequence name used for segment allocation)
  • sequence_prev_id -> sequencePrevId (previous segment id used for segment allocation)
  • upgraded_from_segment_id -> upgradedFromSegmentId (ID of the segment which was upgraded to create the current segment. If the former was itself created as a result of an upgrade, then this ID must refer to the original non-upgraded segment in the hierarchy.)
  • task_allocator_id -> taskAllocatorId (Associates a task / task group / replica group with the pending segment)
  • Field Details

    • DEFAULT_VERSION_FOR_CONCURRENT_APPEND

      public static final String DEFAULT_VERSION_FOR_CONCURRENT_APPEND
      Default lock version used by concurrent APPEND tasks.
    • CONCURRENT_APPEND_VERSION_SUFFIX

      public static final String CONCURRENT_APPEND_VERSION_SUFFIX
      Suffix to use to construct fresh segment versions in the event of a clash. The chosen character S is just for visual ease so that two versions are not easily confused for each other. 1970-01-01T00:00:00.000Z_1 vs 1970-01-01T00:00:00.000ZS_1.
      See Also:
  • Constructor Details

  • Method Details

    • fromJson

      public static PendingSegmentRecord fromJson(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, @Nullable String upgradedFromSegmentId, @Nullable String taskAllocatorId)
    • getId

      public SegmentIdWithShardSpec getId()
    • getSequenceName

      public String getSequenceName()
    • getSequencePrevId

      public String getSequencePrevId()
      Previous segment ID allocated for the same sequence.
      Returns:
      Empty string if there is no previous segment in the sequence.
    • getUpgradedFromSegmentId

      @Nullable public String getUpgradedFromSegmentId()
      The original pending segment using which this upgraded segment was created. Can be null for pending segments allocated before this column was added or for segments that have not been upgraded.
    • getTaskAllocatorId

      @Nullable public String getTaskAllocatorId()
      task / taskGroup / replica group of task that allocated this segment. Can be null for pending segments allocated before this column was added.
    • getCreatedDate

      public org.joda.time.DateTime getCreatedDate()
      This field is not serialized since tasks do not use it.
    • computeSequenceNamePrevIdSha1

      public String computeSequenceNamePrevIdSha1(boolean skipSegmentLineageCheck)
      Computes a hash for this record to serve as UNIQUE key, ensuring we don't have more than one segment per sequence per interval. A single column is used instead of (sequence_name, sequence_prev_id) as some MySQL storage engines have difficulty with large unique keys (see #2319)
    • create

      public static PendingSegmentRecord create(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, @Nullable String upgradedFromSegmentId, @Nullable String taskAllocatorId)
      Creates a new record (with the current timestamp) that can be used to create a new entry in the pending segments metadata table.
      Returns:
      A new PendingSegmentRecord with the given parameters and the current time as the created date.
    • fromResultSet

      public static PendingSegmentRecord fromResultSet(ResultSet resultSet, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Maps the given result set into a PendingSegmentRecord. The columns required in the result set are:
      • payload
      • sequence_name
      • sequence_prev_id
      • upgraded_from_segment_id
      • task_allocator_id
      • created_date