Search in sources :

Example 21 with TestingTypeManager

use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.

the class TestTupleDomain method testJsonSerialization.

@Test
public void testJsonSerialization() throws Exception {
    TestingTypeManager typeManager = new TestingTypeManager();
    TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
    ObjectMapper mapper = new JsonObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(ColumnHandle.class, new JsonDeserializer<ColumnHandle>() {

        @Override
        public ColumnHandle deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return new JsonObjectMapperProvider().get().readValue(jsonParser, TestingColumnHandle.class);
        }
    }).addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
    TupleDomain<ColumnHandle> tupleDomain = TupleDomain.all();
    assertEquals(tupleDomain, mapper.readValue(mapper.writeValueAsString(tupleDomain), new TypeReference<TupleDomain<ColumnHandle>>() {
    }));
    tupleDomain = TupleDomain.none();
    assertEquals(tupleDomain, mapper.readValue(mapper.writeValueAsString(tupleDomain), new TypeReference<TupleDomain<ColumnHandle>>() {
    }));
    tupleDomain = TupleDomain.fromFixedValues(ImmutableMap.of(A, NullableValue.of(BIGINT, 1L), B, NullableValue.asNull(VARCHAR)));
    assertEquals(tupleDomain, mapper.readValue(mapper.writeValueAsString(tupleDomain), new TypeReference<TupleDomain<ColumnHandle>>() {
    }));
}
Also used : TestingColumnHandle(com.facebook.presto.spi.TestingColumnHandle) ColumnHandle(com.facebook.presto.spi.ColumnHandle) TestingBlockEncodingSerde(com.facebook.presto.common.block.TestingBlockEncodingSerde) IOException(java.io.IOException) TestingColumnHandle(com.facebook.presto.spi.TestingColumnHandle) Type(com.facebook.presto.common.type.Type) TestingTypeDeserializer(com.facebook.presto.common.type.TestingTypeDeserializer) JsonObjectMapperProvider(com.facebook.airlift.json.JsonObjectMapperProvider) JsonDeserializer(com.fasterxml.jackson.databind.JsonDeserializer) TestingTypeDeserializer(com.facebook.presto.common.type.TestingTypeDeserializer) DeserializationContext(com.fasterxml.jackson.databind.DeserializationContext) Block(com.facebook.presto.common.block.Block) TestingBlockJsonSerde(com.facebook.presto.common.block.TestingBlockJsonSerde) TypeReference(com.fasterxml.jackson.core.type.TypeReference) TestingTypeManager(com.facebook.presto.common.type.TestingTypeManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) JsonParser(com.fasterxml.jackson.core.JsonParser) Test(org.testng.annotations.Test)

Aggregations

TestingTypeManager (com.facebook.presto.common.type.TestingTypeManager)21 Test (org.testng.annotations.Test)21 Column (com.facebook.presto.hive.metastore.Column)12 HiveMaterializedViewUtils.getMaterializedDataPredicates (com.facebook.presto.hive.HiveMaterializedViewUtils.getMaterializedDataPredicates)11 MaterializedDataPredicates (com.facebook.presto.spi.MaterializedViewStatus.MaterializedDataPredicates)11 ImmutableList (com.google.common.collect.ImmutableList)11 List (java.util.List)11 JsonObjectMapperProvider (com.facebook.airlift.json.JsonObjectMapperProvider)7 TestingTypeDeserializer (com.facebook.presto.common.type.TestingTypeDeserializer)7 Type (com.facebook.presto.common.type.Type)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)7 Block (com.facebook.presto.common.block.Block)6 TestingBlockEncodingSerde (com.facebook.presto.common.block.TestingBlockEncodingSerde)6 TestingBlockJsonSerde (com.facebook.presto.common.block.TestingBlockJsonSerde)6 Storage (com.facebook.presto.hive.metastore.Storage)3 CacheConfig (com.facebook.presto.cache.CacheConfig)2 StorageFormat (com.facebook.presto.hive.metastore.StorageFormat)2 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)2 SchemaTableName (com.facebook.presto.spi.SchemaTableName)2