Search in sources :

Example 1 with PartitionTableModel

use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionTableModel in project ignite by apache.

the class PartitionExtractor method prepareTableModel.

/**
 * Prepare table model.
 *
 * @param from FROM clause.
 * @return Join model.
 */
private PartitionTableModel prepareTableModel(GridSqlAst from) {
    PartitionTableModel res = new PartitionTableModel();
    prepareTableModel0(from, res);
    return res;
}
Also used : PartitionTableModel(org.apache.ignite.internal.sql.optimizer.affinity.PartitionTableModel)

Example 2 with PartitionTableModel

use of org.apache.ignite.internal.sql.optimizer.affinity.PartitionTableModel in project ignite by apache.

the class PartitionExtractor method extract.

/**
 * Extract partitions.
 *
 * @param qry Query.
 * @return Partitions.
 */
public PartitionResult extract(GridSqlQuery qry) throws IgniteCheckedException {
    // No unions support yet.
    if (!(qry instanceof GridSqlSelect))
        return null;
    GridSqlSelect select = (GridSqlSelect) qry;
    // Prepare table model.
    PartitionTableModel tblModel = prepareTableModel(select.from());
    // Do extract.
    PartitionNode tree = extractFromExpression(select.where(), tblModel, false);
    assert tree != null;
    // Reduce tree if possible.
    tree = tree.optimize();
    if (tree instanceof PartitionAllNode)
        return null;
    // Done.
    return new PartitionResult(tree, tblModel.joinGroupAffinity(tree.joinGroup()), ctx.cache().context().exchange().readyAffinityVersion());
}
Also used : PartitionAllNode(org.apache.ignite.internal.sql.optimizer.affinity.PartitionAllNode) PartitionNode(org.apache.ignite.internal.sql.optimizer.affinity.PartitionNode) PartitionTableModel(org.apache.ignite.internal.sql.optimizer.affinity.PartitionTableModel) PartitionResult(org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult) GridSqlSelect(org.apache.ignite.internal.processors.query.h2.sql.GridSqlSelect)

Aggregations

PartitionTableModel (org.apache.ignite.internal.sql.optimizer.affinity.PartitionTableModel)2 GridSqlSelect (org.apache.ignite.internal.processors.query.h2.sql.GridSqlSelect)1 PartitionAllNode (org.apache.ignite.internal.sql.optimizer.affinity.PartitionAllNode)1 PartitionNode (org.apache.ignite.internal.sql.optimizer.affinity.PartitionNode)1 PartitionResult (org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult)1