diff --git a/lib/go/camli/index/memindex.go b/lib/go/camli/index/memindex.go index 0e5c42d50..fce8b3317 100644 --- a/lib/go/camli/index/memindex.go +++ b/lib/go/camli/index/memindex.go @@ -28,7 +28,30 @@ import ( ) func init() { - blobserver.RegisterStorageConstructor("memory-only-dev-indexer", blobserver.StorageConstructor(newMemoryIndexFromConfig)) + blobserver.RegisterStorageConstructor("memory-only-dev-indexer", + blobserver.StorageConstructor(newMemoryIndexFromConfig)) +} + +func newMemoryIndexFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Storage, os.Error) { + blobPrefix := config.RequiredString("blobSource") + + db := memdb.New(nil) + memStorage := &memKeys{db: db} + + ix := New(memStorage) + if err := config.Validate(); err != nil { + return nil, err + } + sto, err := ld.GetStorage(blobPrefix) + if err != nil { + return nil, err + } + ix.BlobSource = sto + + // Good enough, for now: + ix.KeyFetcher = ix.BlobSource + + return ix, err } // memKeys is a naive in-memory implementation of IndexStorage for test & development @@ -105,27 +128,5 @@ func (mk *memKeys) CommitBatch(bm BatchMutation) os.Error { } } return nil - } -func newMemoryIndexFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Storage, os.Error) { - blobPrefix := config.RequiredString("blobSource") - - db := memdb.New(nil) - memStorage := &memKeys{db: db} - - ix := New(memStorage) - if err := config.Validate(); err != nil { - return nil, err - } - sto, err := ld.GetStorage(blobPrefix) - if err != nil { - return nil, err - } - ix.BlobSource = sto - - // Good enough, for now: - ix.KeyFetcher = ix.BlobSource - - return ix, err -} diff --git a/lib/go/camli/index/receive.go b/lib/go/camli/index/receive.go index ea88e9e78..5b454a4aa 100644 --- a/lib/go/camli/index/receive.go +++ b/lib/go/camli/index/receive.go @@ -67,8 +67,28 @@ func (ix *Index) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (retsb // populateMutation populates keys & values into the provided BatchMutation. // // the blobref can be trusted at this point (it's been fully consumed -// and verified to match), and the sniffer has been copied into +// and verified to match), and the sniffer has been populated. func (ix *Index) populateMutation(br *blobref.BlobRef, sniffer *BlobSniffer, bm BatchMutation) os.Error { bm.Set("have:"+br.String(), fmt.Sprintf("%d", sniffer.Size())) + + if camli, ok := sniffer.Superset(); ok { + switch camli.Type { + /* + case "claim": + if err := ix.populateClaim(blobRef, camli, sniffer, bm); err != nil { + return err + } + case "permanode": + if err := mi.populatePermanode(blobRef, camli, bm); err != nil { + return err + } + case "file": + if err := mi.populateFile(blobRef, camli, bm); err != nil { + return err + } + } + */ + } + } return nil }