use of org.apache.ignite.internal.sql.engine.util.IndexConditions in project ignite-3 by apache.
the class IgniteLogicalIndexScan method create.
/**
* Creates a IgniteLogicalIndexScan.
*/
public static IgniteLogicalIndexScan create(RelOptCluster cluster, RelTraitSet traits, RelOptTable table, String idxName, @Nullable List<RexNode> proj, @Nullable RexNode cond, @Nullable ImmutableBitSet requiredColumns) {
InternalIgniteTable tbl = table.unwrap(InternalIgniteTable.class);
IgniteTypeFactory typeFactory = Commons.typeFactory(cluster);
RelCollation collation = tbl.getIndex(idxName).collation();
if (requiredColumns != null) {
Mappings.TargetMapping targetMapping = Commons.mapping(requiredColumns, tbl.getRowType(typeFactory).getFieldCount());
collation = collation.apply(targetMapping);
}
IndexConditions idxCond = new IndexConditions();
if (collation != null && !collation.getFieldCollations().isEmpty()) {
idxCond = RexUtils.buildSortedIndexConditions(cluster, collation, cond, tbl.getRowType(typeFactory), requiredColumns);
}
return new IgniteLogicalIndexScan(cluster, traits, table, idxName, proj, cond, idxCond, requiredColumns);
}
use of org.apache.ignite.internal.sql.engine.util.IndexConditions in project ignite-3 by apache.
the class FilterSpoolMergeToSortedIndexSpoolRule method onMatch.
/**
* {@inheritDoc}
*/
@Override
public void onMatch(RelOptRuleCall call) {
final IgniteFilter filter = call.rel(0);
final IgniteTableSpool spool = call.rel(1);
RelOptCluster cluster = spool.getCluster();
RelTraitSet trait = spool.getTraitSet();
CorrelationTrait filterCorr = TraitUtils.correlation(filter);
if (filterCorr.correlated()) {
trait = trait.replace(filterCorr);
}
RelNode input = spool.getInput();
IndexConditions idxCond = RexUtils.buildSortedIndexConditions(cluster, TraitUtils.collation(input), filter.getCondition(), spool.getRowType(), null);
if (nullOrEmpty(idxCond.lowerCondition()) && nullOrEmpty(idxCond.upperCondition())) {
return;
}
RelCollation collation = TraitUtils.createCollation(idxCond.keys());
RelNode res = new IgniteSortedIndexSpool(cluster, trait.replace(collation), convert(input, input.getTraitSet().replace(collation)), collation, filter.getCondition(), idxCond);
call.transformTo(res);
}
Aggregations