Search in sources :

Example 1 with PrepareStoreEntity

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);
    }
}
Also used : OperatorListManager(com.alibaba.maxgraph.compiler.optimizer.OperatorListManager) QueryFlowManager(com.alibaba.maxgraph.compiler.optimizer.QueryFlowManager) PrepareStoreEntity(com.alibaba.maxgraph.compiler.prepare.store.PrepareStoreEntity) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) IOException(java.io.IOException)

Example 2 with PrepareStoreEntity

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);
    }
}
Also used : PrepareStoreEntity(com.alibaba.maxgraph.compiler.prepare.store.PrepareStoreEntity)

Aggregations

PrepareStoreEntity (com.alibaba.maxgraph.compiler.prepare.store.PrepareStoreEntity)2 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)1 OperatorListManager (com.alibaba.maxgraph.compiler.optimizer.OperatorListManager)1 QueryFlowManager (com.alibaba.maxgraph.compiler.optimizer.QueryFlowManager)1 IOException (java.io.IOException)1