Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/5836#discussion_r29884854
--- Diff:
unsafe/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java ---
@@ -173,18 +173,35 @@ public BytesToBytesMap(
public Iterator<Location> iterator() {
return new Iterator<Location>() {
- private int nextPos = bitset.nextSetBit(0);
+ private int cur = 0;
+
+ private int pageCur = 0;
+
+ private MemoryBlock currentPage;
+
+ private long addr;
@Override
public boolean hasNext() {
- return nextPos != -1;
+ return cur != size;
}
@Override
public Location next() {
- final int pos = nextPos;
- nextPos = bitset.nextSetBit(nextPos + 1);
- return loc.with(pos, 0, true);
+ if (currentPage == null) {
+ currentPage = dataPages.get(pageCur++);
+ addr = currentPage.getBaseOffset();
+ }
+ long keySize =
PlatformDependent.UNSAFE.getLong(memoryManager.getPage(addr), addr);
+ if (keySize == -1L) {
--- End diff --
-1 should be lifted into a static constant named `END_OF_BLOCK` or
something to clarify the fact that it's used as an end of block marker.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]