@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { return new EnumerableSort(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE).replace(collation), // sole(inputs), collation, offset, fetch); }
@Override public EnumerableSort copy( RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { return new EnumerableSort(getCluster(), traitSet, newInput, newCollation, offset, fetch); }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), result.format); Expression childExp = builder.append("child", result.block); PhysType inputPhysType = result.physType; final Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( collation.getFieldCollations()); builder.add( Expressions.return_(null, Expressions.call(childExp, BuiltInMethod.ORDER_BY.method, Expressions.list( builder.append("keySelector", pair.left)) .appendIfNotNull( builder.appendIfNotNull("comparator", pair.right))))); return implementor.result(physType, builder.toBlock()); } }
private PlannerOp planSort(EnumerableSort op, RelDataType rowType) { PlannerOp input = convertRelNode(op.getInput(), rowType, false); RelCollation collation = op.getCollation(); List<RelFieldCollation> fieldCollations = collation.getFieldCollations(); boolean[] directions = new boolean[fieldCollations.size()]; int[] fields = new int[fieldCollations.size()]; int i = 0; for (RelFieldCollation col : fieldCollations) { RelFieldCollation.Direction direction = col.getDirection(); int index = col.getFieldIndex(); directions[i] = direction == RelFieldCollation.Direction.ASCENDING || direction == RelFieldCollation.Direction.STRICTLY_ASCENDING; fields[i++] = index; } return new SortOp(input, directions, fields); }
/** * Creates an EnumerableSort. * * <p>Use {@link #create} unless you know what you're doing. */ public EnumerableSort(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { super(cluster, traitSet, input, collation, offset, fetch); assert getConvention() instanceof EnumerableConvention; assert getConvention() == input.getConvention(); }
public RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelNode input = sort.getInput(); return EnumerableSort.create( convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), sort.getCollation(), null, null); } }
@Override public EnumerableSort copy( RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) { return new EnumerableSort(getCluster(), traitSet, newInput, newCollation, offset, fetch); }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); final PhysType physType = PhysTypeImpl.of( implementor.getTypeFactory(), getRowType(), result.format); Expression childExp = builder.append("child", result.block); PhysType inputPhysType = result.physType; final Pair<Expression, Expression> pair = inputPhysType.generateCollationKey( collation.getFieldCollations()); builder.add( Expressions.return_(null, Expressions.call(childExp, BuiltInMethod.ORDER_BY.method, Expressions.list( builder.append("keySelector", pair.left)) .appendIfNotNull( builder.appendIfNotNull("comparator", pair.right))))); return implementor.result(physType, builder.toBlock()); } }
/** * Creates an EnumerableSort. * * <p>Use {@link #create} unless you know what you're doing. */ public EnumerableSort(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, RelCollation collation, RexNode offset, RexNode fetch) { super(cluster, traitSet, input, collation, offset, fetch); assert getConvention() instanceof EnumerableConvention; assert getConvention() == input.getConvention(); }
public RelNode convert(RelNode rel) { final Sort sort = (Sort) rel; if (sort.offset != null || sort.fetch != null) { return null; } final RelNode input = sort.getInput(); return EnumerableSort.create( convert( input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), sort.getCollation(), null, null); } }
/** Creates an EnumerableSort. */ public static EnumerableSort create(RelNode child, RelCollation collation, RexNode offset, RexNode fetch) { final RelOptCluster cluster = child.getCluster(); final RelTraitSet traitSet = cluster.traitSetOf(EnumerableConvention.INSTANCE) .replace(collation); return new EnumerableSort(cluster, traitSet, child, collation, offset, fetch); }
/** Creates an EnumerableSort. */ public static EnumerableSort create(RelNode child, RelCollation collation, RexNode offset, RexNode fetch) { final RelOptCluster cluster = child.getCluster(); final RelTraitSet traitSet = cluster.traitSetOf(EnumerableConvention.INSTANCE) .replace(collation); return new EnumerableSort(cluster, traitSet, child, collation, offset, fetch); }
@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { return new EnumerableSort(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE).replace(collation), // sole(inputs), collation, offset, fetch); }