use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionCompositeNode in project ignite by apache.
the class PartitionExtractor method extractFromAnd.
/**
* Extract partition information from AND.
*
* @param op Operation.
* @param tblModel Table model.
* @param disjunct Disjunction marker.
* @return Partition.
*/
private PartitionNode extractFromAnd(GridSqlOperation op, PartitionTableModel tblModel, boolean disjunct) throws IgniteCheckedException {
assert op.size() == 2;
PartitionNode betweenNodes = tryExtractBetween(op, tblModel);
if (betweenNodes != null)
return betweenNodes;
PartitionNode part1 = extractFromExpression(op.child(0), tblModel, disjunct);
PartitionNode part2 = extractFromExpression(op.child(1), tblModel, disjunct);
return new PartitionCompositeNode(part1, part2, PartitionCompositeNodeOperator.AND);
}
use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionCompositeNode in project ignite by apache.
the class PartitionExtractor method extractFromOr.
/**
* Extract partition information from OR.
*
* @param op Operation.
* @param tblModel Table model.
* @return Partition.
*/
private PartitionNode extractFromOr(GridSqlOperation op, PartitionTableModel tblModel) throws IgniteCheckedException {
assert op.size() == 2;
// Parse inner expressions recursively with disjuncion flag set.
PartitionNode part1 = extractFromExpression(op.child(0), tblModel, true);
PartitionNode part2 = extractFromExpression(op.child(1), tblModel, true);
return new PartitionCompositeNode(part1, part2, PartitionCompositeNodeOperator.OR);
}
use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionCompositeNode in project ignite by apache.
the class PartitionExtractor method mergeMapQueries.
/**
* Merge partition info from multiple queries.
*
* @param qrys Queries.
* @return Partition result or {@code null} if nothing is resolved.
*/
@SuppressWarnings("IfMayBeConditional")
public PartitionResult mergeMapQueries(List<GridCacheSqlQuery> qrys) {
// Check if merge is possible.
PartitionTableAffinityDescriptor aff = null;
for (GridCacheSqlQuery qry : qrys) {
PartitionResult qryRes = (PartitionResult) qry.derivedPartitions();
// Failed to get results for one query -> broadcast.
if (qryRes == null)
return null;
// This only possible if query is resolved to "NONE". Will be skipped later during map request prepare.
if (qryRes.affinity() == null)
continue;
if (aff == null)
aff = qryRes.affinity();
else if (!aff.isCompatible(qryRes.affinity()))
// Queries refer to incompatible affinity groups, cannot merge -> broadcast.
return null;
}
// Merge.
PartitionNode tree = null;
AffinityTopologyVersion affinityTopVer = null;
for (GridCacheSqlQuery qry : qrys) {
PartitionResult qryRes = (PartitionResult) qry.derivedPartitions();
if (tree == null)
tree = qryRes.tree();
else
tree = new PartitionCompositeNode(tree, qryRes.tree(), PartitionCompositeNodeOperator.OR);
if (affinityTopVer == null)
affinityTopVer = qryRes.topologyVersion();
else
assert affinityTopVer.equals(qryRes.topologyVersion());
}
// Optimize.
assert tree != null;
tree = tree.optimize();
if (tree instanceof PartitionAllNode)
return null;
// If there is no affinity, then we assume "NONE" result.
assert aff != null || tree == PartitionNoneNode.INSTANCE;
// TODO: during PartitionResult construction/application.
assert affinityTopVer != null;
return new PartitionResult(tree, aff, affinityTopVer);
}
Aggregations