Search in sources :

Example 1 with PartitionParameterNode

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

the class PartitionExtractor method extractSingle.

/**
 * Extract single partition.
 *
 * @param leftCol Left column.
 * @param rightConst Right constant.
 * @param rightParam Right parameter.
 * @param tblModel Table model.
 * @return Partition or {@code null} if failed to extract.
 */
@Nullable
private PartitionSingleNode extractSingle(GridSqlColumn leftCol, GridSqlConst rightConst, GridSqlParameter rightParam, PartitionTableModel tblModel) throws IgniteCheckedException {
    assert leftCol != null;
    Column leftCol0 = leftCol.column();
    assert leftCol0.getTable() != null;
    assert leftCol0.getTable() instanceof GridH2Table;
    GridH2Table tbl = (GridH2Table) leftCol0.getTable();
    if (!tbl.isColumnForPartitionPruning(leftCol0))
        return null;
    PartitionTable tbl0 = tblModel.table(leftCol.tableAlias());
    // If table is in ignored set, then we cannot use it for partition extraction.
    if (tbl0 == null)
        return null;
    if (rightConst != null) {
        int part = partResolver.partition(rightConst.value().getObject(), leftCol0.getType(), tbl.cacheName());
        return new PartitionConstantNode(tbl0, part);
    } else if (rightParam != null) {
        int colType = leftCol0.getType();
        return new PartitionParameterNode(tbl0, partResolver, rightParam.index(), leftCol0.getType(), mappedType(colType));
    } else
        return null;
}
Also used : PartitionTable(org.apache.ignite.internal.sql.optimizer.affinity.PartitionTable) Column(org.h2.table.Column) GridSqlColumn(org.apache.ignite.internal.processors.query.h2.sql.GridSqlColumn) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) PartitionParameterNode(org.apache.ignite.internal.sql.optimizer.affinity.PartitionParameterNode) PartitionConstantNode(org.apache.ignite.internal.sql.optimizer.affinity.PartitionConstantNode) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)1 GridSqlColumn (org.apache.ignite.internal.processors.query.h2.sql.GridSqlColumn)1 PartitionConstantNode (org.apache.ignite.internal.sql.optimizer.affinity.PartitionConstantNode)1 PartitionParameterNode (org.apache.ignite.internal.sql.optimizer.affinity.PartitionParameterNode)1 PartitionTable (org.apache.ignite.internal.sql.optimizer.affinity.PartitionTable)1 Column (org.h2.table.Column)1 Nullable (org.jetbrains.annotations.Nullable)1