diff --git a/pkg/index/corpus.go b/pkg/index/corpus.go new file mode 100644 index 000000000..a147482fa --- /dev/null +++ b/pkg/index/corpus.go @@ -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 +} diff --git a/pkg/index/index.go b/pkg/index/index.go index d5319d92e..d819a07b1 100644 --- a/pkg/index/index.go +++ b/pkg/index/index.go @@ -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)