Skip to content

Commit

Permalink
PR FIXUP - Suffix fetcher names
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Dec 12, 2024
1 parent 17365a8 commit 79a5013
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 50 deletions.
18 changes: 9 additions & 9 deletions internal/db/fetcher/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"github.com/sourcenetwork/defradb/internal/keys"
)

// document is the type responsible for fetching documents from the datastore.
// documentFetcher is the type responsible for fetching documents from the datastore.
//
// It does not filter the data in any way.
type document struct {
type documentFetcher struct {
// The set of fields to fetch, mapped by field ID.
fieldsByID map[uint32]client.FieldDefinition
// The status to assign fetched documents.
Expand All @@ -46,7 +46,7 @@ type document struct {
nextKV immutable.Option[keyValue]
}

var _ fetcher = (*document)(nil)
var _ fetcher = (*documentFetcher)(nil)

func newDocumentFetcher(
ctx context.Context,
Expand All @@ -55,7 +55,7 @@ func newDocumentFetcher(
prefix keys.DataStoreKey,
status client.DocumentStatus,
execInfo *ExecInfo,
) (*document, error) {
) (*documentFetcher, error) {
if status == client.Active {
prefix = prefix.WithValueFlag()
} else if status == client.Deleted {
Expand All @@ -67,7 +67,7 @@ func newDocumentFetcher(
return nil, err
}

Check warning on line 68 in internal/db/fetcher/document.go

View check run for this annotation

Codecov / codecov/patch

internal/db/fetcher/document.go#L67-L68

Added lines #L67 - L68 were not covered by tests

return &document{
return &documentFetcher{
fieldsByID: fieldsByID,
kvResultsIter: kvResultsIter,
status: status,
Expand All @@ -81,7 +81,7 @@ type keyValue struct {
Value []byte
}

func (f *document) NextDoc() (immutable.Option[string], error) {
func (f *documentFetcher) NextDoc() (immutable.Option[string], error) {
if f.nextKV.HasValue() {
docID := f.nextKV.Value().Key.DocID
f.currentKV = f.nextKV.Value()
Expand Down Expand Up @@ -120,7 +120,7 @@ func (f *document) NextDoc() (immutable.Option[string], error) {
return immutable.Some(f.currentKV.Key.DocID), nil
}

func (f *document) GetFields() (immutable.Option[EncodedDocument], error) {
func (f *documentFetcher) GetFields() (immutable.Option[EncodedDocument], error) {
doc := encodedDocument{}
doc.id = []byte(f.currentKV.Key.DocID)
doc.status = f.status
Expand Down Expand Up @@ -161,7 +161,7 @@ func (f *document) GetFields() (immutable.Option[EncodedDocument], error) {
return immutable.Some[EncodedDocument](&doc), nil
}

func (f *document) appendKv(doc *encodedDocument, kv keyValue) error {
func (f *documentFetcher) appendKv(doc *encodedDocument, kv keyValue) error {
if kv.Key.FieldID == keys.DATASTORE_DOC_VERSION_FIELD_ID {
doc.schemaVersionID = string(kv.Value)
return nil
Expand Down Expand Up @@ -192,6 +192,6 @@ func (f *document) appendKv(doc *encodedDocument, kv keyValue) error {
return nil
}

func (f *document) Close() error {
func (f *documentFetcher) Close() error {
return f.kvResultsIter.Close()
}
16 changes: 8 additions & 8 deletions internal/db/fetcher/filtered.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ import (
"github.com/sourcenetwork/defradb/internal/planner/mapper"
)

// filtered fetcher is responsible for the filtering documents based on the provided
// filteredFetcher fetcher is responsible for the filtering documents based on the provided
// conditions.
type filtered struct {
type filteredFetcher struct {
filter *mapper.Filter
mapping *core.DocumentMapping

fetcher fetcher
}

var _ fetcher = (*filtered)(nil)
var _ fetcher = (*filteredFetcher)(nil)

func newFilteredFetcher(
filter *mapper.Filter,
mapping *core.DocumentMapping,
fetcher fetcher,
) *filtered {
return &filtered{
) *filteredFetcher {
return &filteredFetcher{
filter: filter,
mapping: mapping,
fetcher: fetcher,
}
}

func (f *filtered) NextDoc() (immutable.Option[string], error) {
func (f *filteredFetcher) NextDoc() (immutable.Option[string], error) {
return f.fetcher.NextDoc()
}

func (f *filtered) GetFields() (immutable.Option[EncodedDocument], error) {
func (f *filteredFetcher) GetFields() (immutable.Option[EncodedDocument], error) {
doc, err := f.fetcher.GetFields()
if err != nil {
return immutable.None[EncodedDocument](), err
Expand All @@ -71,6 +71,6 @@ func (f *filtered) GetFields() (immutable.Option[EncodedDocument], error) {
return doc, nil
}

func (f *filtered) Close() error {
func (f *filteredFetcher) Close() error {
return f.fetcher.Close()
}
16 changes: 8 additions & 8 deletions internal/db/fetcher/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/sourcenetwork/immutable"
)

// multi is a fetcher that orchastrates the fetching of documents via multiple child fetchers.
// multiFetcher is a fetcher that orchastrates the fetching of documents via multiple child fetchers.
//
// The documents are yielded ordered by docID independently of which child fetcher they are sourced from.
type multi struct {
type multiFetcher struct {
children []fetcherDocID

// The index of the fetcher that last returned an item from `NextDoc`.
Expand All @@ -28,11 +28,11 @@ type multi struct {
currentFetcherIndex int
}

var _ fetcher = (*multi)(nil)
var _ fetcher = (*multiFetcher)(nil)

func newMultiFetcher(
children ...fetcher,
) *multi {
) *multiFetcher {
fetcherDocIDs := make([]fetcherDocID, len(children))

for i, fetcher := range children {
Expand All @@ -41,7 +41,7 @@ func newMultiFetcher(
}
}

return &multi{
return &multiFetcher{
children: fetcherDocIDs,
}
}
Expand All @@ -54,7 +54,7 @@ type fetcherDocID struct {
docID immutable.Option[string]
}

func (f *multi) NextDoc() (immutable.Option[string], error) {
func (f *multiFetcher) NextDoc() (immutable.Option[string], error) {
selectedFetcherIndex := -1
var selectedDocID immutable.Option[string]

Expand Down Expand Up @@ -93,7 +93,7 @@ func (f *multi) NextDoc() (immutable.Option[string], error) {
return selectedDocID, nil
}

func (f *multi) GetFields() (immutable.Option[EncodedDocument], error) {
func (f *multiFetcher) GetFields() (immutable.Option[EncodedDocument], error) {
doc, err := f.children[f.currentFetcherIndex].fetcher.GetFields()
if err != nil {
return immutable.None[EncodedDocument](), err
Expand All @@ -104,7 +104,7 @@ func (f *multi) GetFields() (immutable.Option[EncodedDocument], error) {
return doc, nil
}

func (f *multi) Close() error {
func (f *multiFetcher) Close() error {
errs := []error{}
for _, child := range f.children {
err := child.fetcher.Close()
Expand Down
16 changes: 8 additions & 8 deletions internal/db/fetcher/permissioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/sourcenetwork/defradb/internal/db/permission"
)

// permissioned fetcher applies access control based filtering to documents fetched.
type permissioned struct {
// permissionedFetcher fetcher applies access control based filtering to documents fetched.
type permissionedFetcher struct {
ctx context.Context

identity immutable.Option[acpIdentity.Identity]
Expand All @@ -32,16 +32,16 @@ type permissioned struct {
fetcher fetcher
}

var _ fetcher = (*permissioned)(nil)
var _ fetcher = (*permissionedFetcher)(nil)

func newPermissionedFetcher(
ctx context.Context,
identity immutable.Option[acpIdentity.Identity],
acp acp.ACP,
col client.Collection,
fetcher fetcher,
) *permissioned {
return &permissioned{
) *permissionedFetcher {
return &permissionedFetcher{
ctx: ctx,
identity: identity,
acp: acp,
Expand All @@ -50,7 +50,7 @@ func newPermissionedFetcher(
}
}

func (f *permissioned) NextDoc() (immutable.Option[string], error) {
func (f *permissionedFetcher) NextDoc() (immutable.Option[string], error) {
docID, err := f.fetcher.NextDoc()
if err != nil {
return immutable.None[string](), err
Expand Down Expand Up @@ -79,10 +79,10 @@ func (f *permissioned) NextDoc() (immutable.Option[string], error) {
return docID, nil
}

func (f *permissioned) GetFields() (immutable.Option[EncodedDocument], error) {
func (f *permissionedFetcher) GetFields() (immutable.Option[EncodedDocument], error) {
return f.fetcher.GetFields()
}

func (f *permissioned) Close() error {
func (f *permissionedFetcher) Close() error {
return f.fetcher.Close()
}
18 changes: 9 additions & 9 deletions internal/db/fetcher/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/sourcenetwork/defradb/internal/keys"
)

// prefix is a fetcher type responsible for iterating through multiple prefixes.
// prefixFetcher is a fetcher type responsible for iterating through multiple prefixes.
//
// It manages the document fetcher instances that will do the actual scanning.
type prefix struct {
type prefixFetcher struct {
// The prefixes that this prefix fetcher must fetch from.
prefixes []keys.DataStoreKey
// The Iterator this prefix fetcher will use to scan.
Expand All @@ -36,7 +36,7 @@ type prefix struct {
// The index of the current prefix being fetched.
currentPrefix int
// The child document fetcher, specific to the current prefix.
fetcher *document
fetcher *documentFetcher

// The below properties are only held here in order to pass them on to the next
// child fetcher instance.
Expand All @@ -46,7 +46,7 @@ type prefix struct {
execInfo *ExecInfo
}

var _ fetcher = (*prefix)(nil)
var _ fetcher = (*prefixFetcher)(nil)

func newPrefixFetcher(
ctx context.Context,
Expand All @@ -56,7 +56,7 @@ func newPrefixFetcher(
fieldsByID map[uint32]client.FieldDefinition,
status client.DocumentStatus,
execInfo *ExecInfo,
) (*prefix, error) {
) (*prefixFetcher, error) {
kvIter, err := txn.Datastore().GetIterator(dsq.Query{})
if err != nil {
return nil, err
Expand Down Expand Up @@ -92,7 +92,7 @@ func newPrefixFetcher(
return nil, err
}

Check warning on line 93 in internal/db/fetcher/prefix.go

View check run for this annotation

Codecov / codecov/patch

internal/db/fetcher/prefix.go#L92-L93

Added lines #L92 - L93 were not covered by tests

return &prefix{
return &prefixFetcher{
kvIter: kvIter,
prefixes: prefixes,
ctx: ctx,
Expand All @@ -103,7 +103,7 @@ func newPrefixFetcher(
}, nil
}

func (f *prefix) NextDoc() (immutable.Option[string], error) {
func (f *prefixFetcher) NextDoc() (immutable.Option[string], error) {
docID, err := f.fetcher.NextDoc()
if err != nil {
return immutable.None[string](), err
Expand Down Expand Up @@ -133,10 +133,10 @@ func (f *prefix) NextDoc() (immutable.Option[string], error) {
return docID, nil
}

func (f *prefix) GetFields() (immutable.Option[EncodedDocument], error) {
func (f *prefixFetcher) GetFields() (immutable.Option[EncodedDocument], error) {
return f.fetcher.GetFields()
}

func (f *prefix) Close() error {
func (f *prefixFetcher) Close() error {
return f.kvIter.Close()
}
16 changes: 8 additions & 8 deletions internal/db/fetcher/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"github.com/sourcenetwork/defradb/internal/request/graphql/parser"
)

// wrapper is a fetcher type that bridges between the existing [Fetcher] interface
// wrappingFetcher is a fetcher type that bridges between the existing [Fetcher] interface
// and the newer [fetcher] interface.
type wrapper struct {
type wrappingFetcher struct {
fetcher fetcher
execInfo *ExecInfo

Expand All @@ -43,13 +43,13 @@ type wrapper struct {
showDeleted bool
}

var _ Fetcher = (*wrapper)(nil)
var _ Fetcher = (*wrappingFetcher)(nil)

func NewDocumentFetcher() Fetcher {
return &wrapper{}
return &wrappingFetcher{}
}

func (f *wrapper) Init(
func (f *wrappingFetcher) Init(
ctx context.Context,
identity immutable.Option[acpIdentity.Identity],
txn datastore.Txn,
Expand All @@ -72,7 +72,7 @@ func (f *wrapper) Init(
return nil
}

func (f *wrapper) Start(ctx context.Context, prefixes ...keys.Walkable) error {
func (f *wrappingFetcher) Start(ctx context.Context, prefixes ...keys.Walkable) error {
err := f.Close()
if err != nil {
return err
Expand Down Expand Up @@ -147,7 +147,7 @@ func (f *wrapper) Start(ctx context.Context, prefixes ...keys.Walkable) error {
return nil
}

func (f *wrapper) FetchNext(ctx context.Context) (EncodedDocument, ExecInfo, error) {
func (f *wrappingFetcher) FetchNext(ctx context.Context) (EncodedDocument, ExecInfo, error) {
docID, err := f.fetcher.NextDoc()
if err != nil {
return nil, ExecInfo{}, err
Expand Down Expand Up @@ -175,7 +175,7 @@ func (f *wrapper) FetchNext(ctx context.Context) (EncodedDocument, ExecInfo, err
return doc.Value(), execInfo, nil
}

func (f *wrapper) Close() error {
func (f *wrappingFetcher) Close() error {
if f.fetcher != nil {
return f.fetcher.Close()
}
Expand Down

0 comments on commit 79a5013

Please sign in to comment.