index

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2019 License: Apache-2.0 Imports: 12 Imported by: 24

Documentation

Overview

Package index is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrDocNotFound = errors.New("no document with given postings ID")

ErrDocNotFound is the error returned when there is no document for a given postings ID.

View Source
var (
	// ErrDuplicateID is the error returned when a batch contains duplicate IDs.
	ErrDuplicateID = errors.New("a batch cannot contain duplicate IDs")
)

Functions

func IsBatchPartialError

func IsBatchPartialError(err error) bool

IsBatchPartialError returns a bool indicating whether err is a BatchPartialError or not.

Types

type Batch

type Batch struct {
	Docs []doc.Document

	// If AllowPartialUpdates is true the index will continue to index documents in the batch
	// even if it encounters an error attempting to index a previous document in the batch.
	// If false, on the other hand, then any errors encountered indexing a document will cause
	// the entire batch to fail and none of the documents in the batch will be indexed.
	AllowPartialUpdates bool
}

Batch represents a batch of documents that should be inserted into the index.

func NewBatch

func NewBatch(docs []doc.Document, opts ...BatchOption) Batch

NewBatch returns a Batch of documents.

type BatchError

type BatchError struct {
	Err error
	Idx int
}

BatchError is an error that occurred for a document being inserted.

type BatchMatcher

type BatchMatcher interface {
	gomock.Matcher
}

BatchMatcher matches a `Batch`.

func NewBatchMatcher

func NewBatchMatcher(b Batch) BatchMatcher

NewBatchMatcher returns a new BatchMatcher.

type BatchOption

type BatchOption interface {
	// contains filtered or unexported methods
}

BatchOption is an option for a Batch.

func AllowPartialUpdates

func AllowPartialUpdates() BatchOption

AllowPartialUpdates permits an index to continue indexing documents in a batch even if it encountered an error inserting a prior document.

type BatchPartialError

type BatchPartialError struct {
	// contains filtered or unexported fields
}

BatchPartialError indicates an error was encountered inserting some documents in a batch. It is not safe for concurrent use.

func NewBatchPartialError

func NewBatchPartialError() *BatchPartialError

NewBatchPartialError returns a new BatchPartialError.

func (*BatchPartialError) Add

func (e *BatchPartialError) Add(err BatchError)

Add adds an error to e. Any nil errors are ignored.

func (*BatchPartialError) Error

func (e *BatchPartialError) Error() string

func (*BatchPartialError) Errs

func (e *BatchPartialError) Errs() []BatchError

Errs returns the errors with the indexes of the documents in the batch which were not indexed.

func (*BatchPartialError) FilterDuplicateIDErrors

func (e *BatchPartialError) FilterDuplicateIDErrors() error

FilterDuplicateIDErrors returns a new BatchPartialError (or nil), without any DuplicateIDError(s). NB(prateek): it mutates the order of errors in the original error to avoid allocations.

func (*BatchPartialError) IsEmpty

func (e *BatchPartialError) IsEmpty() bool

IsEmpty returns a bool indicating whether e is empty or not.

type CompiledRegex added in v0.4.1

type CompiledRegex struct {
	Simple      *regexp.Regexp
	FST         *vregex.Regexp
	FSTSyntax   *syntax.Regexp
	PrefixBegin []byte
	PrefixEnd   []byte
}

CompiledRegex is a collection of regexp compiled structs to allow amortisation of regexp construction costs.

func CompileRegex added in v0.4.4

func CompileRegex(r []byte) (CompiledRegex, error)

CompileRegex compiles the provided regexp into an object that can be used to query the various segment implementations.

type DocRetriever

type DocRetriever interface {
	Doc(id postings.ID) (doc.Document, error)
}

DocRetriever returns the document associated with a postings ID. It returns ErrDocNotFound if there is no document corresponding to the given postings ID.

type IDDocIterator

type IDDocIterator interface {
	doc.Iterator

	// PostingsID returns the current document postings ID.
	PostingsID() postings.ID
}

IDDocIterator is an extented documents Iterator which can also return the postings ID of the current document.

func NewIDDocIterator

func NewIDDocIterator(r DocRetriever, pi postings.Iterator) IDDocIterator

NewIDDocIterator returns a new NewIDDocIterator.

type IDIterator added in v0.5.0

type IDIterator interface {
	// Next returns a bool indicating if the iterator has any more documents
	// to return.
	Next() bool

	// Current returns the current document ID.
	Current() []byte

	// PostingsID returns the current document postings ID.
	PostingsID() postings.ID

	// Err returns any errors encountered during iteration.
	Err() error

	// Close releases any internal resources used by the iterator.
	Close() error
}

IDIterator is a document ID iterator.

type Index

type Index interface {
	Writer

	// Readers returns a set of readers representing a point-in-time snapshot of the index.
	Readers() (Readers, error)

	// Close closes the index and releases any internal resources.
	Close() error
}

Index is a collection of searchable documents.

type MockDocRetriever

type MockDocRetriever struct {
	// contains filtered or unexported fields
}

MockDocRetriever is a mock of DocRetriever interface

func NewMockDocRetriever

func NewMockDocRetriever(ctrl *gomock.Controller) *MockDocRetriever

NewMockDocRetriever creates a new mock instance

func (*MockDocRetriever) Doc

func (m *MockDocRetriever) Doc(arg0 postings.ID) (doc.Document, error)

Doc mocks base method

func (*MockDocRetriever) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

type MockDocRetrieverMockRecorder

type MockDocRetrieverMockRecorder struct {
	// contains filtered or unexported fields
}

MockDocRetrieverMockRecorder is the mock recorder for MockDocRetriever

func (*MockDocRetrieverMockRecorder) Doc

func (mr *MockDocRetrieverMockRecorder) Doc(arg0 interface{}) *gomock.Call

Doc indicates an expected call of Doc

type MockReader

type MockReader struct {
	// contains filtered or unexported fields
}

MockReader is a mock of Reader interface

func NewMockReader

func NewMockReader(ctrl *gomock.Controller) *MockReader

NewMockReader creates a new mock instance

func (*MockReader) AllDocs

func (m *MockReader) AllDocs() (IDDocIterator, error)

AllDocs mocks base method

func (*MockReader) Close

func (m *MockReader) Close() error

Close mocks base method

func (*MockReader) Doc

func (m *MockReader) Doc(arg0 postings.ID) (doc.Document, error)

Doc mocks base method

func (*MockReader) Docs

func (m *MockReader) Docs(arg0 postings.List) (doc.Iterator, error)

Docs mocks base method

func (*MockReader) EXPECT

func (m *MockReader) EXPECT() *MockReaderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockReader) MatchAll

func (m *MockReader) MatchAll() (postings.MutableList, error)

MatchAll mocks base method

func (*MockReader) MatchRegexp

func (m *MockReader) MatchRegexp(arg0 []byte, arg1 CompiledRegex) (postings.List, error)

MatchRegexp mocks base method

func (*MockReader) MatchTerm

func (m *MockReader) MatchTerm(arg0, arg1 []byte) (postings.List, error)

MatchTerm mocks base method

type MockReaderMockRecorder

type MockReaderMockRecorder struct {
	// contains filtered or unexported fields
}

MockReaderMockRecorder is the mock recorder for MockReader

func (*MockReaderMockRecorder) AllDocs

func (mr *MockReaderMockRecorder) AllDocs() *gomock.Call

AllDocs indicates an expected call of AllDocs

func (*MockReaderMockRecorder) Close

func (mr *MockReaderMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockReaderMockRecorder) Doc

func (mr *MockReaderMockRecorder) Doc(arg0 interface{}) *gomock.Call

Doc indicates an expected call of Doc

func (*MockReaderMockRecorder) Docs

func (mr *MockReaderMockRecorder) Docs(arg0 interface{}) *gomock.Call

Docs indicates an expected call of Docs

func (*MockReaderMockRecorder) MatchAll

func (mr *MockReaderMockRecorder) MatchAll() *gomock.Call

MatchAll indicates an expected call of MatchAll

func (*MockReaderMockRecorder) MatchRegexp

func (mr *MockReaderMockRecorder) MatchRegexp(arg0, arg1 interface{}) *gomock.Call

MatchRegexp indicates an expected call of MatchRegexp

func (*MockReaderMockRecorder) MatchTerm

func (mr *MockReaderMockRecorder) MatchTerm(arg0, arg1 interface{}) *gomock.Call

MatchTerm indicates an expected call of MatchTerm

type Readable

type Readable interface {
	DocRetriever

	// MatchTerm returns a postings list over all documents which match the given term.
	MatchTerm(field, term []byte) (postings.List, error)

	// MatchRegexp returns a postings list over all documents which match the given
	// regular expression.
	MatchRegexp(field []byte, c CompiledRegex) (postings.List, error)

	// MatchAll returns a postings list for all documents known to the Reader.
	MatchAll() (postings.MutableList, error)

	// Docs returns an iterator over the documents whose IDs are in the provided
	// postings list.
	Docs(pl postings.List) (doc.Iterator, error)

	// AllDocs returns an iterator over the documents known to the Reader.
	AllDocs() (IDDocIterator, error)
}

Readable provides a point-in-time accessor to the documents in an index.

type Reader

type Reader interface {
	Readable

	// Close closes the reader and releases any internal resources.
	Close() error
}

Reader provides a point-in-time accessor to the documents in an index.

type Readers

type Readers []Reader

Readers is a slice of Reader.

func (Readers) Close

func (rs Readers) Close() error

Close closes all of the Readers in rs.

type Writer

type Writer interface {
	// Insert inserts the given document into the index and returns its ID. The document
	// is guaranteed to be searchable once the Insert method returns.
	Insert(d doc.Document) ([]byte, error)

	// InsertBatch inserts a batch of metrics into the index. The documents are guaranteed
	// to be searchable all at once when the Batch method returns. If the batch supports
	// partial updates and any errors are encountered on individual documents then a
	// BatchPartialError is returned.
	InsertBatch(b Batch) error
}

Writer is used to insert documents into an index.

Directories

Path Synopsis
Package segment is a generated GoMock package.
Package segment is a generated GoMock package.
fst
Package fst is a generated GoMock package.
Package fst is a generated GoMock package.
mem
Package mem is a generated GoMock package.
Package mem is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL