Add search.EdgesTo method to search interface. No implementation yet.

Change-Id: Ie3a9eb91e218e172b195d55cb9c17cb6c8f819ce
This commit is contained in:
Brad Fitzpatrick 2012-11-03 16:08:37 +01:00
parent 69e155af64
commit 4b0d2841ee
3 changed files with 32 additions and 0 deletions

View File

@ -554,4 +554,9 @@ func (x *Index) GetFileInfo(fileRef *blobref.BlobRef) (*search.FileInfo, error)
return fi, nil
}
func (x *Index) EdgesTo(ref *blobref.BlobRef, opts *search.EdgesToOpts) ([]*search.Edge, error) {
// unimplemented.
return nil, errors.New("TODO: implement")
}
func (x *Index) Storage() IndexStorage { return x.s }

View File

@ -125,6 +125,18 @@ type PermanodeByAttrRequest struct {
MaxResults int // optional max results
}
type EdgesToOpts struct {
Max int
// TODO: filter by type?
}
type Edge struct {
From *blobref.BlobRef
FromType string // "permanode", "directory", etc
FromTitle string // name of source permanode or directory
To *blobref.BlobRef
}
type Index interface {
// dest must be closed, even when returning an error.
// limit is <= 0 for default. smallest possible default is 0
@ -198,6 +210,17 @@ type Index interface {
// Most recent Path claim for (signer, base, suffix) as of
// provided time 'at', or most recent if 'at' is nil.
PathLookup(signer, base *blobref.BlobRef, suffix string, at time.Time) (*Path, error)
// EdgesTo finds references to the provided ref.
//
// For instance, if ref is a permanode, it might find the parent permanodes
// that have ref as a member.
// Or, if ref is a static file, it might find static directories which contain
// that file.
// This is a way to go "up" or "back" in a hierarchy.
//
// opts may be nil to accept the defaults.
EdgesTo(ref *blobref.BlobRef, opts *EdgesToOpts) ([]*Edge, error)
}
// TODO(bradfitz): rename this? This is really about signer-attr-value

View File

@ -171,3 +171,7 @@ func (fi *FakeIndex) PathLookup(signer, base *blobref.BlobRef, suffix string, at
log.Printf("PathLookup miss for signer %q, base %q, suffix %q", signer, base, suffix)
return nil, os.ErrNotExist
}
func (fi *FakeIndex) EdgesTo(ref *blobref.BlobRef, opts *search.EdgesToOpts) ([]*search.Edge, error) {
panic("NOIMPL")
}