klsince commented on code in PR #13107:
URL: https://github.com/apache/pinot/pull/13107#discussion_r1624820901


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/UploadedRealtimeSegmentName.java:
##########
@@ -0,0 +1,199 @@
+/**
+ * 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.pinot.common.utils;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+
+/**
+ * Class to represent segment names like: 
uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}__{
+ * optionalSuffix}
+ *
+ * <p>This naming convention is adopted to represent a segment uploaded to a 
realtime table. The naming
+ * convention has been kept similar to {@LLCSegmentName} to but differentiates 
between stream generated LLCSegments
+ * based on the prefix "uploaded" and an optional suffix.
+ */
+public class UploadedRealtimeSegmentName implements 
Comparable<UploadedRealtimeSegmentName> {
+
+  private static final String UPLOADED_PREFIX = "uploaded";
+  private static final String SEPARATOR = "__";
+  private static final String DATE_FORMAT = "yyyyMMdd'T'HHmm'Z'";
+  private static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormat.forPattern(DATE_FORMAT).withZoneUTC();
+  private final String _tableName;
+  private final int _partitionId;
+  private final int _sequenceId;
+  private final String _creationTime;
+  private final String _segmentName;
+
+  @Nullable
+  private String _suffix = null;
+
+  public UploadedRealtimeSegmentName(String segmentName) {
+
+    // split the segment name by the separator and get creation time, sequence 
id, partition id and table name from
+    // the end and validate segment name starts with prefix uploaded_
+    try {
+      String[] parts = StringUtils.splitByWholeSeparator(segmentName, 
SEPARATOR);
+      Preconditions.checkState((parts.length == 5 || parts.length == 6) && 
parts[0].equals(UPLOADED_PREFIX),
+          "Uploaded segment name must be of the format "
+              + 
"uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}");
+      int idx = parts.length - 1;
+      if (parts.length == 6) {
+        _suffix = parts[idx--];
+      }
+      _creationTime = parts[idx--];
+      _sequenceId = Integer.parseInt(parts[idx--]);
+      _partitionId = Integer.parseInt(parts[idx]);
+      _tableName = Joiner.on(SEPARATOR).join(Arrays.copyOfRange(parts, 1, 
idx));
+      _segmentName = segmentName;
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid segment name: " + 
segmentName, e);
+    }
+  }
+
+  /**
+   * Constructor to create a segment name from the table name, partition id, 
sequence id, creation time and optional
+   * suffix
+   * @param tableName
+   * @param partitionId
+   * @param sequenceId
+   * @param msSinceEpoch
+   * @param suffix
+   */
+  public UploadedRealtimeSegmentName(String tableName, int partitionId, int 
sequenceId, long msSinceEpoch,
+      String suffix) {

Review Comment:
   `@nullable` on suffix



##########
pinot-common/src/main/java/org/apache/pinot/common/utils/UploadedRealtimeSegmentName.java:
##########
@@ -0,0 +1,199 @@
+/**
+ * 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.pinot.common.utils;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+
+/**
+ * Class to represent segment names like: 
uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}__{
+ * optionalSuffix}
+ *
+ * <p>This naming convention is adopted to represent a segment uploaded to a 
realtime table. The naming
+ * convention has been kept similar to {@LLCSegmentName} to but differentiates 
between stream generated LLCSegments
+ * based on the prefix "uploaded" and an optional suffix.
+ */
+public class UploadedRealtimeSegmentName implements 
Comparable<UploadedRealtimeSegmentName> {
+
+  private static final String UPLOADED_PREFIX = "uploaded";
+  private static final String SEPARATOR = "__";
+  private static final String DATE_FORMAT = "yyyyMMdd'T'HHmm'Z'";
+  private static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormat.forPattern(DATE_FORMAT).withZoneUTC();
+  private final String _tableName;
+  private final int _partitionId;
+  private final int _sequenceId;
+  private final String _creationTime;
+  private final String _segmentName;
+
+  @Nullable
+  private String _suffix = null;
+
+  public UploadedRealtimeSegmentName(String segmentName) {
+
+    // split the segment name by the separator and get creation time, sequence 
id, partition id and table name from
+    // the end and validate segment name starts with prefix uploaded_
+    try {
+      String[] parts = StringUtils.splitByWholeSeparator(segmentName, 
SEPARATOR);
+      Preconditions.checkState((parts.length == 5 || parts.length == 6) && 
parts[0].equals(UPLOADED_PREFIX),
+          "Uploaded segment name must be of the format "
+              + 
"uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}");
+      int idx = parts.length - 1;
+      if (parts.length == 6) {
+        _suffix = parts[idx--];
+      }
+      _creationTime = parts[idx--];

Review Comment:
   It seems more intuitive to use index number directly, assuming no double 
underscore in table name (as done in LLCSegmentName.java)
   ```
   _tableName = parts[1];
   _partitionGroupId = Integer.parseInt(parts[2]);
   ...
   ```
   
   If assuming table name may contain double underscores, the checkState() on 5 
or 6 fields would already fail.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/ConcurrentMapPartitionUpsertMetadataManager.java:
##########
@@ -158,6 +158,51 @@ protected void addOrReplaceSegment(ImmutableSegmentImpl 
segment, ThreadSafeMutab
     }
   }
 
+  /**
+   * <li> When the replacing segment and current segment are of {@link 
LLCSegmentName} then the PK should resolve to
+   * row in segment with higher sequence id.
+   * <li> When the replacing segment and current segment are of {@link 
UploadedRealtimeSegmentName} then the PK
+   * should resolve to row in segment with higher sequence id, creation time.
+   * <li> When either is of type {@link UploadedRealtimeSegmentName} then 
resolve on creation time, if same(rare
+   * scenario) then give preference to uploaded time
+   *
+   * @param segmentName replacing segment name
+   * @param currentSegmentName current segment name having the record for the 
given primary key
+   * @param segmentCreationTimeMs replacing segment creation time
+   * @param currentSegmentCreationTimeMs current segment creation time
+   * @return true if the record in replacing segment should replace the record 
in current segment
+   */
+  private boolean shouldReplaceOnComparisonTie(String segmentName, String 
currentSegmentName,
+      long segmentCreationTimeMs, long currentSegmentCreationTimeMs) {
+
+    LLCSegmentName llcSegmentName = LLCSegmentName.of(segmentName);
+    LLCSegmentName currentLLCSegmentName = 
LLCSegmentName.of(currentSegmentName);
+    if (llcSegmentName != null && currentLLCSegmentName != null) {
+      return llcSegmentName.getSequenceNumber() > 
currentLLCSegmentName.getSequenceNumber();
+    }
+
+    UploadedRealtimeSegmentName uploadedSegmentName = 
UploadedRealtimeSegmentName.of(segmentName);
+    UploadedRealtimeSegmentName currentUploadedSegmentName = 
UploadedRealtimeSegmentName.of(currentSegmentName);
+
+    if (uploadedSegmentName != null && currentUploadedSegmentName != null) {
+      int comparisonResult = 
uploadedSegmentName.compareTo(currentUploadedSegmentName);

Review Comment:
   we may skip compareTo(), since we didn't do this for LLCSegmentName either. 
The compareTo() checks table name, partition id which are checked while the 
segment is uploaded already. I think we can just compare seqId and ctime here. 



##########
pinot-common/src/main/java/org/apache/pinot/common/utils/UploadedRealtimeSegmentName.java:
##########
@@ -0,0 +1,199 @@
+/**
+ * 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.pinot.common.utils;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+
+/**
+ * Class to represent segment names like: 
uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}__{
+ * optionalSuffix}
+ *
+ * <p>This naming convention is adopted to represent a segment uploaded to a 
realtime table. The naming
+ * convention has been kept similar to {@LLCSegmentName} to but differentiates 
between stream generated LLCSegments
+ * based on the prefix "uploaded" and an optional suffix.
+ */
+public class UploadedRealtimeSegmentName implements 
Comparable<UploadedRealtimeSegmentName> {

Review Comment:
   It might be helpful to that "Not like the seqId in LLCSemgentName, the seqId 
here is not ensured to monotonically increase but more for avoiding name 
conflicts when uploading segments with same ctime suffix. As to why using same 
ctime, it would allow one to overwrite previously segments more easily."



##########
pinot-common/src/main/java/org/apache/pinot/common/utils/UploadedRealtimeSegmentName.java:
##########
@@ -0,0 +1,199 @@
+/**
+ * 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.pinot.common.utils;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+
+/**
+ * Class to represent segment names like: 
uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}__{
+ * optionalSuffix}
+ *
+ * <p>This naming convention is adopted to represent a segment uploaded to a 
realtime table. The naming
+ * convention has been kept similar to {@LLCSegmentName} to but differentiates 
between stream generated LLCSegments
+ * based on the prefix "uploaded" and an optional suffix.
+ */
+public class UploadedRealtimeSegmentName implements 
Comparable<UploadedRealtimeSegmentName> {
+
+  private static final String UPLOADED_PREFIX = "uploaded";
+  private static final String SEPARATOR = "__";
+  private static final String DATE_FORMAT = "yyyyMMdd'T'HHmm'Z'";
+  private static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormat.forPattern(DATE_FORMAT).withZoneUTC();
+  private final String _tableName;
+  private final int _partitionId;
+  private final int _sequenceId;
+  private final String _creationTime;
+  private final String _segmentName;
+
+  @Nullable
+  private String _suffix = null;
+
+  public UploadedRealtimeSegmentName(String segmentName) {
+
+    // split the segment name by the separator and get creation time, sequence 
id, partition id and table name from
+    // the end and validate segment name starts with prefix uploaded_
+    try {
+      String[] parts = StringUtils.splitByWholeSeparator(segmentName, 
SEPARATOR);
+      Preconditions.checkState((parts.length == 5 || parts.length == 6) && 
parts[0].equals(UPLOADED_PREFIX),
+          "Uploaded segment name must be of the format "
+              + 
"uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}");
+      int idx = parts.length - 1;
+      if (parts.length == 6) {
+        _suffix = parts[idx--];
+      }
+      _creationTime = parts[idx--];
+      _sequenceId = Integer.parseInt(parts[idx--]);
+      _partitionId = Integer.parseInt(parts[idx]);
+      _tableName = Joiner.on(SEPARATOR).join(Arrays.copyOfRange(parts, 1, 
idx));
+      _segmentName = segmentName;
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid segment name: " + 
segmentName, e);
+    }
+  }
+
+  /**
+   * Constructor to create a segment name from the table name, partition id, 
sequence id, creation time and optional
+   * suffix
+   * @param tableName
+   * @param partitionId
+   * @param sequenceId
+   * @param msSinceEpoch
+   * @param suffix
+   */
+  public UploadedRealtimeSegmentName(String tableName, int partitionId, int 
sequenceId, long msSinceEpoch,
+      String suffix) {
+    _tableName = tableName;
+    _partitionId = partitionId;
+    _sequenceId = sequenceId;
+    _creationTime = DATE_FORMATTER.print(msSinceEpoch);
+    _suffix = suffix;
+    _segmentName = Joiner.on(SEPARATOR).skipNulls()
+        .join(UPLOADED_PREFIX, tableName, partitionId, sequenceId, 
_creationTime, suffix);
+  }
+
+  public static boolean isUploadedRealtimeSegmentName(String segmentName) {
+    String[] parts = StringUtils.splitByWholeSeparator(segmentName, SEPARATOR);
+    if (!(parts.length == 5 || parts.length == 6)) {
+      return false;
+    }
+    if (!parts[0].equals(UPLOADED_PREFIX)) {
+      return false;
+    }
+
+    int idx = parts.length == 5 ? parts.length - 1 : parts.length - 2;
+    // validate creation time is of format yyyyMMdd'T'HHmm'Z'
+    try {
+      DATE_FORMATTER.parseDateTime(parts[idx--]);
+    } catch (IllegalArgumentException e) {
+      return false;
+    }
+
+    // return false if sequenceId and partitionId are not int
+    try {
+      Integer.parseInt(parts[idx]);
+      Integer.parseInt(parts[idx - 1]);
+    } catch (NumberFormatException e) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Nullable
+  public static UploadedRealtimeSegmentName of(String segmentName) {
+    try {
+      return new UploadedRealtimeSegmentName(segmentName);
+    } catch (Exception e) {
+      return null;
+    }
+  }
+
+  public String getTableName() {
+    return _tableName;
+  }
+
+  public int getPartitionId() {
+    return _partitionId;
+  }
+
+  public int getSequenceId() {
+    return _sequenceId;
+  }
+
+  /**
+   * Returns the creation time in the format yyyyMMdd'T'HHmm'Z'
+   * To be used for only human readability and not for any computation
+   * @return
+   */
+  public String getCreationTime() {
+    return _creationTime;
+  }
+
+  public String getSegmentName() {
+    return _segmentName;
+  }
+
+  @Nullable
+  public String getSuffix() {
+    return _suffix;
+  }
+
+  @Override
+  public int compareTo(UploadedRealtimeSegmentName other) {
+    Preconditions.checkState(_tableName.equals(other._tableName));
+    if (_partitionId != other._partitionId) {
+      return Integer.compare(_partitionId, other._partitionId);
+    }
+    return Integer.compare(_sequenceId, other._sequenceId);
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (!(o instanceof UploadedRealtimeSegmentName)) {
+      return false;
+    }
+    UploadedRealtimeSegmentName that = (UploadedRealtimeSegmentName) o;
+    return _segmentName.equals(that._segmentName);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(_segmentName);
+  }
+
+  @Override
+  public String toString() {
+    return _segmentName;
+  }
+
+  // create a enum for source: externalUplaod, minion
+  public enum Source {

Review Comment:
   no need for this? as this would limit the potential suffix user wants to set



##########
pinot-common/src/main/java/org/apache/pinot/common/utils/UploadedRealtimeSegmentName.java:
##########
@@ -0,0 +1,199 @@
+/**
+ * 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.pinot.common.utils;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+
+/**
+ * Class to represent segment names like: 
uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}__{
+ * optionalSuffix}
+ *
+ * <p>This naming convention is adopted to represent a segment uploaded to a 
realtime table. The naming
+ * convention has been kept similar to {@LLCSegmentName} to but differentiates 
between stream generated LLCSegments
+ * based on the prefix "uploaded" and an optional suffix.
+ */
+public class UploadedRealtimeSegmentName implements 
Comparable<UploadedRealtimeSegmentName> {
+
+  private static final String UPLOADED_PREFIX = "uploaded";
+  private static final String SEPARATOR = "__";
+  private static final String DATE_FORMAT = "yyyyMMdd'T'HHmm'Z'";
+  private static final DateTimeFormatter DATE_FORMATTER = 
DateTimeFormat.forPattern(DATE_FORMAT).withZoneUTC();
+  private final String _tableName;
+  private final int _partitionId;
+  private final int _sequenceId;
+  private final String _creationTime;
+  private final String _segmentName;
+
+  @Nullable
+  private String _suffix = null;
+
+  public UploadedRealtimeSegmentName(String segmentName) {
+
+    // split the segment name by the separator and get creation time, sequence 
id, partition id and table name from
+    // the end and validate segment name starts with prefix uploaded_
+    try {
+      String[] parts = StringUtils.splitByWholeSeparator(segmentName, 
SEPARATOR);
+      Preconditions.checkState((parts.length == 5 || parts.length == 6) && 
parts[0].equals(UPLOADED_PREFIX),
+          "Uploaded segment name must be of the format "
+              + 
"uploaded__{tableName}__{partitionId}__{sequenceId}__{creationTime}");
+      int idx = parts.length - 1;
+      if (parts.length == 6) {
+        _suffix = parts[idx--];
+      }
+      _creationTime = parts[idx--];
+      _sequenceId = Integer.parseInt(parts[idx--]);
+      _partitionId = Integer.parseInt(parts[idx]);
+      _tableName = Joiner.on(SEPARATOR).join(Arrays.copyOfRange(parts, 1, 
idx));
+      _segmentName = segmentName;
+    } catch (NumberFormatException e) {
+      throw new IllegalArgumentException("Invalid segment name: " + 
segmentName, e);
+    }
+  }
+
+  /**
+   * Constructor to create a segment name from the table name, partition id, 
sequence id, creation time and optional
+   * suffix
+   * @param tableName
+   * @param partitionId
+   * @param sequenceId
+   * @param msSinceEpoch
+   * @param suffix
+   */
+  public UploadedRealtimeSegmentName(String tableName, int partitionId, int 
sequenceId, long msSinceEpoch,
+      String suffix) {
+    _tableName = tableName;
+    _partitionId = partitionId;
+    _sequenceId = sequenceId;
+    _creationTime = DATE_FORMATTER.print(msSinceEpoch);
+    _suffix = suffix;
+    _segmentName = Joiner.on(SEPARATOR).skipNulls()
+        .join(UPLOADED_PREFIX, tableName, partitionId, sequenceId, 
_creationTime, suffix);
+  }
+
+  public static boolean isUploadedRealtimeSegmentName(String segmentName) {
+    String[] parts = StringUtils.splitByWholeSeparator(segmentName, SEPARATOR);
+    if (!(parts.length == 5 || parts.length == 6)) {
+      return false;
+    }
+    if (!parts[0].equals(UPLOADED_PREFIX)) {
+      return false;
+    }
+
+    int idx = parts.length == 5 ? parts.length - 1 : parts.length - 2;
+    // validate creation time is of format yyyyMMdd'T'HHmm'Z'
+    try {
+      DATE_FORMATTER.parseDateTime(parts[idx--]);
+    } catch (IllegalArgumentException e) {
+      return false;
+    }
+
+    // return false if sequenceId and partitionId are not int
+    try {
+      Integer.parseInt(parts[idx]);
+      Integer.parseInt(parts[idx - 1]);
+    } catch (NumberFormatException e) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Nullable
+  public static UploadedRealtimeSegmentName of(String segmentName) {
+    try {
+      return new UploadedRealtimeSegmentName(segmentName);
+    } catch (Exception e) {
+      return null;
+    }
+  }
+
+  public String getTableName() {
+    return _tableName;
+  }
+
+  public int getPartitionId() {
+    return _partitionId;
+  }
+
+  public int getSequenceId() {
+    return _sequenceId;
+  }
+
+  /**
+   * Returns the creation time in the format yyyyMMdd'T'HHmm'Z'
+   * To be used for only human readability and not for any computation
+   * @return
+   */
+  public String getCreationTime() {
+    return _creationTime;
+  }
+
+  public String getSegmentName() {
+    return _segmentName;
+  }
+
+  @Nullable
+  public String getSuffix() {
+    return _suffix;
+  }
+
+  @Override
+  public int compareTo(UploadedRealtimeSegmentName other) {
+    Preconditions.checkState(_tableName.equals(other._tableName));

Review Comment:
   ```
   Preconditions.checkArgument(_tableName.equals(other._tableName),
           "Cannot compare segment names from different table: %s, %s", 
_segmentName, other.getSegmentName()); 
   ```
   (borrowed from LLCSegmentName class)



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/ConcurrentMapPartitionUpsertMetadataManager.java:
##########
@@ -158,6 +158,51 @@ protected void addOrReplaceSegment(ImmutableSegmentImpl 
segment, ThreadSafeMutab
     }
   }
 
+  /**
+   * <li> When the replacing segment and current segment are of {@link 
LLCSegmentName} then the PK should resolve to
+   * row in segment with higher sequence id.
+   * <li> When the replacing segment and current segment are of {@link 
UploadedRealtimeSegmentName} then the PK
+   * should resolve to row in segment with higher sequence id, creation time.
+   * <li> When either is of type {@link UploadedRealtimeSegmentName} then 
resolve on creation time, if same(rare
+   * scenario) then give preference to uploaded time
+   *

Review Comment:
   I'd propose, for all possible comparison between `LLC`, `Uploaded`, 
`Unknown`:
   1. if both LLC, compare seqId
   2. if both Uploaded, compare seqid+ctime
   3. if one segment is Uploaded and one is LLC, compare ctime but upon tie, 
favor Uploaded
   4. if there is a segment with Unknown format, return `false`, i.e. favor the 
one already set in metadata as of today's comparison logic. But we may favor 
the segment with known format, unless both segments are of Unknown format.
   
   thoughts?



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to