if (type.isPrimitive()) { checkInspectorCategory(inspector, ObjectInspector.Category.PRIMITIVE); writePrimitive(value, (PrimitiveObjectInspector) inspector);
/** * @return this if it's a group type * @throws ClassCastException if not */ public GroupType asGroupType() { if (isPrimitive()) { throw new ClassCastException(this + " is not a group"); } return (GroupType)this; }
public GroupType asGroupType() { if (isPrimitive()) { throw new ClassCastException(this.getName() + " is not a group"); } return (GroupType)this; }
private Converter newConverter(Type type, int i) { if(!type.isPrimitive()) { throw new IllegalArgumentException("cascading can only build tuples from primitive types"); } else { return new TuplePrimitiveConverter(this, i); } }
void membersDisplayString(StringBuilder sb, String indent) { for (Type field : fields) { field.writeToStringBuilder(sb, indent); if (field.isPrimitive()) { sb.append(";"); } sb.append("\n"); } }
public PrimitiveType asPrimitiveType() { if (!isPrimitive()) { throw new ClassCastException(this.getName() + " is not a primititve"); } return (PrimitiveType)this; }
private Column convertField(final Type fieldType) { if (fieldType.isPrimitive()) { return convertPrimitiveField(fieldType); } else { return convertComplexField(fieldType); } }
private static BlockConverter createConverter(Type prestoType, String columnName, parquet.schema.Type parquetType, int fieldIndex) { if (parquetType.isPrimitive()) { return new ParquetPrimitiveConverter(prestoType, fieldIndex); } return createGroupConverter(prestoType, columnName, parquetType, fieldIndex); }
/** * {@inheritDoc} */ @Override protected boolean equals(Type otherType) { return !otherType.isPrimitive() && super.equals(otherType) && getFields().equals(otherType.asGroupType().getFields()); }
private FieldSchema getFieldSchema(Type parquetType) throws FrontendException { final String fieldName = parquetType.getName(); if (parquetType.isPrimitive()) { return getSimpleFieldSchema(fieldName, parquetType); } else { return getComplexFieldSchema(fieldName, parquetType); } }
@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); }
protected static Converter getConverterFromDescription(Type type, int index, ConverterParent parent) { if (type == null) { return null; } if (type.isPrimitive()) { return getConverterFromDescription(type.asPrimitiveType(), index, parent); } return getConverterFromDescription(type.asGroupType(), index, parent); }
@Override void checkContains(Type subType) { super.checkContains(subType); if (!subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } PrimitiveType primitiveType = subType.asPrimitiveType(); if (this.primitive != primitiveType.primitive) { throw new InvalidRecordException(subType + " found: expected " + this); } }
@Override void checkContains(Type subType) { super.checkContains(subType); if (!subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } PrimitiveType primitiveType = subType.asPrimitiveType(); if (this.primitive != primitiveType.primitive) { throw new InvalidRecordException(subType + " found: expected " + this); } }
private boolean contains(GroupType group, String[] path, int index) { if (index == path.length) { return false; } if (group.containsField(path[index])) { Type type = group.getType(path[index]); if (type.isPrimitive()) { return index + 1 == path.length; } else { return contains(type.asGroupType(), path, index + 1); } } return false; }
@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()); }
void checkGroupContains(Type subType) { if (subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } List<Type> fields = subType.asGroupType().getFields(); for (Type otherType : fields) { Type thisType = this.getType(otherType.getName()); thisType.checkContains(otherType); } }
@Override protected Type union(Type toMerge, boolean strict) { if (toMerge.isPrimitive()) { throw new IncompatibleSchemaModificationException("can not merge primitive type " + toMerge + " into group type " + this); } return new GroupType(toMerge.getRepetition(), getName(), mergeFields(toMerge.asGroupType())); }
private void writeNull(ColumnIO undefinedField, int r, int d) { if (undefinedField.getType().isPrimitive()) { columnWriter[((PrimitiveColumnIO)undefinedField).getId()].writeNull(r, d); } else { GroupColumnIO groupColumnIO = (GroupColumnIO)undefinedField; int childrenCount = groupColumnIO.getChildrenCount(); for (int i = 0; i < childrenCount; i++) { writeNull(groupColumnIO.getChild(i), r, d); } } }
private void writeNull(ColumnIO undefinedField, int r, int d) { if (undefinedField.getType().isPrimitive()) { columnWriter[((PrimitiveColumnIO)undefinedField).getId()].writeNull(r, d); } else { GroupColumnIO groupColumnIO = (GroupColumnIO)undefinedField; int childrenCount = groupColumnIO.getChildrenCount(); for (int i = 0; i < childrenCount; i++) { writeNull(groupColumnIO.getChild(i), r, d); } } }