Search in sources :

Example 1 with TestingBlockEncodingSerde

use of com.facebook.presto.spi.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(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)));
    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));
}
Also used : Type(com.facebook.presto.spi.type.Type) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) TestingBlockEncodingSerde(com.facebook.presto.spi.block.TestingBlockEncodingSerde) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) Block(com.facebook.presto.spi.block.Block) TestingBlockJsonSerde(com.facebook.presto.spi.block.TestingBlockJsonSerde) TestingTypeManager(com.facebook.presto.spi.type.TestingTypeManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 2 with TestingBlockEncodingSerde

use of com.facebook.presto.spi.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(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)));
    EquatableValueSet set = EquatableValueSet.all(ID);
    assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
    set = EquatableValueSet.none(ID);
    assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
    set = EquatableValueSet.of(ID, 1L);
    assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
    set = EquatableValueSet.of(ID, 1L, 2L);
    assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
    set = EquatableValueSet.of(ID, 1L, 2L).complement();
    assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
}
Also used : Type(com.facebook.presto.spi.type.Type) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) TestingBlockEncodingSerde(com.facebook.presto.spi.block.TestingBlockEncodingSerde) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) Block(com.facebook.presto.spi.block.Block) TestingBlockJsonSerde(com.facebook.presto.spi.block.TestingBlockJsonSerde) TestingTypeManager(com.facebook.presto.spi.type.TestingTypeManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 3 with TestingBlockEncodingSerde

use of com.facebook.presto.spi.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(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)));
    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));
}
Also used : Type(com.facebook.presto.spi.type.Type) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) TestingBlockEncodingSerde(com.facebook.presto.spi.block.TestingBlockEncodingSerde) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) Block(com.facebook.presto.spi.block.Block) TestingBlockJsonSerde(com.facebook.presto.spi.block.TestingBlockJsonSerde) TestingTypeManager(com.facebook.presto.spi.type.TestingTypeManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 4 with TestingBlockEncodingSerde

use of com.facebook.presto.spi.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(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)));
    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));
}
Also used : Type(com.facebook.presto.spi.type.Type) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) TestingBlockEncodingSerde(com.facebook.presto.spi.block.TestingBlockEncodingSerde) TestingTypeDeserializer(com.facebook.presto.spi.type.TestingTypeDeserializer) Block(com.facebook.presto.spi.block.Block) TestingBlockJsonSerde(com.facebook.presto.spi.block.TestingBlockJsonSerde) TestingTypeManager(com.facebook.presto.spi.type.TestingTypeManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 5 with TestingBlockEncodingSerde

use of com.facebook.presto.spi.block.TestingBlockEncodingSerde in project presto by prestodb.

the class TaskTestUtils method createTestingPlanner.

public static LocalExecutionPlanner createTestingPlanner() {
    MetadataManager metadata = MetadataManager.createTestMetadataManager();
    PageSourceManager pageSourceManager = new PageSourceManager();
    pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
    // we don't start the finalizer so nothing will be collected, which is ok for a test
    FinalizerService finalizerService = new FinalizerService();
    NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService));
    NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler);
    return new LocalExecutionPlanner(metadata, new SqlParser(), Optional.empty(), pageSourceManager, new IndexManager(), nodePartitioningManager, new PageSinkManager(), new MockExchangeClientSupplier(), new ExpressionCompiler(metadata), new JoinFilterFunctionCompiler(metadata), new IndexJoinLookupStats(), new CompilerConfig(), new TaskManagerConfig(), new BinarySpillerFactory(new BlockEncodingManager(metadata.getTypeManager()), new FeaturesConfig()), new TestingBlockEncodingSerde(new TestingTypeManager()), new PagesIndex.TestingFactory(), new JoinCompiler(), new LookupJoinOperators(new JoinProbeCompiler()));
}
Also used : FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PagesIndex(com.facebook.presto.operator.PagesIndex) PageSourceManager(com.facebook.presto.split.PageSourceManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) JoinProbeCompiler(com.facebook.presto.sql.gen.JoinProbeCompiler) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) TestingTypeManager(com.facebook.presto.spi.type.TestingTypeManager) PageSinkManager(com.facebook.presto.split.PageSinkManager) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) MockExchangeClientSupplier(com.facebook.presto.execution.TestSqlTaskManager.MockExchangeClientSupplier) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) TestingBlockEncodingSerde(com.facebook.presto.spi.block.TestingBlockEncodingSerde) JoinFilterFunctionCompiler(com.facebook.presto.sql.gen.JoinFilterFunctionCompiler) SqlParser(com.facebook.presto.sql.parser.SqlParser) CompilerConfig(com.facebook.presto.sql.planner.CompilerConfig) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) IndexManager(com.facebook.presto.index.IndexManager) MetadataManager(com.facebook.presto.metadata.MetadataManager) BlockEncodingManager(com.facebook.presto.block.BlockEncodingManager) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) BinarySpillerFactory(com.facebook.presto.spiller.BinarySpillerFactory) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler)

Aggregations

TestingBlockEncodingSerde (com.facebook.presto.spi.block.TestingBlockEncodingSerde)7 TestingTypeManager (com.facebook.presto.spi.type.TestingTypeManager)7 Block (com.facebook.presto.spi.block.Block)6 TestingBlockJsonSerde (com.facebook.presto.spi.block.TestingBlockJsonSerde)6 TestingTypeDeserializer (com.facebook.presto.spi.type.TestingTypeDeserializer)6 Type (com.facebook.presto.spi.type.Type)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)6 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)6 Test (org.testng.annotations.Test)6 BlockEncodingManager (com.facebook.presto.block.BlockEncodingManager)1 MockExchangeClientSupplier (com.facebook.presto.execution.TestSqlTaskManager.MockExchangeClientSupplier)1 LegacyNetworkTopology (com.facebook.presto.execution.scheduler.LegacyNetworkTopology)1 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)1 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)1 IndexManager (com.facebook.presto.index.IndexManager)1 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)1 MetadataManager (com.facebook.presto.metadata.MetadataManager)1 LookupJoinOperators (com.facebook.presto.operator.LookupJoinOperators)1 PagesIndex (com.facebook.presto.operator.PagesIndex)1