Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-14083

Analyze JVM bytecode and turn closures into Catalyst expressions

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Incomplete
    • None
    • None
    • SQL

    Description

      One big advantage of the Dataset API is the type safety, at the cost of performance due to heavy reliance on user-defined closures/lambdas. These closures are typically slower than expressions because we have more flexibility to optimize expressions (known data types, no virtual function calls, etc). In many cases, it's actually not going to be very difficult to look into the byte code of these closures and figure out what they are trying to do. If we can understand them, then we can turn them directly into Catalyst expressions for more optimized executions.

      Some examples are:

      df.map(_.name)  // equivalent to expression col("name")
      
      ds.groupBy(_.gender)  // equivalent to expression col("gender")
      
      df.filter(_.age > 18)  // equivalent to expression GreaterThan(col("age"), lit(18)
      
      df.map(_.id + 1)  // equivalent to Add(col("age"), lit(1))
      

      The goal of this ticket is to design a small framework for byte code analysis and use that to convert closures/lambdas into Catalyst expressions in order to speed up Dataset execution. It is a little bit futuristic, but I believe it is very doable. The framework should be easy to reason about (e.g. similar to Catalyst).

      Note that a big emphasis on "small" and "easy to reason about". A patch should be rejected if it is too complicated or difficult to reason about.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rxin Reynold Xin
              Votes:
              10 Vote for this issue
              Watchers:
              52 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: