Skip to content

Commit 73c9da6

Browse files
committed
Generalize forEachValue/Entry
1 parent e186435 commit 73c9da6

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/java/org/apache/cassandra/db/tries/BaseTrie.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ default void addPathBytes(DirectBuffer buffer, int pos, int count)
7878
}
7979

8080
/// Call the given consumer on all content values in the trie in order.
81-
default void forEachValue(ValueConsumer<T> consumer)
81+
default void forEachValue(ValueConsumer<? super T> consumer)
8282
{
8383
process(Direction.FORWARD, consumer);
8484
}
8585

8686
/// Call the given consumer on all content values in the trie in order.
87-
default void forEachValue(Direction direction, ValueConsumer<T> consumer)
87+
default void forEachValue(Direction direction, ValueConsumer<? super T> consumer)
8888
{
8989
process(direction, consumer);
9090
}
9191

9292
/// Call the given consumer on all (path, content) pairs with non-null content in the trie in order.
93-
default void forEachEntry(BiConsumer<ByteComparable, T> consumer)
93+
default void forEachEntry(BiConsumer<ByteComparable, ? super T> consumer)
9494
{
9595
forEachEntry(Direction.FORWARD, consumer);
9696
}
9797

9898
/// Call the given consumer on all (path, content) pairs with non-null content in the trie in order.
99-
default void forEachEntry(Direction direction, BiConsumer<ByteComparable, T> consumer)
99+
default void forEachEntry(Direction direction, BiConsumer<ByteComparable, ? super T> consumer)
100100
{
101101
Cursor<T> cursor = cursor(direction);
102102
cursor.process(new TrieEntriesWalker.WithConsumer<>(consumer, cursor.byteComparableVersion()));
@@ -111,14 +111,14 @@ default <R> R process(Direction direction, Cursor.Walker<? super T, R> walker)
111111
}
112112

113113
/// Process the trie using the given [ValueConsumer], skipping all branches below the top content-bearing node.
114-
default void forEachValueSkippingBranches(Direction direction, ValueConsumer<T> consumer)
114+
default void forEachValueSkippingBranches(Direction direction, ValueConsumer<? super T> consumer)
115115
{
116116
processSkippingBranches(direction, consumer);
117117
}
118118

119119
/// Call the given consumer on all `(path, content)` pairs with non-null content in the trie in order, skipping all
120120
/// branches below the top content-bearing node.
121-
default void forEachEntrySkippingBranches(Direction direction, BiConsumer<ByteComparable, T> consumer)
121+
default void forEachEntrySkippingBranches(Direction direction, BiConsumer<ByteComparable, ? super T> consumer)
122122
{
123123
Cursor<T> cursor = cursor(direction);
124124
cursor.processSkippingBranches(new TrieEntriesWalker.WithConsumer<>(consumer, cursor.byteComparableVersion()));
@@ -127,7 +127,7 @@ default void forEachEntrySkippingBranches(Direction direction, BiConsumer<ByteCo
127127
}
128128

129129
/// Process the trie using the given [Cursor.Walker], skipping all branches below the top content-bearing node.
130-
default <R> R processSkippingBranches(Direction direction, Cursor.Walker<T, R> walker)
130+
default <R> R processSkippingBranches(Direction direction, Cursor.Walker<? super T, R> walker)
131131
{
132132
return cursor(direction).processSkippingBranches(walker);
133133
}

src/java/org/apache/cassandra/db/tries/Cursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ default <R> R process(Cursor.Walker<? super T, R> walker)
289289

290290
/// Process the trie using the given [Walker], skipping over branches where content was found.
291291
/// This method should only be called on a freshly constructed cursor.
292-
default <R> R processSkippingBranches(Cursor.Walker<T, R> walker)
292+
default <R> R processSkippingBranches(Cursor.Walker<? super T, R> walker)
293293
{
294294
assert depth() == 0 : "The provided cursor has already been advanced.";
295295
T content = content(); // handle content on the root node

src/java/org/apache/cassandra/db/tries/DepthAdjustedCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public <R> R process(Walker<? super T, R> walker)
121121
}
122122

123123
@Override
124-
public <R> R processSkippingBranches(Walker<T, R> walker)
124+
public <R> R processSkippingBranches(Walker<? super T, R> walker)
125125
{
126126
throw new AssertionError("Depth-adjusted cursors cannot be walked directly.");
127127
}

src/java/org/apache/cassandra/db/tries/TrieEntriesWalker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public void content(T content)
3636
/// Iterator representing the content of the trie a sequence of (path, content) pairs.
3737
static class WithConsumer<T> extends TrieEntriesWalker<T, Void>
3838
{
39-
private final BiConsumer<ByteComparable, T> consumer;
39+
private final BiConsumer<ByteComparable, ? super T> consumer;
4040
private final ByteComparable.Version byteComparableVersion;
4141

42-
public WithConsumer(BiConsumer<ByteComparable, T> consumer, ByteComparable.Version byteComparableVersion)
42+
public WithConsumer(BiConsumer<ByteComparable, ? super T> consumer, ByteComparable.Version byteComparableVersion)
4343
{
4444
this.consumer = consumer;
4545
this.byteComparableVersion = byteComparableVersion;

0 commit comments

Comments
 (0)