You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2019/01/03 18:01:58 UTC
[calcite] branch master updated: Revert "[CALCITE-2764]
RelCompositeTrait#satisfies does not work for non-trivial traits"
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 8e36344 Revert "[CALCITE-2764] RelCompositeTrait#satisfies does not work for non-trivial traits"
8e36344 is described below
commit 8e36344414f7583c1fe5489ae41915190e0f6a1b
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Thu Jan 3 21:01:42 2019 +0300
Revert "[CALCITE-2764] RelCompositeTrait#satisfies does not work for non-trivial traits"
This reverts commit 92978d981e6ca2eb352c1654d14c7b64fb8710fd.
---
.../org/apache/calcite/plan/RelCompositeTrait.java | 15 ------
.../java/org/apache/calcite/plan/RelTraitTest.java | 56 ----------------------
2 files changed, 71 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/plan/RelCompositeTrait.java b/core/src/main/java/org/apache/calcite/plan/RelCompositeTrait.java
index d1190e4..e3555b8 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelCompositeTrait.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelCompositeTrait.java
@@ -89,21 +89,6 @@ class RelCompositeTrait<T extends RelMultipleTrait> implements RelTrait {
}
public boolean satisfies(RelTrait trait) {
- if (trait instanceof RelCompositeTrait) {
- if (equals(trait)) {
- return true;
- }
- //noinspection unchecked
- RelCompositeTrait<T> other = (RelCompositeTrait<T>) trait;
- // This trait should be the same or stricter, so this trait should satisfy each component
- for (T t : other.traits) {
- if (!satisfies(t)) {
- return false;
- }
- }
- return true;
- }
- // This trait might be stricter, so at least one component should satisfy given trait
for (T t : traits) {
if (t.satisfies(trait)) {
return true;
diff --git a/core/src/test/java/org/apache/calcite/plan/RelTraitTest.java b/core/src/test/java/org/apache/calcite/plan/RelTraitTest.java
index 78fccd2..043a5ab 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelTraitTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelTraitTest.java
@@ -19,7 +19,6 @@ package org.apache.calcite.plan;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollationTraitDef;
import org.apache.calcite.rel.RelCollations;
-import org.apache.calcite.rel.RelFieldCollation;
import com.google.common.collect.ImmutableList;
@@ -58,61 +57,6 @@ public class RelTraitTest {
assertCanonical("composite with two elements",
() -> ImmutableList.of(RelCollations.of(0), RelCollations.of(1)));
}
-
- private void assertSatisfies(RelTrait a, RelTrait b) {
- Assert.assertTrue(a + ".satisfies(" + b + ")", a.satisfies(b));
- if (!a.equals(b)) {
- // a should be "the same or stricter" than b, so b cannot be stricter than a at the same time
- Assert.assertTrue(b + ".NOTsatisfies(" + a + ")", !b.satisfies(a));
- }
- }
-
- /**
- * Tests for {@link RelCompositeTrait#satisfies(RelTrait)}.
- */
- @Test public void compositeSatisfies() {
- //noinspection unchecked
- RelCompositeTrait<RelCollation> abc_bc_c = (RelCompositeTrait) RelCompositeTrait.of(COLLATION,
- ImmutableList.of(
- RelCollations.of(
- new RelFieldCollation(0),
- new RelFieldCollation(1),
- new RelFieldCollation(2)),
- RelCollations.of(
- new RelFieldCollation(1),
- new RelFieldCollation(2)),
- RelCollations.of(
- new RelFieldCollation(2))));
-
- // A composite trait must satisfy its sub-traits
- for (RelCollation collation : abc_bc_c.traitList()) {
- assertSatisfies(abc_bc_c, collation);
- }
-
- // A trait must satisfy to itself
- assertSatisfies(abc_bc_c, abc_bc_c);
-
- //noinspection unchecked
- RelCompositeTrait<RelCollation> bc_c = (RelCompositeTrait) RelCompositeTrait.of(COLLATION,
- ImmutableList.of(
- RelCollations.of(
- new RelFieldCollation(1),
- new RelFieldCollation(2)),
- RelCollations.of(
- new RelFieldCollation(2))));
-
- assertSatisfies(abc_bc_c, bc_c);
-
- //noinspection unchecked
- RelCompositeTrait<RelCollation> b_c = (RelCompositeTrait) RelCompositeTrait.of(COLLATION,
- ImmutableList.of(
- RelCollations.of(
- new RelFieldCollation(1)),
- RelCollations.of(
- new RelFieldCollation(2))));
-
- assertSatisfies(abc_bc_c, b_c);
- }
}
// End RelTraitTest.java