diff --git a/src/m3ninx/search/executor/executor.go b/src/m3ninx/search/executor/executor.go index 79eca270fe..e5f606a82f 100644 --- a/src/m3ninx/search/executor/executor.go +++ b/src/m3ninx/search/executor/executor.go @@ -33,7 +33,7 @@ var ( errExecutorClosed = errors.New("executor is closed") ) -type newIteratorFn func(s search.Searcher, rs index.Readers) (doc.MetadataIterator, error) +type newIteratorFn func(s search.Searcher, rs index.Readers) (doc.Iterator, error) type executor struct { sync.RWMutex @@ -52,7 +52,7 @@ func NewExecutor(rs index.Readers) search.Executor { } } -func (e *executor) Execute(q search.Query) (doc.MetadataIterator, error) { +func (e *executor) Execute(q search.Query) (doc.Iterator, error) { e.RLock() defer e.RUnlock() if e.closed { diff --git a/src/m3ninx/search/executor/executor_test.go b/src/m3ninx/search/executor/executor_test.go index ce8ef85a04..25e611efc0 100644 --- a/src/m3ninx/search/executor/executor_test.go +++ b/src/m3ninx/search/executor/executor_test.go @@ -36,7 +36,7 @@ type testIterator struct{} func newTestIterator() testIterator { return testIterator{} } func (it testIterator) Next() bool { return false } -func (it testIterator) Current() doc.Metadata { return doc.Metadata{} } +func (it testIterator) Current() doc.Document { return doc.Document{} } func (it testIterator) Err() error { return nil } func (it testIterator) Close() error { return nil } @@ -58,7 +58,7 @@ func TestExecutor(t *testing.T) { e := NewExecutor(rs).(*executor) // Override newIteratorFn to return test iterator. - e.newIteratorFn = func(_ search.Searcher, _ index.Readers) (doc.MetadataIterator, error) { + e.newIteratorFn = func(_ search.Searcher, _ index.Readers) (doc.Iterator, error) { return newTestIterator(), nil } diff --git a/src/m3ninx/search/executor/iterator.go b/src/m3ninx/search/executor/iterator.go index c1cc471ef9..3ca5e82781 100644 --- a/src/m3ninx/search/executor/iterator.go +++ b/src/m3ninx/search/executor/iterator.go @@ -31,14 +31,14 @@ type iterator struct { readers index.Readers idx int - currDoc doc.Metadata - currIter doc.MetadataIterator + currDoc doc.Document + currIter doc.Iterator err error closed bool } -func newIterator(s search.Searcher, rs index.Readers) (doc.MetadataIterator, error) { +func newIterator(s search.Searcher, rs index.Readers) (doc.Iterator, error) { it := &iterator{ searcher: s, readers: rs, @@ -91,7 +91,7 @@ func (it *iterator) Next() bool { return true } -func (it *iterator) Current() doc.Metadata { +func (it *iterator) Current() doc.Document { return it.currDoc } @@ -108,9 +108,9 @@ func (it *iterator) Close() error { } // nextIter gets the next document iterator by getting the next postings list from -// the it's searcher and then getting the documents for that postings list from the -// corresponding reader associated with that postings list. -func (it *iterator) nextIter() (doc.MetadataIterator, bool, error) { +// the it's searcher and then getting the encoded documents for that postings list from +// the corresponding reader associated with that postings list. +func (it *iterator) nextIter() (doc.Iterator, bool, error) { it.idx++ if it.idx >= len(it.readers) { return nil, false, nil @@ -122,7 +122,7 @@ func (it *iterator) nextIter() (doc.MetadataIterator, bool, error) { return nil, false, err } - iter, err := reader.MetadataIterator(pl) + iter, err := reader.Docs(pl) if err != nil { return nil, false, err } diff --git a/src/m3ninx/search/executor/iterator_test.go b/src/m3ninx/search/executor/iterator_test.go index 28cf95f021..6ebcfe9bcb 100644 --- a/src/m3ninx/search/executor/iterator_test.go +++ b/src/m3ninx/search/executor/iterator_test.go @@ -44,35 +44,14 @@ func TestIterator(t *testing.T) { require.NoError(t, secondPL.Insert(67)) // Set up Readers. - docs := []doc.Metadata{ - { - Fields: []doc.Field{ - { - Name: []byte("apple"), - Value: []byte("red"), - }, - }, - }, - { - Fields: []doc.Field{ - { - Name: []byte("banana"), - Value: []byte("yellow"), - }, - }, - }, - { - Fields: []doc.Field{ - { - Name: []byte("carrot"), - Value: []byte("orange"), - }, - }, - }, + docs := []doc.Document{ + doc.NewDocumentFromEncoded(doc.Encoded{Bytes: []byte("encodedbytes1")}), + doc.NewDocumentFromEncoded(doc.Encoded{Bytes: []byte("encodedbytes2")}), + doc.NewDocumentFromEncoded(doc.Encoded{Bytes: []byte("encodedbytes3")}), } - firstDocIter := doc.NewMockMetadataIterator(mockCtrl) - secondDocIter := doc.NewMockMetadataIterator(mockCtrl) + firstDocIter := doc.NewMockIterator(mockCtrl) + secondDocIter := doc.NewMockIterator(mockCtrl) gomock.InOrder( firstDocIter.EXPECT().Next().Return(true), firstDocIter.EXPECT().Current().Return(docs[0]), @@ -92,8 +71,8 @@ func TestIterator(t *testing.T) { firstReader := index.NewMockReader(mockCtrl) secondReader := index.NewMockReader(mockCtrl) gomock.InOrder( - firstReader.EXPECT().MetadataIterator(firstPL).Return(firstDocIter, nil), - secondReader.EXPECT().MetadataIterator(secondPL).Return(secondDocIter, nil), + firstReader.EXPECT().Docs(firstPL).Return(firstDocIter, nil), + secondReader.EXPECT().Docs(secondPL).Return(secondDocIter, nil), ) searcher := search.NewMockSearcher(mockCtrl) diff --git a/src/m3ninx/search/search_mock.go b/src/m3ninx/search/search_mock.go index b070619f5f..3c327a7bba 100644 --- a/src/m3ninx/search/search_mock.go +++ b/src/m3ninx/search/search_mock.go @@ -1,7 +1,7 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/m3db/m3/src/m3ninx/search/types.go -// Copyright (c) 2018 Uber Technologies, Inc. +// Copyright (c) 2021 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -59,10 +59,10 @@ func (m *MockExecutor) EXPECT() *MockExecutorMockRecorder { } // Execute mocks base method -func (m *MockExecutor) Execute(q Query) (doc.MetadataIterator, error) { +func (m *MockExecutor) Execute(q Query) (doc.Iterator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Execute", q) - ret0, _ := ret[0].(doc.MetadataIterator) + ret0, _ := ret[0].(doc.Iterator) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/src/m3ninx/search/types.go b/src/m3ninx/search/types.go index cb21903fda..d4fc76b4ab 100644 --- a/src/m3ninx/search/types.go +++ b/src/m3ninx/search/types.go @@ -32,7 +32,7 @@ import ( // Executor is responsible for executing queries over a snapshot. type Executor interface { // Execute executes a query over the Executor's snapshot. - Execute(q Query) (doc.MetadataIterator, error) + Execute(q Query) (doc.Iterator, error) // Close closes the iterator. Close() error