Search in sources :

Example 1 with SerializationConfig

use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.SerializationConfig in project legend-engine by finos.

the class ExecutionNodeExecutor method visit.

@Override
public Result visit(PureExpressionPlatformExecutionNode pureExpressionPlatformExecutionNode) {
    if (!(pureExpressionPlatformExecutionNode.implementation instanceof JavaPlatformImplementation)) {
        throw new RuntimeException("Only Java implementations are currently supported, found: " + pureExpressionPlatformExecutionNode.implementation);
    }
    JavaPlatformImplementation javaPlatformImpl = (JavaPlatformImplementation) pureExpressionPlatformExecutionNode.implementation;
    String executionClassName = JavaHelper.getExecutionClassFullName(javaPlatformImpl);
    Class<?> clazz = ExecutionNodeJavaPlatformHelper.getClassToExecute(pureExpressionPlatformExecutionNode, executionClassName, this.executionState, this.profiles);
    if (Arrays.asList(clazz.getInterfaces()).contains(IPlatformPureExpressionExecutionNodeSerializeSpecifics.class)) {
        try {
            org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics nodeSpecifics = (org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics) clazz.newInstance();
            Result childResult = pureExpressionPlatformExecutionNode.executionNodes().getFirst().accept(new ExecutionNodeExecutor(profiles, executionState));
            IExecutionNodeContext context = new DefaultExecutionNodeContext(this.executionState, childResult);
            AppliedFunction f = (AppliedFunction) pureExpressionPlatformExecutionNode.pure;
            SerializationConfig config = f.parameters.size() == 3 ? (SerializationConfig) f.parameters.get(2) : null;
            return ExecutionNodeSerializerHelper.executeSerialize(nodeSpecifics, config, childResult, context);
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
    if (Arrays.asList(clazz.getInterfaces()).contains(IPlatformPureExpressionExecutionNodeGraphFetchUnionSpecifics.class)) {
        StreamingObjectResult<?> streamResult1 = (StreamingObjectResult) pureExpressionPlatformExecutionNode.executionNodes.get(0).accept(new ExecutionNodeExecutor(this.profiles, this.executionState));
        StreamingObjectResult<?> streamResult2 = (StreamingObjectResult) pureExpressionPlatformExecutionNode.executionNodes.get(1).accept(new ExecutionNodeExecutor(this.profiles, this.executionState));
        Result childResult = new Result("success") {

            @Override
            public <T> T accept(ResultVisitor<T> resultVisitor) {
                throw new RuntimeException("Not implemented");
            }

            @Override
            public void close() {
                streamResult1.close();
                streamResult2.close();
            }
        };
        return new StreamingObjectResult<>(Stream.concat(streamResult1.getObjectStream(), streamResult2.getObjectStream()), streamResult1.getResultBuilder(), childResult);
    }
    if (Arrays.asList(clazz.getInterfaces()).contains(IPlatformPureExpressionExecutionNodeGraphFetchMergeSpecifics.class)) {
        StreamingObjectResult<?> streamResult = (StreamingObjectResult) pureExpressionPlatformExecutionNode.executionNodes.get(0).accept(new ExecutionNodeExecutor(this.profiles, this.executionState));
        return streamResult;
    } else {
        return ExecutionNodeJavaPlatformHelper.executeJavaImplementation(pureExpressionPlatformExecutionNode, DefaultExecutionNodeContext.factory(), this.profiles, this.executionState);
    }
}
Also used : ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) GraphFetchResult(org.finos.legend.engine.plan.execution.result.graphFetch.GraphFetchResult) StreamingObjectResult(org.finos.legend.engine.plan.execution.result.object.StreamingObjectResult) ErrorResult(org.finos.legend.engine.plan.execution.result.ErrorResult) Result(org.finos.legend.engine.plan.execution.result.Result) MultiResult(org.finos.legend.engine.plan.execution.result.MultiResult) IPlatformPureExpressionExecutionNodeSerializeSpecifics(org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics) JavaPlatformImplementation(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.nodes.JavaPlatformImplementation) SerializationConfig(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.SerializationConfig) StreamingObjectResult(org.finos.legend.engine.plan.execution.result.object.StreamingObjectResult) IPlatformPureExpressionExecutionNodeSerializeSpecifics(org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics) IExecutionNodeContext(org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext) DefaultExecutionNodeContext(org.finos.legend.engine.plan.execution.nodes.helpers.platform.DefaultExecutionNodeContext) AppliedFunction(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.application.AppliedFunction) ResultVisitor(org.finos.legend.engine.plan.execution.result.ResultVisitor)

Aggregations

IPlatformPureExpressionExecutionNodeSerializeSpecifics (org.finos.legend.engine.plan.dependencies.store.platform.IPlatformPureExpressionExecutionNodeSerializeSpecifics)1 IExecutionNodeContext (org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext)1 DefaultExecutionNodeContext (org.finos.legend.engine.plan.execution.nodes.helpers.platform.DefaultExecutionNodeContext)1 ConstantResult (org.finos.legend.engine.plan.execution.result.ConstantResult)1 ErrorResult (org.finos.legend.engine.plan.execution.result.ErrorResult)1 MultiResult (org.finos.legend.engine.plan.execution.result.MultiResult)1 Result (org.finos.legend.engine.plan.execution.result.Result)1 ResultVisitor (org.finos.legend.engine.plan.execution.result.ResultVisitor)1 GraphFetchResult (org.finos.legend.engine.plan.execution.result.graphFetch.GraphFetchResult)1 StreamingObjectResult (org.finos.legend.engine.plan.execution.result.object.StreamingObjectResult)1 JavaPlatformImplementation (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.nodes.JavaPlatformImplementation)1 AppliedFunction (org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.application.AppliedFunction)1 SerializationConfig (org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.SerializationConfig)1