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


Java Type.equals方法代码示例

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


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

示例1: jdbcType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
public static JDBCType jdbcType(Type type)
{
    if (type.equals(BooleanType.BOOLEAN)) {
        return JDBCType.BOOLEAN;
    }
    if (type.equals(BigintType.BIGINT) || type.equals(TimestampType.TIMESTAMP)) {
        return JDBCType.BIGINT;
    }
    if (type.equals(DoubleType.DOUBLE)) {
        return JDBCType.DOUBLE;
    }
    if (type.equals(DateType.DATE)) {
        return JDBCType.INTEGER;
    }
    if (type.equals(VarcharType.VARCHAR)) {
        return JDBCType.VARBINARY;
    }
    return null;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:ShardPredicate.java

示例2: doComputeColumnStats

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static ColumnStats doComputeColumnStats(OrcReader orcReader, long columnId, Type type)
        throws IOException
{
    int columnIndex = columnIndex(orcReader.getColumnNames(), columnId);
    OrcRecordReader reader = orcReader.createRecordReader(ImmutableMap.of(columnIndex, type), OrcPredicate.TRUE, UTC, new AggregatedMemoryContext());

    if (type.equals(BooleanType.BOOLEAN)) {
        return indexBoolean(type, reader, columnIndex, columnId);
    }
    if (type.equals(BigintType.BIGINT) ||
            type.equals(DateType.DATE) ||
            type.equals(TimestampType.TIMESTAMP)) {
        return indexLong(type, reader, columnIndex, columnId);
    }
    if (type.equals(DoubleType.DOUBLE)) {
        return indexDouble(type, reader, columnIndex, columnId);
    }
    if (type.equals(VarcharType.VARCHAR)) {
        return indexString(type, reader, columnIndex, columnId);
    }
    return null;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:ShardStats.java

示例3: specialize

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public ScalarFunctionImplementation specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry)
{
    Type fromType = types.get("F");
    Type toType = types.get("T");

    Class<?> returnType = Primitives.wrap(toType.getJavaType());
    MethodHandle tryCastHandle;

    if (fromType.equals(UNKNOWN)) {
        tryCastHandle = dropArguments(constant(returnType, null), 0, Void.class);
    }
    else {
        // the resulting method needs to return a boxed type
        Signature signature = functionRegistry.getCoercion(fromType, toType);
        MethodHandle coercion = functionRegistry.getScalarFunctionImplementation(signature).getMethodHandle();
        coercion = coercion.asType(methodType(returnType, coercion.type()));

        MethodHandle exceptionHandler = dropArguments(constant(returnType, null), 0, RuntimeException.class);
        tryCastHandle = catchException(coercion, RuntimeException.class, exceptionHandler);
    }

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

示例4: getLong

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public final long getLong()
{
    long millis = getMillis();

    Type type = columnHandle.getType();
    if (type.equals(DATE)) {
        return TimeUnit.MILLISECONDS.toDays(millis);
    }
    if (type.equals(TIMESTAMP) || type.equals(TIME)) {
        return millis;
    }
    if (type.equals(TIMESTAMP_WITH_TIME_ZONE) || type.equals(TIME_WITH_TIME_ZONE)) {
        return packDateTimeWithZone(millis, 0);
    }

    return millis;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:JsonFieldDecoder.java

示例5: analyzeHaving

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private void analyzeHaving(QuerySpecification node, RelationType tupleDescriptor, AnalysisContext context)
{
    if (node.getHaving().isPresent()) {
        Expression predicate = node.getHaving().get();

        ExpressionAnalysis expressionAnalysis = analyzeExpression(predicate, tupleDescriptor, context);
        analysis.recordSubqueries(node, expressionAnalysis);

        Type predicateType = expressionAnalysis.getType(predicate);
        if (!predicateType.equals(BOOLEAN) && !predicateType.equals(UNKNOWN)) {
            throw new SemanticException(TYPE_MISMATCH, predicate, "HAVING clause must evaluate to a boolean: actual type %s", predicateType);
        }

        analysis.setHaving(node, predicate);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:StatementAnalyzer.java

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

示例7: visitComparisonExpression

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
protected ExtractionResult visitComparisonExpression(ComparisonExpression node, Boolean complement)
{
    Optional<NormalizedSimpleComparison> optionalNormalized = toNormalizedSimpleComparison(session, metadata, types, node);
    if (!optionalNormalized.isPresent()) {
        return super.visitComparisonExpression(node, complement);
    }
    NormalizedSimpleComparison normalized = optionalNormalized.get();

    Symbol symbol = Symbol.fromQualifiedName(normalized.getNameReference().getName());
    Type type = checkedTypeLookup(symbol);
    NullableValue value = normalized.getValue();

    // Handle the cases where implicit coercions can happen in comparisons
    // TODO: how to abstract this out
    if (value.getType().equals(DOUBLE) && type.equals(BIGINT)) {
        return process(coerceDoubleToLongComparison(normalized), complement);
    }
    if (value.getType().equals(BIGINT) && type.equals(DOUBLE)) {
        value = NullableValue.of(DOUBLE, ((Long) value.getValue()).doubleValue());
    }
    checkState(value.isNull() || value.getType().equals(type), "INVARIANT: comparison should be working on the same types");
    return createComparisonExtractionResult(normalized.getComparisonType(), symbol, type, value.getValue(), complement);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:DomainTranslator.java

示例8: getSlice

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
@Override
public Slice getSlice(int fieldId)
{
    checkState(!closed, "Cursor is closed");

    Type type = types[fieldId];
    if (!type.equals(VARCHAR) && !type.equals(VARBINARY) && !isStructuralType(hiveTypes[fieldId])) {
        // we don't use Preconditions.checkArgument because it requires boxing fieldId, which affects inner loop performance
        throw new IllegalArgumentException(format("Expected field to be VARCHAR or VARBINARY, actual %s (field %s)", type, fieldId));
    }

    if (!loaded[fieldId]) {
        parseStringColumn(fieldId);
    }
    return slices[fieldId];
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:ColumnarBinaryHiveRecordCursor.java

示例9: checkFieldType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private void checkFieldType(int field, Type... expected)
{
    log.info("INFORMATION: AmpoolRecordCursor checkFieldType() called.");

    Type actual = getType(field);
    for (Type type : expected) {
        if (actual.equals(type)) {
            return;
        }
    }
    String expectedTypes = Joiner.on(", ").join(expected);
    throw new IllegalArgumentException(format("Expected field %s to be type %s but is %s", field, expectedTypes, actual));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:AmpoolRecordCursor.java

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

示例11: coerceToSingleType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private Type coerceToSingleType(StackableAstVisitorContext<AnalysisContext> context, Node node, String message, Expression first, Expression second)
{
    Type firstType = null;
    if (first != null) {
        firstType = process(first, context);
    }
    Type secondType = null;
    if (second != null) {
        secondType = process(second, context);
    }

    if (firstType == null) {
        return secondType;
    }
    if (secondType == null) {
        return firstType;
    }
    if (firstType.equals(secondType)) {
        return firstType;
    }

    // coerce types if possible
    if (canCoerce(firstType, secondType)) {
        expressionCoercions.put(first, secondType);
        return secondType;
    }
    if (canCoerce(secondType, firstType)) {
        expressionCoercions.put(second, firstType);
        return firstType;
    }
    throw new SemanticException(TYPE_MISMATCH, node, message, firstType, secondType);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:33,代码来源:ExpressionAnalyzer.java

示例12: toConjuncts

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private List<String> toConjuncts(List<JdbcColumnHandle> columns, TupleDomain<ColumnHandle> tupleDomain)
{
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    for (JdbcColumnHandle column : columns) {
        Type type = column.getColumnType();
        if (type.equals(BigintType.BIGINT) || type.equals(DoubleType.DOUBLE) || type.equals(BooleanType.BOOLEAN)) {
            Domain domain = tupleDomain.getDomains().get().get(column);
            if (domain != null) {
                builder.add(toPredicate(column.getColumnName(), domain));
            }
        }
    }
    return builder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:QueryBuilder.java

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

示例14: createPages

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static List<Page> createPages(int pageCount, int channelCount, Type type)
{
    int positionCount = PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES / (channelCount * 8);

    List<Page> pages = new ArrayList<>(pageCount);
    for (int numPage = 0; numPage < pageCount; numPage++) {
        Block[] blocks = new Block[channelCount];
        for (int numChannel = 0; numChannel < channelCount; numChannel++) {
            if (type.equals(BIGINT)) {
                blocks[numChannel] = BlockAssertions.createLongSequenceBlock(0, positionCount);
            }
            else if (type.equals(VARCHAR)) {
                blocks[numChannel] = BlockAssertions.createStringSequenceBlock(0, positionCount);
            }
            else if (type.equals(DOUBLE)) {
                blocks[numChannel] = BlockAssertions.createDoubleSequenceBlock(0, positionCount);
            }
            else if (type.equals(BOOLEAN)) {
                blocks[numChannel] = BlockAssertions.createBooleanSequenceBlock(0, positionCount);
            }
            else {
                throw new IllegalArgumentException("Unsupported type: " + type);
            }
        }
        pages.add(new Page(blocks));
    }
    return pages;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:29,代码来源:BenchmarkPagesIndexPageSorter.java

示例15: jdbcDataType

import com.facebook.presto.spi.type.Type; //导入方法依赖的package包/类
private static int jdbcDataType(Type type)
{
    if (type.equals(BOOLEAN)) {
        return Types.BOOLEAN;
    }
    if (type.equals(BIGINT)) {
        return Types.BIGINT;
    }
    if (type.equals(DOUBLE)) {
        return Types.DOUBLE;
    }
    if (type.equals(VARCHAR)) {
        return Types.LONGNVARCHAR;
    }
    if (type.equals(VARBINARY)) {
        return Types.LONGVARBINARY;
    }
    if (type.equals(TIME)) {
        return Types.TIME;
    }
    if (type.equals(TIME_WITH_TIME_ZONE)) {
        return Types.TIME_WITH_TIMEZONE;
    }
    if (type.equals(TIMESTAMP)) {
        return Types.TIMESTAMP;
    }
    if (type.equals(TIMESTAMP_WITH_TIME_ZONE)) {
        return Types.TIMESTAMP_WITH_TIMEZONE;
    }
    if (type.equals(DATE)) {
        return Types.DATE;
    }
    if (type instanceof ArrayType) {
        return Types.ARRAY;
    }
    return Types.JAVA_OBJECT;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:38,代码来源:ColumnJdbcTable.java


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