/** * Given the target type, get the appropriate cast function * @param targetMinorType the target data type * @return the name of cast function */ public static String getCastFunc(MinorType targetMinorType) { String func = TYPE_TO_CAST_FUNC.get(targetMinorType); if (func != null) { return func; } throw new IllegalArgumentException( String.format("cast function for type %s is not defined", targetMinorType.name())); }
/** * The union vector is a map of types. The following method provides * the standard name to use in the type map. It replaces the many * ad-hoc appearances of this code in each reference to the map. * * @param type Drill data type * @return string key to use for this type in a union vector type * map */ public static String typeKey(MinorType type) { return type.name().toLowerCase(); } }
.append(name) .append("` (") .append(type.getMinorType().name());
public static UnsupportedConversionError nullError(ColumnMetadata schema) { return new UnsupportedConversionError( String.format("Column `%s`: Type %s %s is not nullable", schema.name(), schema.mode().name(), schema.type().name())); } }
private static final void appendType(MajorType mt, StringBuilder sb) { sb.append(mt.getMinorType().name()); sb.append(":"); sb.append(mt.getMode().name()); }
private InvalidAccessException newInvalidAccessException(String name) { return new InvalidAccessException( String.format( "Requesting value of type %s for an object of type %s:%s is not allowed.", name, getType().getMinorType().name(), getType().getMode().name())); } }
/** * The union vector is a map of types. The following method provides * the standard name to use in the type map. It replaces the many * ad-hoc appearances of this code in each reference to the map. * * @param type Drill data type * @return string key to use for this type in a union vector type * map */ public static String typeKey(MinorType type) { return type.name().toLowerCase(); } }
public static UnsupportedConversionError readError(ColumnMetadata schema, String javaType) { return new UnsupportedConversionError( String.format("Column `%s`: Unsupported conversion from Drill type %s to Java type %s", schema.name(), schema.type().name(), javaType)); }
public static UnsupportedConversionError writeError(ColumnMetadata schema, String javaType) { return new UnsupportedConversionError( String.format("Column `%s`: Unsupported conversion from Java type %s to Drill type %s", schema.name(), schema.type().name(), javaType)); }
private static void printType(MaterializedField field, StringBuilder msg) { final MajorType type = field.getType(); msg.append(type.getMinorType().name()); msg.append(':'); msg.append(type.getMode().name()); }
@Override public void eval() { String typeName = input.getType().getMinorType().name(); byte[] type = typeName.getBytes(); buf = buf.reallocIfNeeded(type.length); buf.setBytes(0, type); out.buffer = buf; out.start = 0; out.end = type.length; } }
e.getInput().accept(this, sb); sb.append(" ) as "); sb.append(mt.getMinorType().name());
throw UserException .dataWriteError() .message("Data type: '%s' not supported in Kudu.", t.getMinorType().name()) .build(logger);
/** * "Classic" way to add a subtype when working directly with a union vector. * Creates the vector, adds it to the internal structures and creates a * new buffer of the default size. * * @param type the type to add * @param vectorClass class of the vector to create * @return typed form of the new value vector */ private <T extends ValueVector> T classicAddType(MinorType type, Class<? extends ValueVector> vectorClass) { int vectorCount = internalMap.size(); @SuppressWarnings("unchecked") T vector = (T) internalMap.addOrGet(type.name().toLowerCase(), MAJOR_TYPES[type.ordinal()], vectorClass); cachedSubtypes[type.ordinal()] = vector; if (internalMap.size() > vectorCount) { vector.allocateNew(); addSubType(type); if (callBack != null) { callBack.doWork(); } } return vector; }
private FieldWriter promoteToUnion() { String name = vector.getField().getName(); TransferPair tp = vector.getTransferPair(vector.getField().getType().getMinorType().name().toLowerCase(), vector.getAllocator()); tp.transfer(); if (parentContainer != null) { unionVector = parentContainer.addOrGet(name, Types.optional(MinorType.UNION), UnionVector.class); } else if (listVector != null) { unionVector = listVector.promoteToUnion(); } unionVector.addVector(tp.getTo()); writer = new UnionWriter(unionVector); writer.setPosition(idx()); for (int i = 0; i < idx(); i++) { unionVector.getMutator().setType(i, vector.getField().getType().getMinorType()); } vector = null; state = State.UNION; return writer; }
/** * Add a vector that matches the argument. Transfer the buffer from the argument * to the new vector. * * @param v the vector to clone and add * @return the cloned vector that now holds the data from the argument */ public ValueVector addVector(ValueVector v) { String name = v.getField().getType().getMinorType().name().toLowerCase(); MajorType type = v.getField().getType(); MinorType minorType = type.getMinorType(); Preconditions.checkState(internalMap.getChild(name) == null, String.format("%s vector already exists", name)); final ValueVector newVector = internalMap.addOrGet(name, type, BasicTypeHelper.getValueVectorClass(minorType, type.getMode())); v.makeTransferPair(newVector).transfer(); internalMap.putChild(name, newVector); cachedSubtypes[minorType.ordinal()] = newVector; addSubType(minorType); return newVector; }
/** * Add an externally-created subtype vector. The vector must represent a type that * does not yet exist in the union, and must be of OPTIONAL mode. Does not call * the callback since the client (presumably) knows that it is adding the type. * The caller must also allocate the buffer for the vector. * * @param vector subtype vector to add */ public void addType(ValueVector vector) { MinorType type = vector.getField().getType().getMinorType(); assert subtype(type) == null; assert vector.getField().getType().getMode() == DataMode.OPTIONAL; assert vector.getField().getName().equals(type.name().toLowerCase()); cachedSubtypes[type.ordinal()] = vector; internalMap.putChild(type.name(), vector); addSubType(type); }
public static UnsupportedConversionError nullError(ColumnMetadata schema) { return new UnsupportedConversionError( String.format("Column `%s`: Type %s %s is not nullable", schema.name(), schema.mode().name(), schema.type().name())); } }
public static UnsupportedConversionError writeError(ColumnMetadata schema, String javaType) { return new UnsupportedConversionError( String.format("Column `%s`: Unsupported conversion from Java type %s to Drill type %s", schema.name(), schema.type().name(), javaType)); }
public static UnsupportedConversionError readError(ColumnMetadata schema, String javaType) { return new UnsupportedConversionError( String.format("Column `%s`: Unsupported conversion from Drill type %s to Java type %s", schema.name(), schema.type().name(), javaType)); }