Documentation
¶
Index ¶
- Variables
- func BadDeveloperError(msg string)
- func CreateCacheBucket(bucket string)
- func EvictCache(bucket, key string)
- func GetCache(bucket, key string) *interface{}
- func InitLogging(level zapcore.Level)
- func PutCache(bucket, key string, value interface{})
- func WalkDirFollowSymlinks(root string, fn fs.WalkDirFunc) error
- func WrapJsonErrorf(path string, err error, text string, args ...interface{}) error
- func WrapRange(value, start, end int) int
- func WrappedJsonErrorf(path string, text string, args ...interface{}) error
- type CacheBucket
- type Index
- type KeyTableEntry
- type Kind
- type NavigableMap
- func MapToNavigableMap(entries map[string]interface{}) NavigableMap[string, interface{}]
- func NewNavigableMap[K comparable, V any]() NavigableMap[K, V]
- func NewNavigableMapWithCapacity[K comparable, V any](capacity int) NavigableMap[K, V]
- func ToNavigableMap(entries ...interface{}) NavigableMap[string, interface{}]
- func (m *NavigableMap[K, V]) AppendKeys(dst []K) []K
- func (m *NavigableMap[K, V]) AppendValues(dst []V) []V
- func (m *NavigableMap[K, V]) Clear()
- func (m *NavigableMap[K, V]) Compact()
- func (m *NavigableMap[K, V]) ContainsKey(key K) bool
- func (m *NavigableMap[K, V]) ContainsMatchingKey(match func(K) bool) bool
- func (m *NavigableMap[K, V]) ForEach(fn func(K, V))
- func (m *NavigableMap[K, V]) ForEachUntil(fn func(K, V) bool)
- func (m *NavigableMap[K, V]) Get(key K) V
- func (m *NavigableMap[K, V]) IsEmpty() bool
- func (m *NavigableMap[K, V]) Keys() []K
- func (m *NavigableMap[K, V]) Put(key K, value V)
- func (m *NavigableMap[K, V]) Range(fn func(K, V) bool)
- func (m *NavigableMap[K, V]) Remove(key K)
- func (m *NavigableMap[K, V]) Reserve(n int)
- func (m *NavigableMap[K, V]) SetAutoCompact(percent, minTombstones int)
- func (m *NavigableMap[K, V]) Size() int
- func (m *NavigableMap[K, V]) Sort(comparer func(K, K) int)
- func (m *NavigableMap[K, V]) TryGet(key K) (V, bool)
- func (m *NavigableMap[K, V]) Values() []V
- type Node
Constants ¶
This section is empty.
Variables ¶
var Logger *zap.SugaredLogger
var LoggerLevel zap.AtomicLevel
Functions ¶
func BadDeveloperError ¶
func BadDeveloperError(msg string)
BadDeveloperError panics with a message that indicates a bug in the code. It should only be used in places that should never be reached or can only be reached if there is a bug in the code.
func CreateCacheBucket ¶
func CreateCacheBucket(bucket string)
CreateCacheBucket creates a cache bucket
func InitLogging ¶
func WalkDirFollowSymlinks ¶
func WalkDirFollowSymlinks(root string, fn fs.WalkDirFunc) error
WalkDirFollowSymlinks walks the directory tree rooted at root, calling fn for each file or directory. If a directory is a symlink, its contents are also walked.
func WrapJsonErrorf ¶
WrapJsonErrorf wraps an error with a stack trace and adds additional formatted text information.
func WrappedJsonErrorf ¶
WrappedJsonErrorf creates an error with a stack trace from formatted text and appends the path.
Types ¶
type CacheBucket ¶
type CacheBucket struct {
Items map[string]*interface{}
// contains filtered or unexported fields
}
CacheBucket is a bucket of cache entries
type Index ¶
type Index struct {
Src []byte
Nodes []Node
ChildRefs []int32
// contains filtered or unexported fields
}
Index is a structural representation of a JSON document without materializing values.
func (*Index) BuildKeyTable ¶
func (idx *Index) BuildKeyTable(objIdx int, buf []KeyTableEntry) ([]KeyTableEntry, error)
BuildKeyTable returns object members sorted by (hash, canonical-key-bytes). If buf is nil, it may return an internal cached slice.
type KeyTableEntry ¶
type KeyTableEntry struct {
Hash uint64
// Raw key span (without quotes, escapes still present in source bytes).
KeyLo int32
KeyHi int32
ValIndex int32
HasDollar bool
HasCaret bool
HasEscape bool
}
KeyTableEntry stores preprocessed object member metadata. Hash is computed from the unescaped key bytes.
type NavigableMap ¶
type NavigableMap[K comparable, V any] struct { // contains filtered or unexported fields }
func MapToNavigableMap ¶
func MapToNavigableMap(entries map[string]interface{}) NavigableMap[string, interface{}]
MapToNavigableMap creates a new NavigableMap from a golang map.
func NewNavigableMap ¶
func NewNavigableMap[K comparable, V any]() NavigableMap[K, V]
NewNavigableMap creates a new NavigableMap.
func NewNavigableMapWithCapacity ¶
func NewNavigableMapWithCapacity[K comparable, V any](capacity int) NavigableMap[K, V]
NewNavigableMapWithCapacity creates a new NavigableMap with preallocated storage.
func ToNavigableMap ¶
func ToNavigableMap(entries ...interface{}) NavigableMap[string, interface{}]
ToNavigableMap creates a new NavigableMap with given keys and values.
func (*NavigableMap[K, V]) AppendKeys ¶
func (m *NavigableMap[K, V]) AppendKeys(dst []K) []K
func (*NavigableMap[K, V]) AppendValues ¶
func (m *NavigableMap[K, V]) AppendValues(dst []V) []V
func (*NavigableMap[K, V]) Clear ¶
func (m *NavigableMap[K, V]) Clear()
func (*NavigableMap[K, V]) Compact ¶
func (m *NavigableMap[K, V]) Compact()
func (*NavigableMap[K, V]) ContainsKey ¶
func (m *NavigableMap[K, V]) ContainsKey(key K) bool
func (*NavigableMap[K, V]) ContainsMatchingKey ¶
func (m *NavigableMap[K, V]) ContainsMatchingKey(match func(K) bool) bool
ContainsMatchingKey returns true if match(key) is true for any key. It uses Range (slice-based, no hashing) and short-circuits on first hit.
func (*NavigableMap[K, V]) ForEach ¶
func (m *NavigableMap[K, V]) ForEach(fn func(K, V))
For compatibility with existing code:
func (*NavigableMap[K, V]) ForEachUntil ¶
func (m *NavigableMap[K, V]) ForEachUntil(fn func(K, V) bool)
func (*NavigableMap[K, V]) Get ¶
func (m *NavigableMap[K, V]) Get(key K) V
func (*NavigableMap[K, V]) IsEmpty ¶
func (m *NavigableMap[K, V]) IsEmpty() bool
func (*NavigableMap[K, V]) Keys ¶
func (m *NavigableMap[K, V]) Keys() []K
func (*NavigableMap[K, V]) Put ¶
func (m *NavigableMap[K, V]) Put(key K, value V)
func (*NavigableMap[K, V]) Range ¶
func (m *NavigableMap[K, V]) Range(fn func(K, V) bool)
func (*NavigableMap[K, V]) Remove ¶
func (m *NavigableMap[K, V]) Remove(key K)
func (*NavigableMap[K, V]) Reserve ¶
func (m *NavigableMap[K, V]) Reserve(n int)
Reserve grows internal capacity to at least n additional free slots.
func (*NavigableMap[K, V]) SetAutoCompact ¶
func (m *NavigableMap[K, V]) SetAutoCompact(percent, minTombstones int)
SetAutoCompact sets the automatic compaction thresholds. percent is the minimum percentage of tombstones (0..100) to trigger compaction. minTombstones is the minimum absolute number of tombstones to trigger compaction. SetAutoCompact(0, 0) disables automatic compaction.
func (*NavigableMap[K, V]) Size ¶
func (m *NavigableMap[K, V]) Size() int
func (*NavigableMap[K, V]) Sort ¶
func (m *NavigableMap[K, V]) Sort(comparer func(K, K) int)
Sort orders valid entries by the provided comparer while keeping stability. It avoids touching tombstones during compare/swap by sorting a dense index list, then applies the permutation once to keys/values/valid and rebuilds index.
func (*NavigableMap[K, V]) TryGet ¶
func (m *NavigableMap[K, V]) TryGet(key K) (V, bool)
func (*NavigableMap[K, V]) Values ¶
func (m *NavigableMap[K, V]) Values() []V
type Node ¶
type Node struct {
Kind Kind
Parent int32
// Direct children live in Index.ChildRefs[ChildLo:ChildHi].
ChildLo int32
ChildHi int32
// ValLo/ValHi points to the exact value bytes in source.
ValLo int32
ValHi int32
// Key span without surrounding quotes.
KeyLo int32
KeyHi int32
}
Node points into the original source bytes. KeyLo/KeyHi are set only for object members; for array elements they are -1.