Union predicate appears to have indexes range issue in evaluate

Issue #3 open
Eric Milles created an issue

The implementation of evaluate() in UnionPredicate (included below for reference) appears to have an issue when iterating over the indexes array. The counting loop goes from 0 to indexes.length. I believe it should go from 0 to current.

    public List<Value> evaluate(List<Value> values, List<Value> results) {
        for(Value value: values) {
            int currentValueSize = value.size();
            for(int j=0;j<Array.getLength(indexes);j++) {
                if(indexes[j] >= 0 && indexes[j] < currentValueSize) {
                    results.add(value.get(indexes[j]));
                } else if(indexes[j] < 0 && (currentValueSize - indexes[j]) >= 0) {
                    results.add(value.get(currentValueSize + indexes[j]));
                }
            }
        }
        return results;
    }

Comments (3)

  1. John Marsden repo owner
    • changed status to open
    • edited description

    If I re-use this union predicate I will make sure to fix this.

  2. Log in to comment