{"id":15994110,"url":"https://github.com/knutwalker/netty-vbuf","last_synced_at":"2025-07-31T14:04:31.012Z","repository":{"id":19631873,"uuid":"22883873","full_name":"knutwalker/netty-vbuf","owner":"knutwalker","description":"Variable length encoding ByteBuf implementation","archived":false,"fork":false,"pushed_at":"2020-11-05T17:03:20.000Z","size":93,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-21T16:16:46.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knutwalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-12T16:11:39.000Z","updated_at":"2020-11-05T17:03:22.000Z","dependencies_parsed_at":"2022-08-24T14:01:52.166Z","dependency_job_id":null,"html_url":"https://github.com/knutwalker/netty-vbuf","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/knutwalker/netty-vbuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fnetty-vbuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fnetty-vbuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fnetty-vbuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fnetty-vbuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knutwalker","download_url":"https://codeload.github.com/knutwalker/netty-vbuf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutwalker%2Fnetty-vbuf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268052161,"owners_count":24187837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T07:06:03.492Z","updated_at":"2025-07-31T14:04:30.944Z","avatar_url":"https://github.com/knutwalker.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"netty-vbuf\n==========\n\nVariable length encoding ByteBuf implementation.\n\n[![Build Status](https://travis-ci.org/knutwalker/netty-vbuf.svg?branch=master)](https://travis-ci.org/knutwalker/netty-vbuf)\n[![Coverage Status](https://img.shields.io/coveralls/knutwalker/netty-vbuf.svg)](https://coveralls.io/r/knutwalker/netty-vbuf)\n\nOverview\n--------\n\nThis is a `ByteBuf` implementation, that's using [variable length encoding](http://en.wikipedia.org/wiki/Variable-length_quantity) for `int`s and `long`s to save memory consumption and eventually cpu time.\n\n\n## Get it\n\n### from Maven Central\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ede.knutwalker\u003c/groupId\u003e\n        \u003cartifactId\u003enetty-vbuf\u003c/artifactId\u003e\n        \u003cversion\u003e0.1.3\u003c/version\u003e\n    \u003c/dependency\u003e\n\n\n### from release binary\n\nDownload the [netty-vbuf-0.1.3.jar](https://github.com/knutwalker/netty-vbuf/releases/download/v0.1.3/netty-vbuf-0.1.3.jar) of the [latest release](https://github.com/knutwalker/netty-vbuf/releases/tag/v0.1.3)\nand place it in your classpath.\n\n### from source\n\nClone this repo and run `mvn package -DskipTests` and then add the `target/netty-vbuf-0.1.4-SNAPSHOT.jar` jar to your classpath.\n\n\n## Use it\n\n```java\nimport io.netty.buffer.VByteBuf;\n...\nByteBuf vBuf = VByteBuf.wrap(existingByteBuf);\n```\n\nThe methods `set`, `get`, `read`, and `write` for both, `Int` and `Long` are reimplemented, all others delegate to the wrapped buffer.\n\n\n## Profit\n\nVariable length encoding used the highest bit of each byte to encode whether the next byte\n belongs to the current number. This allows for an int to be encoded in 1 to 5 bytes.\nIf you're encoding primarily small numbers, using a variable length encoding can drastically save memory consumption.\n\nThese are some examples for the different encodings\n\n\nint        | regular encoding                    | variable length encoding                     | memory savings\n----------:|-------------------------------------|:---------------------------------------------|----------------\n42         | 00000000 00000000 00000000 00101010 | 00101010                                     | 75%\n1337       | 00000000 00000000 00000101 00111001 | 10001010 00111001                            | 50%\n134217728  | 00001000 00000000 00000000 00000000 | 11000000 10000000 10000000 00000000          | 0%\n2147483647 | 01111111 11111111 11111111 11111111 | 10000111 11111111 11111111 11111111 01111111 | -25% (loss)\n\n\nIf you write many small numbers to a ByteBuf, that isn't over sized and needs to resize once in a while,\nusing variable length encoding can reduce the number of costly memory copy operations and therefore reduce used cpu time.\n\nOtherwise, the encoding adds a runtime overhead, mostly due to the repeated boundary checking for each byte, where the regular encoding would just check once for all bytes.\n\nThese are some possible savings, when writing 100M (continuously increasing) longs:\n\n         writing 7-bit long with resizing used 87.50% less memory and 95.14% less time\n       writing growing long with resizing used 50.26% less memory and 69.69% less time\n      writing 7-bit long without resizing used 87.50% less memory and 31.83% less time\n    writing growing long without resizing used 50.26% less memory and 242.82% more time\n\nThese are just `nanoTime`s, so no real, useful benchmarks, but they give a hint in the right direction.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutwalker%2Fnetty-vbuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknutwalker%2Fnetty-vbuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutwalker%2Fnetty-vbuf/lists"}