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

    https://github.com/apache/spark/pull/11517#discussion_r58008863
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/basicOperators.scala ---
    @@ -194,6 +194,71 @@ case class Sample(
           child.execute().randomSampleWithRange(lowerBound, upperBound, seed)
         }
       }
    +
    +  override def upstreams(): Seq[RDD[InternalRow]] = {
    +    child.asInstanceOf[CodegenSupport].upstreams()
    +  }
    +
    +  private var rowBuffer: String = _
    +
    +  protected override def doProduce(ctx: CodegenContext): String = {
    +    child.asInstanceOf[CodegenSupport].produce(ctx, this)
    +  }
    +
    +  override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: 
ExprCode): String = {
    +    val sampler = ctx.freshName("sampler")
    +
    +    if (withReplacement) {
    +      val samplerClass = classOf[PoissonSampler[UnsafeRow]].getName
    +      val classTag = ctx.freshName("classTag")
    +      val classTagClass = "scala.reflect.ClassTag<UnsafeRow>"
    +      ctx.addMutableState(classTagClass, classTag,
    +        s"$classTag = 
($classTagClass)scala.reflect.ClassTag$$.MODULE$$.apply(UnsafeRow.class);")
    +
    +      val initSampler = ctx.freshName("initSampler")
    +      ctx.addMutableState(s"$samplerClass<UnsafeRow>", sampler,
    +        s"$initSampler();")
    +
    +      val random = ctx.freshName("random")
    --- End diff --
    
    Since these are used in a separate function, we don't need to generate 
fresh name for 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 [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