K - public class GenericMapLoader<K> extends Object implements MapLoader<K,GenericRecord>, MapLoaderLifecycleSupport
MapLoader built
 on top of Hazelcast SQL engine.
 It works with any SQL connector supporting SELECT statements.
Usage:
 First define data link, e.g. for JDBC use JdbcDataLink:
 
 Config config = new Config();
 config.addDataLinkConfig(
   new DataLinkConfig("mysql-ref")
     .setClassName(JdbcDataLink.class.getName())
     .setProperty("jdbcUrl", dbConnectionUrl)
 );
 Then create a Map with MapLoader using the GenericMapLoader implementation:
 
 MapConfig mapConfig = new MapConfig(mapName);
 MapStoreConfig mapStoreConfig = new MapStoreConfig();
 mapStoreConfig.setClassName(GenericMapLoader.class.getName());
 mapStoreConfig.setProperty(JdbcSqlConnector.OPTION_DATA_LINK_REF, "mysql-ref");
 mapConfig.setMapStoreConfig(mapStoreConfig);
 instance().getConfig().addMapConfig(mapConfig);The GenericMapLoader creates a SQL mapping with name "__map-store." + mapName. This mapping is removed when the map is destroyed.
| Modifier and Type | Field and Description | 
|---|---|
| protected List<SqlColumnMetadata> | columnMetadataList | 
| protected com.hazelcast.mapstore.GenericMapStoreProperties | genericMapStoreProperties | 
| static HazelcastProperty | MAPSTORE_INIT_TIMEOUTTimeout for initialization of GenericMapLoader | 
| protected com.hazelcast.mapstore.Queries | queries | 
| protected SqlService | sqlService | 
| Constructor and Description | 
|---|
| GenericMapLoader() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | awaitSuccessfulInit()Awaits successful initialization; if the initialization fails, throws an exception. | 
| void | destroy()Hazelcast will call this method before shutting down. | 
| void | init(HazelcastInstance instance,
    Properties properties,
    String mapName)Initializes this MapLoader implementation. | 
| GenericRecord | load(K key)Loads the value of a given key. | 
| Map<K,GenericRecord> | loadAll(Collection<K> keys)Size of the  keyscollection is limited byClusterProperty.MAP_LOAD_CHUNK_SIZE | 
| Iterable<K> | loadAllKeys()Loads all of the keys from the store. | 
public static final HazelcastProperty MAPSTORE_INIT_TIMEOUT
protected SqlService sqlService
protected com.hazelcast.mapstore.GenericMapStoreProperties genericMapStoreProperties
protected com.hazelcast.mapstore.Queries queries
protected List<SqlColumnMetadata> columnMetadataList
public void init(HazelcastInstance instance, Properties properties, String mapName)
MapLoaderLifecycleSupportMapLoader is configured, can be obtained from the
 hazelcastInstance in this method's implementation.
 
 On members joining a cluster, this method is executed during finalization
 of the join operation, therefore care should be taken to adhere to the
 rules for PostJoinAwareService.getPostJoinOperation().
 If the implementation executes operations which may wait on locks or otherwise
 block (e.g. waiting for network operations), this may result in a time-out and
 obstruct the new member from joining the cluster. If blocking operations are
 required for initialization of the MapLoader, consider deferring them
 with a lazy initialization scheme.
 
init in interface MapLoaderLifecycleSupportinstance - HazelcastInstance of this mapLoader.properties - Properties set for this mapStore. see MapStoreConfigmapName - name of the map.public void destroy()
MapLoaderLifecycleSupportdestroy in interface MapLoaderLifecycleSupportpublic GenericRecord load(K key)
MapLoaderload in interface MapLoader<K,GenericRecord>null value signals value missing in the underlying storepublic Map<K,GenericRecord> loadAll(Collection<K> keys)
keys collection is limited by ClusterProperty.MAP_LOAD_CHUNK_SIZEloadAll in interface MapLoader<K,GenericRecord>keys - keys of the values entries to loadpublic Iterable<K> loadAllKeys()
MapLoaderIterable may return the keys lazily
 by loading them in batches. The Iterator of this Iterable may implement the
 Closeable interface in which case it will be closed once iteration is over.
 This is intended for releasing resources such as closing a JDBC result set.
 
 The returned Iterable should not contain any null keys.
loadAllKeys in interface MapLoader<K,GenericRecord>null.protected void awaitSuccessfulInit()
Copyright © 2023 Hazelcast, Inc.. All rights reserved.