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 --");
}
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()));
}
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());
}
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()));
}
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()));
}
Aggregations