Documentation ¶
Index ¶
- type Chunk
- type ChunkMeta
- type ChunkStorage
- type InMemoryChunkStorage
- func (s *InMemoryChunkStorage) Read(chunkIds []uint32) (map[uint32]*Chunk, error)
- func (s *InMemoryChunkStorage) ReadMeta() (*Meta, error)
- func (s *InMemoryChunkStorage) Remove(chunkIds []uint32) error
- func (s *InMemoryChunkStorage) Save(chunks map[uint32]*Chunk) error
- func (s *InMemoryChunkStorage) SaveMeta(meta *Meta) error
- type Meta
- func (m *Meta) Add(metas []*ChunkMeta)
- func (m *Meta) FindRelevantForInsert(item uint32) []*ChunkMeta
- func (m *Meta) FindRelevantForRead(item uint32) *ChunkMeta
- func (m *Meta) FindRelevantForReadRange(min, max uint32) []*ChunkMeta
- func (m *Meta) GetChunkById(id uint32) *ChunkMeta
- func (m *Meta) Remove(meta *ChunkMeta)
- func (m *Meta) Serialize() ([]byte, error)
- func (m *Meta) TakeNextId() (id uint32)
- type SortedArray
- type SortedArraySqlTxStorage
- func (s *SortedArraySqlTxStorage) Read(chunkIds []uint32) (map[uint32]*Chunk, error)
- func (s *SortedArraySqlTxStorage) ReadMeta() (*Meta, error)
- func (s *SortedArraySqlTxStorage) Remove(chunkIds []uint32) error
- func (s *SortedArraySqlTxStorage) Save(chunks map[uint32]*Chunk) error
- func (s *SortedArraySqlTxStorage) SaveMeta(meta *Meta) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk struct {
Items []uint32
}
Chunk represents an asc sorted array of numbers, grouped together for faster processing the type chosen to be uint32 to contain unix timestamps in seconds enough for general index purposes when there are not many events per second
func UnserializeChunk ¶
func (*Chunk) Add ¶
Add insert new values to the sorted array with just one allocation return the number of NEW elements added to the array
func (*Chunk) GetInRange ¶
type ChunkMeta ¶
type ChunkMeta struct {
// contains filtered or unexported fields
}
ChunkMeta is a light description of a chunk used to select relevant chunks before fetching them
type ChunkStorage ¶
type ChunkStorage interface { // Read if err is nil then it always return a map of size = len(chunkIds) Read(chunkIds []uint32) (map[uint32]*Chunk, error) Save(chunks map[uint32]*Chunk) error Remove(chunkIds []uint32) error ReadMeta() (*Meta, error) SaveMeta(*Meta) error }
ChunkStorage does simple CRUD operations on persistent storage Serialization(+compression) must be implemented at this level
type InMemoryChunkStorage ¶
type InMemoryChunkStorage struct {
// contains filtered or unexported fields
}
func NewInMemoryChunkStorage ¶
func NewInMemoryChunkStorage() *InMemoryChunkStorage
func (*InMemoryChunkStorage) Read ¶
func (s *InMemoryChunkStorage) Read(chunkIds []uint32) (map[uint32]*Chunk, error)
func (*InMemoryChunkStorage) ReadMeta ¶
func (s *InMemoryChunkStorage) ReadMeta() (*Meta, error)
func (*InMemoryChunkStorage) Remove ¶
func (s *InMemoryChunkStorage) Remove(chunkIds []uint32) error
func (*InMemoryChunkStorage) Save ¶
func (s *InMemoryChunkStorage) Save(chunks map[uint32]*Chunk) error
func (*InMemoryChunkStorage) SaveMeta ¶
func (s *InMemoryChunkStorage) SaveMeta(meta *Meta) error
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
Meta contains a list of SORTED chunks descriptions No overlapping allowed
func UnserializeMeta ¶
func (*Meta) FindRelevantForInsert ¶
FindRelevantForInsert returns possible chunks that can be used for insertion that includes ones that include the item via [min,max], or surround the item (chunk +item+ chunk)
func (*Meta) FindRelevantForRead ¶
FindRelevantForRead return a link to a chunk description that CAN contains the item null means that no chunk CAN contain this item (used in Search)
func (*Meta) FindRelevantForReadRange ¶
FindRelevantForReadRange return does the same as FindRelevantForRead but for a range
func (*Meta) GetChunkById ¶
func (*Meta) TakeNextId ¶
TakeNextId starts from 0 and returns the NEXT available id
type SortedArray ¶
type SortedArray struct {
// contains filtered or unexported fields
}
SortedArray manages ASC sorted array in chunks for better performance Chunks contain up to maxInsertSize items and may not intersect with each other
func NewSortedArray ¶
func NewSortedArray(maxChunkSize uint32, s ChunkStorage) *SortedArray
func (*SortedArray) Add ¶
func (a *SortedArray) Add(items []uint32) error
Add Puts new items to the array
func (*SortedArray) Delete ¶
func (a *SortedArray) Delete(items []uint32) error
func (*SortedArray) Flush ¶
func (a *SortedArray) Flush() error
func (*SortedArray) GetInRange ¶
func (a *SortedArray) GetInRange(min, max uint32) (sorted_numeric_streams.SortedNumbersStream[uint32], error)
GetInRange returns a stream of items (min,max are INCLUDED)
func (*SortedArray) ToSlice ¶
func (a *SortedArray) ToSlice() []uint32
ToSlice dump all index to a single slice (for debugging/testing)
type SortedArraySqlTxStorage ¶
type SortedArraySqlTxStorage struct {
// contains filtered or unexported fields
}
SortedArraySqlTxStorage implemented sorted array storage for sqlite it uses blobs to store chunks and meta key is used to produce unique ids for the blobs in a shared table
func NewSqliteTxSortedArrayStorage ¶
func NewSqliteTxSortedArrayStorage(tx *sql.Tx, key []byte) *SortedArraySqlTxStorage
func (*SortedArraySqlTxStorage) Read ¶
func (s *SortedArraySqlTxStorage) Read(chunkIds []uint32) (map[uint32]*Chunk, error)
func (*SortedArraySqlTxStorage) ReadMeta ¶
func (s *SortedArraySqlTxStorage) ReadMeta() (*Meta, error)
func (*SortedArraySqlTxStorage) Remove ¶
func (s *SortedArraySqlTxStorage) Remove(chunkIds []uint32) error
func (*SortedArraySqlTxStorage) Save ¶
func (s *SortedArraySqlTxStorage) Save(chunks map[uint32]*Chunk) error
func (*SortedArraySqlTxStorage) SaveMeta ¶
func (s *SortedArraySqlTxStorage) SaveMeta(meta *Meta) error