Documentation
¶
Overview ¶
Package wildcat
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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.
Package wildcat ¶
(C) Copyright Alex Gaetano Padula
Licensed under the Mozilla Public License, v. 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
https://www.mozilla.org/en-US/MPL/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 ¶
- Constants
- type Compactor
- type DB
- type Flusher
- type IDGenerator
- type IDGeneratorState
- type KLogEntry
- type Level
- type Memtable
- type MergeIterator
- func (mi *MergeIterator) HasNext() bool
- func (mi *MergeIterator) HasPrev() bool
- func (mi *MergeIterator) IsAscending() bool
- func (mi *MergeIterator) Next() ([]byte, []byte, int64, bool)
- func (mi *MergeIterator) Prev() ([]byte, []byte, int64, bool)
- func (mi *MergeIterator) SetDirection(ascending bool) error
- type Options
- type SSTable
- type SyncOption
- type Txn
- func (txn *Txn) Commit() error
- func (txn *Txn) Delete(key []byte) error
- func (txn *Txn) Get(key []byte) ([]byte, error)
- func (txn *Txn) NewIterator(asc bool) (*MergeIterator, error)
- func (txn *Txn) NewPrefixIterator(prefix []byte, asc bool) (*MergeIterator, error)
- func (txn *Txn) NewRangeIterator(startKey []byte, endKey []byte, asc bool) (*MergeIterator, error)
- func (txn *Txn) Put(key []byte, value []byte) error
- func (txn *Txn) Rollback() error
- type WAL
Constants ¶
const ( SSTablePrefix = "sst_" // Prefix for SSTable files LevelPrefix = "l" // Prefix for level directories i.e. "l1", "l2", etc. WALFileExtension = ".wal" // Extension for Write Ahead Log files <timestamp>.wal KLogExtension = ".klog" // Extension for KLog files VLogExtension = ".vlog" // Extension for VLog files IDGSTFileName = "idgstate" // Filename for ID generator state )
Prefixes, filenames, extensions constants
const ( DefaultWriteBufferSize = 64 * 1024 * 1024 // Default write buffer size DefaultSyncOption = SyncNone // Default sync option for write operations DefaultSyncInterval = 16 * time.Nanosecond // Default sync interval for write operations DefaultLevelCount = 6 // Default number of levels in the LSM tree DefaultLevelMultiplier = 10 // Multiplier for the number of levels // 64MB -> 640MB -> 6.4GB -> 64GB -> 640GB -> 6.4TB DefaultBlockManagerLRUSize = 1024 // Size of the LRU cache for block managers DefaultBlockManagerLRUEvictRatio = 0.20 // Eviction ratio for the LRU cache DefaultBlockManagerLRUAccessWeight = 0.8 // Access weight for the LRU cache DefaultPermission = 0750 // Default permission for created files DefaultBloomFilter = false // Default Bloom filter option DefaultMaxCompactionConcurrency = 4 // Default max compaction concurrency DefaultCompactionCooldownPeriod = 5 * time.Second // Default cooldown period for compaction DefaultCompactionBatchSize = 8 // Default max number of SSTables to compact at once DefaultCompactionSizeRatio = 1.1 // Default level size ratio that triggers compaction DefaultCompactionSizeThreshold = 8 // Default number of files to trigger size-tiered compaction DefaultCompactionScoreSizeWeight = 0.8 // Default weight for size-based score DefaultCompactionScoreCountWeight = 0.2 // Default weight for count-based score DefaultFlusherTickerInterval = 1 * time.Millisecond DefaultCompactorTickerInterval = 250 * time.Millisecond // Default interval for compactor ticker DefaultBloomFilterProbability = 0.01 // Default probability for Bloom filter DefaultWALAppendRetry = 10 // Default number of retries for WAL append DefaultWALAppendBackoff = 128 * time.Microsecond // Default backoff duration for WAL append DefaultSSTableBTreeOrder = 10 // Default order of the B-tree for SSTables )
Defaults
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compactor ¶
type Compactor struct {
// contains filtered or unexported fields
}
Compactor is responsible for managing compaction jobs
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents the main Wildcat structure
func (*DB) ForceFlush ¶
ForceFlush forces the flush of all memtables and immutable memtables
func (*DB) GetTxn ¶
GetTxn retrieves a transaction by ID. Can be used on system recovery. You can recover an incomplete transaction.
func (*DB) Stats ¶ added in v1.0.0
Stats returns a string with the current statistics of the Wildcat database
type Flusher ¶
type Flusher struct {
// contains filtered or unexported fields
}
Flusher is responsible for queuing and flushing memtables to disk
type IDGenerator ¶
type IDGenerator struct {
// contains filtered or unexported fields
}
IDGenerator is a thread-safe ID generator
type IDGeneratorState ¶
type IDGeneratorState struct {
// contains filtered or unexported fields
}
IDGeneratorState represents the state of the ID generator. When system shuts down the state is saved to disk and restored on next startup.
type KLogEntry ¶
type KLogEntry struct {
Key []byte // Key of the entry
Timestamp int64 // Timestamp of the entry
ValueBlockID int64 // Block ID of the value
}
KLogEntry represents a key-value entry in the KLog
type Level ¶
type Level struct {
// contains filtered or unexported fields
}
Level is a disk level within Wildcat, which contains a list of immutable SSTables
type Memtable ¶
type Memtable struct {
// contains filtered or unexported fields
}
Memtable is a memory table structure
type MergeIterator ¶
type MergeIterator struct {
// contains filtered or unexported fields
}
MergeIterator combines multiple iterators into a single iterator
func NewMergeIterator ¶
func NewMergeIterator(iterators []*iterator, ts int64, ascending bool) (*MergeIterator, error)
NewMergeIterator creates a new MergeIterator with the given iterators
func (*MergeIterator) HasNext ¶ added in v1.0.0
func (mi *MergeIterator) HasNext() bool
HasNext returns true if there are more entries in the configured direction
func (*MergeIterator) HasPrev ¶ added in v1.0.0
func (mi *MergeIterator) HasPrev() bool
HasPrev returns true if there are entries in the opposite direction
func (*MergeIterator) IsAscending ¶ added in v1.0.0
func (mi *MergeIterator) IsAscending() bool
IsAscending returns the current iteration direction
func (*MergeIterator) Next ¶
func (mi *MergeIterator) Next() ([]byte, []byte, int64, bool)
Next returns the next key-value pair in the configured direction
func (*MergeIterator) Prev ¶
func (mi *MergeIterator) Prev() ([]byte, []byte, int64, bool)
Prev returns the previous key-value pair (opposite of configured direction)
func (*MergeIterator) SetDirection ¶ added in v1.0.0
func (mi *MergeIterator) SetDirection(ascending bool) error
SetDirection changes the iteration direction
type Options ¶
type Options struct {
Directory string // Directory for Wildcat
WriteBufferSize int64 // Size of the write buffer
SyncOption SyncOption // Sync option for write operations
SyncInterval time.Duration // Interval for syncing the write buffer
LevelCount int // Number of levels in the LSM tree
LevelMultiplier int // Multiplier for the number of levels
BlockManagerLRUSize int // Size of the LRU cache for block managers
BlockManagerLRUEvictRatio float64 // Eviction ratio for the LRU cache
BlockManagerLRUAccesWeight float64 // Access weight for the LRU cache
Permission os.FileMode // Permission for created files
LogChannel chan string // Channel for logging
BloomFilter bool // Enable Bloom filter for SSTables
MaxCompactionConcurrency int // Maximum number of concurrent compactions
CompactionCooldownPeriod time.Duration // Cooldown period for compaction
CompactionBatchSize int // Max number of SSTables to compact at once
CompactionSizeRatio float64 // Level size ratio that triggers compaction
CompactionSizeThreshold int // Number of files to trigger size-tiered compaction
CompactionScoreSizeWeight float64 // Weight for size-based score
CompactionScoreCountWeight float64 // Weight for count-based score
FlusherTickerInterval time.Duration // Interval for flusher ticker
CompactorTickerInterval time.Duration // Interval for compactor ticker
BloomFilterFPR float64 // False positive rate for Bloom filter
WalAppendRetry int // Number of retries for WAL append
WalAppendBackoff time.Duration // Backoff duration for WAL append
SSTableBTreeOrder int // Order of the B-tree for SSTables
}
Options represents the configuration options for Wildcat
type SSTable ¶
type SSTable struct {
Id int64 // SStable ID
Min []byte // The minimum key in the SSTable
Max []byte // The maximum key in the SSTable
Size int64 // The size of the SSTable in bytes
EntryCount int // The number of entries in the SSTable
Level int // The level of the SSTable
BloomFilter *bloomfilter.BloomFilter // Optional bloom filter for fast lookups
Timestamp int64 // Timestamp of latest entry in the SSTable
// contains filtered or unexported fields
}
SSTable represents a sorted string table
type SyncOption ¶
type SyncOption int
SyncOption is a block manager sync option that can be set by the user.
const ( SyncNone SyncOption = iota // We don't sync SyncFull // We sync the entire block manager after each write SyncPartial // We sync based at intervals based on the SyncInterval option.. So every SyncInterval we sync the block manager. )
type Txn ¶
type Txn struct {
Id int64 // The transactions id, can be recovered
ReadSet map[string]int64 // Key -> Timestamp
WriteSet map[string][]byte // Key -> Value
DeleteSet map[string]bool // Key -> Deleted
Timestamp int64 // The timestamp of the transaction
Committed bool // Whether the transaction is committed
// contains filtered or unexported fields
}
Txn represents a transaction in Wildcat
func (*Txn) NewIterator ¶
func (txn *Txn) NewIterator(asc bool) (*MergeIterator, error)
NewIterator creates a new bidirectional iterator
func (*Txn) NewPrefixIterator ¶ added in v1.0.0
func (txn *Txn) NewPrefixIterator(prefix []byte, asc bool) (*MergeIterator, error)
NewPrefixIterator creates a new prefix bidirectional iterator
func (*Txn) NewRangeIterator ¶ added in v1.0.0
NewRangeIterator creates a new range bidirectional iterator
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package blockmanager
|
Package blockmanager |
|
Package bloomfilter
|
Package bloomfilter |
|
Package lru
|
Package lru |
|
Package queue
|
Package queue |
|
Package skiplist
|
Package skiplist |
|
Package tree
|
Package tree |

