Documentation
¶
Index ¶
Constants ¶
const ( SyncPoolAllocatorSkipBuckets = 6 SyncPoolAllocatorLargestBucket = 33 )
Variables ¶
This section is empty.
Functions ¶
func PurgeGlobalCache ¶ added in v1.0.0
func PurgeGlobalCache()
PurgeGlobalCache purges the global LRU cache that holds decompressed blocks. It is safe to call this function at any time.
func SetGlobalLRUSize ¶
func SetGlobalLRUSize(n int)
SetGlobalLRUSize configures the number of blocks that can be in the global compressed blocks LRU at any time.
Types ¶
type Option ¶
func WithAllocator ¶
WithAllocator can be passed to New() to use an alternative allocator.
func WithAllowBuildIndex ¶
func WithAllowBuildIndex() Option
WithAllowBuildIndex fall back to indexing the stream ourselves if it isn't present in the stream.
type Seeker ¶
type Seeker struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new Seeker from a slice of compressed S2 (or Snappy) stream. The given slice is never written to. The index must be either: 1. At the end of the stream 2. Built during new (if WithAllowBuildIndex() is passed) 3. Given with WithIndex()
func (*Seeker) Get ¶
Get the uncompressed data at the given (uncompressed) offset. Will return a slice with length $length and a deref function that should be called exactly once. The returned slice is valid until a call to deref and should not be modified. If an error is returned, no deref function will be returned.
func (*Seeker) ReadAt ¶ added in v0.0.6
ReadAt reads uncompressed data from the compressed stream at the given (uncompressed) offset. Currently reads where offset+len(dst) is past the end of the stream fail with 0, io.ErrUnexpectedEOF, but that might be changed in the future to give a partial result together with io.EOF.
type Stats ¶ added in v1.1.0
type Stats struct {
// NumCalls is the number of calls to .Get() or .ReadAt().
NumCalls uint64
// NumBlockDecompresses is the number of S2 blocks that were decompressed.
NumBlockDecompresses uint64
// NumBlockCacheHits is the number of S2 blocks that were not decompressed but where the call could be served from the cache.
NumBlockCacheHits uint64
// NumBlockCacheEvictions is the number of blocks that were evicted from the cache.
NumBlockCacheEvictions uint64
// NumCrossChunkReads is the number of calls that crossed an S2 block boundary. (So might've caused multiple decompressions.)
NumCrossChunkReads uint64
// NumExpectedDerefs is the number of Get() calls where their deref has not yet been called. If this keeps increasing, you have a leak.
NumExpectedDerefs int64
}
type SyncPoolAllocator ¶
type SyncPoolAllocator struct {
Pools [SyncPoolAllocatorLargestBucket - SyncPoolAllocatorSkipBuckets]sync.Pool
}
SyncPoolAllocator is an Allocator that uses one `sync.Pool` for each n**2 for n in (SyncPoolAllocatorSkipBuckets, SyncPoolAllocatorLargestBucket].
func (*SyncPoolAllocator) Alloc ¶
func (a *SyncPoolAllocator) Alloc(n int) []byte
func (*SyncPoolAllocator) Free ¶
func (a *SyncPoolAllocator) Free(b []byte)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package s2ramalloc provides a `s2randomacess.Allocator` that uses calloc(3).
|
Package s2ramalloc provides a `s2randomacess.Allocator` that uses calloc(3). |