Search in sources :

Example 1 with TypeDeserializer

use of io.prestosql.type.TypeDeserializer in project hetu-core by openlookeng.

the class SplitCacheStateManager method startStateServices.

@PostConstruct
public void startStateServices() {
    if (!PropertyService.getBooleanProperty(HetuConstant.SPLIT_CACHE_MAP_ENABLED)) {
        log.info("Split cache map feature is disabled.");
        return;
    }
    if (!PropertyService.getBooleanProperty(HetuConstant.MULTI_COORDINATOR_ENABLED)) {
        return;
    }
    BlockEncodingSerde blockEncodingSerde = metadata.getFunctionAndTypeManager().getBlockEncodingSerde();
    ObjectMapper mapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TypeDeserializer(metadata)).addSerializer(Block.class, new BlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new BlockJsonSerde.Deserializer(blockEncodingSerde)).addKeyDeserializer(SplitKey.class, new SplitKey.KeyDeserializer()));
    AtomicReference<InitializationStatus> status = new AtomicReference<>(InitializationStatus.INITIALIZING);
    // Async: One-shot action. Fetch split cache map info from state store if available
    if (initializer == null) {
        final Duration delay = new Duration(2, TimeUnit.SECONDS);
        final Duration timeout = new Duration(60, TimeUnit.SECONDS);
        initializer = new SplitCacheStateInitializer(provider, splitCacheMap, delay, timeout, mapper, status);
        initializer.start();
    }
    if (updater == null) {
        Duration updateInterval = PropertyService.getDurationProperty(HetuConstant.SPLIT_CACHE_STATE_UPDATE_INTERVAL);
        // Async Task - Periodically update state store with local split cache map changes
        updater = new SplitCacheStateUpdater(provider, splitCacheMap, updateInterval, mapper, status);
        updater.start();
    }
    log.info("-- Initialized split cache map state store and started state services --");
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) Duration(io.airlift.units.Duration) BlockEncodingSerde(io.prestosql.spi.block.BlockEncodingSerde) InitializationStatus(io.prestosql.execution.SplitCacheStateInitializer.InitializationStatus) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) BlockJsonSerde(io.prestosql.block.BlockJsonSerde) Block(io.prestosql.spi.block.Block) TypeDeserializer(io.prestosql.type.TypeDeserializer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) PostConstruct(javax.annotation.PostConstruct)

Example 2 with TypeDeserializer

use of io.prestosql.type.TypeDeserializer in project hetu-core by openlookeng.

the class TestSplitCacheChangesListener method setup.

@BeforeSuite
public void setup() {
    Metadata metadata = MetadataManager.createTestMetadataManager();
    PropertyService.setProperty(HetuConstant.SPLIT_CACHE_MAP_ENABLED, true);
    BlockEncodingSerde encodingSerde = metadata.getFunctionAndTypeManager().getBlockEncodingSerde();
    objectMapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TypeDeserializer(metadata)).addSerializer(Block.class, new BlockJsonSerde.Serializer(encodingSerde)).addDeserializer(Block.class, new BlockJsonSerde.Deserializer(encodingSerde)).addKeyDeserializer(SplitKey.class, new SplitKey.KeyDeserializer()));
}
Also used : EntryEventType(io.prestosql.spi.statestore.listener.EntryEventType) Type(io.prestosql.spi.type.Type) BlockJsonSerde(io.prestosql.block.BlockJsonSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) Metadata(io.prestosql.metadata.Metadata) Block(io.prestosql.spi.block.Block) BlockEncodingSerde(io.prestosql.spi.block.BlockEncodingSerde) TestingBlockEncodingSerde(io.prestosql.spi.block.TestingBlockEncodingSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 3 with TypeDeserializer

use of io.prestosql.type.TypeDeserializer in project hetu-core by openlookeng.

the class TestSignature method testSerializationRoundTrip.

@Test
public void testSerializationRoundTrip() {
    ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
    objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(createTestMetadataManager())));
    JsonCodec<Signature> codec = new JsonCodecFactory(objectMapperProvider, true).jsonCodec(Signature.class);
    Signature expected = new Signature(QualifiedObjectName.valueOfDefaultFunction("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(io.prestosql.spi.type.Type) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) Signature(io.prestosql.spi.function.Signature) TypeDeserializer(io.prestosql.type.TypeDeserializer) JsonCodecFactory(io.airlift.json.JsonCodecFactory) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) Test(org.testng.annotations.Test)

Example 4 with TypeDeserializer

use of io.prestosql.type.TypeDeserializer in project hetu-core by openlookeng.

the class TestSplitCacheStateInitializer method setup.

@BeforeSuite
public void setup() {
    Metadata metadata = MetadataManager.createTestMetadataManager();
    BlockEncodingSerde encodingSerde = metadata.getFunctionAndTypeManager().getBlockEncodingSerde();
    objectMapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TypeDeserializer(metadata)).addSerializer(Block.class, new BlockJsonSerde.Serializer(encodingSerde)).addDeserializer(Block.class, new BlockJsonSerde.Deserializer(encodingSerde)).addKeyDeserializer(SplitKey.class, new SplitKey.KeyDeserializer()));
}
Also used : Type(io.prestosql.spi.type.Type) BlockJsonSerde(io.prestosql.block.BlockJsonSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) Metadata(io.prestosql.metadata.Metadata) Block(io.prestosql.spi.block.Block) BlockEncodingSerde(io.prestosql.spi.block.BlockEncodingSerde) TestingBlockEncodingSerde(io.prestosql.spi.block.TestingBlockEncodingSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 5 with TypeDeserializer

use of io.prestosql.type.TypeDeserializer in project hetu-core by openlookeng.

the class TestSplitCacheStateUpdater method setup.

@BeforeSuite
public void setup() {
    Metadata metadata = MetadataManager.createTestMetadataManager();
    PropertyService.setProperty(HetuConstant.SPLIT_CACHE_MAP_ENABLED, true);
    BlockEncodingSerde encodingSerde = metadata.getFunctionAndTypeManager().getBlockEncodingSerde();
    objectMapper = new ObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TypeDeserializer(metadata)).addSerializer(Block.class, new BlockJsonSerde.Serializer(encodingSerde)).addDeserializer(Block.class, new BlockJsonSerde.Deserializer(encodingSerde)).addKeyDeserializer(SplitKey.class, new SplitKey.KeyDeserializer()));
}
Also used : Type(io.prestosql.spi.type.Type) BlockJsonSerde(io.prestosql.block.BlockJsonSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) Metadata(io.prestosql.metadata.Metadata) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) Block(io.prestosql.spi.block.Block) BlockEncodingSerde(io.prestosql.spi.block.BlockEncodingSerde) TestingBlockEncodingSerde(io.prestosql.spi.block.TestingBlockEncodingSerde) TypeDeserializer(io.prestosql.type.TypeDeserializer) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) BeforeSuite(org.testng.annotations.BeforeSuite)

Aggregations

ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)5 TypeDeserializer (io.prestosql.type.TypeDeserializer)5 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)4 BlockJsonSerde (io.prestosql.block.BlockJsonSerde)4 Block (io.prestosql.spi.block.Block)4 BlockEncodingSerde (io.prestosql.spi.block.BlockEncodingSerde)4 Type (io.prestosql.spi.type.Type)4 Metadata (io.prestosql.metadata.Metadata)3 TestingBlockEncodingSerde (io.prestosql.spi.block.TestingBlockEncodingSerde)3 ColumnMetadata (io.prestosql.spi.connector.ColumnMetadata)3 BeforeSuite (org.testng.annotations.BeforeSuite)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonCodecFactory (io.airlift.json.JsonCodecFactory)1 Duration (io.airlift.units.Duration)1 InitializationStatus (io.prestosql.execution.SplitCacheStateInitializer.InitializationStatus)1 Signature (io.prestosql.spi.function.Signature)1 EntryEventType (io.prestosql.spi.statestore.listener.EntryEventType)1 TypeSignature.parseTypeSignature (io.prestosql.spi.type.TypeSignature.parseTypeSignature)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 PostConstruct (javax.annotation.PostConstruct)1