index: start of optional support for keeping index all tightly in-memory for search

Change-Id: Ie7fbafa1376505d10b0c01470089d260a0c0f97f
This commit is contained in:
Brad Fitzpatrick 2013-11-16 12:55:09 -08:00
parent 7f8e035be6
commit 2a42678f0c
2 changed files with 46 additions and 0 deletions

44
pkg/index/corpus.go Normal file
View File

@ -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
}

View File

@ -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)