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/06 18:09:03 UTC
[GitHub] [ignite-3] sashapolo opened a new pull request, #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
sashapolo opened a new pull request, #1172:
URL: https://github.com/apache/ignite-3/pull/1172
https://issues.apache.org/jira/browse/IGNITE-17818
--
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
[GitHub] [ignite-3] ibessonov commented on a diff in pull request #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #1172:
URL: https://github.com/apache/ignite-3/pull/1172#discussion_r989983565
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java:
##########
@@ -120,26 +119,60 @@ public void remove(IndexRow row) {
@Override
public Cursor<IndexRow> scan(@Nullable BinaryTuplePrefix lowerBound, @Nullable BinaryTuplePrefix upperBound, int flags) {
- Cursor<SortedIndexRow> cursor;
+ boolean includeLower = (flags & GREATER_OR_EQUAL) != 0;
+ boolean includeUpper = (flags & LESS_OR_EQUAL) != 0;
+
+ SortedIndexRowKey lower = createLowerBound(lowerBound, includeLower);
+
+ SortedIndexRowKey upper = createUpperBound(upperBound, includeUpper);
try {
- cursor = sortedIndexTree.find(
- toSortedIndexRowKey(lowerBound),
- toSortedIndexRowKey(upperBound),
- (flags & GREATER_OR_EQUAL) != 0,
- (flags & LESS_OR_EQUAL) != 0,
- null,
- null
- );
+ Cursor<SortedIndexRow> cursor = sortedIndexTree.find(lower, upper, includeLower, includeUpper, null, null);
Review Comment:
Passing these flags is pointless I believe. Simple `sortedIndexTree.find(lower, upper)` will give us the same result
##########
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 is new for me, how can it happen?
--
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
[GitHub] [ignite-3] ibessonov commented on a diff in pull request #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #1172:
URL: https://github.com/apache/ignite-3/pull/1172#discussion_r990008176
##########
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:
Ok, thank you!
--
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
[GitHub] [ignite-3] sashapolo commented on a diff in pull request #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [ignite-3] ibessonov merged pull request #1172: IGNITE-17818 Optimize RocksDB-based sorted index scan
Posted by GitBox <gi...@apache.org>.
ibessonov merged PR #1172:
URL: https://github.com/apache/ignite-3/pull/1172
--
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