Giter Site home page Giter Site logo

Comments (5)

LoranceChen avatar LoranceChen commented on August 16, 2024 1

Hi, great to see can solve it.
Glade to take a PR if possiable and I need sometime to familiar with the repository.

from incubator-fury.

chaokunyang avatar chaokunyang commented on August 16, 2024 1

If the field doesn't exist in serialization process, but does exist in deserialization process, we can invoke method like SomeClass$.apply$default$2:()I to get default value for such field, and set it the object

from incubator-fury.

chaokunyang avatar chaokunyang commented on August 16, 2024 1

You can configure FURY_CODE_DIR environment variable to set generated code dir, if you set it to src directory, then you can debug it in IDE when rerun the code

from incubator-fury.

chaokunyang avatar chaokunyang commented on August 16, 2024

Hi @LoranceChen , thanks for bring this up. It's very necessary to support this in Apache Fury.

Scala didn't provide a method to construct object with default value at bytecode level. It generate bytecode to invoke constructor with all parameters provided, and default params are provided at callsite.

If we need to provide default value when creating object, we need to extract the default value. Fortunately, scala generate a
method like SomeClass$.apply$default$2:()I:

case class SomeClass(v: List[IdAnyVal], x:Int=1)

// Callsite bytecode
      34: getstatic     #131                // Field org/apache/fury/serializer/SomeClass$.MODULE$:Lorg/apache/fury/serializer/SomeClass$;
      37: invokevirtual #135                // Method org/apache/fury/serializer/SomeClass$.apply$default$2:()I
      40: invokespecial #138                // Method org/apache/fury/serializer/SomeClass."<init>":(Lscala/collection/immutable/List;I)V
      43: putstatic     #87                 // Field p:Lorg/apache/fury/serializer/SomeClass;
      46: getstatic     #143                // Field scala/Predef$.MODULE$:Lscala/Predef$;

We may can detect whether such method exists to know which parameter has default value, and provide it as default value when constructing object. This will take some horse work. We don't have time for this currently. Would you like to contribute to this? The record contructor in Fury org.apache.fury.builder.ObjectCodecBuilder#createRecord/org.apache.fury.serializer.ObjectSerializer#read can be taken as an example.

from incubator-fury.

LoranceChen avatar LoranceChen commented on August 16, 2024

Hi, @chaokunyang , do you some advice to debug the codegen init process?
The generated code seems not easy to trace the logic where it is.
image

Thanks

from incubator-fury.

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.