public OrcStruct serialize(BaseRow row, OrcStruct struct) { for (int i = 0; i < fieldConverters.length; i++) { if (row.isNullAt(i)) { struct.setFieldValue(i, null); } else { struct.setFieldValue(i, fieldConverters[i].convert(BaseRowUtil.get(row, i, fieldTypes[i]))); } } return struct; }
static OrcStruct nextStruct(ColumnVector vector, int row, TypeDescription schema, Object previous) { if (vector.isRepeating) { row = 0; } if (vector.noNulls || !vector.isNull[row]) { OrcStruct result; List<TypeDescription> childrenTypes = schema.getChildren(); int numChildren = childrenTypes.size(); if (previous == null || previous.getClass() != OrcStruct.class) { result = new OrcStruct(schema); } else { result = (OrcStruct) previous; } StructColumnVector struct = (StructColumnVector) vector; for(int f=0; f < numChildren; ++f) { result.setFieldValue(f, nextValue(struct.fields[f], row, childrenTypes.get(f), result.getFieldValue(f))); } return result; } else { return null; } }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (!ensureBatch()) { return false; } if (schema.getCategory() == TypeDescription.Category.STRUCT) { OrcStruct result = (OrcStruct) row; List<TypeDescription> children = schema.getChildren(); int numberOfChildren = children.size(); for(int i=0; i < numberOfChildren; ++i) { result.setFieldValue(i, OrcMapredRecordReader.nextValue(batch.cols[i], rowInBatch, children.get(i), result.getFieldValue(i))); } } else { OrcMapredRecordReader.nextValue(batch.cols[0], rowInBatch, schema, row); } rowInBatch += 1; return true; }
@Override public boolean next(NullWritable key, V value) throws IOException { if (!ensureBatch()) { return false; } if (schema.getCategory() == TypeDescription.Category.STRUCT) { OrcStruct result = (OrcStruct) value; List<TypeDescription> children = schema.getChildren(); int numberOfChildren = children.size(); for(int i=0; i < numberOfChildren; ++i) { result.setFieldValue(i, nextValue(batch.cols[i], rowInBatch, children.get(i), result.getFieldValue(i))); } } else { nextValue(batch.cols[0], rowInBatch, schema, value); } rowInBatch += 1; return true; }
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (key == null || key.fileName == null) { key = new CombineFileWritable(); key.fileName = path.toString(); } if (!ensureBatch()) { return false; } if (schema.getCategory() == TypeDescription.Category.STRUCT) { OrcStruct result = row; List<TypeDescription> children = schema.getChildren(); int numberOfChildren = children.size(); for (int i = 0; i < numberOfChildren; ++i) { result.setFieldValue(i, OrcMapredRecordReader.nextValue(batch.cols[i], rowInBatch, children.get(i), result.getFieldValue(i))); } } else { OrcMapredRecordReader.nextValue(batch.cols[0], rowInBatch, schema, row); } rowInBatch += 1; return true; }
int c = 0; for(TypeDescription child: type.getChildren()) { result.setFieldValue(c++, createValue(child));