Package org.apache.druid.metadata
Class PendingSegmentRecord
java.lang.Object
org.apache.druid.metadata.PendingSegmentRecord
Representation of a record in the pending segments table.
Mapping of column in table to field:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPendingSegmentRecord(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, String upgradedFromSegmentId, String taskAllocatorId, org.joda.time.DateTime createdDate) -
Method Summary
Modifier and TypeMethodDescriptioncomputeSequenceNamePrevIdSha1(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.static PendingSegmentRecordcreate(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, String upgradedFromSegmentId, 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.static PendingSegmentRecordfromJson(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, String upgradedFromSegmentId, String taskAllocatorId) static PendingSegmentRecordfromResultSet(ResultSet resultSet, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) Maps the given result set into aPendingSegmentRecord.org.joda.time.DateTimeThis field is not serialized since tasks do not use it.getId()Previous segment ID allocated for the same sequence.task / taskGroup / replica group of task that allocated this segment.The original pending segment using which this upgraded segment was created.
-
Field Details
-
DEFAULT_VERSION_FOR_CONCURRENT_APPEND
Default lock version used by concurrent APPEND tasks. -
CONCURRENT_APPEND_VERSION_SUFFIX
Suffix to use to construct fresh segment versions in the event of a clash. The chosen characterSis just for visual ease so that two versions are not easily confused for each other.1970-01-01T00:00:00.000Z_1vs1970-01-01T00:00:00.000ZS_1.- See Also:
-
-
Constructor Details
-
PendingSegmentRecord
public PendingSegmentRecord(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, String upgradedFromSegmentId, String taskAllocatorId, org.joda.time.DateTime createdDate)
-
-
Method Details
-
fromJson
public static PendingSegmentRecord fromJson(SegmentIdWithShardSpec id, String sequenceName, String sequencePrevId, @Nullable String upgradedFromSegmentId, @Nullable String taskAllocatorId) -
getId
-
getSequenceName
-
getSequencePrevId
Previous segment ID allocated for the same sequence.- Returns:
- Empty string if there is no previous segment in the sequence.
-
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
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
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 aPendingSegmentRecord. The columns required in the result set are:payloadsequence_namesequence_prev_idupgraded_from_segment_idtask_allocator_idcreated_date
-