use of org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable in project ignite-3 by apache.
the class LogicalRelImplementor method visit.
/**
* {@inheritDoc}
*/
@Override
public Node<RowT> visit(IgniteTableScan rel) {
RexNode condition = rel.condition();
List<RexNode> projects = rel.projects();
ImmutableBitSet requiredColumns = rel.requiredColumns();
InternalIgniteTable tbl = rel.getTable().unwrap(InternalIgniteTable.class);
assert tbl != null;
IgniteTypeFactory typeFactory = ctx.getTypeFactory();
RelDataType rowType = tbl.getRowType(typeFactory, requiredColumns);
Predicate<RowT> filters = condition == null ? null : expressionFactory.predicate(condition, rowType);
Function<RowT, RowT> prj = projects == null ? null : expressionFactory.project(projects, rowType);
ColocationGroup group = ctx.group(rel.sourceId());
if (!group.nodeIds().contains(ctx.localNodeId())) {
return new ScanNode<>(ctx, rowType, Collections.emptyList());
}
return new TableScanNode<>(ctx, rowType, tbl, group.partitions(ctx.localNodeId()), filters, prj, requiredColumns);
}
use of org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable in project ignite-3 by apache.
the class LogicalRelImplementor method visit.
/**
* {@inheritDoc}
*/
@Override
public Node<RowT> visit(IgniteIndexScan rel) {
// TODO: fix this
// RexNode condition = rel.condition();
// List<RexNode> projects = rel.projects();
InternalIgniteTable tbl = rel.getTable().unwrap(InternalIgniteTable.class);
IgniteTypeFactory typeFactory = ctx.getTypeFactory();
ImmutableBitSet requiredColumns = rel.requiredColumns();
// List<RexNode> lowerCond = rel.lowerBound();
// List<RexNode> upperCond = rel.upperBound();
RelDataType rowType = tbl.getRowType(typeFactory, requiredColumns);
// Predicate<Row> filters = condition == null ? null : expressionFactory.predicate(condition, rowType);
// Supplier<Row> lower = lowerCond == null ? null : expressionFactory.rowSource(lowerCond);
// Supplier<Row> upper = upperCond == null ? null : expressionFactory.rowSource(upperCond);
// Function<Row, Row> prj = projects == null ? null : expressionFactory.project(projects, rowType);
//
// IgniteIndex idx = tbl.getIndex(rel.indexName());
//
// ColocationGroup group = ctx.group(rel.sourceId());
Iterable<RowT> rowsIter = (Iterable<RowT>) List.of(new Object[] { 0, 0 }, // idx.scan(ctx, group, filters, lower, upper, prj, requiredColumns);
new Object[] { 1, 1 });
return new ScanNode<>(ctx, rowType, rowsIter);
}
use of org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable 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.schema.InternalIgniteTable in project ignite-3 by apache.
the class ExposeIndexRule method onMatch.
/**
* {@inheritDoc}
*/
@Override
public void onMatch(RelOptRuleCall call) {
IgniteLogicalTableScan scan = call.rel(0);
RelOptCluster cluster = scan.getCluster();
RelOptTable optTable = scan.getTable();
InternalIgniteTable igniteTable = optTable.unwrap(InternalIgniteTable.class);
List<RexNode> proj = scan.projects();
RexNode condition = scan.condition();
ImmutableBitSet requiredCols = scan.requiredColumns();
List<IgniteLogicalIndexScan> indexes = igniteTable.indexes().keySet().stream().map(idxName -> igniteTable.toRel(cluster, optTable, idxName, proj, condition, requiredCols)).collect(Collectors.toList());
if (indexes.isEmpty()) {
return;
}
Map<RelNode, RelNode> equivMap = new HashMap<>(indexes.size());
for (int i = 1; i < indexes.size(); i++) {
equivMap.put(indexes.get(i), scan);
}
call.transformTo(indexes.get(0), equivMap);
}
use of org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable in project ignite-3 by apache.
the class LogicalRelImplementor method visit.
/**
* {@inheritDoc}
*/
@Override
public Node<RowT> visit(IgniteTableModify rel) {
switch(rel.getOperation()) {
case INSERT:
case UPDATE:
case DELETE:
case MERGE:
InternalIgniteTable tbl = rel.getTable().unwrap(InternalIgniteTable.class);
assert tbl != null;
ModifyNode<RowT> node = new ModifyNode<>(ctx, rel.getRowType(), tbl, rel.getOperation(), rel.getUpdateColumnList());
Node<RowT> input = visit(rel.getInput());
node.register(input);
return node;
default:
throw new AssertionError("Unsupported operation: " + rel.getOperation());
}
}
Aggregations