Git Product home page Git Product logo

msgpack4z-core's Introduction

msgpack4z-core's People

Contributors

densh avatar dependabot[bot] avatar scala-steward-bot avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

msgpack4z-core's Issues

How to create CaseMapCodecs with recursive case classes

I have two case classes, one being recursive while the other references the recursive case class.

case class InitFunction(
  id: String,
  timestamp: Long,
  tree: Function
)

case class Function(
  name: String,
  path: String,
  callees: Option[List[Function]]
)

This was how I was planning to create codecs for these case classes:

    val factory = new PackerUnpackerFactory {
      def packer: MsgOutBuffer = MsgOutBuffer.create()
      def unpacker(bytes: Array[Byte]) = MsgInBuffer(bytes)
    }

    val mapCodec = CaseMapCodec.string(factory)

    implicit lazy val codec: MsgpackCodec[PythonFunction] = mapCodec.codec(PythonFunction.apply _, PythonFunction.unapply _)("name", "path", "callees")

    implicit val initCodec: MsgpackCodec[PythonInitFunction] = mapCodec.codec(PythonInitFunction.apply _, PythonInitFunction.unapply _)("id", "timestamp", "tree")

but I was getting a java.lang.StackOverflowError from the lazy codec constantly calling itself. Is there a correct way to unpack recursive case classes?

Maven Central badge?

Hey, sorry for using the issue tracker for this. Could you tell me how you created this nice Maven Central badge in your README? Is this something that any project can use? Thanks!

Where's MsgOutBuffer?

I was trying to follow the examples and couldn't find MsgOutBuffer. Have I missed something? I've added the following in my build.sbt

libraryDependencies += "com.github.xuwei-k" %% "msgpack4z-core" % "0.3.7" 

Cannot handle optional values

Hi,

if I have the following case class:

case class Foo(a: String, b: Option[Int])

If i read a message pack encoded byte array which is equivalent to the following json (not encoded with msgpack4z):

{ "a": "test" }

I get a unpack error. Since the case class map codec looks for the presence of each key and fails if any key is not present.

It seems that the optionCodec expects the message pack encoded data to include the key regardless of whether there is a value for it or not.

Aside from writing my own case class codec, is there a way to handle unpacking such types?

Why does the CaseCodec serialize case classes into FixedArray?

I was confused that CaseCodec seems to serialize case classes into FixedArrays.
In jackson-dataformat-msgpack, objects seem to be serialized into FixedMap that retains keys but msgpack4z does not.

What do you think about that?
Should I just use the MapCodec instead?

I think msgpack4z has better type class based functional API so I wanna use this rather than Jackson module.

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.