final ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo; final TypeInfo elementTypeInfo = listTypeInfo.getListElementTypeInfo(); return new Field(name, FieldType.nullable(MinorType.LIST.getType()), Lists.newArrayList(toField(DEFAULT_ARROW_FIELD_NAME, elementTypeInfo))); case STRUCT: structFields.add(toField(fieldNames.get(i), fieldTypeInfos.get(i))); return new Field(name, FieldType.nullable(MinorType.STRUCT.getType()), structFields); case UNION: final UnionTypeInfo unionTypeInfo = (UnionTypeInfo) typeInfo; unionFields.add(toField(DEFAULT_ARROW_FIELD_NAME, objectTypeInfos.get(i))); return new Field(name, FieldType.nullable(MinorType.UNION.getType()), unionFields); case MAP: final MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo;
public Field toField(String name) { return new Field(name, true, type, children); }
/** * Shortcut method for returning a field * given an arrow type and name * with no sub fields * @param name the name of the field * @param arrowType the arrow type of the field * @return the resulting field */ public static Field field(String name,ArrowType arrowType) { return new Field(name,FieldType.nullable(arrowType), new ArrayList<Field>()); }
@Override public Field getField() { List<Field> children = new ArrayList<>(); for (ValueVector child : getChildren()) { children.add(child.getField()); } return new Field(name, fieldType, children); }
public static Field getFieldForNameAndMajorType(String name, MajorType majorType) { try { return new Field( name, true, getArrowTypeForMajorType(majorType), getChildrenForMajorType(majorType) ); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Could not get field for name: %s, majorType:%s", name, majorType), e); } }
@Override public Field getField() { List<Field> children = Collections.singletonList(getDataVector().getField()); return new Field(name, fieldType, children); }
public BaseFixedWidthVector(final String name, final BufferAllocator allocator, FieldType fieldType, final int typeWidth) { super(name, allocator); this.typeWidth = typeWidth; field = new Field(name, fieldType, null); valueCount = 0; allocationMonitor = 0; validityBuffer = allocator.getEmpty(); valueBuffer = allocator.getEmpty(); initialValueAllocation = INITIAL_VALUE_ALLOCATION; }
@Override public <T extends FieldVector> T addOrGet(String childName, FieldType fieldType, Class<T> clazz) { try { Field field = new Field(childName, fieldType, null); final FieldVector v = mutator.addField(field, clazz); putChild(childName, v); return this.typeify(v, clazz); } catch (SchemaChangeException e) { throw new IllegalStateException(e); } }
private Field getVector(String name, MajorType type, int length) { assert context != null : "Context shouldn't be null."; final Field f = new Field(name, true, getArrowTypeForMajorType(type), null); return f; }
@Override public <T extends FieldVector> T addOrGet(String childName, FieldType fieldType, Class<T> clazz) { Field field = new Field(childName, fieldType, null); final FieldVector v = vc.addOrGet(field); putChild(childName, v); return this.typeify(v, clazz); }
public void setup(OutputMutator output){ vector = (DecimalVector)output.getVector(name); if (vector == null) { vector = output.addField(new Field(name, true, new Decimal(precision, scale), null), DecimalVector.class); } }
@Override public Field visit(ArrowType.List type) { if(field.getName().equals(column.getAsUnescapedPath())){ Field child = field.getChildren().get(0); return new Field(field.getName(), child.isNullable(), child.getType(), child.getChildren()); } return field; }
public <T extends ValueVector> T addOrGet(String name, MajorType type, Class<T> clazz) { Field field = new Field(name, true, getArrowMinorType(type.getMinorType()).getType(), null); return addOrGet(field); }
@Override public Field toField(String name) { return new Field(name, true, getType(), ImmutableList.of(CompleteType.BIGINT.toField("$data$"))); } }
@Override public void init(OutputMutator output) throws SchemaChangeException { // MaterializedField mf = MajorTypeHelper.getFieldForNameAndMajorType(field.getName(), type); org.apache.arrow.vector.types.pojo.Field mf = new org.apache.arrow.vector.types.pojo.Field(field.getName(), true, getArrowMinorType(type.getMinorType()).getType(), null); @SuppressWarnings("unchecked") Class<V> valueVectorClass = (Class<V>) TypeHelper.getValueVectorClass(getArrowMinorType(type.getMinorType())); this.vector = output.addField(mf, valueVectorClass); }
@Override public Field getField() { List<org.apache.arrow.vector.types.pojo.Field> childFields = new ArrayList<>(); List<FieldVector> children = internalStruct.getChildren(); int[] typeIds = new int[children.size()]; for (ValueVector v : children) { typeIds[childFields.size()] = v.getMinorType().ordinal(); childFields.add(v.getField()); } return new Field(name, FieldType.nullable(new ArrowType.Union(Sparse, typeIds)), childFields); }
public void setup(OutputMutator output){ vector = (DecimalVector)output.getVector(pair.getName()); if (vector == null) { vector = output.addField(new Field(pair.getName(), true, new Decimal(value.precision, value.scale), null), DecimalVector.class); } }
public BatchSchema getSchema() { SchemaBuilder builder = BatchSchema.newBuilder() .addField(new Field("n_nationKey", true, MinorType.BIGINT.getType(), null)) .addField(new Field("n_name", true, MinorType.VARCHAR.getType(), null)) .addField(new Field("n_regionKey", true, MinorType.BIGINT.getType(), null)) .addField(new Field("n_comment", true, MinorType.VARCHAR.getType(), null)); return builder.build(); } }
public BatchSchema getSchema() { SchemaBuilder builder = BatchSchema.newBuilder() .addField(new Field("n_nationKey", true, MinorType.BIGINT.getType(), null)) .addField(new Field("n_name", true, MinorType.VARCHAR.getType(), null)) .addField(new Field("n_regionKey", true, MinorType.BIGINT.getType(), null)) .addField(new Field("n_comment", true, MinorType.VARCHAR.getType(), null)); return builder.build(); } }
@Test public void falseWhenChildrenAreSelected() { BatchSchema schema = mock(BatchSchema.class); when(schema.iterator()) .thenReturn(Lists.newArrayList( new Field("a1", new FieldType(true, new ArrowType.Struct(), null), Lists.newArrayList(Field.nullable("a2", new ArrowType.Bool()))), Field.nullable("a3", new ArrowType.Bool())).iterator()); assertFalse(EasyScanOperatorCreator.selectsAllColumns(schema, Lists.newArrayList(SchemaPath.getSimplePath("a1"), SchemaPath.getCompoundPath("a1", "a2"), SchemaPath.getSimplePath("a3")))); }