I have a buffer of let's say 4KB, containing data in JSON-like format. I need to add significantly more information (up to let's say 3x more) to it, but I have to fit in this small chunk of memory. I was thinking about using libZ to compress text, but I'm afraid it will not perform well since the data consists mostly of some unique substrings. What would you recommend in this situation? Thanks, Chris
Compressing small piece of data
808 Views Asked by k_wisniewski At
2
There are 2 best solutions below
0
Eric J.
On
If you really want to stick with compression, a compression algorithm that uses a custom dictionary that leverages the specific structure of your data will perform the best. I implemented something just like that with SharpZipLib.
If you want to store more data in the buffer and aren't stuck on using compression of text-like data, consider a binary protocol such as Google's Protocol Buffers.
Update
@Mark's answer outlines how to use a custom dictionary with zlib.
Related Questions in JSON
- getting undefined while iterating json
- How can I serialize a numpy array while preserving matrix dimensions?
- What is best way to check if any of the property of object is null or empty?
- How to query JSON data according to JSON array's size with Spark SQL?
- Extracting data from json_decode with lat and lng geolocation
- Convert JSON.gz to JSON in node js
- How do I get the type to convert to when deserializing from Jackson
- Escape dot in jquery validate plugin
- Are allOf and properties keywords interchangeable?
- Sort continents by amount of countries
- Is there a data format lighter than json?
- Object of class CS_REST_Wrapper_Result could not be converted to string in CAMPAIGN MONITOR
- How to read JSON data from a web server running PHP and MySQL?
- Parse Nsmutabledictionary and extract value
- Handle empty JSON values in Java
Related Questions in COMPRESSION
- How to use deflate/inflate SetDictionary with raw deflate/inflate?
- C# How to get file/ copy file from a bzip2 (.bz2) file without extracting the file
- How can I compress four floats into a string?
- Create ZIP File Then Send to Client
- compress json data from rest node.js use express compression
- Advanced Data Compression
- Tools to minify CDD and JS files
- How to use multiple threads for zlib compression (same input source)
- Data compression in RDBMS like Oracle, MySQL etc
- Haskell - Lempel-Ziv 78 Compression - very slow, why?
- Python: how to create tar file and compress it on the fly with external module, using different compression methods not available in tarfile module?
- Why isn't lossless compression automatic on computers?
- PHP Image Compression Before Upload
- Compression of char size integer by removing leading zeroes
- BMP Image Compression and Decompression in java
Related Questions in ZLIB
- How to use deflate/inflate SetDictionary with raw deflate/inflate?
- Zlib decompression method warning using ios 64bit Architecture
- Can't open zip file to read unicode characters
- decoding a compressed binary blob using zlib
- Compression is not working in ZLib library
- Xcode throws compile errors in zlib.h
- How to use multiple threads for zlib compression (same input source)
- Zip file encryption readable by some Zip clients, not others
- zlib uncompress a .zip file
- Zlib minimum deflate size
- "End of file reached" error OR Zlib::BufError using HTTParty
- Using zlib for std::string and stringstream
- Python 2.7 cant decode deflate encoding
- Uncaught incorrect header check using pako.js
- Extracting a gz file content with zlib and save it
Related Questions in LIBZ
- Xcode throws compile errors in zlib.h
- gzstream lib opening not existing file
- crc32() missing when building libzip on OSX 10.9
- Compressing small piece of data
- Which decompression algorithms are safe to use on attacker-supplied buffers?
- How to add dependencies between ExternalProjects in CMake?
- arm-linux-ar: illegal option -- z
- Libz not getting linked in XCode
- PAK archives and zlib (zlib.dylib)
- RAR Decompress on iPhone Device
- unable to compile ffmpeg bohr on ubuntu 14.04 32bit
- libz or/and libpng for Windows (Phone) 8 Apps
- Linking: Why does linker not honour symlink to library?
- Error with iOS 5.1 when i use ASIHTTPRequest and SBJSON
- Cannot install Ruby 1.9.3 on Mountain Lion w/ RVM: Error running make
Related Questions in TEXT-COMPRESSION
- Encode/Decode a given string on a shared given (non standard) charset in a minimal byte array
- LZW compression on text
- compress the text text file full of integer[python]
- Issues with a Reference Code for Running Canonical Huffman Code on Java
- Compressing a string, end result without line breaks?
- Compressing small piece of data
- Blazor / ASP.NET Text Compression - Google speed test do not agree, why?
- How are LSTMs used for data compression?
- What compression is used in txt file
- Compression of XML containing base64 data
- Canonical Huffman Encoder : Contents of Encoded Bitstream
- log module with pre-allocated memory
- What's the best practice for storing huge amounts of text (into a DB or as a file?), and what about compressing it?
- TEXT compression in python
- How can i save Scrapy logs in gzip after scrapping without using scripts in bash?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Consider a fixed dictionary containing up to 32K of strings that you expect to appear in your data. You would use zlib's
deflateSetDictionary()andinflateSetDictionary()on each end (the sender and receiver of the data respectively) with the same dictionary on both ends. That may get you the compression you're looking for. Without a dictionary, you are unlikely to get that sort of compression with such a small amount of data.