Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6159#discussion_r30552904
  
    --- Diff: 
unsafe/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java ---
    @@ -162,6 +169,55 @@ public BytesToBytesMap(
        */
       public int size() { return size; }
     
    +  private static final class BytesToBytesMapIterator implements 
Iterator<Location> {
    +
    +    private final int numRecords;
    +    private final Iterator<MemoryBlock> dataPagesIterator;
    +    private final Location loc;
    +
    +    private int currentRecordNumber = 0;
    +    private Object pageBaseObject;
    +    private long offsetInPage;
    +
    +    BytesToBytesMapIterator(int numRecords, Iterator<MemoryBlock> 
dataPagesIterator, Location loc) {
    +      this.numRecords = numRecords;
    +      this.dataPagesIterator = dataPagesIterator;
    +      this.loc = loc;
    +      if (dataPagesIterator.hasNext()) {
    +        advanceToNextPage();
    +      }
    +    }
    +
    +    private void advanceToNextPage() {
    +      final MemoryBlock currentPage = dataPagesIterator.next();
    +      pageBaseObject = currentPage.getBaseObject();
    +      offsetInPage = currentPage.getBaseOffset();
    +    }
    +
    +    @Override
    +    public boolean hasNext() {
    +      return currentRecordNumber != numRecords;
    +    }
    +
    +    @Override
    +    public Location next() {
    --- End diff --
    
    If we decide to do this, there's other places where we should also perform 
the same change.  I'd like to defer this decision for now and deal with it in a 
follow up patch that makes the change more broadly.


---
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]

Reply via email to