1

我是 Ignıte 的初学者。我正在做一个示例应用程序来测量它的查询时间。

所以缓存中的key是String,value是Map。值映射中的字段之一是“order_item_subtotal”,因此查询如下:

select * from Map where order_item_subtotal>400

示例代码是:

Ignite ignite= Ignition.ignite();
IgniteCache<String, Map<String, Object>> dummyCache= ignite.getOrCreateCache(cfg);
Map<String,Map<String, Object>> bufferMap=new HashMap<String,Map<String, Object>>();

int i=0;
for (String jsonStr : jsonStrs) {
    if(i%1000==0){
        dummyCache.putAll(bufferMap);
        bufferMap.clear();
    }
    Map data=mapper.readValue(jsonStr, Map.class);
    bufferMap.put(data.get("order_item_id").toString(), data);
    i++;
}

SqlFieldsQuery asd=new SqlFieldsQuery("select * from Map where order_item_subtotal>400");

List<List<?>> result=  dummyCache.query(asd).getAll();

但结果总是“[]”,表示为空。并且没有错误或异常。

我在这里想念什么?有任何想法吗?

PS:样本数据如下

{order_item_id=99, order_item_order_id=37, order_item_product_id=365, order_item_quantity=1, order_item_subtotal=59.9900016784668, order_item_product_price=59.9900016784668, product_id=365, product_category_id=17, product_name=Perfect Fitness Perfect Rip Deck, product_description=, product_price=59.9900016784668, product_image=http://images.acmesports.sports/Perfect+Fitness+Perfect+Rip+Deck}
4

1 回答 1

2

这是不支持的。您应该使用简单的 POJO 类而不是映射来使其工作。

请注意,Ignite 将以二进制格式存储数据,并且在运行查询时不会反序列化对象。所以你仍然不需要在服务器节点上部署类定义。有关详细信息,请参阅此页面:https ://apacheignite.readme.io/docs/binary-marshaller

于 2016-04-05T18:54:56.053 回答