Skip to content

Commit

Permalink
[core] Remove Predicate.test(Object[]) to use InternalRow (apache#2796)
Browse files Browse the repository at this point in the history
  • Loading branch information
JingsongLi authored Jan 26, 2024
1 parent 973e686 commit 6d15bd3
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 243 deletions.
10 changes: 0 additions & 10 deletions paimon-common/src/main/java/org/apache/paimon/predicate/And.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public class And extends CompoundPredicate.Function {

private And() {}

@Override
public boolean test(Object[] values, List<Predicate> children) {
for (Predicate child : children) {
if (!child.test(values)) {
return false;
}
}
return true;
}

@Override
public boolean test(InternalRow row, List<Predicate> children) {
for (Predicate child : children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public List<Predicate> children() {
return children;
}

@Override
public boolean test(Object[] values) {
return function.test(values, children);
}

@Override
public boolean test(InternalRow row) {
return function.test(row, children);
Expand Down Expand Up @@ -95,8 +90,6 @@ public String toString() {
/** Evaluate the predicate result based on multiple {@link Predicate}s. */
public abstract static class Function implements Serializable {

public abstract boolean test(Object[] values, List<Predicate> children);

public abstract boolean test(InternalRow row, List<Predicate> children);

public abstract boolean test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public LeafPredicate copyWithNewIndex(int fieldIndex) {
return new LeafPredicate(function, type, fieldIndex, fieldName, literals);
}

@Override
public boolean test(Object[] values) {
return function.test(type, values[fieldIndex], literals);
}

@Override
public boolean test(InternalRow row) {
return function.test(type, InternalRowUtils.get(row, fieldIndex, type), literals);
Expand Down
10 changes: 0 additions & 10 deletions paimon-common/src/main/java/org/apache/paimon/predicate/Or.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public class Or extends CompoundPredicate.Function {

private Or() {}

@Override
public boolean test(Object[] values, List<Predicate> children) {
for (Predicate child : children) {
if (child.test(values)) {
return true;
}
}
return false;
}

@Override
public boolean test(InternalRow row, List<Predicate> children) {
for (Predicate child : children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@
@Public
public interface Predicate extends Serializable {

/**
* Test based on the specific input column values.
*
* @return return true when hit, false when not hit.
*/
boolean test(Object[] values);

/**
* Test based on the specific input row.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.paimon.predicate;

import org.apache.paimon.data.GenericRow;
import org.apache.paimon.format.FieldStats;
import org.apache.paimon.types.IntType;
import org.apache.paimon.types.RowType;
Expand All @@ -36,11 +37,11 @@ public void testBetween() {
PredicateBuilder builder = new PredicateBuilder(RowType.of(new IntType()));
Predicate predicate = builder.between(0, 1, 3);

assertThat(predicate.test(new Object[] {1})).isEqualTo(true);
assertThat(predicate.test(new Object[] {2})).isEqualTo(true);
assertThat(predicate.test(new Object[] {3})).isEqualTo(true);
assertThat(predicate.test(new Object[] {4})).isEqualTo(false);
assertThat(predicate.test(new Object[] {null})).isEqualTo(false);
assertThat(predicate.test(GenericRow.of(1))).isEqualTo(true);
assertThat(predicate.test(GenericRow.of(2))).isEqualTo(true);
assertThat(predicate.test(GenericRow.of(3))).isEqualTo(true);
assertThat(predicate.test(GenericRow.of(4))).isEqualTo(false);
assertThat(predicate.test(GenericRow.of((Object) null))).isEqualTo(false);

assertThat(predicate.test(3, new FieldStats[] {new FieldStats(0, 5, 0L)})).isEqualTo(true);
assertThat(predicate.test(3, new FieldStats[] {new FieldStats(2, 5, 0L)})).isEqualTo(true);
Expand All @@ -55,11 +56,11 @@ public void testBetweenNull() {
PredicateBuilder builder = new PredicateBuilder(RowType.of(new IntType()));
Predicate predicate = builder.between(0, 1, null);

assertThat(predicate.test(new Object[] {1})).isEqualTo(false);
assertThat(predicate.test(new Object[] {2})).isEqualTo(false);
assertThat(predicate.test(new Object[] {3})).isEqualTo(false);
assertThat(predicate.test(new Object[] {4})).isEqualTo(false);
assertThat(predicate.test(new Object[] {null})).isEqualTo(false);
assertThat(predicate.test(GenericRow.of(1))).isEqualTo(false);
assertThat(predicate.test(GenericRow.of(2))).isEqualTo(false);
assertThat(predicate.test(GenericRow.of(3))).isEqualTo(false);
assertThat(predicate.test(GenericRow.of(4))).isEqualTo(false);
assertThat(predicate.test(GenericRow.of((Object) null))).isEqualTo(false);

assertThat(predicate.test(3, new FieldStats[] {new FieldStats(0, 5, 0L)})).isEqualTo(false);
assertThat(predicate.test(3, new FieldStats[] {new FieldStats(2, 5, 0L)})).isEqualTo(false);
Expand Down
Loading

0 comments on commit 6d15bd3

Please sign in to comment.