[ https://issues.apache.org/jira/browse/DRILL-5324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899873#comment-15899873 ]
Paul Rogers edited comment on DRILL-5324 at 3/7/17 6:13 PM: ------------------------------------------------------------ The idea is to provide a uniform column access interface, similar to how JDBC works (but much simpler!). Assume a row reader defined elsewhere: {code} public interface RowSetReader { boolean next(); ColumnReader column(int colIndex); } {code} Then, we can read values as follows. Assume a schema of (Int, VarChar): {code} RowSetReader reader = ...; assertEquals(10, reader.column(0).getInt()); assertEquals("foo", reader.column(1).getString()); {code} Proposed interfaces (without comments): {code} public enum ValueType { INTEGER, LONG, DOUBLE, STRING, BYTES } public interface ColumnReader { ValueType getType(); boolean isNull(); int getInt(); long getLong(); double getDouble(); String getString(); byte[] getBytes(); } public interface ColumnWriter { ValueType getType(); void setNull(); void setInt(int value); void setLong(long value); void setDouble(double value); void setString(String value); void setBytes(byte[] value); } {code} was (Author: paul-rogers): The idea is to provide a uniform column access interface, similar to how JDBC works (but much simpler!). Assume a row reader defined elsewhere: {code} public interface RowSetReader { boolean next(); ColumnReader column(int colIndex); } {code} Then, we can read values as follows. Assume a schema of (Int, VarChar): {code} RowSetReader reader = ...; assertEquals(10, reader.column(0).getInt()); assertEquals("foo", reader.column(1).getString()); {code} Proposed interfaces (without comments): {code} public interface ColumnReader { ValueType getType(); boolean isNull(); int getInt(); long getLong(); double getDouble(); String getString(); byte[] getBytes(); } public interface ColumnWriter { ValueType getType(); void setNull(); void setInt(int value); void setLong(long value); void setDouble(double value); void setString(String value); void setBytes(byte[] value); } {code} > Provide simplified column reader/writer for use in tests > -------------------------------------------------------- > > Key: DRILL-5324 > URL: https://issues.apache.org/jira/browse/DRILL-5324 > Project: Apache Drill > Issue Type: Sub-task > Components: Tools, Build & Test > Affects Versions: 1.11.0 > Reporter: Paul Rogers > Assignee: Paul Rogers > Fix For: 1.11.0 > > > In support of DRILL-5323, we wish to provide a very easy way to work with row > sets. See the comment section for examples of the target API. > Drill provides over 100 different value vectors, any of which may be required > to perform a specific unit test. Creating these vectors, populating them, and > retrieving values, is very tedious. The work is so complex that it acts to > discourage developers from writing such tests. > To simplify the task, we wish to provide a simplified row set reader and > writer. To do that, we need to generate the corresponding column reader and > writer for each value vector. This ticket focuses on the column-level readers > and writers, and the required code generation. > Drill already provides vector readers and writers derived from > {{FieldReader}}. However, these readers do not provide a uniform get/set > interface that is type independent on the application side. Instead, > application code must be aware of the type of the vector, something we seek > to avoid for test code. > The reader and writer classes are designed to be used in many contexts, not > just for testing. As a result, their implementation makes no assumptions > about the broader row reader and writer, other than that a row index and the > required value vector are both available. -- This message was sent by Atlassian JIRA (v6.3.15#6346)