gpt4 book ai didi

java - Apache 点燃: Continuous SQLFieldQuery

转载 作者:行者123 更新时间:2023-11-30 02:35:54 27 4
gpt4 key购买 nike

我希望公开 Apache Ignite 缓存,并且客户端应用程序可以访问它。我可以在 Apache Ignite 版本 1.9 中看到连续查询支持 - https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousAsyncQueryExample.java

但是我找不到任何如何实现 Continuous SQLFieldQuery 的示例。

public static void main(String[] args) throws Exception {
System.out.println("Run Spring example!!");
Ignition.setClientMode(true);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIncludeEventTypes( EVTS_CACHE);
cfg.setPeerClassLoadingEnabled(true);
TcpDiscoveryMulticastIpFinder discoveryMulticastIpFinder = new TcpDiscoveryMulticastIpFinder();
Set<String> set = new HashSet<>();

set.add("serverhost:47500..47509");
discoveryMulticastIpFinder.setAddresses(set);

TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setIpFinder(discoveryMulticastIpFinder);

cfg.setDiscoverySpi(discoverySpi);

cfg.setPeerClassLoadingEnabled(true);
cfg.setIncludeEventTypes(EVTS_CACHE);
Ignite ignite = Ignition.start(cfg);

CacheConfiguration<String, BinaryObject> cacheConfiguration = new CacheConfiguration<>(CACHE_NAME);


IgniteCache<String, BinaryObject> cache = ignite.getOrCreateCache(cacheConfiguration).withKeepBinary();


QueryCursor<List<?>> query = cache.query(new SqlFieldsQuery("select Field1 from table1 where Field1='TEST'"));
List<List<?>> all = query.getAll();
for (List<?> l : all) {
System.out.println(l);
}


}

最佳答案

连续查询仅基于谓词,这里不支持 SQL。您可以提供一个远程过滤器,服务器端的每次更新都会调用该过滤器。所有满足过滤器的更新都将被批量发送到订阅者,在订阅者中调用本地监听器。

详情请参阅此页面:https://apacheignite.readme.io/docs/continuous-queries

关于java - Apache 点燃: Continuous SQLFieldQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43072792/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com