mirror of https://github.com/perkeep/perkeep.git
rearrange some indexer code, comments, add some todos.
Change-Id: I94b1a68a8ff0095e2a758d01dcbe8253da57fb27
This commit is contained in:
parent
fff17c762b
commit
20975cf2f8
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue