当前位置: 首页>>代码示例>>Java>>正文


Java Type.getTypeSignature方法代码示例

本文整理汇总了Java中com.facebook.presto.spi.type.Type.getTypeSignature方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getTypeSignature方法的具体用法?Java Type.getTypeSignature怎么用?Java Type.getTypeSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.presto.spi.type.Type的用法示例。


在下文中一共展示了Type.getTypeSignature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSlice

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public Slice getSlice(int field)
{
    checkState(!closed, "cursor is closed");
    try {
        Type type = getType(field);
        if (type.equals(VarcharType.VARCHAR)) {
            return utf8Slice(resultSet.getString(field + 1));
        }
        if (type.equals(VarbinaryType.VARBINARY)) {
            return wrappedBuffer(resultSet.getBytes(field + 1));
        }
        throw new PrestoException(INTERNAL_ERROR, "Unhandled type for slice: " + type.getTypeSignature());
    }
    catch (SQLException e) {
        throw handleSqlException(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:JdbcRecordCursor.java

示例2: toFastutilHashSet

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public static Set<?> toFastutilHashSet(Set<?> set, Type type, FunctionRegistry registry)
{
    // 0.25 as the load factor is chosen because the argument set is assumed to be small (<10000),
    // and the return set is assumed to be read-heavy.
    // The performance of InCodeGenerator heavily depends on the load factor being small.
    Class<?> javaElementType = type.getJavaType();
    if (javaElementType == long.class) {
        return new LongOpenCustomHashSet((Collection<Long>) set, 0.25f, new LongStrategy(registry, type));
    }
    if (javaElementType == double.class) {
        return new DoubleOpenCustomHashSet((Collection<Double>) set, 0.25f, new DoubleStrategy(registry, type));
    }
    if (javaElementType == boolean.class) {
        return new BooleanOpenHashSet((Collection<Boolean>) set, 0.25f);
    }
    else if (!type.getJavaType().isPrimitive()) {
        return new ObjectOpenCustomHashSet(set, 0.25f, new ObjectStrategy(registry, type));
    }
    else {
        throw new UnsupportedOperationException("Unsupported native type in set: " + type.getJavaType() + " with type " + type.getTypeSignature());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:FastutilSetHelper.java

示例3: testMultimapAgg

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static <K, V> void testMultimapAgg(Type keyType, List<K> expectedKeys, Type valueType, List<V> expectedValues)
{
    checkState(expectedKeys.size() == expectedValues.size(), "expectedKeys and expectedValues should have equal size");

    MapType mapType = new MapType(keyType, new ArrayType(valueType));
    Signature signature = new Signature(NAME, AGGREGATE, mapType.getTypeSignature(), keyType.getTypeSignature(), valueType.getTypeSignature());
    InternalAggregationFunction aggFunc = metadata.getFunctionRegistry().getAggregateFunctionImplementation(signature);

    Map<K, List<V>> map = new HashMap<>();
    for (int i = 0; i < expectedKeys.size(); i++) {
        if (!map.containsKey(expectedKeys.get(i))) {
            map.put(expectedKeys.get(i), new ArrayList<>());
        }
        map.get(expectedKeys.get(i)).add(expectedValues.get(i));
    }

    RowPageBuilder builder = RowPageBuilder.rowPageBuilder(keyType, valueType);
    for (int i = 0; i < expectedKeys.size(); i++) {
        builder.row(expectedKeys.get(i), expectedValues.get(i));
    }

    assertAggregation(aggFunc, 1.0, map.isEmpty() ? null : map, builder.build().getBlocks());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TestMultimapAggAggregation.java

示例4: getLong

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public long getLong(int field)
{
    checkState(!closed, "cursor is closed");
    try {
        Type type = getType(field);
        if (type.equals(BigintType.BIGINT)) {
            return resultSet.getLong(field + 1);
        }
        if (type.equals(DateType.DATE)) {
            // JDBC returns a date using a timestamp at midnight in the JVM timezone
            long localMillis = resultSet.getDate(field + 1).getTime();
            // Convert it to a midnight in UTC
            long utcMillis = ISOChronology.getInstance().getZone().getMillisKeepLocal(UTC, localMillis);
            // convert to days
            return TimeUnit.MILLISECONDS.toDays(utcMillis);
        }
        if (type.equals(TimeType.TIME)) {
            Time time = resultSet.getTime(field + 1);
            return UTC_CHRONOLOGY.millisOfDay().get(time.getTime());
        }
        if (type.equals(TimestampType.TIMESTAMP)) {
            Timestamp timestamp = resultSet.getTimestamp(field + 1);
            return timestamp.getTime();
        }
        throw new PrestoException(INTERNAL_ERROR, "Unhandled type for long: " + type.getTypeSignature());
    }
    catch (SQLException e) {
        throw handleSqlException(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:32,代码来源:JdbcRecordCursor.java

示例5: toSqlType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
protected String toSqlType(Type type)
{
    String sqlType = SQL_TYPES.get(type);
    if (sqlType != null) {
        return sqlType;
    }
    throw new PrestoException(NOT_SUPPORTED, "Unsuported column type: " + type.getTypeSignature());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:9,代码来源:BaseJdbcClient.java

示例6: getMagicLiteralFunctionSignature

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Signature getMagicLiteralFunctionSignature(Type type)
{
    TypeSignature argumentType = typeForMagicLiteral(type).getTypeSignature();

    return new Signature(MAGIC_LITERAL_FUNCTION_PREFIX + type.getTypeSignature(),
            SCALAR,
            type.getTypeSignature(),
            argumentType);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:FunctionRegistry.java

示例7: window

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public FunctionListBuilder window(String name, Type returnType, List<? extends Type> argumentTypes, Class<? extends WindowFunction> functionClass)
{
    WindowFunctionSupplier windowFunctionSupplier = new ReflectionWindowFunctionSupplier<>(
            new Signature(name, WINDOW, returnType.getTypeSignature(), Lists.transform(ImmutableList.copyOf(argumentTypes), Type::getTypeSignature)),
            functionClass);

    functions.add(new SqlWindowFunction(windowFunctionSupplier));
    return this;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:FunctionListBuilder.java

示例8: operator

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private FunctionListBuilder operator(OperatorType operatorType, Type returnType, List<Type> parameterTypes, MethodHandle function, Optional<MethodHandle> instanceFactory, boolean nullable, List<Boolean> nullableArguments)
{
    TypeSignature returnTypeSignature = returnType.getTypeSignature();
    List<TypeSignature> argumentTypes = parameterTypes.stream()
            .map(Type::getTypeSignature)
            .collect(ImmutableCollectors.toImmutableList());
    operatorType.validateSignature(returnTypeSignature, argumentTypes);
    functions.add(SqlOperator.create(operatorType, argumentTypes, returnTypeSignature, function, instanceFactory, nullable, nullableArguments));
    return this;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:FunctionListBuilder.java

示例9: processScalarFunction

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private boolean processScalarFunction(Method method)
        throws IllegalAccessException
{
    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
    if (scalarFunction == null) {
        return false;
    }
    checkValidMethod(method);
    Optional<MethodHandle> instanceFactory = getInstanceFactory(method);
    MethodHandle methodHandle = lookup().unreflect(method);
    String name = scalarFunction.value();
    if (name.isEmpty()) {
        name = camelToSnake(method.getName());
    }
    SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
    checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
    Type returnType = type(typeManager, returnTypeAnnotation);
    Signature signature = new Signature(name.toLowerCase(ENGLISH), SCALAR, returnType.getTypeSignature(), Lists.transform(parameterTypes(typeManager, method), Type::getTypeSignature));

    verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes(), typeManager);

    List<Boolean> nullableArguments = getNullableArguments(method);

    scalar(signature, methodHandle, instanceFactory, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class), nullableArguments);
    for (String alias : scalarFunction.alias()) {
        scalar(signature.withAlias(alias.toLowerCase(ENGLISH)), methodHandle, instanceFactory, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class), nullableArguments);
    }
    return true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:30,代码来源:FunctionListBuilder.java

示例10: hashPosition

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static long hashPosition(MethodHandle methodHandle, Type type, Block block, int position)
{
    if (block.isNull(position)) {
        return NULL_HASH_CODE;
    }
    try {
        if (type.getJavaType() == boolean.class) {
            return (long) methodHandle.invoke(type.getBoolean(block, position));
        }
        else if (type.getJavaType() == long.class) {
            return (long) methodHandle.invoke(type.getLong(block, position));
        }
        else if (type.getJavaType() == double.class) {
            return (long) methodHandle.invoke(type.getDouble(block, position));
        }
        else if (type.getJavaType() == Slice.class) {
            return (long) methodHandle.invoke(type.getSlice(block, position));
        }
        else if (!type.getJavaType().isPrimitive()) {
            return (long) methodHandle.invoke(type.getObject(block, position));
        }
        else {
            throw new UnsupportedOperationException("Unsupported native container type: " + type.getJavaType() + " with type " + type.getTypeSignature());
        }
    }
    catch (Throwable throwable) {
        throw Throwables.propagate(throwable);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:30,代码来源:TypeUtils.java

示例11: getTypeSignature

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Nonnull
private static TypeSignature getTypeSignature(TypeInfo typeInfo)
{
    switch (typeInfo.getCategory()) {
        case PRIMITIVE:
            PrimitiveObjectInspector.PrimitiveCategory primitiveCategory = ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory();
            Type primitiveType = getPrimitiveType(primitiveCategory);
            if (primitiveType == null) {
                break;
            }
            return primitiveType.getTypeSignature();
        case MAP:
            MapTypeInfo mapTypeInfo = checkType(typeInfo, MapTypeInfo.class, "fieldInspector");
            TypeSignature keyType = getTypeSignature(mapTypeInfo.getMapKeyTypeInfo());
            TypeSignature valueType = getTypeSignature(mapTypeInfo.getMapValueTypeInfo());
            return new TypeSignature(
                    StandardTypes.MAP,
                    ImmutableList.of(TypeSignatureParameter.of(keyType), TypeSignatureParameter.of(valueType)));
        case LIST:
            ListTypeInfo listTypeInfo = checkType(typeInfo, ListTypeInfo.class, "fieldInspector");
            TypeSignature elementType = getTypeSignature(listTypeInfo.getListElementTypeInfo());
            return new TypeSignature(
                    StandardTypes.ARRAY,
                    ImmutableList.of(TypeSignatureParameter.of(elementType)));
        case STRUCT:
            StructTypeInfo structTypeInfo = checkType(typeInfo, StructTypeInfo.class, "fieldInspector");
            List<TypeSignature> fieldTypes = structTypeInfo.getAllStructFieldTypeInfos()
                    .stream()
                    .map(HiveType::getTypeSignature)
                    .collect(toList());
            return new TypeSignature(StandardTypes.ROW, fieldTypes, structTypeInfo.getAllStructFieldNames());
    }
    throw new PrestoException(NOT_SUPPORTED, format("Unsupported Hive type: %s", typeInfo));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:35,代码来源:HiveType.java

示例12: ReflectionWindowFunctionSupplier

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public ReflectionWindowFunctionSupplier(String name, Type returnType, List<? extends Type> argumentTypes, Class<T> type)
{
    this(new Signature(name, WINDOW, returnType.getTypeSignature(), Lists.transform(argumentTypes, Type::getTypeSignature)), type);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:5,代码来源:ReflectionWindowFunctionSupplier.java

示例13: ifSignature

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Signature ifSignature(Type returnType)
{
    return new Signature(IF, SCALAR, returnType.getTypeSignature());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:5,代码来源:Signatures.java

示例14: nullIfSignature

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Signature nullIfSignature(Type returnType, Type firstType, Type secondType)
{
    return new Signature(NULL_IF, SCALAR, returnType.getTypeSignature(), firstType.getTypeSignature(), secondType.getTypeSignature());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:5,代码来源:Signatures.java

示例15: switchSignature

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Signature switchSignature(Type returnType)
{
    return new Signature(SWITCH, SCALAR, returnType.getTypeSignature());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:5,代码来源:Signatures.java


注:本文中的com.facebook.presto.spi.type.Type.getTypeSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。