Giter Site home page Giter Site logo

Comments (4)

kanterov avatar kanterov commented on May 24, 2024

It works after #99 was rebased on latest master.

from frameless.

kanterov avatar kanterov commented on May 24, 2024

Is it relevant? I guess everything works out of the box right now.

from frameless.

imarios avatar imarios commented on May 24, 2024

@kanterov I think we can close this. Let me run some thoughts by you and let me know if I am describing what we are doing correctly.

  • In Spark single entries (Rows) are represented (encoded) as InternalRow. So Dataset[Vector[Int]] is represented with InternalRow(Array[Int]). That is, there is an encoder that takes you from Vector[Int] => Array[Int].
  • We have a udf with this type signature Vector[Int] => String
  • When we need to apply the udf to the Dataset, we cannot really apply it as is. We need to somehow adapt it to work with Array[Int] as input an potentially with UTF8String as output. Therefore the adapted udf needs to be Array[Int] => UTF8String.
  • Essentially we need wrap our udf in the following: (a: Array[Int]) => UTF8Codec.encode(udf(VectorCodec.decode(a))) . Now we have a function with the correct signature Array[Int] => UTF8String.

from frameless.

imarios avatar imarios commented on May 24, 2024

Overall, if you want to be fast, if you want your UDFs to run fast, then it's better to have your case classes use types that are closer to what Spark uses internally:

that is,

case class Person(ids: Array[Int], name: UTF8String) 

would in principle perform faster than

case class Person(ids: Vector[Int], name: String)

at least it terms of UDFs/UDAFs ?

(in this way, you save yourself with a lot of encoding/decoding conversions)

from frameless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.