GithubHelp home page GithubHelp logo

Comments (6)

nrwiersma avatar nrwiersma commented on June 10, 2024

I see no way to make that work on decoding. TLDR; There is not way to set the interface type (iface).

Basically, I would need something in there of the same type to be able to decode it without falling back to reflect Types and Values. If it is nil, or not of the right type, any attempt to set it would cause a seg fault or a type error. As you cannot create a new iface type, as it instantly becomes nil and an untyped nil at that, and there is no way to convert the decoded type to the iface type, I dont see how this would be doable.

This is not the same case in the encode side, as you already have the type, so none of this type conversion stuff applies here.

This means we can only really support efaces, unless you see another way I am not seeing.

from avro.

tylerwendell avatar tylerwendell commented on June 10, 2024

I have been trying to step through the code and figure out how to make it work and I cannot see how to make it work either. Thanks for the quick response. Ill close.

from avro.

nrwiersma avatar nrwiersma commented on June 10, 2024

I literally spend 3 hours to try get the initial interface type to accept a new pointer, but to no avail.

from avro.

tylerwendell avatar tylerwendell commented on June 10, 2024

There isn't a single go avro library that makes it work. A lot of them won't even marshal union types.

from avro.

pckhoi avatar pckhoi commented on June 10, 2024

Sorry but I don't understand why decoder couldn't be made to work. The decoder could treat interface receivers in this way:

  1. Inspect the data and figure out the name of the concrete avro type
  2. Look up the registered Go type under that name. If not found, fallback to the old implementation
  3. Check if the registered Go type fulfill the given interface, if not return an error
  4. Check if the receiver is of the registered type, if not return an error
  5. Decode the data into the receiver and profit

Unless there's something else I'm not understanding.

from avro.

nrwiersma avatar nrwiersma commented on June 10, 2024

Interface types (iface) are not createable in Go, you are only able to covert a concrete into an iface type. In reflect this possible, but using rtypes and unsafe pointers, there is no mechanism to do this.

Getting the concrete is not an issue, but as the interface is nil, there is no way to get the value out again.

from avro.

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.