Search in sources :

Example 1 with TypeDeserializer

use of com.facebook.presto.type.TypeDeserializer in project presto by prestodb.

the class TestSignature method testSerializationRoundTrip.

@Test
public void testSerializationRoundTrip() {
    ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
    objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(new TypeRegistry())));
    JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);
    Signature expected = new Signature("function", SCALAR, parseTypeSignature(StandardTypes.BIGINT), ImmutableList.of(parseTypeSignature(StandardTypes.BOOLEAN), parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.VARCHAR)));
    String json = codec.toJson(expected);
    Signature actual = codec.fromJson(json);
    assertEquals(actual.getName(), expected.getName());
    assertEquals(actual.getKind(), expected.getKind());
    assertEquals(actual.getReturnType(), expected.getReturnType());
    assertEquals(actual.getArgumentTypes(), expected.getArgumentTypes());
}
Also used : Type(com.facebook.presto.spi.type.Type) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) TypeDeserializer(com.facebook.presto.type.TypeDeserializer) TypeRegistry(com.facebook.presto.type.TypeRegistry) JsonCodecFactory(io.airlift.json.JsonCodecFactory) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 2 with TypeDeserializer

use of com.facebook.presto.type.TypeDeserializer in project presto by prestodb.

the class MetadataManager method createTestingViewCodec.

private static JsonCodec<ViewDefinition> createTestingViewCodec() {
    ObjectMapperProvider provider = new ObjectMapperProvider();
    provider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(new TypeRegistry())));
    return new JsonCodecFactory(provider).jsonCodec(ViewDefinition.class);
}
Also used : OperatorType(com.facebook.presto.spi.function.OperatorType) Type(com.facebook.presto.spi.type.Type) TypeDeserializer(com.facebook.presto.type.TypeDeserializer) TypeRegistry(com.facebook.presto.type.TypeRegistry) JsonCodecFactory(io.airlift.json.JsonCodecFactory) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider)

Aggregations

Type (com.facebook.presto.spi.type.Type)2 TypeDeserializer (com.facebook.presto.type.TypeDeserializer)2 TypeRegistry (com.facebook.presto.type.TypeRegistry)2 JsonCodecFactory (io.airlift.json.JsonCodecFactory)2 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)2 OperatorType (com.facebook.presto.spi.function.OperatorType)1 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)1 Test (org.testng.annotations.Test)1