Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nbroyles committed Jan 13, 2021
1 parent 0bf540f commit e4f8579
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/dbnode/network/server/tchannelthrift/node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ func (s *service) query(ctx context.Context, db storage.Database, req *rpc.Query
if req.NoData != nil && *req.NoData {
fetchData = false
}
// Re-use reader and id for more memory-efficient processing of
// tags from doc.Metadata
reader := docs.NewEncodedDocumentReader()
id := ident.NewReusableBytesID()
for _, entry := range queryResult.Results.Map().Iter() {
Expand Down Expand Up @@ -545,8 +547,7 @@ func (s *service) query(ctx context.Context, db storage.Database, req *rpc.Query
continue
}
id.Reset(entry.Key())
tsID := id
datapoints, err := s.readDatapoints(ctx, db, nsID, tsID, start, end,
datapoints, err := s.readDatapoints(ctx, db, nsID, id, start, end,
req.ResultTimeType)
if err != nil {
return nil, convert.ToRPCError(err)
Expand Down Expand Up @@ -804,14 +805,15 @@ func (s *service) fetchReadEncoded(ctx context.Context,
defer sp.Finish()

i := 0
// Re-use reader and id for more memory-efficient processing of
// tags from doc.Metadata
reader := docs.NewEncodedDocumentReader()
id := ident.NewReusableBytesID()
for _, entry := range results.Map().Iter() {
idx := i
i++

id.Reset(entry.Key())
tsID := id

d := entry.Value()
metadata, err := docs.MetadataFromDocument(d, reader)
Expand All @@ -829,15 +831,15 @@ func (s *service) fetchReadEncoded(ctx context.Context,

elem := &rpc.FetchTaggedIDResult_{
NameSpace: nsIDBytes,
ID: tsID.Bytes(),
ID: id.Bytes(),
EncodedTags: encodedTags.Bytes(),
}
response.Elements = append(response.Elements, elem)
if !fetchData {
continue
}

encoded, err := db.ReadEncoded(ctx, nsID, tsID,
encoded, err := db.ReadEncoded(ctx, nsID, id,
opts.StartInclusive, opts.EndExclusive)
if err != nil {
return convert.ToRPCError(err)
Expand Down
1 change: 0 additions & 1 deletion src/dbnode/storage/index/results_new_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func newResultsMap(idPool ident.Pool) *ResultsMap {
return ResultsMapHash(xxhash.Sum64(k))
},
equals: bytes.Equal,
// TODO(nate); are these copy and finalize implementations right?
copy: func(k []byte) []byte {
return idPool.Clone(ident.BytesID(k)).Bytes()
},
Expand Down
3 changes: 1 addition & 2 deletions src/dbnode/storage/index_query_concurrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import (
"testing"
"time"

testutil "github.com/m3db/m3/src/dbnode/test"

"github.com/m3db/m3/src/dbnode/storage/index"
"github.com/m3db/m3/src/dbnode/storage/index/convert"
testutil "github.com/m3db/m3/src/dbnode/test"
"github.com/m3db/m3/src/m3ninx/doc"
"github.com/m3db/m3/src/m3ninx/idx"
"github.com/m3db/m3/src/x/context"
Expand Down

0 comments on commit e4f8579

Please sign in to comment.