Search in sources :

Example 16 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class GridH2CollocationModel method isAffinityColumn.

/**
     * @param f Table filter.
     * @param expCol Expression column.
     * @param validate Query validation flag.
     * @return {@code true} It it is an affinity column.
     */
private static boolean isAffinityColumn(TableFilter f, ExpressionColumn expCol, boolean validate) {
    Column col = expCol.getColumn();
    if (col == null)
        return false;
    Table t = col.getTable();
    if (t.isView()) {
        Query qry;
        if (f.getIndex() != null)
            qry = getSubQuery(f);
        else
            qry = GridSqlQueryParser.VIEW_QUERY.get((TableView) t);
        return isAffinityColumn(qry, expCol, validate);
    }
    if (t instanceof GridH2Table) {
        if (validate && ((GridH2Table) t).rowDescriptor().context().customAffinityMapper())
            throw customAffinityError(((GridH2Table) t).cacheName());
        IndexColumn affCol = ((GridH2Table) t).getAffinityKeyColumn();
        return affCol != null && col.getColumnId() == affCol.column.getColumnId();
    }
    return false;
}
Also used : Table(org.h2.table.Table) Query(org.h2.command.dml.Query) ExpressionColumn(org.h2.expression.ExpressionColumn) Column(org.h2.table.Column) IndexColumn(org.h2.table.IndexColumn) IndexColumn(org.h2.table.IndexColumn)

Example 17 with IndexColumn

use of org.h2.table.IndexColumn in project ignite by apache.

the class GridH2IndexBase method createLookupBatch.

/** {@inheritDoc} */
@Override
public IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter) {
    GridH2QueryContext qctx = GridH2QueryContext.get();
    if (qctx == null || qctx.distributedJoinMode() == OFF || !getTable().isPartitioned())
        return null;
    IndexColumn affCol = getTable().getAffinityKeyColumn();
    GridH2RowDescriptor desc = getTable().rowDescriptor();
    int affColId = -1;
    boolean ucast = false;
    if (affCol != null) {
        affColId = affCol.column.getColumnId();
        int[] masks = filters[filter].getMasks();
        if (masks != null) {
            ucast = (masks[affColId] & IndexCondition.EQUALITY) != 0 || desc.checkKeyIndexCondition(masks, IndexCondition.EQUALITY);
        }
    }
    GridCacheContext<?, ?> cctx = getTable().rowDescriptor().context();
    return new DistributedLookupBatch(cctx, ucast, affColId);
}
Also used : IndexColumn(org.h2.table.IndexColumn)

Aggregations

IndexColumn (org.h2.table.IndexColumn)17 Column (org.h2.table.Column)5 ArrayList (java.util.ArrayList)4 GridH2RowDescriptor (org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor)3 ExpressionColumn (org.h2.expression.ExpressionColumn)3 LinkedHashMap (java.util.LinkedHashMap)2 CacheException (javax.cache.CacheException)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)2 SB (org.apache.ignite.internal.util.typedef.internal.SB)2 AlterTableAddConstraint (org.h2.command.ddl.AlterTableAddConstraint)2 Query (org.h2.command.dml.Query)2 Schema (org.h2.schema.Schema)2 Value (org.h2.value.Value)2 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1