msgpack-ruby | MessagePack implementation for Ruby / msgpack.org | Performance Testing library

 by   msgpack Ruby Version: v1.7.0 License: Apache-2.0

kandi X-RAY | msgpack-ruby Summary

kandi X-RAY | msgpack-ruby Summary

msgpack-ruby is a Ruby library typically used in Testing, Performance Testing applications. msgpack-ruby has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

MessagePack implementation for Ruby / msgpack.org[Ruby]
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              msgpack-ruby has a low active ecosystem.
              It has 717 star(s) with 116 fork(s). There are 25 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 3 open issues and 99 have been closed. On average issues are closed in 903 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of msgpack-ruby is v1.7.0

            kandi-Quality Quality

              msgpack-ruby has 0 bugs and 0 code smells.

            kandi-Security Security

              msgpack-ruby has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              msgpack-ruby code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              msgpack-ruby is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              msgpack-ruby releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.
              It has 6492 lines of code, 373 functions and 60 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of msgpack-ruby
            Get all kandi verified functions for this library.

            msgpack-ruby Key Features

            No Key Features are available at this moment for msgpack-ruby.

            msgpack-ruby Examples and Code Snippets

            No Code Snippets are available at this moment for msgpack-ruby.

            Community Discussions

            Trending Discussions on msgpack-ruby

            QUESTION

            How to store 32-bit floats using ruby-msgpack gem?
            Asked 2018-Sep-09 at 17:40

            I am working on a data system that needs to store large amounts of simple, extensible data (alongside some specialist indexing we are developing in-house, and not part of this question). I expect there to be billions of records stored, so efficient serialisation is a key part of the system. The serialisation needs to be fast, space-efficient, and supported in multiple platforms and languages (because packing and unpacking this data will be a client component responsibility, not part of the storage system)

            The data type is effectively a hash with optional key/value pairs. Keys will be small integers (interpreted at application layer). Values can be a variety of simple data types - String, Integer, Float.

            As a technology choice, we have picked MessagePack, and I am writing code to perform data serialisation via Ruby's msgpack-ruby gem.

            I don't need the precision of Ruby's 64-bit Float. None of the numbers being stored has meaningful precision even to limits of 32-bit. So I want to use MessagePack support for 32-bit floating point values. This definitely exists. However, the default behaviour in Ruby on any 64-bit system is to serialise Float to 64 bits:

            ...

            ANSWER

            Answered 2018-Sep-07 at 12:29
            Overriding Float

            As of right now (version 1.2.4 of msgpack-ruby) this is not possible in the exact fashion you tried: the msgpack_packer_write_value function first checks all hard-coded data types, and handles them with its default implementation. Only if the current object does not fit any of those types are the extensions handled.

            In other words: you cannot override the default pack formats with MessagePack::DefaultFactory#register_type, calling that will simply be a no-op.

            Using extensions

            Furthermore, the extension mechanism is not what you are looking at, anyways. Using that, messagepack would emit a marker byte "this is an extension", followed by the extension ID (the value "0" in your example), followed by what is already encoded as float32 - alternatively you would need to handle the binary encoding/decoding yourself.

            Creating your own Float class

            You could, in principle, create your own FloatX class or whatever, but this is just a very bad move:

            • Float has no new method which you could monkeypatch, and I know of no way to tell ruby to create a FloatX instance when you write 10.3 in your code. So you would have to do manual object creation throughout your code, probably with severe impact on performance.
            • You would end up with the extension mechanism anyways, infeasible as shown above.
            Overriding the behaviour of msgpack_packer_write_value

            You would need to to override the msgpack_packer_write_value implementation of packer.c. Unfortunately you cannot do that in the ruby world since there is no equivalent ruby method defined for it. So the usual monkeypatching of ruby cannot be used.

            Also, the method is called from plenty of other methods inside the packer.c implementation, for example in the respective methods responsible for writing arrays or hashes. Those of course would not call a ruby method of the same name either, as they're living in their binary world completely.

            Finally, whily the usage of a factory mechanism seems to imply that you can somehow create different implementations of packers, I see no evidence that this is actually true - reading the C code of the Gem, there seems to be no provision for anything of that kind. The factory seems to be there to handle the ruby<->C interactions of the Gem.

            What now

            If I were in your shoes, I would clone that Gem and modify msgpack_packer_write_value in packer.c to behave as you wish. Check the case T_FLOAT and go on from there. The code seems pretty straightforward - it soon proceeds to the following method in packer.h:

            Source https://stackoverflow.com/questions/52182794

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install msgpack-ruby

            Before building msgpack, you need to install bundler and dependencies.
            To build -java gems for JRuby, run:. If this directory has Gemfile.lock (generated with MRI), remove it beforehand.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/msgpack/msgpack-ruby.git

          • CLI

            gh repo clone msgpack/msgpack-ruby

          • sshUrl

            git@github.com:msgpack/msgpack-ruby.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link