rohityadav1993 commented on code in PR #16727: URL: https://github.com/apache/pinot/pull/16727#discussion_r2366358075
########## pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/ColumnReader.java: ########## @@ -0,0 +1,83 @@ +/** + * 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.spi.data.readers; + +import java.io.Closeable; +import java.io.IOException; +import java.io.Serializable; +import javax.annotation.Nullable; + + +/** + * The <code>ColumnReader</code> interface is used to read column data from various data sources + * for columnar segment building. Unlike RecordReader which reads row-by-row, ColumnReader provides + * column-wise access to data, enabling efficient columnar segment creation. + * + * <p>This interface follows an iterator pattern similar to RecordReader: + * <ul> + * <li>Sequential iteration over all values in a column using hasNext() and next()</li> + * <li>Null value detection for the current value</li> + * <li>Rewind capability to restart iteration</li> + * <li>Resource cleanup</li> + * </ul> + * + * <p>Implementations should handle data type conversions, default values for new columns, + * and efficient column-wise data access patterns. + */ +public interface ColumnReader extends Closeable, Serializable { + + /** + * Return <code>true</code> if more values remain to be read in this column. + * <p>This method should not throw exception. Caller is not responsible for handling exceptions from this method. + */ + boolean hasNext(); + + /** + * Get the next value in the column. + * <p>This method should be called only if {@link #hasNext()} returns <code>true</code>. Caller is responsible for + * handling exceptions from this method and skip the value if user wants to continue reading the remaining values. + * + * @return Next column value, or null if the value is null + * @throws IOException If an I/O error occurs while reading + */ + @Nullable + Object next() throws IOException; + + /** + * Check if the current value (last returned by next()) is null. + * <p>This method should be called after {@link #next()} to check if the returned value represents a null. + * + * @return true if the current value is null, false otherwise + */ + boolean isNull(); Review Comment: Can be handled in `next()`, let me update. Originally, idea was to add custom null check handling in `isNull()`, e.g. "null" string --> null -- 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]
