Skip to content

Commit 1e3b09a

Browse files
committed
Revert "Add new ImmutableBitSet#isMinimal API and check unique keys minimality in tests"
The codebase has already "minimization" code in various other places (e.g., RelMdUniqueKeys#filterSupersets) and there is overlapping functionality with the new isMinimal API. Based on these findings, I don't think a new API is necessary thus I reverted the respective code changes from here. If we want to add a new public API its better to refactor/use the existing "minimization" logic. However, the refactoring will require some discussion on where to move the code and how we want the API to look like so it is out of the scope of this PR.
1 parent 66ab17c commit 1e3b09a

File tree

3 files changed

+0
-45
lines changed

3 files changed

+0
-45
lines changed

core/src/main/java/org/apache/calcite/util/ImmutableBitSet.java

-12
Original file line numberDiff line numberDiff line change
@@ -978,18 +978,6 @@ public static boolean allContain(Collection<ImmutableBitSet> bitSets, int bit) {
978978
return true;
979979
}
980980

981-
/**
982-
* Returns whether this is a minimal set with respect to the specified collection of bitSets.
983-
*/
984-
public boolean isMinimal(Collection<ImmutableBitSet> bitSets) {
985-
for (ImmutableBitSet other : bitSets) {
986-
if (!this.equals(other) && this.contains(other)) {
987-
return false;
988-
}
989-
}
990-
return true;
991-
}
992-
993981
/** Returns whether a given predicate evaluates to true for all bits in this
994982
* set. */
995983
public boolean allMatch(IntPredicate predicate) {

core/src/test/java/org/apache/calcite/util/ImmutableBitSetTest.java

-32
Original file line numberDiff line numberDiff line change
@@ -668,38 +668,6 @@ private List<ImmutableBitSet> getSortedList() {
668668
assertFalse(ImmutableBitSet.allContain(collection2, 4));
669669
}
670670

671-
@Test void testIsMinimal() {
672-
ImmutableBitSet se = ImmutableBitSet.of();
673-
ImmutableBitSet s0 = ImmutableBitSet.of(0);
674-
ImmutableBitSet s1 = ImmutableBitSet.of(1);
675-
ImmutableBitSet s01 = ImmutableBitSet.of(0, 1);
676-
677-
assertTrue(se.isMinimal(Collections.singletonList(se)));
678-
assertTrue(se.isMinimal(Collections.singletonList(s0)));
679-
assertTrue(se.isMinimal(Collections.singletonList(s1)));
680-
assertTrue(se.isMinimal(Collections.singletonList(s01)));
681-
682-
assertFalse(s0.isMinimal(Collections.singletonList(se)));
683-
assertTrue(s0.isMinimal(Collections.singletonList(s0)));
684-
assertTrue(s0.isMinimal(Collections.singletonList(s1)));
685-
assertTrue(s0.isMinimal(Collections.singletonList(s01)));
686-
687-
assertFalse(s1.isMinimal(Collections.singletonList(se)));
688-
assertTrue(s1.isMinimal(Collections.singletonList(s0)));
689-
assertTrue(s1.isMinimal(Collections.singletonList(s1)));
690-
assertTrue(s1.isMinimal(Collections.singletonList(s01)));
691-
692-
assertFalse(s01.isMinimal(Collections.singletonList(se)));
693-
assertFalse(s01.isMinimal(Collections.singletonList(s0)));
694-
assertFalse(s01.isMinimal(Collections.singletonList(s1)));
695-
assertTrue(s01.isMinimal(Collections.singletonList(s01)));
696-
697-
assertTrue(se.isMinimal(Arrays.asList(s0, s1)));
698-
assertTrue(s0.isMinimal(Arrays.asList(s0, s1)));
699-
assertTrue(s1.isMinimal(Arrays.asList(s0, s1)));
700-
assertFalse(s01.isMinimal(Arrays.asList(s0, s1)));
701-
}
702-
703671
/**
704672
* Test case for {@link ImmutableBitSet#anyMatch(IntPredicate)}
705673
* and {@link ImmutableBitSet#allMatch(IntPredicate)}.

testkit/src/main/java/org/apache/calcite/test/RelMetadataFixture.java

-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ public RelMetadataFixture assertThatUniqueKeysAre(
356356
ImmutableSortedSet.copyOf(result),
357357
is(ImmutableSortedSet.copyOf(expectedUniqueKeys)));
358358
checkUniqueConsistent(rel);
359-
assertThat(result.stream().allMatch(s -> s.isMinimal(result)), is(true));
360359
return this;
361360
}
362361

0 commit comments

Comments
 (0)