Skip to content

Commit

Permalink
IGNITE-12455 Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandasch committed Sep 29, 2023
1 parent e23b973 commit b479581
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -83,12 +84,16 @@ public PartitionExtractor(IgniteTypeFactory typeFactory) {
@Override protected IgniteRel processNode(IgniteRel rel) {
IgniteRel res = super.processNode(rel);

if (rel.getInputs().size() <= 1)
if (rel.getInputs().isEmpty())
return res;

List<PartitionNode> operands = new ArrayList<>();
for (int i = 0; i < rel.getInputs().size(); ++i)
for (int i = 0; i < rel.getInputs().size(); ++i) {
if (stack.isEmpty())
break;

operands.add(stack.pop());
}

stack.push(PartitionOperandNode.createOrOperandNode(operands));

Expand Down Expand Up @@ -139,7 +144,12 @@ private void processScan(IgniteRel rel) {
types.add(Primitives.wrap((Class<?>)typeFactory.getJavaClass(field.getType())));
}

List<Integer> requiredCols = ((ProjectableFilterableTableScan)rel).requiredColumns().asList();
List<Integer> requiredCols;
if (((ProjectableFilterableTableScan)rel).requiredColumns() != null)
requiredCols = ((ProjectableFilterableTableScan)rel).requiredColumns().asList();
else
requiredCols = Collections.emptyList();

PartitionNode partNode = processCondition(condition, types, keys, requiredCols, cacheId);

stack.push(partNode);
Expand All @@ -166,7 +176,9 @@ private PartitionNode processCondition(
if (!left.isA(SqlKind.LOCAL_REF))
return PartitionAllNode.INSTANCE;

int idx = requiredCols.get(((RexLocalRef)left).getIndex());
int idx = ((RexLocalRef)left).getIndex();
if (!requiredCols.isEmpty())
idx = requiredCols.get(idx);

if (!keys.contains(idx))
return PartitionAllNode.INSTANCE;
Expand All @@ -193,7 +205,9 @@ private PartitionNode processCondition(
if (!right.isA(SqlKind.LITERAL) && !right.isA(SqlKind.DYNAMIC_PARAM))
return PartitionAllNode.INSTANCE;

int idx = requiredCols.get(((RexLocalRef)left).getIndex());
int idx = ((RexLocalRef)left).getIndex();
if (!requiredCols.isEmpty())
idx = requiredCols.get(idx);

if (!keys.contains(idx))
return PartitionAllNode.INSTANCE;
Expand Down

0 comments on commit b479581

Please sign in to comment.