Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions map_it_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
* Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -651,6 +651,7 @@ func mapLoadAllWithoutReplacing(t *testing.T) {
return "test-map"
}
it.MapTesterWithConfigAndName(t, makeMapName, nil, func(t *testing.T, m *hz.Map) {
it.Must(m.Destroy(context.Background()))
putSampleKeyValues(m, 2)
it.Must(m.EvictAll(context.Background()))
it.Must(m.PutTransient(context.Background(), "k0", "new-v0"))
Expand All @@ -674,20 +675,24 @@ func mapLoadAllReplacing(t *testing.T) {
return "test-map"
}
it.MapTesterWithConfigAndName(t, makeMapName, nil, func(t *testing.T, m *hz.Map) {
keys := putSampleKeyValues(m, 10)
it.Must(m.EvictAll(context.Background()))
it.Must(m.LoadAllReplacing(context.Background()))
entrySet := it.MustValue(m.GetAll(context.Background(), keys...)).([]types.Entry)
if len(keys) != len(entrySet) {
t.Fatalf("target len: %d != %d", len(keys), len(entrySet))
}
it.Must(m.EvictAll(context.Background()))
keys = keys[:5]
it.Must(m.LoadAllReplacing(context.Background(), keys...))
entrySet = it.MustValue(m.GetAll(context.Background(), keys...)).([]types.Entry)
if len(keys) != len(entrySet) {
t.Fatalf("target len: %d != %d", len(keys), len(entrySet))
}
ctx := context.Background()
it.Must(m.Destroy(ctx))
keys := putSampleKeyValues(m, 2)
// load all keys
it.Must(m.EvictAll(ctx))
size := it.MustValue(m.Size(ctx))
assert.Equal(t, 0, size)
it.Must(m.LoadAllReplacing(ctx))
size = it.MustValue(m.Size(ctx))
assert.Equal(t, 2, size)
// load some keys
it.Must(m.EvictAll(ctx))
size = it.MustValue(m.Size(ctx))
assert.Equal(t, 0, size)
keys = keys[:1]
it.Must(m.LoadAllReplacing(ctx, keys...))
size = it.MustValue(m.Size(ctx))
assert.Equal(t, 1, size)
})
}

Expand Down
11 changes: 6 additions & 5 deletions proxy_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,12 +1392,13 @@ func (m *Map) addEntryListener(ctx context.Context, flags int32, includeValue bo
return subscriptionID, err
}

func (m *Map) loadAll(ctx context.Context, replaceExisting bool, keys ...interface{}) error {
if len(keys) == 0 {
return nil
}
func (m *Map) loadAll(ctx context.Context, replaceExisting bool, keys ...interface{}) (err error) {
if m.hasNearCache {
return m.ncm.LoadAll(ctx, m, replaceExisting, keys)
defer func() {
if err == nil {
err = m.ncm.Clear(ctx, m)
}
}()
}
return m.loadAllFromRemote(ctx, replaceExisting, keys)
}
Expand Down
Loading