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

    https://github.com/apache/spark/pull/12836#discussion_r65120450
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/objects.scala ---
    @@ -325,6 +330,80 @@ case class MapGroupsExec(
     }
     
     /**
    + * Groups the input rows together and calls the R function with each group 
and an iterator
    + * containing all elements in the group.
    + * The result of this function is flattened before being output.
    + */
    +case class FlatMapGroupsInRExec(
    +    func: Array[Byte],
    +    packageNames: Array[Byte],
    +    broadcastVars: Array[Broadcast[Object]],
    +    inputSchema: StructType,
    +    outputSchema: StructType,
    +    keyDeserializer: Expression,
    +    valueDeserializer: Expression,
    +    groupingAttributes: Seq[Attribute],
    +    dataAttributes: Seq[Attribute],
    +    outputObjAttr: Attribute,
    +    child: SparkPlan) extends UnaryExecNode with ObjectProducerExec {
    +
    +  override def output: Seq[Attribute] = outputObjAttr :: Nil
    +  override def producedAttributes: AttributeSet = 
AttributeSet(outputObjAttr)
    +
    +  override def requiredChildDistribution: Seq[Distribution] =
    +    ClusteredDistribution(groupingAttributes) :: Nil
    +
    +  override def requiredChildOrdering: Seq[Seq[SortOrder]] =
    +    Seq(groupingAttributes.map(SortOrder(_, Ascending)))
    +
    +  override protected def doExecute(): RDD[InternalRow] = {
    +    val isDeserializedRData =
    +      if (outputSchema == SERIALIZED_R_DATA_SCHEMA) true else false
    +    val serializerForR = if (!isDeserializedRData) {
    +      SerializationFormats.ROW
    +    } else {
    +      SerializationFormats.BYTE
    +    }
    +    val (deserializerForR, colNames) =
    +      (SerializationFormats.ROW, inputSchema.fieldNames)
    +
    +    child.execute().mapPartitionsInternal { iter =>
    +      val grouped = GroupedIterator(iter, groupingAttributes, child.output)
    +      val getKey = ObjectOperator.deserializeRowToObject(keyDeserializer, 
groupingAttributes)
    +      val getValue = 
ObjectOperator.deserializeRowToObject(valueDeserializer, dataAttributes)
    +      val outputObject = 
ObjectOperator.wrapObjectToRow(outputObjAttr.dataType)
    +      val groupNames = groupingAttributes.map(_.name).toArray
    +
    +      val runner = new RRunner[Array[Byte]](
    +        func, deserializerForR, serializerForR, packageNames, 
broadcastVars,
    +        isDataFrame = true, colNames = colNames, key = groupNames)
    +
    +      val hasGroups = grouped.hasNext
    --- End diff --
    
    Did some refactoring!


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