mirror of https://github.com/perkeep/perkeep.git
index: start of optional support for keeping index all tightly in-memory for search
Change-Id: Ie7fbafa1376505d10b0c01470089d260a0c0f97f
This commit is contained in:
parent
7f8e035be6
commit
2a42678f0c
|
@ -0,0 +1,44 @@
|
|||
package index
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"camlistore.org/pkg/blob"
|
||||
)
|
||||
|
||||
// Corpus is an in-memory summary of all of a user's blobs' metadata.
|
||||
type Corpus struct {
|
||||
mu sync.RWMutex
|
||||
strs map[string]string // interned strings
|
||||
blobs map[blob.Ref]BlobMeta
|
||||
// TODO: add GoLLRB to third_party; keep sorted BlobMeta
|
||||
files map[blob.Ref]*FileMeta
|
||||
permanodes map[blob.Ref]*PermanodeMeta
|
||||
deletedBy map[blob.Ref]blob.Ref // key is deleted by value
|
||||
}
|
||||
|
||||
type BlobMeta struct {
|
||||
Size int
|
||||
CamliType string
|
||||
}
|
||||
|
||||
type FileMeta struct {
|
||||
size int64
|
||||
mimeType string
|
||||
wholeRefs []blob.Ref
|
||||
}
|
||||
|
||||
type PermanodeMeta struct {
|
||||
OwnerKeyId string
|
||||
// Claims ClaimList
|
||||
}
|
||||
|
||||
func NewCorpusFromStorage(s Storage) (*Corpus, error) {
|
||||
panic("TODO")
|
||||
}
|
||||
|
||||
func (x *Index) KeepInMemory() (*Corpus, error) {
|
||||
var err error
|
||||
x.corpus, err = NewCorpusFromStorage(x.s)
|
||||
return x.corpus, err
|
||||
}
|
|
@ -150,6 +150,8 @@ type Index struct {
|
|||
// of the blobs in the index. It makes for faster reads than the otherwise
|
||||
// recursive calls on the index.
|
||||
deletes *deletionCache
|
||||
|
||||
corpus *Corpus // or nil, if not being kept in memory
|
||||
}
|
||||
|
||||
var _ blobserver.Storage = (*Index)(nil)
|
||||
|
|
Loading…
Reference in New Issue