Skip to content

Commit

Permalink
Rename GetFromDocument to MetadataFromDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
nbroyles committed Jan 13, 2021
1 parent e6143fa commit 0bf540f
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/cmd/tools/query_index_segments/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func run(opts runOptions) {
fields := make(map[string]string)
for iter.Next() {
d := iter.Current()
m, err := docs.GetFromDocument(d, reader)
m, err := docs.MetadataFromDocument(d, reader)
if err != nil {
log.Fatal("error retrieve document metadata", zap.Error(err))
}
Expand Down
4 changes: 2 additions & 2 deletions src/dbnode/network/server/tchannelthrift/node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (s *service) query(ctx context.Context, db storage.Database, req *rpc.Query
id := ident.NewReusableBytesID()
for _, entry := range queryResult.Results.Map().Iter() {
d := entry.Value()
metadata, err := docs.GetFromDocument(d, reader)
metadata, err := docs.MetadataFromDocument(d, reader)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -814,7 +814,7 @@ func (s *service) fetchReadEncoded(ctx context.Context,
tsID := id

d := entry.Value()
metadata, err := docs.GetFromDocument(d, reader)
metadata, err := docs.MetadataFromDocument(d, reader)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions src/dbnode/storage/index/aggregate_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (r *aggregatedResults) addDocumentsBatchWithLock(
func (r *aggregatedResults) addDocumentTermsWithLock(
container doc.Document,
) error {
document, err := docs.GetFromDocument(container, &r.encodedDocReader)
document, err := docs.MetadataFromDocument(container, &r.encodedDocReader)
if err != nil {
return fmt.Errorf("unable to decode encoded document; %w", err)
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func (r *aggregatedResults) addTermWithLock(
func (r *aggregatedResults) addDocumentWithLock(
container doc.Document,
) error {
document, err := docs.GetFromDocument(container, &r.encodedDocReader)
document, err := docs.MetadataFromDocument(container, &r.encodedDocReader)
if err != nil {
return fmt.Errorf("unable to decode encoded document; %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/index/results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func TestResultsInsertDoesNotCopy(t *testing.T) {
// Ensure the underlying []byte for ID/Fields is the same.
require.True(t, xtest.ByteSlicesBackedBySameData(key, dValid.ID))
d := entry.Value()
m, err := docs.GetFromDocument(d, reader)
m, err := docs.MetadataFromDocument(d, reader)
require.NoError(t, err)

tags := idxconvert.ToSeriesTags(m, idxconvert.Opts{NoClone: true})
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/index/wide_query_results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func buildExpected(t *testing.T, docs [][]doc.Document) [][]string {
for _, batch := range docs {
idBatch := make([]string, 0, len(batch))
for _, document := range batch { // nolint:gocritic
m, err := encoding.GetFromDocument(document, reader)
m, err := encoding.MetadataFromDocument(document, reader)
require.NoError(t, err)
idBatch = append(idBatch, string(m.ID))
}
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/index_queue_forward_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestNamespaceForwardIndexInsertQuery(t *testing.T) {
require.Equal(t, "testns1", results.Namespace().String())

d, ok := results.Map().Get(ident.BytesID("foo"))
md, err := docs.GetFromDocument(d, reader)
md, err := docs.MetadataFromDocument(d, reader)
require.NoError(t, err)
tags := idxconvert.ToSeriesTags(md, idxconvert.Opts{NoClone: true})

Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/index_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestNamespaceIndexInsertQuery(t *testing.T) {

reader := docs.NewEncodedDocumentReader()
d, ok := results.Map().Get(ident.BytesID("foo"))
md, err := docs.GetFromDocument(d, reader)
md, err := docs.MetadataFromDocument(d, reader)
require.NoError(t, err)
tags := idxconvert.ToSeriesTags(md, idxconvert.Opts{NoClone: true})

Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
// ident.TagIterator.
func DocumentToTagIter(t *testing.T, doc doc.Document) ident.TagIterator {
reader := docs.NewEncodedDocumentReader()
m, err := docs.GetFromDocument(doc, reader)
m, err := docs.MetadataFromDocument(doc, reader)
require.NoError(t, err)

return convert.ToSeriesTags(m, convert.Opts{NoClone: true})
Expand Down
4 changes: 2 additions & 2 deletions src/m3ninx/index/segment/fst/encoding/docs/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func ReadEncodedDocumentID(encoded doc.Encoded) ([]byte, error) {
return id, err
}

// GetFromDocument retrieves a doc.Metadata from a doc.Document.
func GetFromDocument(document doc.Document, reader *EncodedDocumentReader) (doc.Metadata, error) {
// MetadataFromDocument retrieves a doc.Metadata from a doc.Document.
func MetadataFromDocument(document doc.Document, reader *EncodedDocumentReader) (doc.Metadata, error) {
if d, ok := document.Metadata(); ok {
return d, nil
}
Expand Down
4 changes: 2 additions & 2 deletions src/m3ninx/search/proptest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func (m *documentIteratorMatcher) Matches(i doc.Iterator) error {

func (m *documentIteratorMatcher) compareDocs(d1 doc.Document, d2 doc.Document) bool {
docReader := idxdocs.NewEncodedDocumentReader()
d1Metadata, err := idxdocs.GetFromDocument(d1, docReader)
d1Metadata, err := idxdocs.MetadataFromDocument(d1, docReader)
require.NoError(m.t, err)

d2Metadata, err := idxdocs.GetFromDocument(d2, docReader)
d2Metadata, err := idxdocs.MetadataFromDocument(d2, docReader)
require.NoError(m.t, err)

return d1Metadata.Equal(d2Metadata)
Expand Down

0 comments on commit 0bf540f

Please sign in to comment.