use of io.prestosql.spi.block.BlockEncodingSerde 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.spi.block.BlockEncodingSerde in project hetu-core by openlookeng.
the class ExecutingStatementResource method getQuery.
protected Query getQuery(QueryId queryId, String slug) {
Query query = queries.get(queryId);
if (query != null) {
if (!query.isSlugValid(slug)) {
throw badRequest(NOT_FOUND, "Query not found");
}
return query;
}
// this is the first time the query has been accessed on this coordinator
Session session;
try {
if (!queryManager.isQuerySlugValid(queryId, slug)) {
throw badRequest(NOT_FOUND, "Query not found");
}
session = queryManager.getQuerySession(queryId);
} catch (NoSuchElementException e) {
throw badRequest(NOT_FOUND, "Query not found");
}
query = queries.computeIfAbsent(queryId, id -> {
ExchangeClient exchangeClient = exchangeClientSupplier.get(new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), ExecutingStatementResource.class.getSimpleName()));
if (SystemSessionProperties.isSnapshotEnabled(session)) {
exchangeClient.setSnapshotEnabled(snapshotUtils.getOrCreateQuerySnapshotManager(queryId, session));
}
return Query.create(session, slug, queryManager, exchangeClient, responseExecutor, timeoutExecutor, blockEncodingSerde);
});
return query;
}
use of io.prestosql.spi.block.BlockEncodingSerde 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.spi.block.BlockEncodingSerde in project hetu-core by openlookeng.
the class GroupIdOperator method capture.
@Override
public Object capture(BlockEncodingSerdeProvider serdeProvider) {
GroupIdOperatorState myState = new GroupIdOperatorState();
myState.operatorContext = operatorContext.capture(serdeProvider);
BlockEncodingSerde blockSerde = serdeProvider.getBlockEncodingSerde();
myState.nullBlocks = new byte[nullBlocks.length][];
for (int i = 0; i < nullBlocks.length; i++) {
myState.nullBlocks[i] = serializeBlock(nullBlocks[i], blockSerde);
}
myState.groupIdBlocks = new byte[groupIdBlocks.length][];
for (int i = 0; i < groupIdBlocks.length; i++) {
myState.groupIdBlocks[i] = serializeBlock(groupIdBlocks[i], blockSerde);
}
myState.currentGroupingSet = currentGroupingSet;
myState.finishing = finishing;
return myState;
}
use of io.prestosql.spi.block.BlockEncodingSerde in project hetu-core by openlookeng.
the class GroupIdOperator method restore.
@Override
public void restore(Object state, BlockEncodingSerdeProvider serdeProvider) {
GroupIdOperatorState myState = (GroupIdOperatorState) state;
this.operatorContext.restore(myState.operatorContext, serdeProvider);
BlockEncodingSerde blockSerde = serdeProvider.getBlockEncodingSerde();
for (int i = 0; i < nullBlocks.length; i++) {
this.nullBlocks[i] = deserializeBlock(myState.nullBlocks[i], blockSerde);
}
for (int i = 0; i < groupIdBlocks.length; i++) {
this.groupIdBlocks[i] = deserializeBlock(myState.groupIdBlocks[i], blockSerde);
}
this.currentGroupingSet = myState.currentGroupingSet;
this.finishing = myState.finishing;
}
Aggregations