查询内存中集合 [英] querying in-memory collection

查看:163
本文介绍了查询内存中集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个集合,一个地图列表,地图是 Map< String,String> 。我需要通过比较,逻辑,喜欢,不在运算符中查询此集合。类似SQL的东西。

I have a collection, a List of Map, the map is Map<String, String>. I need to query this collection with comparison, logical, like, not in operators. Something like SQL.

我将从数据库存储过程填充列表,所以我不知道大小。但是,我想这个大小不应该超过10,000条记录。

I will be populating the list from a database stored procedure, so I am not sure about the size. But, I guess the size should not be more than 10,000 records.

发布这个时候,我看看Apache函子,我不知道他们会帮助这里。

While posting this I am having a look at Apache functors, I don't know if they will help here.

我想到的其他方法是使用内存数据库Derby来实现这一点。

Other way that I am thinking of is using the in-memory database Derby to achieve this.

请让我知道任何Java库或任何其他方式这样做。

Please let me know of any Java library or any other way of doing this.

列表中的地图将如下所示:

The maps in the list will be like below:

Map<String, String> m1 = new Map<String, String>();
m1.put("name","Mark");
m1.put("age","21");
m1.put("city","some city");

Map<String, String> m1 = new Map<String, String>();
m1.put("name","David");
m1.put("age","25");
m1.put("city","other city");

我需要查询列表以获取Map,其中包含:

I need to query the list to get Map which has:


  1. name = Mark

  2. name = Mark年龄> 30

  3. 城市不在其他城市

  1. name=Mark
  2. name=Mark and age > 30
  3. city not in "other city"


推荐答案

我发现 JFilter ,它可以帮助您过滤内存数据(java对象)。下面是JFilter网站的描述。

I found JFilter which helps you with filtering in-memory data (java objects ). Below is the description from JFilter website.

JFilter是一个简单和高性能的开源库,用于过滤(查询),映射(选择) Java集合。查询以json格式给出,如Mongodb查询。

JFilter is a simple and high performance open source library to filter (query), map (select) and reduce (aggregate) objects in a Java collection. Query is given in json format like Mongodb queries.

我写了一个 post ,了解如何使用 JFilter 和我使用 JFilter存储数据和查询/过滤的一般方法

I have written a post on using JFilter with Maps, which I am using as a generic way of storing data and querying/filtering using JFilter

以下是帖子的链接使用 JFilter查询/过滤内存数据

Here is the link to the post Using JFilter to query/filter in-memory data

这篇关于查询内存中集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆