Search in sources :

Example 1 with FragmentMappingException

use of org.apache.ignite.internal.sql.engine.metadata.FragmentMappingException in project ignite-3 by apache.

the class QueryTemplate method map.

/**
 * Map.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 */
public ExecutionPlan map(MappingService mappingService, MappingQueryContext ctx) {
    ExecutionPlan executionPlan = this.executionPlan.get();
    if (executionPlan != null && Objects.equals(executionPlan.topologyVersion(), ctx.topologyVersion())) {
        return executionPlan;
    }
    List<Fragment> fragments = Commons.transform(this.fragments, fragment -> fragment.attach(ctx.cluster()));
    Exception ex = null;
    RelMetadataQuery mq = first(fragments).root().getCluster().getMetadataQuery();
    for (int i = 0; i < 3; i++) {
        try {
            ExecutionPlan executionPlan0 = new ExecutionPlan(ctx.topologyVersion(), map(mappingService, fragments, ctx, mq));
            if (executionPlan == null || executionPlan.topologyVersion() < executionPlan0.topologyVersion()) {
                this.executionPlan.compareAndSet(executionPlan, executionPlan0);
            }
            return executionPlan0;
        } catch (FragmentMappingException e) {
            if (ex == null) {
                ex = e;
            } else {
                ex.addSuppressed(e);
            }
            fragments = replace(fragments, e.fragment(), new FragmentSplitter(e.node()).go(e.fragment()));
        }
    }
    throw new IgniteException("Failed to map query.", ex);
}
Also used : RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) FragmentMappingException(org.apache.ignite.internal.sql.engine.metadata.FragmentMappingException) IgniteException(org.apache.ignite.lang.IgniteException) FragmentMappingException(org.apache.ignite.internal.sql.engine.metadata.FragmentMappingException) IgniteException(org.apache.ignite.lang.IgniteException)

Aggregations

RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)1 FragmentMappingException (org.apache.ignite.internal.sql.engine.metadata.FragmentMappingException)1 IgniteException (org.apache.ignite.lang.IgniteException)1