@Override public void visit(PrimitiveType primitiveType) { if (!currentRequestedType.isPrimitive() || (this.strictTypeChecking && currentRequestedType.asPrimitiveType().getPrimitiveTypeName() != primitiveType.getPrimitiveTypeName())) { incompatibleSchema(primitiveType, currentRequestedType); } PrimitiveColumnIO newIO = new PrimitiveColumnIO(primitiveType, current, currentRequestedIndex, leaves.size()); current.add(newIO); leaves.add(newIO); }
private void visitChildren(GroupColumnIO newIO, GroupType groupType, GroupType requestedGroupType) { GroupColumnIO oldIO = current; current = newIO; for (Type type : groupType.getFields()) { // if the file schema does not contain the field it will just stay null if (requestedGroupType.containsField(type.getName())) { currentRequestedIndex = requestedGroupType.getFieldIndex(type.getName()); currentRequestedType = requestedGroupType.getType(currentRequestedIndex); if (currentRequestedType.getRepetition().isMoreRestrictiveThan(type.getRepetition())) { incompatibleSchema(type, currentRequestedType); } type.accept(this); } } current = oldIO; }
@Override public void visit(MessageType messageType) { columnIO = new MessageColumnIO(messageType, validating); visitChildren(columnIO, messageType); columnIO.setLevels(); columnIO.setLeaves(leaves); }
/** * @param schema the schema we want to read/write * @return the corresponding serializing/deserializing structure */ public MessageColumnIO getColumnIO(MessageType schema) { ColumnIOCreatorVisitor visitor = new ColumnIOCreatorVisitor(validating); schema.accept(visitor); return visitor.getColumnIO(); }
@Override public void visit(GroupType groupType) { GroupColumnIO newIO; if (groupType.getRepetition() == Repetition.REPEATED) { newIO = new GroupColumnIO(groupType, current, current.getChildrenCount()); } else { newIO = new GroupColumnIO(groupType, current, current.getChildrenCount()); } current.add(newIO); visitChildren(newIO, groupType); }
/** * @param schema the requestedSchema we want to read/write * @param fileSchema the file schema (when reading it can be different from the requested schema) * @param strict should file type and requested primitive types match * @return the corresponding serializing/deserializing structure */ public MessageColumnIO getColumnIO(MessageType requestedSchema, MessageType fileSchema, boolean strict) { ColumnIOCreatorVisitor visitor = new ColumnIOCreatorVisitor(validating, requestedSchema, strict); fileSchema.accept(visitor); return visitor.getColumnIO(); }
@Override public void visit(GroupType groupType) { if (currentRequestedType.isPrimitive()) { incompatibleSchema(groupType, currentRequestedType); } GroupColumnIO newIO = new GroupColumnIO(groupType, current, currentRequestedIndex); current.add(newIO); visitChildren(newIO, groupType, currentRequestedType.asGroupType()); }
@Override public void visit(MessageType messageType) { columnIO = new MessageColumnIO(requestedSchema, validating); visitChildren(columnIO, messageType, requestedSchema); columnIO.setLevels(); columnIO.setLeaves(leaves); }