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


Java Type.getJavaType方法代码示例

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


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

示例1: normalizeValue

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object normalizeValue(Type type, @Nullable Object value)
{
    if (value == null) {
        return value;
    }

    Class<?> javaType = type.getJavaType();
    if (javaType.isPrimitive()) {
        checkArgument(Primitives.wrap(javaType).isInstance(value), "Type %s incompatible with %s", type, value);
        return value;
    }
    if (javaType == Slice.class) {
        if (value instanceof Slice) {
            return value;
        }
        if (value instanceof String) {
            return utf8Slice(((String) value));
        }
        if (value instanceof byte[]) {
            return wrappedBuffer((byte[]) value);
        }
    }
    throw new IllegalArgumentException(format("Type %s incompatible with %s", type, value));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:ValueBuffer.java

示例2: bindField

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static void bindField(ValueBuffer valueBuffer, PreparedStatement preparedStatement, int parameterIndex, boolean isUuid)
        throws SQLException
{
    Type type = valueBuffer.getType();
    if (valueBuffer.isNull()) {
        preparedStatement.setNull(parameterIndex, typeToSqlType(type));
    }
    else if (type.getJavaType() == long.class) {
        preparedStatement.setLong(parameterIndex, valueBuffer.getLong());
    }
    else if (type.getJavaType() == double.class) {
        preparedStatement.setDouble(parameterIndex, valueBuffer.getDouble());
    }
    else if (type.getJavaType() == boolean.class) {
        preparedStatement.setBoolean(parameterIndex, valueBuffer.getBoolean());
    }
    else if (type.getJavaType() == Slice.class && isUuid) {
        preparedStatement.setBytes(parameterIndex, valueBuffer.getSlice().getBytes());
    }
    else if (type.getJavaType() == Slice.class) {
        preparedStatement.setString(parameterIndex, new String(valueBuffer.getSlice().getBytes()));
    }
    else {
        throw new IllegalArgumentException("Unknown Java type: " + type.getJavaType());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:PreparedStatementBuilder.java

示例3: getNativeContainerValue

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object getNativeContainerValue(Type type, Block block, int position)
{
    if (block.isNull(position)) {
        return null;
    }
    else if (type.getJavaType() == boolean.class) {
        return type.getBoolean(block, position);
    }
    else if (type.getJavaType() == long.class) {
        return type.getLong(block, position);
    }
    else if (type.getJavaType() == double.class) {
        return type.getDouble(block, position);
    }
    else if (type.getJavaType() == Slice.class) {
        return type.getSlice(block, position);
    }
    else if (type.getJavaType() == Block.class) {
        return type.getObject(block, position);
    }
    else {
        throw new AssertionError("Unimplemented type: " + type);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:Row.java

示例4: mapKeyToObject

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object mapKeyToObject(ConnectorSession session, String jsonKey, Type type)
{
    BlockBuilder blockBuilder;
    if (type instanceof FixedWidthType) {
        blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1);
    }
    else {
        blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1, jsonKey.length());
    }
    if (type.getJavaType() == boolean.class) {
        type.writeBoolean(blockBuilder, Boolean.parseBoolean(jsonKey));
    }
    else if (type.getJavaType() == long.class) {
        type.writeLong(blockBuilder, Long.parseLong(jsonKey));
    }
    else if (type.getJavaType() == double.class) {
        type.writeDouble(blockBuilder, Double.parseDouble(jsonKey));
    }
    else if (type.getJavaType() == Slice.class) {
        type.writeSlice(blockBuilder, Slices.utf8Slice(jsonKey));
    }
    return type.getObjectValue(session, blockBuilder.build(), 0);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:TypeJsonUtils.java

示例5: extractObject

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Object extractObject(RecordCursor cursor, int field, Type type)
{
    if (cursor.isNull(field)) {
        return null;
    }

    Class<?> javaType = type.getJavaType();
    if (javaType == boolean.class) {
        return cursor.getBoolean(field);
    }
    else if (javaType == long.class) {
        return cursor.getLong(field);
    }
    else if (javaType == double.class) {
        return cursor.getDouble(field);
    }
    else if (javaType == Slice.class) {
        return cursor.getSlice(field).toStringUtf8();
    }
    throw new AssertionError("Unsupported type: " + type);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TpchIndexedData.java

示例6: createBlock

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static Block createBlock(Type type, Object value)
{
    BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1);

    Class<?> javaType = type.getJavaType();
    if (value == null) {
        blockBuilder.appendNull();
    }
    else if (javaType == boolean.class) {
        type.writeBoolean(blockBuilder, (Boolean) value);
    }
    else if (javaType == long.class) {
        type.writeLong(blockBuilder, (Long) value);
    }
    else if (javaType == double.class) {
        type.writeDouble(blockBuilder, (Double) value);
    }
    else if (javaType == Slice.class) {
        Slice slice = (Slice) value;
        type.writeSlice(blockBuilder, slice, 0, slice.length());
    }
    else {
        type.writeObject(blockBuilder, value);
    }
    return blockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:AbstractTestType.java

示例7: indexStackValues

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static SortedMap<Integer, Object> indexStackValues(Type type, Block block)
{
    SortedMap<Integer, Object> values = new TreeMap<>();
    for (int position = 0; position < block.getPositionCount(); position++) {
        if (block.isNull(position)) {
            values.put(position, null);
        }
        else if (type.getJavaType() == boolean.class) {
            values.put(position, type.getBoolean(block, position));
        }
        else if (type.getJavaType() == long.class) {
            values.put(position, type.getLong(block, position));
        }
        else if (type.getJavaType() == double.class) {
            values.put(position, type.getDouble(block, position));
        }
        else if (type.getJavaType() == Slice.class) {
            values.put(position, type.getSlice(block, position));
        }
        else {
            values.put(position, type.getObject(block, position));
        }
    }
    return unmodifiableSortedMap(values);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:AbstractTestType.java

示例8: specialize

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public ScalarFunctionImplementation specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)
{
    Type type = types.get("E");
    MethodHandle equalMethodHandle = functionRegistry.getScalarFunctionImplementation(internalOperator(EQUAL, BOOLEAN, ImmutableList.of(type, type))).getMethodHandle();
    MethodHandle arrayPositionMethodHandle;
    if (type.getJavaType() == boolean.class) {
        arrayPositionMethodHandle = METHOD_HANDLE_BOOLEAN;
    }
    else if (type.getJavaType() == long.class) {
        arrayPositionMethodHandle = METHOD_HANDLE_LONG;
    }
    else if (type.getJavaType() == double.class) {
        arrayPositionMethodHandle = METHOD_HANDLE_DOUBLE;
    }
    else if (type.getJavaType() == Slice.class) {
        arrayPositionMethodHandle = METHOD_HANDLE_SLICE;
    }
    else {
        arrayPositionMethodHandle = METHOD_HANDLE_OBJECT;
    }
    return new ScalarFunctionImplementation(false, ImmutableList.of(false, false), arrayPositionMethodHandle.bindTo(type).bindTo(equalMethodHandle), isDeterministic());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:ArrayPositionFunction.java

示例9: specialize

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public ScalarFunctionImplementation specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)
{
    Type toType = types.get("E");
    MethodHandle methodHandle;
    if (toType.getJavaType() == long.class) {
        methodHandle = METHOD_HANDLE_LONG;
    }
    else if (toType.getJavaType() == double.class) {
        methodHandle = METHOD_HANDLE_DOUBLE;
    }
    else if (toType.getJavaType() == boolean.class) {
        methodHandle = METHOD_HANDLE_BOOLEAN;
    }
    else if (toType.getJavaType() == Slice.class) {
        methodHandle = METHOD_HANDLE_SLICE;
    }
    else {
        methodHandle = METHOD_HANDLE_OBJECT.asType(METHOD_HANDLE_OBJECT.type().changeReturnType(toType.getJavaType()));
    }
    return new ScalarFunctionImplementation(true, ImmutableList.of(true), methodHandle, isDeterministic());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:CastFromUnknownOperator.java

示例10: specialize

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public ScalarFunctionImplementation specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)
{
    Type type = types.get("E");
    MethodHandle methodHandle;
    if (type.getJavaType() == boolean.class) {
        methodHandle = METHOD_HANDLE_BOOLEAN;
    }
    else if (type.getJavaType() == long.class) {
        methodHandle = METHOD_HANDLE_LONG;
    }
    else if (type.getJavaType() == double.class) {
        methodHandle = METHOD_HANDLE_DOUBLE;
    }
    else if (type.getJavaType() == Slice.class) {
        methodHandle = METHOD_HANDLE_SLICE;
    }
    else {
        methodHandle = METHOD_HANDLE_OBJECT;
    }
    methodHandle = methodHandle.bindTo(type);

    return new ScalarFunctionImplementation(false, ImmutableList.of(false, false), methodHandle, isDeterministic());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:ArrayToElementConcatFunction.java

示例11: typeForMagicLiteral

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static Type typeForMagicLiteral(Type type)
{
    Class<?> clazz = type.getJavaType();
    clazz = Primitives.unwrap(clazz);

    if (clazz == long.class) {
        return BIGINT;
    }
    if (clazz == double.class) {
        return DOUBLE;
    }
    if (!clazz.isPrimitive()) {
        if (type.equals(VARCHAR)) {
            return VARCHAR;
        }
        else {
            return VARBINARY;
        }
    }
    if (clazz == boolean.class) {
        return BOOLEAN;
    }
    throw new IllegalArgumentException("Unhandled Java type: " + clazz.getName());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:FunctionRegistry.java

示例12: 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

示例13: toStorageType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static StorageType toStorageType(Type type)
{
    Class<?> javaType = type.getJavaType();
    if (javaType == boolean.class) {
        return StorageType.BOOLEAN;
    }
    if (javaType == long.class) {
        return StorageType.LONG;
    }
    if (javaType == double.class) {
        return StorageType.DOUBLE;
    }
    if (javaType == Slice.class) {
        if (type.equals(VarcharType.VARCHAR)) {
            return StorageType.STRING;
        }
        if (type.equals(VarbinaryType.VARBINARY)) {
            return StorageType.BYTES;
        }
    }
    if (isArrayType(type)) {
        return arrayOf(toStorageType(type.getTypeParameters().get(0)));
    }
    if (isMapType(type)) {
        return mapOf(toStorageType(type.getTypeParameters().get(0)), toStorageType(type.getTypeParameters().get(1)));
    }
    throw new PrestoException(NOT_SUPPORTED, "No storage type for type: " + type);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:29,代码来源:OrcFileWriter.java

示例14: getMaterializedResults

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static List<MaterializedRow> getMaterializedResults(RecordCursor cursor, List<ColumnMetadata> columns)
{
    List<Type> types = columns.stream().map(ColumnMetadata::getType).collect(toList());

    ImmutableList.Builder<MaterializedRow> rowBuilder = ImmutableList.builder();
    for (int i = 0; i < types.size(); i++) {
        assertEquals(cursor.getType(i), types.get(i));
    }

    while (cursor.advanceNextPosition()) {
        List<Object> values = new ArrayList<>(types.size());
        for (int i = 0; i < columns.size(); i++) {
            Type type = columns.get(i).getType();
            Class<?> javaType = type.getJavaType();
            if (cursor.isNull(i)) {
                continue;
            }
            if (javaType == boolean.class) {
                values.add(i, cursor.getBoolean(i));
            }
            else if (javaType == long.class) {
                values.add(i, cursor.getLong(i));
            }
            else if (javaType == double.class) {
                values.add(i, cursor.getDouble(i));
            }
            else if (javaType == Slice.class) {
                values.add(i, cursor.getSlice(i));
            }
        }
        rowBuilder.add(new MaterializedRow(DEFAULT_PRECISION, values));
    }
    return rowBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:35,代码来源:TestShardMetadataRecordCursor.java

示例15: createZeroBlock

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private Block createZeroBlock(Type type, int rowsCount, Slice constantSlice)
{
    checkArgument(SUPPORTED_TYPES.contains(type), "Unsupported type [%s]", type);
    BlockBuilder builder;

    if (type instanceof FixedWidthType) {
        builder = type.createBlockBuilder(new BlockBuilderStatus(), rowsCount);
    }
    else {
        builder = type.createBlockBuilder(new BlockBuilderStatus(), rowsCount, constantSlice.length());
    }

    for (int i = 0; i < rowsCount; i++) {
        Class<?> javaType = type.getJavaType();
        if (javaType == boolean.class) {
            type.writeBoolean(builder, false);
        }
        else if (javaType == long.class) {
            type.writeLong(builder, 0);
        }
        else if (javaType == double.class) {
            type.writeDouble(builder, 0.0);
        }
        else if (javaType == Slice.class) {
            type.writeSlice(builder, constantSlice, 0, constantSlice.length());
        }
        else {
            throw new UnsupportedOperationException("Unknown javaType: " + javaType.getName());
        }
    }
    return builder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:33,代码来源:BlackHolePageSourceProvider.java


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