You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/10/07 11:52:13 UTC
[GitHub] [ignite-3] sashapolo commented on a diff in pull request #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
sashapolo commented on code in PR #1172:
URL: https://github.com/apache/ignite-3/pull/1172#discussion_r990003603
##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/index/impl/TestSortedIndexStorage.java:
##########
@@ -118,21 +114,31 @@ public Cursor<IndexRow> scan(
boolean includeLower = (flags & GREATER_OR_EQUAL) != 0;
boolean includeUpper = (flags & LESS_OR_EQUAL) != 0;
- Stream<Map.Entry<ByteBuffer, Set<RowId>>> data = index.entrySet().stream();
-
- if (lowerBound != null) {
- ToIntFunction<ByteBuffer> lowerCmp = boundComparator(lowerBound, includeLower ? 0 : -1);
-
- data = data.dropWhile(e -> lowerCmp.applyAsInt(e.getKey()) < 0);
+ if (!includeLower && lowerBound != null) {
+ setEqualityFlag(lowerBound);
}
- if (upperBound != null) {
- ToIntFunction<ByteBuffer> upperCmp = boundComparator(upperBound, includeUpper ? 0 : 1);
+ if (includeUpper && upperBound != null) {
+ setEqualityFlag(upperBound);
+ }
- data = data.takeWhile(e -> upperCmp.applyAsInt(e.getKey()) <= 0);
+ SortedMap<ByteBuffer, Set<RowId>> data;
+
+ if (lowerBound == null && upperBound == null) {
+ data = index;
+ } else if (lowerBound == null) {
+ data = index.headMap(upperBound.byteBuffer());
+ } else if (upperBound == null) {
+ data = index.tailMap(lowerBound.byteBuffer());
+ } else {
+ try {
+ data = index.subMap(lowerBound.byteBuffer(), upperBound.byteBuffer());
+ } catch (IllegalArgumentException e) {
Review Comment:
This exception is thrown if the lowerBound is larger than the upperBound
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org