use of com.facebook.presto.spi.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestMarker method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde(typeManager);
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
Marker marker = Marker.above(BIGINT, 0L);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.exactly(VARCHAR, utf8Slice("abc"));
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.below(DOUBLE, 0.123);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.exactly(BOOLEAN, true);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.upperUnbounded(BIGINT);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.lowerUnbounded(BIGINT);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
}
use of com.facebook.presto.spi.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestTupleDomain method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde(typeManager);
ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(ColumnHandle.class, new JsonDeserializer<ColumnHandle>() {
@Override
public ColumnHandle deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
return new ObjectMapperProvider().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>>() {
}));
}
Aggregations