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

    https://github.com/apache/spark/pull/11065#discussion_r51954518
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala
 ---
    @@ -408,6 +453,210 @@ private[joins] object UnsafeHashedRelation {
           }
         }
     
    +    // TODO: create UniqueUnsafeRelation
         new UnsafeHashedRelation(hashTable)
       }
     }
    +
    +/**
    +  * An interface for a hashed relation that the key is a Long.
    +  */
    +private[joins] trait LongHashedRelation extends HashedRelation {
    +  override def get(key: InternalRow): Seq[InternalRow] = {
    +    get(key.getLong(0))
    +  }
    +}
    +
    +private[joins] final class GeneralLongHashedRelation(
    +  private var hashTable: JavaHashMap[Long, CompactBuffer[UnsafeRow]])
    +  extends LongHashedRelation with Externalizable {
    +
    +  // Needed for serialization (it is public to make Java serialization 
work)
    +  def this() = this(null)
    +
    +  override def get(key: Long): Seq[InternalRow] = hashTable.get(key)
    +
    +  override def writeExternal(out: ObjectOutput): Unit = {
    +    writeBytes(out, SparkSqlSerializer.serialize(hashTable))
    +  }
    +
    +  override def readExternal(in: ObjectInput): Unit = {
    +    hashTable = SparkSqlSerializer.deserialize(readBytes(in))
    +  }
    +}
    +
    +private[joins] final class UniqueLongHashedRelation(
    +  private var hashTable: JavaHashMap[Long, UnsafeRow])
    +  extends UniqueHashedRelation with LongHashedRelation with Externalizable 
{
    +
    +  // Needed for serialization (it is public to make Java serialization 
work)
    +  def this() = this(null)
    +
    +  override def getValue(key: InternalRow): InternalRow = {
    +    getValue(key.getLong(0))
    +  }
    +
    +  override def getValue(key: Long): InternalRow = {
    +    hashTable.get(key)
    +  }
    +
    +  override def writeExternal(out: ObjectOutput): Unit = {
    +    writeBytes(out, SparkSqlSerializer.serialize(hashTable))
    +  }
    +
    +  override def readExternal(in: ObjectInput): Unit = {
    +    hashTable = SparkSqlSerializer.deserialize(readBytes(in))
    +  }
    +}
    +
    +/**
    +  * A relation that pack all the rows into a byte array, together with 
offsets and sizes.
    --- End diff --
    
    This should describe a bit more about it. The input arguments are not 
obvious. It should say it is used for dense keys and how it stores them.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to