Documentation
¶
Overview ¶
Copyright 2025 Stoolap Contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025 Stoolap Contributors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025 Stoolap Contributors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- type Int64Map
- func (m *Int64Map[V]) All() iter.Seq2[int64, V]
- func (m *Int64Map[V]) Clear()
- func (m *Int64Map[V]) Del(key int64) bool
- func (m *Int64Map[V]) ForEach(f func(int64, V) bool)
- func (m *Int64Map[V]) Get(key int64) (V, bool)
- func (m *Int64Map[V]) Has(key int64) bool
- func (m *Int64Map[V]) Keys() iter.Seq[int64]
- func (m *Int64Map[V]) Len() int
- func (m *Int64Map[V]) Put(key int64, val V)
- func (m *Int64Map[V]) PutIfNotExists(key int64, val V) (V, bool)
- func (m *Int64Map[V]) Values() iter.Seq[V]
- type Pair
- type SegmentInt64Map
- func (m *SegmentInt64Map[V]) All() iter.Seq2[int64, V]
- func (m *SegmentInt64Map[V]) Clear()
- func (m *SegmentInt64Map[V]) Del(key int64) bool
- func (m *SegmentInt64Map[V]) ForEach(f func(int64, V) bool)
- func (m *SegmentInt64Map[V]) Get(key int64) (V, bool)
- func (m *SegmentInt64Map[V]) Has(key int64) bool
- func (m *SegmentInt64Map[V]) Keys() iter.Seq[int64]
- func (m *SegmentInt64Map[V]) Len() int64
- func (m *SegmentInt64Map[V]) PutIfNotExists(key int64, value V) (V, bool)
- func (m *SegmentInt64Map[V]) Set(key int64, value V)
- func (m *SegmentInt64Map[V]) Values() iter.Seq[V]
- type SyncInt64Map
- func (m *SyncInt64Map[V]) All() iter.Seq2[int64, V]
- func (m *SyncInt64Map[V]) Del(key int64) bool
- func (m *SyncInt64Map[V]) ForEach(f func(int64, V) bool)
- func (m *SyncInt64Map[V]) Get(key int64) (V, bool)
- func (m *SyncInt64Map[V]) Has(key int64) bool
- func (m *SyncInt64Map[V]) Len() int64
- func (m *SyncInt64Map[V]) Set(key int64, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Int64Map ¶
type Int64Map[V any] struct { // contains filtered or unexported fields }
Int64Map is a specialized map for int64 keys. It is specifically optimized for clustered keys, where keys are likely to be close to each other (e.g., sequential IDs, timestamp ranges).
func NewInt64Map ¶
NewInt64Map creates a new Int64Map with given capacity
func (*Int64Map[V]) PutIfNotExists ¶
PutIfNotExists adds key-value pair only if key doesn't exist
type SegmentInt64Map ¶
type SegmentInt64Map[V any] struct { // contains filtered or unexported fields }
SegmentInt64Map is a fast, thread-safe map for int64 keys that uses sharding (segmentation) to reduce lock contention while maintaining the performance benefits of Int64Map
func NewSegmentInt64Map ¶
func NewSegmentInt64Map[V any](segmentPower uint8, initialCapacity int) *SegmentInt64Map[V]
NewSegmentInt64Map creates a new segmented map for int64 keys segmentPower controls the number of segments (2^segmentPower) initialCapacity is the initial capacity per segment
func (*SegmentInt64Map[V]) All ¶
func (m *SegmentInt64Map[V]) All() iter.Seq2[int64, V]
All returns an iterator over all key-value pairs
func (*SegmentInt64Map[V]) Clear ¶
func (m *SegmentInt64Map[V]) Clear()
Clear removes all entries from the map
func (*SegmentInt64Map[V]) Del ¶
func (m *SegmentInt64Map[V]) Del(key int64) bool
Del removes a key from the map
func (*SegmentInt64Map[V]) ForEach ¶
func (m *SegmentInt64Map[V]) ForEach(f func(int64, V) bool)
ForEach iterates through all key-value pairs Note: The iteration is not atomic and may miss concurrent updates
func (*SegmentInt64Map[V]) Get ¶
func (m *SegmentInt64Map[V]) Get(key int64) (V, bool)
Get retrieves a value by key
func (*SegmentInt64Map[V]) Has ¶
func (m *SegmentInt64Map[V]) Has(key int64) bool
Has checks if a key exists in the map
func (*SegmentInt64Map[V]) Keys ¶
func (m *SegmentInt64Map[V]) Keys() iter.Seq[int64]
Keys returns an iterator over all keys
func (*SegmentInt64Map[V]) Len ¶
func (m *SegmentInt64Map[V]) Len() int64
Len returns the number of elements in the map
func (*SegmentInt64Map[V]) PutIfNotExists ¶
func (m *SegmentInt64Map[V]) PutIfNotExists(key int64, value V) (V, bool)
PutIfNotExists adds the key-value pair only if the key doesn't already exist Returns the value and true if inserted, or existing value and false if not inserted
func (*SegmentInt64Map[V]) Set ¶
func (m *SegmentInt64Map[V]) Set(key int64, value V)
Set adds or updates a key-value pair
func (*SegmentInt64Map[V]) Values ¶
func (m *SegmentInt64Map[V]) Values() iter.Seq[V]
Values returns an iterator over all values
type SyncInt64Map ¶
type SyncInt64Map[V any] struct { // contains filtered or unexported fields }
SyncInt64Map is a highly optimized map for int64 keys This is the production version incorporating all performance optimizations
func NewSyncInt64Map ¶
func NewSyncInt64Map[V any](sizePower uint) *SyncInt64Map[V]
NewSyncInt64Map creates a new optimized map for int64 keys
func (*SyncInt64Map[V]) Del ¶
func (m *SyncInt64Map[V]) Del(key int64) bool
Del removes a key from the map
func (*SyncInt64Map[V]) ForEach ¶
func (m *SyncInt64Map[V]) ForEach(f func(int64, V) bool)
ForEach iterates through all key-value pairs
func (*SyncInt64Map[V]) Get ¶
func (m *SyncInt64Map[V]) Get(key int64) (V, bool)
Get retrieves a value by key
func (*SyncInt64Map[V]) Has ¶
func (m *SyncInt64Map[V]) Has(key int64) bool
Has checks if a key exists in the map without retrieving its value
func (*SyncInt64Map[V]) Len ¶
func (m *SyncInt64Map[V]) Len() int64
Len returns the number of elements in the map
func (*SyncInt64Map[V]) Set ¶
func (m *SyncInt64Map[V]) Set(key int64, value V)
Set adds or updates a key-value pair