Jackie-Jiang commented on a change in pull request #6899: URL: https://github.com/apache/incubator-pinot/pull/6899#discussion_r656358418
########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImpl.java ########## @@ -470,28 +466,32 @@ public void addExtraColumns(Schema newSchema) { @Override public boolean index(GenericRow row, @Nullable RowMetadata rowMetadata) throws IOException { - // Update dictionary first - updateDictionary(row); - - // If metrics aggregation is enabled and if the dimension values were already seen, this will return existing docId, - // else this will return a new docId. - int docId = getOrCreateDocId(); - boolean canTakeMore; - if (docId == _numDocsIndexed) { - // New row + if (isUpsertEnabled()) { + row = handleUpsert(row, _numDocsIndexed); + + updateDictionary(row); addNewRow(row); // Update number of documents indexed at last to make the latest row queryable canTakeMore = _numDocsIndexed++ < _capacity; - - if (isUpsertEnabled()) { - handleUpsert(row, docId); - } } else { - Preconditions.checkArgument(!isUpsertEnabled(), "metrics aggregation cannot be used with upsert"); - assert _aggregateMetrics; - aggregateMetrics(row, docId); - canTakeMore = true; + // Update dictionary first + updateDictionary(row); + + // If metrics aggregation is enabled and if the dimension values were already seen, this will return existing + // docId, else this will return a new docId. + int docId = getOrCreateDocId(); + + if (docId == _numDocsIndexed) { + // New row + addNewRow(row); + // Update number of documents indexed at last to make the latest row queryable + canTakeMore = _numDocsIndexed++ < _capacity; + } else { + assert _aggregateMetrics; Review comment: @deemoliu Please remove this pre-condition check. The check is already performed in the constructor, and the assert here is just for readability -- 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. 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