Skip to content

Commit 39b962d

Browse files
committed
Revert "syncmap"
This reverts commit cd76858.
1 parent 3442163 commit 39b962d

File tree

3 files changed

+11
-209
lines changed

3 files changed

+11
-209
lines changed

internal/verifier/compare.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/10gen/migration-verifier/internal/types"
9-
"github.com/10gen/migration-verifier/syncmap"
109
"github.com/pkg/errors"
1110
"go.mongodb.org/mongo-driver/bson"
1211
"go.mongodb.org/mongo-driver/mongo"
@@ -16,8 +15,6 @@ import (
1615

1716
const readTimeout = 10 * time.Minute
1817

19-
type docCacheMap = syncmap.SyncMap[string, bson.Raw]
20-
2118
func (verifier *Verifier) FetchAndCompareDocuments(
2219
givenCtx context.Context,
2320
task *VerificationTask,
@@ -76,8 +73,8 @@ func (verifier *Verifier) compareDocsFromChannels(
7673

7774
namespace := task.QueryFilter.Namespace
7875

79-
srcCache := &docCacheMap{}
80-
dstCache := &docCacheMap{}
76+
srcCache := map[string]bson.Raw{}
77+
dstCache := map[string]bson.Raw{}
8178

8279
// This is the core document-handling logic. It either:
8380
//
@@ -87,7 +84,7 @@ func (verifier *Verifier) compareDocsFromChannels(
8784
handleNewDoc := func(doc bson.Raw, isSrc bool) error {
8885
mapKey := getMapKey(doc, mapKeyFieldNames)
8986

90-
var ourMap, theirMap *docCacheMap
87+
var ourMap, theirMap map[string]bson.Raw
9188

9289
if isSrc {
9390
ourMap = srcCache
@@ -98,22 +95,22 @@ func (verifier *Verifier) compareDocsFromChannels(
9895
}
9996
// See if we've already cached a document with this
10097
// mapKey from the other channel.
101-
theirDoc, exists := theirMap.Load(mapKey)
98+
theirDoc, exists := theirMap[mapKey]
10299

103100
// If there is no such cached document, then cache the newly-received
104101
// document in our map then proceed to the next document.
105102
//
106103
// (We'll remove the cache entry when/if the other channel yields a
107104
// document with the same mapKey.)
108105
if !exists {
109-
ourMap.Store(mapKey, doc)
106+
ourMap[mapKey] = doc
110107
return nil
111108
}
112109

113110
// We have two documents! First we remove the cache entry. This saves
114111
// memory, but more importantly, it lets us know, once we exhaust the
115112
// channels, which documents were missing on one side or the other.
116-
theirMap.Delete(mapKey)
113+
delete(theirMap, mapKey)
117114

118115
// Now we determine which document came from whom.
119116
var srcDoc, dstDoc bson.Raw
@@ -230,9 +227,9 @@ func (verifier *Verifier) compareDocsFromChannels(
230227
// missing on the other side. We add results for those.
231228

232229
// We might as well pre-grow the slice:
233-
results = slices.Grow(results, srcCache.Len()+dstCache.Len())
230+
results = slices.Grow(results, len(srcCache)+len(dstCache))
234231

235-
srcCache.Range(func(_ string, doc bson.Raw) bool {
232+
for _, doc := range srcCache {
236233
results = append(
237234
results,
238235
VerificationResult{
@@ -243,11 +240,9 @@ func (verifier *Verifier) compareDocsFromChannels(
243240
dataSize: len(doc),
244241
},
245242
)
243+
}
246244

247-
return true
248-
})
249-
250-
dstCache.Range(func(_ string, doc bson.Raw) bool {
245+
for _, doc := range dstCache {
251246
results = append(
252247
results,
253248
VerificationResult{
@@ -258,9 +253,7 @@ func (verifier *Verifier) compareDocsFromChannels(
258253
dataSize: len(doc),
259254
},
260255
)
261-
262-
return true
263-
})
256+
}
264257

265258
return results, docCount, byteCount, nil
266259
}

syncmap/syncmap.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

syncmap/syncmap_test.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)