private static GroupType buildProjectedGroupType( GroupType originalType, List<Type> types) { if (types == null || types.isEmpty()) { return null; } return new GroupType(originalType.getRepetition(), originalType.getName(), types); }
/** * {@inheritDoc} */ @Override public void writeToStringBuilder(StringBuilder sb, String indent) { sb.append(indent) .append(getRepetition().name().toLowerCase(Locale.ENGLISH)) .append(" group ") .append(getName()) .append(getOriginalType() == null ? "" : " (" + getOriginalType() +")") .append(getId() == null ? "" : " = " + getId()) .append(" {\n"); membersDisplayString(sb, indent + " "); sb.append(indent) .append("}"); }
/** * {@inheritDoc} */ @Override public void writeToStringBuilder(StringBuilder sb, String indent) { sb.append(indent) .append(getRepetition().name().toLowerCase(Locale.ENGLISH)) .append(" group ") .append(getName()) .append(getLogicalTypeAnnotation() == null ? "" : " (" + getLogicalTypeAnnotation().toString() +")") .append(getId() == null ? "" : " = " + getId()) .append(" {\n"); membersDisplayString(sb, indent + " "); sb.append(indent) .append("}"); }
/** * @param newFields a list of types to use as fields in a copy of this group * @return a group with the same attributes and new fields. */ public GroupType withNewFields(List<Type> newFields) { return new GroupType(getRepetition(), getName(), getOriginalType(), newFields, getId()); }
/** * @param newFields a list of types to use as fields in a copy of this group * @return a group with the same attributes and new fields. */ public GroupType withNewFields(List<Type> newFields) { return new GroupType(getRepetition(), getName(), getLogicalTypeAnnotation(), newFields, getId()); }
/** * @param id the field id * @return a new GroupType with the same fields and a new id */ @Override public GroupType withId(int id) { return new GroupType(getRepetition(), getName(), getLogicalTypeAnnotation(), fields, new ID(id)); }
/** * @param id the field id * @return a new GroupType with the same fields and a new id */ @Override public GroupType withId(int id) { return new GroupType(getRepetition(), getName(), getOriginalType(), fields, new ID(id)); }
@Override public Type list(GroupType list, Type element) { GroupType repeated = list.getType(0).asGroupType(); Type originalElement = repeated.getType(0); int elementId = getId(originalElement); if (selectedIds.contains(elementId)) { return list; } else if (element != null) { if (element != originalElement) { // the element type was projected return Types.list(list.getRepetition()) .element(element) .id(getId(list)) .named(list.getName()); } return list; } return null; }
@Override public Type map(GroupType map, Type key, Type value) { GroupType repeated = map.getType(0).asGroupType(); Type originalKey = repeated.getType(0); Type originalValue = repeated.getType(1); int keyId = getId(originalKey); int valueId = getId(originalValue); if (selectedIds.contains(keyId) || selectedIds.contains(valueId)) { return map; } else if (value != null) { if (value != originalValue) { return Types.map(map.getRepetition()) .key(originalKey) .value(value) .id(getId(map)) .named(map.getName()); } return map; } return null; }
@Override public void visit(GroupType groupType) { SchemaElement element = new SchemaElement(groupType.getName()); element.setRepetition_type(toParquetRepetition(groupType.getRepetition())); if (groupType.getOriginalType() != null) { element.setConverted_type(getConvertedType(groupType.getOriginalType())); } if (groupType.getId() != null) { element.setField_id(groupType.getId().intValue()); } visitChildren(result, groupType, element); }
@Override public void visit(GroupType groupType) { SchemaElement element = new SchemaElement(groupType.getName()); element.setRepetition_type(toParquetRepetition(groupType.getRepetition())); if (groupType.getLogicalTypeAnnotation() != null) { element.setConverted_type(convertToConvertedType(groupType.getLogicalTypeAnnotation())); element.setLogicalType(convertToLogicalType(groupType.getLogicalTypeAnnotation())); } if (groupType.getId() != null) { element.setField_id(groupType.getId().intValue()); } visitChildren(result, groupType, element); }