diff --git a/src/dbnode/storage/index/results.go b/src/dbnode/storage/index/results.go index f22f8fa3b9..65a0875c04 100644 --- a/src/dbnode/storage/index/results.go +++ b/src/dbnode/storage/index/results.go @@ -44,6 +44,7 @@ type results struct { nsID ident.ID opts QueryResultsOptions + reusableID *ident.ReusableBytesID resultsMap *ResultsMap totalDocsCount int @@ -63,10 +64,11 @@ func NewQueryResults( return &results{ nsID: namespaceID, opts: opts, - resultsMap: newResultsMap(indexOpts.IdentifierPool()), + resultsMap: newResultsMap(), idPool: indexOpts.IdentifierPool(), bytesPool: indexOpts.CheckedBytesPool(), pool: indexOpts.QueryResultsPool(), + reusableID: ident.NewReusableBytesID(), } } @@ -131,7 +133,8 @@ func (r *results) addDocumentWithLock(w doc.Document) (bool, int, error) { } // Need to apply filter if set first. - if r.opts.FilterID != nil && !r.opts.FilterID(ident.BytesID(id)) { + r.reusableID.Reset(id) + if r.opts.FilterID != nil && !r.opts.FilterID(r.reusableID) { return false, r.resultsMap.Len(), nil } diff --git a/src/dbnode/storage/index/results_new_map.go b/src/dbnode/storage/index/results_new_map.go index 6c1c8f1bfe..e0aac29c8b 100644 --- a/src/dbnode/storage/index/results_new_map.go +++ b/src/dbnode/storage/index/results_new_map.go @@ -24,22 +24,20 @@ import ( "bytes" "github.com/cespare/xxhash/v2" - - "github.com/m3db/m3/src/x/ident" ) const ( defaultInitialResultsMapSize = 10 ) -func newResultsMap(idPool ident.Pool) *ResultsMap { +func newResultsMap() *ResultsMap { return _ResultsMapAlloc(_ResultsMapOptions{ hash: func(k []byte) ResultsMapHash { return ResultsMapHash(xxhash.Sum64(k)) }, equals: bytes.Equal, copy: func(k []byte) []byte { - return idPool.Clone(ident.BytesID(k)).Bytes() + return append(make([]byte, 0, len(k)), k...) }, finalize: func(k []byte) { // NB(nate): no-op for bytes IDs