Search in sources :

Example 1 with IgniteReceiver

use of org.apache.ignite.internal.sql.engine.rel.IgniteReceiver in project ignite-3 by apache.

the class QueryTemplate method replace.

private List<Fragment> replace(List<Fragment> fragments, Fragment fragment, List<Fragment> replacement) {
    assert !nullOrEmpty(replacement);
    Long2LongOpenHashMap newTargets = new Long2LongOpenHashMap();
    for (Fragment fragment0 : replacement) {
        for (IgniteReceiver remote : fragment0.remotes()) {
            newTargets.put(remote.exchangeId(), fragment0.fragmentId());
        }
    }
    List<Fragment> fragments0 = new ArrayList<>(fragments.size() + replacement.size() - 1);
    for (Fragment fragment0 : fragments) {
        if (fragment0 == fragment) {
            fragment0 = first(replacement);
        } else if (!fragment0.rootFragment()) {
            IgniteSender sender = (IgniteSender) fragment0.root();
            long newTargetId = newTargets.getOrDefault(sender.exchangeId(), Long.MIN_VALUE);
            if (newTargetId != Long.MIN_VALUE) {
                sender = new IgniteSender(sender.getCluster(), sender.getTraitSet(), sender.getInput(), sender.exchangeId(), newTargetId, sender.distribution());
                fragment0 = new Fragment(fragment0.fragmentId(), sender, fragment0.remotes());
            }
        }
        fragments0.add(fragment0);
    }
    fragments0.addAll(replacement.subList(1, replacement.size()));
    return fragments0;
}
Also used : IgniteSender(org.apache.ignite.internal.sql.engine.rel.IgniteSender) Long2LongOpenHashMap(it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap) ArrayList(java.util.ArrayList) IgniteReceiver(org.apache.ignite.internal.sql.engine.rel.IgniteReceiver)

Example 2 with IgniteReceiver

use of org.apache.ignite.internal.sql.engine.rel.IgniteReceiver in project ignite-3 by apache.

the class AbstractMultiStepPlan method remotes.

/**
 * {@inheritDoc}
 */
@Override
public Long2ObjectOpenHashMap<List<String>> remotes(Fragment fragment) {
    List<IgniteReceiver> remotes = fragment.remotes();
    if (nullOrEmpty(remotes)) {
        return null;
    }
    Long2ObjectOpenHashMap<List<String>> res = new Long2ObjectOpenHashMap<>(capacity(remotes.size()));
    for (IgniteReceiver remote : remotes) {
        res.put(remote.exchangeId(), mapping(remote.sourceFragmentId()).nodeIds());
    }
    return res;
}
Also used : List(java.util.List) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) IgniteReceiver(org.apache.ignite.internal.sql.engine.rel.IgniteReceiver)

Example 3 with IgniteReceiver

use of org.apache.ignite.internal.sql.engine.rel.IgniteReceiver in project ignite-3 by apache.

the class Splitter method visit.

/**
 * {@inheritDoc}
 */
@Override
public IgniteRel visit(IgniteExchange rel) {
    RelOptCluster cluster = rel.getCluster();
    long targetFragmentId = curr.id;
    long sourceFragmentId = IdGenerator.nextId();
    long exchangeId = sourceFragmentId;
    IgniteReceiver receiver = new IgniteReceiver(cluster, rel.getTraitSet(), rel.getRowType(), exchangeId, sourceFragmentId);
    IgniteSender sender = new IgniteSender(cluster, rel.getTraitSet(), rel.getInput(), exchangeId, targetFragmentId, rel.distribution());
    curr.remotes.add(receiver);
    stack.push(new FragmentProto(sourceFragmentId, sender));
    return receiver;
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) IgniteSender(org.apache.ignite.internal.sql.engine.rel.IgniteSender) IgniteReceiver(org.apache.ignite.internal.sql.engine.rel.IgniteReceiver)

Example 4 with IgniteReceiver

use of org.apache.ignite.internal.sql.engine.rel.IgniteReceiver in project ignite-3 by apache.

the class FragmentSplitter method split.

private IgniteRel split(IgniteRel rel) {
    RelOptCluster cluster = rel.getCluster();
    RelTraitSet traits = rel.getTraitSet();
    RelDataType rowType = rel.getRowType();
    RelNode input = rel instanceof IgniteTrimExchange ? rel.getInput(0) : rel;
    long targetFragmentId = curr.id;
    long sourceFragmentId = IdGenerator.nextId();
    long exchangeId = sourceFragmentId;
    IgniteReceiver receiver = new IgniteReceiver(cluster, traits, rowType, exchangeId, sourceFragmentId);
    IgniteSender sender = new IgniteSender(cluster, traits, input, exchangeId, targetFragmentId, rel.distribution());
    curr.remotes.add(receiver);
    stack.push(new FragmentProto(sourceFragmentId, sender));
    return receiver;
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) IgniteSender(org.apache.ignite.internal.sql.engine.rel.IgniteSender) RelNode(org.apache.calcite.rel.RelNode) IgniteTrimExchange(org.apache.ignite.internal.sql.engine.rel.IgniteTrimExchange) RelDataType(org.apache.calcite.rel.type.RelDataType) RelTraitSet(org.apache.calcite.plan.RelTraitSet) IgniteReceiver(org.apache.ignite.internal.sql.engine.rel.IgniteReceiver)

Aggregations

IgniteReceiver (org.apache.ignite.internal.sql.engine.rel.IgniteReceiver)4 IgniteSender (org.apache.ignite.internal.sql.engine.rel.IgniteSender)3 RelOptCluster (org.apache.calcite.plan.RelOptCluster)2 Long2LongOpenHashMap (it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1 RelDataType (org.apache.calcite.rel.type.RelDataType)1 IgniteTrimExchange (org.apache.ignite.internal.sql.engine.rel.IgniteTrimExchange)1