use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by apache.
the class HDF5BatchReader method getColWriter.
private ScalarWriter getColWriter(TupleWriter tupleWriter, String fieldName, TypeProtos.MinorType type) {
int index = tupleWriter.tupleSchema().index(fieldName);
if (index == -1) {
ColumnMetadata colSchema = MetadataUtils.newScalar(fieldName, type, TypeProtos.DataMode.OPTIONAL);
index = tupleWriter.addColumn(colSchema);
}
return tupleWriter.scalar(index);
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by apache.
the class HDF5BatchReader method writeIntListColumn.
/**
* Helper function to write a 2D int list
* @param rowWriter the row to which the data will be written
* @param name the name of the outer list
* @param list the list of data
*/
private void writeIntListColumn(TupleWriter rowWriter, String name, int[] list) {
int index = rowWriter.tupleSchema().index(name);
if (index == -1) {
ColumnMetadata colSchema = MetadataUtils.newScalar(name, TypeProtos.MinorType.INT, TypeProtos.DataMode.REPEATED);
index = rowWriter.addColumn(colSchema);
}
ScalarWriter arrayWriter = rowWriter.column(index).array().scalar();
int maxElements = Math.min(list.length, PREVIEW_ROW_LIMIT);
for (int i = 0; i < maxElements; i++) {
arrayWriter.setInt(list[i]);
}
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by apache.
the class HDF5BatchReader method writeFloat8ListColumn.
private void writeFloat8ListColumn(TupleWriter rowWriter, String name, double[] list) {
int index = rowWriter.tupleSchema().index(name);
if (index == -1) {
ColumnMetadata colSchema = MetadataUtils.newScalar(name, TypeProtos.MinorType.FLOAT8, TypeProtos.DataMode.REPEATED);
index = rowWriter.addColumn(colSchema);
}
ScalarWriter arrayWriter = rowWriter.column(index).array().scalar();
int maxElements = Math.min(list.length, PREVIEW_ROW_LIMIT);
for (int i = 0; i < maxElements; i++) {
arrayWriter.setDouble(list[i]);
}
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by apache.
the class ShpBatchReader method writeStringColumn.
private void writeStringColumn(TupleWriter rowWriter, String name, String value) {
int index = rowWriter.tupleSchema().index(name);
if (index == -1) {
ColumnMetadata colSchema = MetadataUtils.newScalar(name, TypeProtos.MinorType.VARCHAR, TypeProtos.DataMode.OPTIONAL);
index = rowWriter.addColumn(colSchema);
}
ScalarWriter colWriter = rowWriter.scalar(index);
colWriter.setString(value);
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by apache.
the class ShpBatchReader method writeIntColumn.
private void writeIntColumn(TupleWriter rowWriter, String name, int value) {
int index = rowWriter.tupleSchema().index(name);
if (index == -1) {
ColumnMetadata colSchema = MetadataUtils.newScalar(name, TypeProtos.MinorType.INT, TypeProtos.DataMode.OPTIONAL);
index = rowWriter.addColumn(colSchema);
}
ScalarWriter colWriter = rowWriter.scalar(index);
colWriter.setInt(value);
}
Aggregations