Hazelcast: MapLoader documentation gives empty implementation to loadAllKeys

957 views Asked by At

I am implementing hazelcast MapLoader and it works fine for loadAll and load methods.
But, in documentation they have giver person example and it just returns null in loadAllKeys method.

public Set<Long> loadAllKeys() { return null; }

Is this implementation correct or do I need to write any logic here to load keys from database.

2

There are 2 answers

2
noctarius On

If you return null you enable completely lazy loading. Every key will then be passed right down to the database to look up key and value at once.

0
Andres On

Yes, it is a correct implementation.

From the Hazelcast documentation 3.4 section "Initialization On Startup":

You can use the MapLoader.loadAllKeys API to pre-populate the in-memory map when the map is first touched/used. If MapLoader.loadAllKeys returns NULL then nothing will be loaded. Your MapLoader.loadAllKeys implementation can return all or some of the keys. For example, you may select and return only the hot keys. MapLoader.loadAllKeys is the fastest way of pre-populating the map since Hazelcast will optimize the loading process by having each node loading its owned portion of the entries.