Jackie-Jiang commented on a change in pull request #6924: URL: https://github.com/apache/incubator-pinot/pull/6924#discussion_r633945719
########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/readers/PinotSegmentRecordReader.java ########## @@ -132,6 +133,15 @@ public void init(MutableSegment mutableSegment, @Nullable int[] sortedDocIds) { init(mutableSegment, false, null, sortedDocIds, null, false); } + /** + * Initializes the record reader from a immutable segment. Review comment: Move this function in front of the mutable segment one ```suggestion * Initializes the record reader from an immutable segment. ``` ########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/immutable/ImmutableSegmentImpl.java ########## @@ -171,7 +172,15 @@ public ValidDocIndexReader getValidDocIndex() { @Override public GenericRow getRecord(int docId, GenericRow reuse) { // NOTE: Use PinotSegmentRecordReader to read immutable segment Review comment: Remove this line ########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/immutable/ImmutableSegmentImpl.java ########## @@ -171,7 +172,15 @@ public ValidDocIndexReader getValidDocIndex() { @Override public GenericRow getRecord(int docId, GenericRow reuse) { // NOTE: Use PinotSegmentRecordReader to read immutable segment - throw new UnsupportedOperationException(); + try { + PinotSegmentRecordReader pinotSegmentRecordReader = new PinotSegmentRecordReader(); + pinotSegmentRecordReader.init(this); + pinotSegmentRecordReader.getRecord(reuse, docId); + return reuse; + } catch (Exception e) { + LOGGER.error("Failed to use PinotSegmentRecordReader to read immutable segment", e); Review comment: No need to log error here if we are throwing the exception ########## File path: pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/immutable/ImmutableSegmentImpl.java ########## @@ -171,7 +172,15 @@ public ValidDocIndexReader getValidDocIndex() { @Override public GenericRow getRecord(int docId, GenericRow reuse) { // NOTE: Use PinotSegmentRecordReader to read immutable segment - throw new UnsupportedOperationException(); + try { + PinotSegmentRecordReader pinotSegmentRecordReader = new PinotSegmentRecordReader(); Review comment: Please cache the record reader instead of creating one per `getRecord` call -- 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