Documentation ¶
Overview ¶
Package indexdb handles the indexes storage.
Design ¶
The DB is a leveldb instance, and the key-value format is:
|--- Key --|------------------ Value (24) -------------------| +----------+-----------+-----------+-----------+-------------+ | Name (X) | Link (4) | Stamp (4) | Score (8) | Average (8) | +----------+-----------+-----------+-----------+-------------+
Cache ¶
To access indexes faster, indexes are cached in memory, in a trie with goroutine safety.
Read operations are in cache.
Write operations are to persistence and cache.
Index ¶
- Constants
- Variables
- type DB
- func (db *DB) All() (l []*models.Index)
- func (db *DB) Close() error
- func (db *DB) Delete(name string) error
- func (db *DB) Filter(pattern string) (l []*models.Index)
- func (db *DB) Get(name string) (*models.Index, error)
- func (db *DB) Has(name string) bool
- func (db *DB) Len() int
- func (db *DB) NumFilter(pattern string) int
- func (db *DB) Put(idx *models.Index) error
- type Options
Constants ¶
View Source
const MaxNumIndex = 16 * 1024 * 1024
MaxNumIndex is the max value of the number indexes this db can handle. Note that this number has no other meanings, just a limitation of the indexes capacity, it can be larger, theoretically can be MaxUint32.
Variables ¶
View Source
var ( // ErrNotFound is returned when requested data not found. ErrNotFound = errors.New("indexdb: not found") // ErrCorrupted is returned when corrupted data found. ErrCorrupted = errors.New("indexdb: corrupted data found") // ErrNoLink is returned when the index to put has no link. ErrNoLink = errors.New("indexdb: no link") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB handles indexes storage.
Click to show internal directories.
Click to hide internal directories.