use of com.alibaba.maxgraph.compiler.prepare.store.PrepareStoreEntity in project GraphScope by alibaba.
the class TimelyExecutor method prepare.
@Override
public void prepare(String prepareId, TimelyQuery timelyQuery, ExecuteConfig executeConfig) {
QueryFlowManager queryFlowManager = timelyQuery.getQueryFlowManager();
checkArgument(queryFlowManager.checkValidPrepareFlow(), "There's no argument for prepare statement");
try {
if (statementStore.checkExist(prepareId)) {
throw new RuntimeException("PREPARE " + prepareId + " fail for the same name statement has been exist.");
}
QueryFlowOuterClass.QueryFlow queryFlow = queryFlowManager.getQueryFlow().setQueryId(prepareId).build();
rpcConnector.prepare(queryFlow, this.isAsyncGrpc);
OperatorListManager operatorListManager = queryFlowManager.getOperatorListManager();
statementStore.save(prepareId, new PrepareStoreEntity(operatorListManager.getPrepareEntityList(), operatorListManager.getLabelManager(), queryFlowManager.getResultValueType(), queryFlow));
logger.info("PREPARE " + prepareId + " success");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.alibaba.maxgraph.compiler.prepare.store.PrepareStoreEntity in project GraphScope by alibaba.
the class ZKStatementStore method get.
/**
* Get prepareStoreEnty by prepareId, which is used by compiler
* @param prepareId prepare query name
* @return PrepareStoreEntity
* @throws Exception
*/
@Override
public PrepareStoreEntity get(String prepareId) {
// first get prepareStoreEntity from cache
if (prepareStoreEntityMap.containsKey(prepareId)) {
return prepareStoreEntityMap.get(prepareId);
}
String subCompilePath = buildSubCompilePath(prepareId);
try {
byte[] bytes = this.zkUtilsStore.readBinaryData(subCompilePath);
PrepareStoreEntity prepareStoreEntity = PrepareStoreEntity.toPrepareStoreEntity(bytes);
// cache prepare query
this.prepareStoreEntityMap.put(prepareId, prepareStoreEntity);
return prepareStoreEntity;
} catch (Exception e) {
LOGGER.error("Get compile query from ZK failed: " + e);
throw new RuntimeException("Get compile query from ZK failed: " + e);
}
}
Aggregations