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


Java VarcharType类代码示例

本文整理汇总了Java中com.facebook.presto.spi.type.VarcharType的典型用法代码示例。如果您正苦于以下问题:Java VarcharType类的具体用法?Java VarcharType怎么用?Java VarcharType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: jdbcType

import com.facebook.presto.spi.type.VarcharType; //导入依赖的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.VarcharType; //导入依赖的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: getSlice

import com.facebook.presto.spi.type.VarcharType; //导入依赖的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

示例4: serializeSessionProperty

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@NotNull
public static String serializeSessionProperty(Type type, Object value)
{
    if (value == null) {
        throw new PrestoException(INVALID_SESSION_PROPERTY, "Session property can not be null");
    }
    if (BooleanType.BOOLEAN.equals(type)) {
        return value.toString();
    }
    if (BigintType.BIGINT.equals(type)) {
        return value.toString();
    }
    if (DoubleType.DOUBLE.equals(type)) {
        return value.toString();
    }
    if (VarcharType.VARCHAR.equals(type)) {
        return value.toString();
    }
    if (type instanceof ArrayType || type instanceof MapType) {
        return getJsonCodecForType(type).toJson(value);
    }
    throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:SessionPropertyManager.java

示例5: deserializeSessionProperty

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@NotNull
private static Object deserializeSessionProperty(Type type, String value)
{
    if (value == null) {
        throw new PrestoException(INVALID_SESSION_PROPERTY, "Session property can not be null");
    }
    if (VarcharType.VARCHAR.equals(type)) {
        return value;
    }
    if (BooleanType.BOOLEAN.equals(type)) {
        return Boolean.valueOf(value);
    }
    if (BigintType.BIGINT.equals(type)) {
        return Long.valueOf(value);
    }
    if (DoubleType.DOUBLE.equals(type)) {
        return Double.valueOf(value);
    }
    if (type instanceof ArrayType || type instanceof MapType) {
        return getJsonCodecForType(type).fromJson(value);
    }
    throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:SessionPropertyManager.java

示例6: getJsonCodecForType

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
private static <T> JsonCodec<T> getJsonCodecForType(Type type)
{
    if (VarcharType.VARCHAR.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(String.class);
    }
    if (BooleanType.BOOLEAN.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Boolean.class);
    }
    if (BigintType.BIGINT.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Long.class);
    }
    if (DoubleType.DOUBLE.equals(type)) {
        return (JsonCodec<T>) JSON_CODEC_FACTORY.jsonCodec(Double.class);
    }
    if (type instanceof ArrayType) {
        Type elementType = ((ArrayType) type).getElementType();
        return (JsonCodec<T>) JSON_CODEC_FACTORY.listJsonCodec(getJsonCodecForType(elementType));
    }
    if (type instanceof MapType) {
        Type keyType = ((MapType) type).getKeyType();
        Type valueType = ((MapType) type).getValueType();
        return (JsonCodec<T>) JSON_CODEC_FACTORY.mapJsonCodec(getMapKeyType(keyType), getJsonCodecForType(valueType));
    }
    throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property type %s is not supported", type));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:SessionPropertyManager.java

示例7: getMapKeyType

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
private static Class<?> getMapKeyType(Type type)
{
    if (VarcharType.VARCHAR.equals(type)) {
        return String.class;
    }
    if (BooleanType.BOOLEAN.equals(type)) {
        return Boolean.class;
    }
    if (BigintType.BIGINT.equals(type)) {
        return Long.class;
    }
    if (DoubleType.DOUBLE.equals(type)) {
        return Double.class;
    }
    throw new PrestoException(INVALID_SESSION_PROPERTY, format("Session property map key type %s is not supported", type));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:SessionPropertyManager.java

示例8: testVarianceStateSerialization

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testVarianceStateSerialization()
{
    StateCompiler compiler = new StateCompiler();

    AccumulatorStateFactory<VarianceState> factory = compiler.generateStateFactory(VarianceState.class);
    AccumulatorStateSerializer<VarianceState> serializer = compiler.generateStateSerializer(VarianceState.class);
    VarianceState singleState = factory.createSingleState();
    VarianceState deserializedState = factory.createSingleState();

    singleState.setMean(1);
    singleState.setCount(2);
    singleState.setM2(3);

    BlockBuilder builder = VarcharType.VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 1);
    serializer.serialize(singleState, builder);

    Block block = builder.build();
    serializer.deserialize(block, 0, deserializedState);

    assertEquals(deserializedState.getCount(), singleState.getCount());
    assertEquals(deserializedState.getMean(), singleState.getMean());
    assertEquals(deserializedState.getM2(), singleState.getM2());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:TestStateCompiler.java

示例9: testComplexSerialization

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testComplexSerialization()
{
    StateCompiler compiler = new StateCompiler();

    AccumulatorStateFactory<TestComplexState> factory = compiler.generateStateFactory(TestComplexState.class);
    AccumulatorStateSerializer<TestComplexState> serializer = compiler.generateStateSerializer(TestComplexState.class);
    TestComplexState singleState = factory.createSingleState();
    TestComplexState deserializedState = factory.createSingleState();

    singleState.setBoolean(true);
    singleState.setLong(1);
    singleState.setDouble(2.0);
    singleState.setByte((byte) 3);

    BlockBuilder builder = VarcharType.VARCHAR.createBlockBuilder(new BlockBuilderStatus(), 1);
    serializer.serialize(singleState, builder);

    Block block = builder.build();
    serializer.deserialize(block, 0, deserializedState);

    assertEquals(deserializedState.getBoolean(), singleState.getBoolean());
    assertEquals(deserializedState.getLong(), singleState.getLong());
    assertEquals(deserializedState.getDouble(), singleState.getDouble());
    assertEquals(deserializedState.getByte(), singleState.getByte());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestStateCompiler.java

示例10: testNonExistent

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testNonExistent()
        throws Exception
{
    byte[] json = "{}".getBytes(StandardCharsets.UTF_8);

    JsonRowDecoder rowDecoder = new JsonRowDecoder(PROVIDER.get());
    DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "very/deep/varchar", null, null, false, false, false);
    DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", BigintType.BIGINT, "no_bigint", null, null, false, false, false);
    DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", DoubleType.DOUBLE, "double/is_missing", null, null, false, false, false);
    DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "hello", null, null, false, false, false);

    List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
    Set<FieldValueProvider> providers = new HashSet<>();

    boolean corrupt = rowDecoder.decodeRow(json, null, providers, columns, buildMap(columns));
    assertFalse(corrupt);

    assertEquals(providers.size(), columns.size());

    checkIsNull(providers, row1);
    checkIsNull(providers, row2);
    checkIsNull(providers, row3);
    checkIsNull(providers, row4);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:TestJsonDecoder.java

示例11: testStringNumber

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testStringNumber()
        throws Exception
{
    byte[] json = "{\"a_number\":481516,\"a_string\":\"2342\"}".getBytes(StandardCharsets.UTF_8);

    JsonRowDecoder rowDecoder = new JsonRowDecoder(PROVIDER.get());
    DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "a_number", null, null, false, false, false);
    DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", BigintType.BIGINT, "a_number", null, null, false, false, false);
    DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", VarcharType.VARCHAR, "a_string", null, null, false, false, false);
    DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BigintType.BIGINT, "a_string", null, null, false, false, false);

    List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
    Set<FieldValueProvider> providers = new HashSet<>();

    boolean corrupt = rowDecoder.decodeRow(json, null, providers, columns, buildMap(columns));
    assertFalse(corrupt);

    assertEquals(providers.size(), columns.size());

    checkValue(providers, row1, "481516");
    checkValue(providers, row2, 481516);
    checkValue(providers, row3, "2342");
    checkValue(providers, row4, 2342);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:TestJsonDecoder.java

示例12: testFixedWithString

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testFixedWithString()
{
    String str = "Ich bin zwei Oeltanks";
    byte[] row = str.getBytes(StandardCharsets.UTF_8);

    RawRowDecoder rowDecoder = new RawRowDecoder();
    DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, null, null, null, false, false, false);
    DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", VarcharType.VARCHAR, "0", null, null, false, false, false);
    DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", VarcharType.VARCHAR, "0:4", null, null, false, false, false);
    DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", VarcharType.VARCHAR, "5:8", null, null, false, false, false);

    List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
    Set<FieldValueProvider> providers = new HashSet<>();

    boolean corrupt = rowDecoder.decodeRow(row, null, providers, columns, buildMap(columns));
    assertFalse(corrupt);

    assertEquals(providers.size(), columns.size());

    checkValue(providers, row1, str);
    checkValue(providers, row2, str);
    // these only work for single byte encodings...
    checkValue(providers, row3, str.substring(0, 4));
    checkValue(providers, row4, str.substring(5, 8));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestRawDecoder.java

示例13: testNulls

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testNulls()
{
    String csv = ",,,";

    CsvRowDecoder rowDecoder = new CsvRowDecoder();

    DecoderTestColumnHandle row1 = new DecoderTestColumnHandle("", 0, "row1", VarcharType.VARCHAR, "0", null, null, false, false, false);
    DecoderTestColumnHandle row2 = new DecoderTestColumnHandle("", 1, "row2", BigintType.BIGINT, "1", null, null, false, false, false);
    DecoderTestColumnHandle row3 = new DecoderTestColumnHandle("", 2, "row3", DoubleType.DOUBLE, "2", null, null, false, false, false);
    DecoderTestColumnHandle row4 = new DecoderTestColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "3", null, null, false, false, false);

    List<DecoderColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);

    Set<FieldValueProvider> providers = new HashSet<>();

    boolean corrupt = rowDecoder.decodeRow(csv.getBytes(StandardCharsets.UTF_8), null, providers, columns, buildMap(columns));
    assertFalse(corrupt);

    assertEquals(providers.size(), columns.size());

    checkValue(providers, row1, "");
    checkValue(providers, row2, 0);
    checkValue(providers, row3, 0.0d);
    checkValue(providers, row4, false);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestCsvDecoder.java

示例14: testNonExistent

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testNonExistent()
        throws Exception
{
    byte[] json = "{}".getBytes(StandardCharsets.UTF_8);

    JsonKinesisRowDecoder rowDecoder = new JsonKinesisRowDecoder(PROVIDER.get());
    KinesisColumnHandle row1 = new KinesisColumnHandle("", 0, "row1", VarcharType.VARCHAR, "very/deep/varchar", null, null, false, false);
    KinesisColumnHandle row2 = new KinesisColumnHandle("", 1, "row2", BigintType.BIGINT, "no_bigint", null, null, false, false);
    KinesisColumnHandle row3 = new KinesisColumnHandle("", 2, "row3", DoubleType.DOUBLE, "double/is_missing", null, null, false, false);
    KinesisColumnHandle row4 = new KinesisColumnHandle("", 3, "row4", BooleanType.BOOLEAN, "hello", null, null, false, false);

    List<KinesisColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
    Set<KinesisFieldValueProvider> providers = new HashSet<>();

    boolean valid = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
    assertTrue(valid);

    assertEquals(providers.size(), columns.size());

    DecoderTestUtil.checkIsNull(providers, row1);
    DecoderTestUtil.checkIsNull(providers, row2);
    DecoderTestUtil.checkIsNull(providers, row3);
    DecoderTestUtil.checkIsNull(providers, row4);
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:26,代码来源:TestJsonDecoder.java

示例15: testStringNumber

import com.facebook.presto.spi.type.VarcharType; //导入依赖的package包/类
@Test
public void testStringNumber()
        throws Exception
{
    byte[] json = "{\"a_number\":481516,\"a_string\":\"2342\"}".getBytes(StandardCharsets.UTF_8);

    JsonKinesisRowDecoder rowDecoder = new JsonKinesisRowDecoder(PROVIDER.get());
    KinesisColumnHandle row1 = new KinesisColumnHandle("", 0, "row1", VarcharType.VARCHAR, "a_number", null, null, false, false);
    KinesisColumnHandle row2 = new KinesisColumnHandle("", 1, "row2", BigintType.BIGINT, "a_number", null, null, false, false);
    KinesisColumnHandle row3 = new KinesisColumnHandle("", 2, "row3", VarcharType.VARCHAR, "a_string", null, null, false, false);
    KinesisColumnHandle row4 = new KinesisColumnHandle("", 3, "row4", BigintType.BIGINT, "a_string", null, null, false, false);

    List<KinesisColumnHandle> columns = ImmutableList.of(row1, row2, row3, row4);
    Set<KinesisFieldValueProvider> providers = new HashSet<>();

    boolean valid = rowDecoder.decodeRow(json, providers, columns, buildMap(columns));
    assertTrue(valid);

    assertEquals(providers.size(), columns.size());

    DecoderTestUtil.checkValue(providers, row1, "481516");
    DecoderTestUtil.checkValue(providers, row2, 481516);
    DecoderTestUtil.checkValue(providers, row3, "2342");
    DecoderTestUtil.checkValue(providers, row4, 2342);
}
 
开发者ID:qubole,项目名称:presto-kinesis,代码行数:26,代码来源:TestJsonDecoder.java


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