{"id":20795302,"url":"https://github.com/hexon/s2randomaccess","last_synced_at":"2025-06-26T02:37:09.589Z","repository":{"id":246047010,"uuid":"819945084","full_name":"hexon/s2randomaccess","owner":"hexon","description":"Random Access over an S2 compressed stream","archived":false,"fork":false,"pushed_at":"2024-12-22T10:29:17.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T01:34:05.317Z","etag":null,"topics":["compression","golang","golang-library","s2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexon.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-25T13:43:16.000Z","updated_at":"2024-12-22T10:29:20.000Z","dependencies_parsed_at":"2024-09-17T11:48:00.841Z","dependency_job_id":"44ad050c-7155-43a5-be01-36ce117ffd81","html_url":"https://github.com/hexon/s2randomaccess","commit_stats":null,"previous_names":["hexon/s2randomaccess"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/hexon/s2randomaccess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexon%2Fs2randomaccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexon%2Fs2randomaccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexon%2Fs2randomaccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexon%2Fs2randomaccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexon","download_url":"https://codeload.github.com/hexon/s2randomaccess/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexon%2Fs2randomaccess/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261987825,"owners_count":23240916,"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","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":["compression","golang","golang-library","s2"],"created_at":"2024-11-17T16:20:57.268Z","updated_at":"2025-06-26T02:37:09.561Z","avatar_url":"https://github.com/hexon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Random Access over an S2 compressed stream\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/hexon/s2randomaccess.svg)](https://pkg.go.dev/github.com/hexon/s2randomaccess)\n\nS2 is an extension of [Snappy](https://github.com/google/snappy). This package builds on top of the exellent [github.com/klauspost/compress/s2](https://pkg.go.dev/github.com/klauspost/compress/s2).\n\nThis package is similar to [s2.ReadSeeker](https://pkg.go.dev/github.com/klauspost/compress/s2#ReadSeeker), but optimized for concurrent requests and caching decompression of blocks.\n\nThis package requires the entire stream as a `[]byte`, which should not be modified during the lifetime of the `*Seeker`.\n\n```go\nvar compressedStream []byte\n\nfunc baseLibrary() {\n\tseeker, err := s2.NewReader(bytes.NewReader(compressedStream)).ReadSeeker(true, nil)\n\t_, err := seeker.ReadAt(buf, uncompressedOffset)\n}\n\nfunc withS2RandomAccess() {\n\tseeker := s2randomaccess.Open(compressedStream)\n\tbuf, deref, err := seeker.Get(uncompressedOffset, uncompressedLength)\n\tuse(buf)\n\tderef()\n}\n```\n\n## Allocators\n\nThe default allocator simply uses `make([]byte, n)` and never reuses memory. `WithAllocator(\u0026SyncPoolAllocator{})` can be used to reuse buffers using `sync.Pool`s. `WithAllocator(s2ramalloc.Allocator{})` can be used to use malloc(3) and free(3), but requires CGO.\n\nWhen using the default allocator, the returned deref functions can be ignored. With other allocators they must be called exactly once after being done with the returned slice.\n\nReturned slices might point into memory allocated by the chosen Allocator, or straight into the input data if it was in an uncompressed data block in the stream.\n\n## Caching\n\nThis library caches the last 100 decoded blocks globally. The number of globally cached blocks can be changed with `SetGlobalLRUSize(1000)` at any time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexon%2Fs2randomaccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexon%2Fs2randomaccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexon%2Fs2randomaccess/lists"}