@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 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); }
/** * Provide a value look up dictionary based on the * given set of input {@link FieldVector} s for * reading and writing to arrow streams * @param vectors the vectors to use as a lookup * @return the associated {@link DictionaryProvider} for the given * input {@link FieldVector} list */ public static DictionaryProvider providerForVectors(List<FieldVector> vectors,List<Field> fields) { Dictionary[] dictionaries = new Dictionary[vectors.size()]; for(int i = 0; i < vectors.size(); i++) { DictionaryEncoding dictionary = fields.get(i).getDictionary(); if(dictionary == null) { dictionary = new DictionaryEncoding(i,true,null); } dictionaries[i] = new Dictionary(vectors.get(i), dictionary); } return new DictionaryProvider.MapDictionaryProvider(dictionaries); }
@Override public int hashCode() { return Objects.hash(name, isNullable(), getType(), getDictionary(), getMetadata(), children); }
DictionaryEncoding encoding = field.getDictionary(); List<Field> children = field.getChildren();
/** * 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; }
DictionaryEncoding encoding = field.getDictionary(); List<Field> children = field.getChildren();
int typeOffset = getType().getType(builder); int dictionaryOffset = -1; DictionaryEncoding dictionary = getDictionary(); if (dictionary != null) { int dictionaryType = dictionary.getIndexType().getType(builder);