leanken commented on pull request #29104:
URL: https://github.com/apache/spark/pull/29104#issuecomment-660200660


   @cloud-fan And FYI. Inside BroadcastHashJoinExec, the HashedRelation is 
already filtered out with NULL value, so if we want to deal with this issue 
inside BHJ-Exec, might need to update from HashedRelationBroadcastMode to 
IdentityBroadcastMode, in this case all internalRow will be kept.
   
   ```
   // Create a mapping of key -> rows
       var numFields = 0
       while (input.hasNext) {
         val unsafeRow = input.next().asInstanceOf[UnsafeRow]
         numFields = unsafeRow.numFields()
         val rowKey = keyGenerator(unsafeRow)
         if (!rowKey.isNullAt(0)) {
           val key = rowKey.getLong(0)
           map.append(key, unsafeRow)
         }
       }
       map.optimize()
       new LongHashedRelation(numFields, map)
   
    while (input.hasNext) {
         val row = input.next().asInstanceOf[UnsafeRow]
         numFields = row.numFields()
         val key = keyGenerator(row)
         if (!key.anyNull) {
           val loc = binaryMap.lookup(key.getBaseObject, key.getBaseOffset, 
key.getSizeInBytes)
           val success = loc.append(
             key.getBaseObject, key.getBaseOffset, key.getSizeInBytes,
             row.getBaseObject, row.getBaseOffset, row.getSizeInBytes)
           if (!success) {
             binaryMap.free()
             // scalastyle:off throwerror
             throw new SparkOutOfMemoryError("There is not enough memory to 
build hash map")
             // scalastyle:on throwerror
           }
         }
       }
   
       new UnsafeHashedRelation(key.size, numFields, binaryMap)
   
   
   ```


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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to