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
810 views Asked by k_wisniewski At
2
There are 2 answers
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
- Handling both JSON and form values in POST request body with unknown values in Golang
- JSON Body is Not Passing Certain Strings
- Custom rewriter for json
- TypeScript: Type checking while parsing an arbitrary JSON that is typed/
- I dont understand what to do with: System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IEnumerable`1
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Dynamic Nested Multi-Dimensional Arrays in Rust
- Creating bar chart in FastAPI
- How to encode ttsJson data?
- Trying to get the id of the last element in my json file through an api
- How to give index id to my uploaded json file in FastAPI?
- JQ JSON - Values to Array
- Spring boot JSON parse error: Unexpected character error
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Sigma.JS custom rendering
Related Questions in COMPRESSION
- Should I compress images in java backend before sending to frontend?
- saving always adds artefacts to my images that photoshop doesn't
- Kafka compression on Broker side
- I am trying to compress video in Android using ffmpeg
- Compress gzip/Deflate string with golang
- how to convert different length of bits into byte array?
- knowledge distillation in a multistep model
- How to decompress the contents of a var to another var?
- Why response body not compressed when use webtestclient?
- How to monkey-patch np.savez_compressed to add compression level, without editing numpy's source files?
- incorrect header check while implementing GZIP in spring boot REST APIs
- Create algorhitm to create .pak file from unpack code
- Problem with decompressing algorithm in firefox (works in chrome/edge)
- Can I ignore some keyword while compressing css file through webpack? In other words I need a loader which just compress my file without validation
- PNG cropping increases file size
Related Questions in ZLIB
- How can I eliminate compile warnings using ZLib in Visual Studio
- problem with decompressing encrypted data in frontend
- C++ how to unzip file
- How can I decompress gzipped http bodies in a nodejs application?
- Unable to build rsyslog with static libz.a (zlib) file
- Missing System.IO.Compression.Native.dll in .NET 8 leads to error when using GZipStream
- Zlib compression in Powershell
- What is going on with the last two lext[] values in zlib?
- Linker can't find zlib or OpenSSL?
- How can i deobfuscate base64 zlib when i have obfuscate method?
- How to fix puppeteer intermittently failing when downloading chrome-headless-shell on CI
- How do I unpack/unzip a "(.TRS/PACK) TERSE compressed data (PACK, V) (2000/1)" file?
- Unresolved external symbol for statically build zlib
- Can't extract squashfs file system using unsquashfs tools
- how to decompress and write to disk lz4 compressed OS image
Related Questions in LIBZ
- How to update ZLIB version in MacOS CommandLine Tools from version "1.2.11" to "1.2.13" to use CMake?
- How to add dependencies between ExternalProjects in CMake?
- Which decompression algorithms are safe to use on attacker-supplied buffers?
- "libz.so.1: cannot open shared object file: No such file or directory"
- Can not find libz.dylib when build libzip by homebrew in Mac OS 10.16 (Big Sur)
- Linking: Why does linker not honour symlink to library?
- ld cannot find -lz in an empty environment even with LIBRARY_PATH, LD_LIBRARY_PATH and LD_PRELOAD
- Build c++ Qt CLI Tool with Quazip
- POCO sample SSL client code is crashing after receiving certificate
- libz.tbd, missing required architecture unknown
- Julia 0.4.5: libz fails to load on Ubuntu
- Issues with archiving iOS project: libz.dylib not found
- can't find libz for a plone install on osx. brew tap homebrew/dups did not find it
- arm-linux-ar: illegal option -- z
- IOKit claims libz.dylib is wrong version, but it isn't
Related Questions in TEXT-COMPRESSION
- How can I enable text compression in Gen4 VPS Linux 4 CPU
- How are LSTMs used for data compression?
- How can i save Scrapy logs in gzip after scrapping without using scripts in bash?
- Issues with a Reference Code for Running Canonical Huffman Code on Java
- compress the text text file full of integer[python]
- Blazor / ASP.NET Text Compression - Google speed test do not agree, why?
- How to get the same byte Array after stored it as String?
- Compress Data in JavaScript and send it to Flask Server
- Compression of XML containing base64 data
- What compression is used in txt file
- Text compressing - Assembly Language
- log module with pre-allocated memory
- Canonical Huffman Encoder : Contents of Encoded Bitstream
- Encode/Decode a given string on a shared given (non standard) charset in a minimal byte array
- LZW compression on text
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?
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)
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.