suvodeep-pyne commented on code in PR #13913: URL: https://github.com/apache/pinot/pull/13913#discussion_r1742564600
########## pinot-plugins/pinot-input-format/pinot-csv/src/main/java/org/apache/pinot/plugin/inputformat/csv/CSVRecordReader.java: ########## @@ -202,158 +209,142 @@ public Map<String, Integer> getCSVHeaderMap() { @Override public boolean hasNext() { - if (_useLineIterator) { - // When line iterator is used, the call to this method won't throw an exception. The default and the only iterator - // from commons-csv library can throw an exception upon calling the hasNext() method. The line iterator overcomes - // this limitation. - return readNextRecord(); - } return _iterator.hasNext(); } @Override public GenericRow next() throws IOException { - if (_useLineIterator) { - return _nextRecord; - } else { - return next(new GenericRow()); - } + return next(new GenericRow()); } @Override public GenericRow next(GenericRow reuse) throws IOException { - if (_useLineIterator) { - reuse.init(_nextRecord); - } else { - CSVRecord record = _iterator.next(); - _recordExtractor.extract(record, reuse); - } + CSVRecord record = _iterator.next(); + _recordExtractor.extract(record, reuse); return reuse; } @Override public void rewind() throws IOException { - if (_useLineIterator) { - resetLineIteratorResources(); - } - if (_parser != null && !_parser.isClosed()) { _parser.close(); } - - init(); + closeIterator(); + initIterator(); } @Override public void close() throws IOException { - if (_useLineIterator) { - resetLineIteratorResources(); - } + closeIterator(); if (_parser != null && !_parser.isClosed()) { _parser.close(); } } - private boolean readNextRecord() { - try { - _nextRecord = null; - GenericRow genericRow = new GenericRow(); - readNextLine(genericRow); - _nextRecord = genericRow; - } catch (Exception e) { - LOGGER.info("Error parsing next record.", e); + private void closeIterator() + throws IOException { + // if header is not provided by the client it would be rebuilt. When it's provided by the client it's initialized Review Comment: `_skippedLinesCount` is not used anywhere other than logging. I think this ideally should be part of something like `recordReaderStats` that needs to come in through the interface. Then we can summarize, aggregate and escalate as metrics. Currently with a line of log, I just felt it wasn't adding a lot of value. Restoring this back meant casting `Iterator<>` to `LineIterator<>` or persisting it in the parent class at top level. I'd rather introduce a container for this and have readers publish metrics to it. 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