use of com.facebook.presto.common.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestRange 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(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
Range range = Range.all(BIGINT);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.equal(DOUBLE, 0.123);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.greaterThan(BIGINT, 0L);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.greaterThanOrEqual(VARCHAR, utf8Slice("abc"));
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.lessThan(BIGINT, Long.MAX_VALUE);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.lessThanOrEqual(DOUBLE, Double.MAX_VALUE);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
}
use of com.facebook.presto.common.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestEquatableValueSet 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(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
EquatableValueSet set = EquatableValueSet.all(TestingIdType.ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.none(TestingIdType.ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L, 2L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L, 2L).complement();
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
}
use of com.facebook.presto.common.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();
ObjectMapper mapper = new JsonObjectMapperProvider().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.common.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestSortedRangeSet 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(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
SortedRangeSet set = SortedRangeSet.all(BIGINT);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.none(DOUBLE);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(VARCHAR, utf8Slice("abc"));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(Range.equal(BOOLEAN, true), Range.equal(BOOLEAN, false));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
}
use of com.facebook.presto.common.block.TestingBlockEncodingSerde in project presto by prestodb.
the class TestDomain 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(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
Domain domain = Domain.all(BIGINT);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.none(DOUBLE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(BOOLEAN);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(VARCHAR);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(BIGINT, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(ID, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 0L), Range.equal(BIGINT, 1L), Range.range(BIGINT, 2L, true, 3L, true)), true);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
}
Aggregations