0
0

Merge pull request #253 from pmezard/document-index-interfaces

doc: document DocIDReader, and some Index bits
This commit is contained in:
Marty Schoch 2015-10-20 14:47:35 -04:00
commit 89bc8c3a93
2 changed files with 20 additions and 0 deletions

View File

@ -160,7 +160,10 @@ type Index interface {
NewBatch() *Batch
Batch(b *Batch) error
// Document returns specified document or nil if the document is not
// indexed or stored.
Document(id string) (*document.Document, error)
// DocCount returns the number of documents in the index.
DocCount() (uint64, error)
Search(req *SearchRequest) (*SearchResult, error)
@ -185,6 +188,8 @@ type Index interface {
SetInternal(key, val []byte) error
DeleteInternal(key []byte) error
// Advanced returns the indexer and data store, exposing lower level
// methods to enumerate records and access data.
Advanced() (index.Index, store.KVStore, error)
}

View File

@ -35,6 +35,8 @@ type Index interface {
DumpDoc(id string) chan interface{}
DumpFields() chan interface{}
// Reader returns a low-level accessor on the index data. Close it to
// release associated resources.
Reader() (IndexReader, error)
Stats() json.Marshaler
@ -44,6 +46,10 @@ type Index interface {
type IndexReader interface {
TermFieldReader(term []byte, field string) (TermFieldReader, error)
// DocIDReader returns an iterator over documents which identifiers are
// greater than or equal to start and smaller than end. The caller must
// close returned instance to release associated resources.
DocIDReader(start, end string) (DocIDReader, error)
FieldDict(field string) (FieldDict, error)
@ -99,8 +105,17 @@ type FieldDict interface {
Close() error
}
// DocIDReader is the interface exposing enumeration of documents identifiers.
// Close the reader to release associated resources.
type DocIDReader interface {
// Next returns the next document identifier in ascending lexicographic
// byte order, or io.EOF when the end of the sequence is reached.
Next() (string, error)
// Advance resets the iteration to the first identifier greater than or
// equal to ID. If ID is smaller than the start of the range, the iteration
// will start there instead. If ID is greater than or equal to the end of
// the range, Next() call will return io.EOF.
Advance(ID string) (string, error)
Close() error
}