Refine search
public static boolean isMapType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.MAP); }
public static boolean isArrayType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ARRAY); }
public static boolean isArrayType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ARRAY); }
public static boolean isRowType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ROW); }
public static boolean isMapType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.MAP); }
private static boolean isArray(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ARRAY); }
public static boolean isArrayType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ARRAY); }
public static boolean isRowType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ROW); }
public static boolean isMapType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.MAP); }
public static boolean isStructuralType(Type type) { String baseName = type.getTypeSignature().getBase(); return baseName.equals(StandardTypes.MAP) || baseName.equals(StandardTypes.ARRAY) || baseName.equals(StandardTypes.ROW); }
private static boolean isValidJsonObjectKeyType(Type type) { String baseType = type.getTypeSignature().getBase(); return baseType.equals(StandardTypes.BOOLEAN) || baseType.equals(StandardTypes.TINYINT) || baseType.equals(StandardTypes.SMALLINT) || baseType.equals(StandardTypes.INTEGER) || baseType.equals(StandardTypes.BIGINT) || baseType.equals(StandardTypes.REAL) || baseType.equals(StandardTypes.DOUBLE) || baseType.equals(StandardTypes.DECIMAL) || baseType.equals(StandardTypes.VARCHAR); }
public static Block serializeObject(Type type, BlockBuilder builder, Object object) { if (ROW.equals(type.getTypeSignature().getBase())) { return serializeStruct(type, builder, object); } if (MAP.equals(type.getTypeSignature().getBase()) || ARRAY.equals(type.getTypeSignature().getBase())) { throw new IllegalArgumentException("Type not supported: " + type.getDisplayName()); } return serializePrimitive(type, builder, object); }
public boolean canBind(Type type) { if (comparableRequired && !type.isComparable()) { return false; } if (orderableRequired && !type.isOrderable()) { return false; } if (variadicBound != null && !type.getTypeSignature().getBase().equals(variadicBound)) { return false; } return true; }
private boolean satisfiesConstraints(Type type) { if (comparableRequired && !type.isComparable()) { return false; } if (orderableRequired && !type.isOrderable()) { return false; } if (requiredBaseName.isPresent() && !UNKNOWN.equals(type) && !requiredBaseName.get().equals(type.getTypeSignature().getBase())) { // TODO: the case below should be properly handled: // * `type` does not have the `requiredBaseName` but can be coerced to some type that has the `requiredBaseName`. return false; } return true; } }
private boolean isSupportedType(Type type) { if (isSupportedPrimitive(type)) { return true; } if (type.getTypeSignature().getBase().equalsIgnoreCase(ARRAY)) { checkArgument(type.getTypeParameters().size() == 1, "expecting exactly one type parameter for array"); return isSupportedPrimitive(type.getTypeParameters().get(0)); } if (type.getTypeSignature().getBase().equalsIgnoreCase(MAP)) { List<Type> typeParameters = type.getTypeParameters(); checkArgument(typeParameters.size() == 2, "expecting exactly two type parameters for map"); checkArgument(typeParameters.get(0) instanceof VarcharType, "Unsupported column type '%s' for map key", typeParameters.get(0)); return isSupportedPrimitive(type.getTypeParameters().get(1)); } return false; }
public static TypeSignature applyBoundVariables(TypeSignature typeSignature, BoundVariables boundVariables) { String baseType = typeSignature.getBase(); if (boundVariables.containsTypeVariable(baseType)) { checkState(typeSignature.getParameters().isEmpty(), "Type parameters cannot have parameters"); return boundVariables.getTypeVariable(baseType).getTypeSignature(); } List<TypeSignatureParameter> parameters = typeSignature.getParameters().stream() .map(typeSignatureParameter -> applyBoundVariables(typeSignatureParameter, boundVariables)) .collect(toList()); return new TypeSignature(baseType, parameters); }
private ColumnChunk readColumnChunk(Field field) throws IOException { ColumnChunk columnChunk; if (ROW.equals(field.getType().getTypeSignature().getBase())) { columnChunk = readStruct((GroupField) field); } else if (MAP.equals(field.getType().getTypeSignature().getBase())) { columnChunk = readMap((GroupField) field); } else if (ARRAY.equals(field.getType().getTypeSignature().getBase())) { columnChunk = readArray((GroupField) field); } else { columnChunk = readPrimitive((PrimitiveField) field); } return columnChunk; }
@Override public Type getType(TypeSignature signature) { for (Type type : getTypes()) { if (signature.getBase().equals(type.getTypeSignature().getBase())) { return type; } } return null; }
private static Slice getSlice(Object value, Type type, String columnName) { switch (type.getTypeSignature().getBase()) { case VARCHAR: if (value instanceof Utf8) { return truncateToLength(utf8Slice(value.toString()), type); } case VARBINARY: if (value instanceof ByteBuffer) { return Slices.wrappedBuffer((ByteBuffer) value); } default: throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format("cannot decode object of '%s' as '%s' for column '%s'", value.getClass(), type, columnName)); } }
private static Block serializeObject(BlockBuilder builder, Object value, Type type, String columnName) { switch (type.getTypeSignature().getBase()) { case ARRAY: return serializeList(builder, value, type, columnName); case MAP: return serializeMap(builder, value, type, columnName); default: serializeGeneric(builder, value, type, columnName); } return null; }