Giriş
İmzası şöyle
void addIndex(IndexConfig indexConfig); default void addIndex(IndexType type, String... attributes) { IndexConfig config = IndexUtils.createIndexConfig(type, attributes); addIndex(config); }
Örnek - Tek Index
Şöyle yaparız
IMap<String, Person> map = hzClient.getMap("map"); mapWithIndex.addIndex(new IndexConfig(IndexType.HASH, "name"));
Örnek - Key İçin Index
Şöyle yaparız
val userOrderConfig = MapConfig(Caches.USER_ORDERS)
userOrderConfig.apply {
this.evictionConfig = EvictionConfig().setEvictionPolicy(EvictionPolicy.LRU).apply {
this.maxSizePolicy =MaxSizePolicy.PER_NODE
this.size = 10000
}
this.timeToLiveSeconds = (30*60)
}
userOrderConfig.addIndexConfig(IndexConfig(IndexType.SORTED, "__key"))
hzInstance.config.addMapConfig(userOrderConfig)
Örnek - İki Index
Şöyle yaparız
import com.hazelcast.query.Predicates; IMap<String, Employee> map = instance.getMap("employees"); map.addIndex(IndexType.SORTED, "age"); map.addIndex(IndexType.HASH, "active"); Set<Map.Entry<String, Employee>> entries = map .entrySet(Predicates.sql("active=true and age>44"));
Hiç yorum yok:
Yorum Gönder