AmatyaAvadhanula commented on code in PR #16144: URL: https://github.com/apache/druid/pull/16144#discussion_r1567043940
########## server/src/main/java/org/apache/druid/metadata/PendingSegmentRecord.java: ########## @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.metadata; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.hash.Hasher; +import com.google.common.hash.Hashing; +import com.google.common.io.BaseEncoding; +import org.apache.druid.java.util.common.StringUtils; +import org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec; +import org.joda.time.Interval; + +import javax.annotation.Nullable; +import java.sql.ResultSet; + +/** + * Representation of a record in the pending segments table. <br/> + * Mapping of column in table to field: + * <li/> id -> id (Unique identifier for pending segment) + * <li/> sequence_name -> sequenceName (sequence name used for segment allocation) + * <li/> sequence_prev_id -> sequencePrevId (previous segment id used for segment allocation) + * <li/> upgraded_from_segment_id -> upgradedFromSegmentId (Id of the root segment from which this was upgraded) + * <li/> task_allocator_id -> taskAllocatorId (Associates a task / task group / replica group with the pending segment) + */ +public class PendingSegmentRecord +{ + private final SegmentIdWithShardSpec id; + private final String sequenceName; + private final String sequencePrevId; + private final String upgradedFromSegmentId; + private final String taskAllocatorId; + + public PendingSegmentRecord( + SegmentIdWithShardSpec id, + String sequenceName, + String sequencePrevId, + @Nullable String upgradedFromSegmentId, + @Nullable String taskAllocatorId + ) + { + this.id = id; + this.sequenceName = sequenceName; + this.sequencePrevId = sequencePrevId; + this.upgradedFromSegmentId = upgradedFromSegmentId; + this.taskAllocatorId = taskAllocatorId; + } + + public SegmentIdWithShardSpec getId() + { + return id; + } + + public String getSequenceName() + { + return sequenceName; + } + + public String getSequencePrevId() + { + return sequencePrevId; + } + + /** + * The original pending segment using which this upgraded segment was created. + * Corresponds to the column upgraded_from_segment_id in druid_pendingSegments. + * Can be null for pending segments allocated before this column was added or for segments that have not been upgraded. + */ + @Nullable + public String getUpgradedFromSegmentId() + { + return upgradedFromSegmentId; + } + + /** + * task / taskGroup / replica group of task that allocated this segment. + * Corresponds to the column task_allocator_id in druid_pendingSegments. Review Comment: Removed ########## server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java: ########## @@ -281,99 +279,74 @@ public int markSegmentsAsUnusedWithinInterval(String dataSource, Interval interv } /** - * Fetches all the pending segments, whose interval overlaps with the given - * search interval and has a sequence_name that begins with one of the prefixes in sequenceNamePrefixFilter - * from the metadata store. Returns a Map from the pending segment ID to the sequence name. + * Fetches all the pending segments, whose interval overlaps with the given search interval, from the metadata store. */ @VisibleForTesting - Map<SegmentIdWithShardSpec, String> getPendingSegmentsForIntervalWithHandle( + List<PendingSegmentRecord> getPendingSegmentsForIntervalWithHandle( final Handle handle, final String dataSource, - final Interval interval, - final Set<String> sequenceNamePrefixFilter - ) throws IOException + final Interval interval + ) { - if (sequenceNamePrefixFilter.isEmpty()) { - return Collections.emptyMap(); - } - - final List<String> sequenceNamePrefixes = new ArrayList<>(sequenceNamePrefixFilter); - final List<String> sequenceNamePrefixConditions = new ArrayList<>(); - for (int i = 0; i < sequenceNamePrefixes.size(); i++) { - sequenceNamePrefixConditions.add(StringUtils.format("(sequence_name LIKE :prefix%d)", i)); - } + boolean compareIntervalEndpointsAsStrings = Intervals.canCompareEndpointsAsStrings(interval); Review Comment: Done ########## server/src/main/java/org/apache/druid/indexing/overlord/IndexerMetadataStorageCoordinator.java: ########## @@ -340,7 +344,8 @@ SegmentPublishResult commitAppendSegmentsAndMetadata( Set<DataSegment> appendSegments, Map<DataSegment, ReplaceTaskLock> appendSegmentToReplaceLock, DataSourceMetadata startMetadata, - DataSourceMetadata endMetadata + DataSourceMetadata endMetadata, + String taskGroup Review Comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
