public static void toString(Field field, int depth, StringBuilder b) { b.append("\n"); for (int i = 0; i < depth; i++) { b.append(" "); } b.append(field.getName()); b.append(";"); b.append(field.isNullable()); b.append(";"); b.append(Describer.describe(field.getType())); for (Field child : field.getChildren()) { toString(child, depth + 1, b); } }
@Override public boolean equals(Object obj) { if (!(obj instanceof Field)) { return false; } Field that = (Field) obj; return Objects.equals(this.name, that.name) && Objects.equals(this.isNullable(), that.isNullable()) && Objects.equals(this.getType(), that.getType()) && Objects.equals(this.getDictionary(), that.getDictionary()) && Objects.equals(this.getMetadata(), that.getMetadata()) && Objects.equals(this.children, that.children); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (name != null) { sb.append(name).append(": "); } sb.append(getType()); if (getDictionary() != null) { sb.append("[dictionary: ").append(getDictionary().getId()).append("]"); } if (!children.isEmpty()) { sb.append("<").append(children.stream() .map(t -> t.toString()) .collect(Collectors.joining(", "))) .append(">"); } if (!isNullable()) { sb.append(" not null"); } return sb.toString(); } }
@Override public int hashCode() { return Objects.hash(name, isNullable(), getType(), getDictionary(), getMetadata(), children); }
@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; }
private void showSingleBatch (VectorAccessibleSerializable vcSerializable, boolean showHeader) { final VectorContainer vectorContainer = vcSerializable.get(); /* show the header of the batch */ if (showHeader) { System.out.println(getBatchMetaInfo(vcSerializable).toString()); System.out.println("Schema Information"); for (final VectorWrapper w : vectorContainer) { final Field field = w.getValueVector().getField(); System.out.println (String.format("name : %s, minor_type : %s, data_mode : %s", field.getName(), getMinorTypeForArrowType(field.getType()).toString(), field.isNullable() ? "nullable":"non-nullable" )); } } /* show the contents in the batch */ VectorUtil.showVectorAccessibleContent(vectorContainer); }
private static List<Field> maskFields(List<Field> fields, FieldSelection selection) { ImmutableList.Builder<Field> fieldsListBuilder = ImmutableList.builder(); for (Field field : fields) { FieldSelection childSelection = selection.getChild(field.getName()); if (!childSelection.isNeverValid()) { if (field.getType().getTypeID() == ArrowTypeID.List) { Field innerField = field.getChildren().get(0); List<Field> childFields = maskFields(innerField.getChildren(), selection.getChild(field.getName())); Field newInnerField = new Field(innerField.getName(), innerField.isNullable(), innerField.getType(), childFields); fieldsListBuilder.add(new Field(field.getName(), field.isNullable(), field.getType(), Collections.singletonList(newInnerField))); } else { List<Field> childFields = maskFields(field.getChildren(), selection.getChild(field.getName())); fieldsListBuilder.add(new Field(field.getName(), field.isNullable(), field.getType(), childFields)); } } } return fieldsListBuilder.build(); }
return new Field(field.getName(), new FieldType(field.isNullable(), type, encoding, field.getMetadata()), updatedChildren);
/** * Helper method to ensure backward compatibility with schemas generated prior to ARROW-1347, ARROW-1663. * * @param field the field to check * @param originalChildField original field which name might be mutated * @return original or mutated field */ private static Field mutateOriginalNameIfNeeded(org.apache.arrow.flatbuf.Field field, Field originalChildField) { if ((field.typeType() == Type.List || field.typeType() == Type.FixedSizeList) && originalChildField.getName().equals("[DEFAULT]")) { return new Field(DATA_VECTOR_NAME, originalChildField.isNullable(), originalChildField.getType(), originalChildField.getDictionary(), originalChildField.getChildren(), originalChildField.getMetadata()); } return originalChildField; }
FieldType indexFieldType = new FieldType(valueField.isNullable(), dictionary.getEncoding().getIndexType(), dictionary.getEncoding(), valueField.getMetadata()); Field indexField = new Field(valueField.getName(), indexFieldType, null);
@Override protected BatchSchema constructSchema(FunctionLookupContext context) { final BatchSchema childSchema = child.getSchema(context); SchemaBuilder b = BatchSchema.newBuilder(); for (Field field : childSchema.getFields()) { // Revert back to original type if (dictionaryEncodedFields.containsKey(field.getName())) { b.addField(new Field(field.getName(), field.isNullable(), dictionaryEncodedFields.get(field.getName()).getArrowType(), field.getChildren())); } else { b.addField(field); } } b.setSelectionVectorMode(childSchema.getSelectionVectorMode()); return b.build(); }
return new Field(field.getName(), new FieldType(field.isNullable(), type, encoding, field.getMetadata()), updatedChildren);
final ValueVector vvOut = outgoing.addOrGet(new Field(field.getName(), field.isNullable(), config.getDictionaryEncodedFields().get(field.getName()).getArrowType(), field.getChildren()));
org.apache.arrow.flatbuf.Field.addName(builder, nameOffset); org.apache.arrow.flatbuf.Field.addNullable(builder, isNullable()); org.apache.arrow.flatbuf.Field.addTypeType(builder, getType().getTypeID().getFlatbufID()); org.apache.arrow.flatbuf.Field.addType(builder, typeOffset);