Giter VIP home page Giter VIP logo

buffer-builder's People

Contributors

andyfriesen avatar bodigrim avatar chadaustin avatar jfischoff avatar jlee-imvu avatar lysxia avatar michaelt avatar robdockins avatar ryanglscott 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

Watchers

 avatar  avatar  avatar  avatar

buffer-builder's Issues

handle malloc() failure

Plan:

Have an internal 'dead' bit in BufferWriter

bw_new return 0 on failure, checked on Haskell side
bw_append functions don't fail, they just mark as dead on allocation failure
bw_get_and_trim returns failure code, Haskell throws memory error if dead

support chunking growth policy

On naive implementations of realloc(), the current growth implementation copies (lg N) times. If we chunked into a linked list, we'd have the option to produce a Lazy ByteString, avoiding a copy, or we could copy once into a Strict ByteString.

Remove dependency on libstdc++

This fails to build in the absence of libstdc++. Looking at the source code it doesn't look like the c-bits actually use any C++ functionality.

Automatic deriving for ToJson instance

Is it trivial to adapt deriveJson from Aeson to automatically derive ToJson instances? I looked into using buffer builder for a project but got stopped in tracks because I use automatic derivation everywhere (instead of hand-coding it tediously). An example derivation is like this through Data.Aeson.TH:
deriveJSON defaultOptions{fieldLabelModifier = Prelude.drop 5,constructorTagModifier = Prelude.map toLower,omitNothingFields = True} ''ARecordType

It seems that in order to use encodeJson, ToJson instance must be provided which must be hand-coded for now. If it can somehow be derived from Data.Aeson.ToJSON, then it will make it very useful!

Unless I missed something about how to adapt an existing Aeson ToJSON to ToJson?

Would it be possible to view current buffer usage?

I've got some code where the buffered value needs to exceed 1MB before being flushed over the network, and I'm currently having to do my own bookkeeping of the size. I'm pretty sure that the builder tracks its utilization under the hood, so would it be realistic to make that data publicly accessible?

Consider having BufferBuilder maintain an O(1) record of the allocation area it needs to run

Sorry that title isn't very clear. My use case is described here. Essentially I need to be able to do something like:

writeBuilderOnto :: Builder -> ByteArrayThingIMightHaveToGrow -> IO ()

bytestring's Builder almost gets me there with the internal BufferWriter, but unfortunately we can determine the number of bytes that will be written ahead of time from just the Builder. This is a hard requirement for me.

buffer-builder looks like an attractive place for this functionality to live because I think nearly all the instances you provide have O(1) length already, and it looks like your library is super fast to boot. I think only lazy bytestrings and the String case would need to force the spine to get an O(n) length, which needs to happen anyway.

Does that analysis seem right, and make sense? And would you be open to:

  1. Limiting BufferBuilder such that its allocation area is known before running
  2. Providing a lower-level BufferWriter-like function that I can run on a pre-allocated buffer

Let me know what you think, and I may hack on this in the next couple months if it's the sort of thing you'd be interested in having here.

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.