use*_*281 2 java collections data-structures
我们是否有一些IBM pureQuery的开源替代方案来查询Java Collection Framework或复合Java对象的内存中集合?
正如我的评论中所提到的,我不完全确定我理解你的问题:我不确定你是否在询问是否存在对pureQuery的OSS替代方案以及pureQuery是否适用于Java Collection Framework的内存DS,如果你想要一个OSS替代品,它可以在内存中集合中工作,特别是Java Collections Framework.
但是,我会尝试一下......
如果您正在寻找一个用于与持久层进行查询库交互的开源软件,那么显而易见的解决方案非常简单:
请注意,这些也可以在内存数据库中使用(如H2或HSQLDb).
但是,如果要查询集合,则有一些项目,例如:
java查询语言(JQL)语言扩展:
ArrayList<String> words = dict.getWords(Puzzle.MEDIUM);
ArrayList<Integer> gaplengths = puzzle.getGapLengths();
List<Object[]> matches = selectAll(
String w : words,
Integer i : gaplengths | w.length() == i);
Run Code Online (Sandbox Code Playgroud)List<Product> products = getProductList();
List<Product> expensiveInStockProducts = #{
products
where unitsInStock > 0 and unitPrice > 3.00
};
Run Code Online (Sandbox Code Playgroud)List myObjs = getMyObjects ();
Query q = new Query ();
q.parse ("SELECT * FROM java.io.File WHERE name LIKE '%.java'");
QueryResults qr = q.execute (myObjs);
List res = qr.getResults ();
Run Code Online (Sandbox Code Playgroud)jxpath,用于XPath表达式的不同方法:
Address address = (Address)JXPathContext
.newContext(vendor)
.getValue("locations[address/zipCode='90210']/address");
Run Code Online (Sandbox Code Playgroud)对Java函数式编程库提供了类似的功能,因为它们给你访问基本的功能结构filter,map,collect,transform等...例如,对于:
Set<String> strings = buildSetStrings();
Collection<String> filteredStrings =
Collections2.filter(strings, Predicates.containsPattern("^J"));
Run Code Online (Sandbox Code Playgroud)Array<Integer> a = array(97, 44, 67, 3, 22, 90, 1, 77, 98, 1078, 6, 64, 6, 79, 42);
final Array<Integer> b = a.filter(even);
Run Code Online (Sandbox Code Playgroud)// with normal interfaces:
List<Person> buyersSortedByAges = sort(
extract(
select(sales, having(on(Sale.class).getValue(), greaterThan(50000)))
), on(Sale.class).getBuyer()
), on(Person.class).getAge());
// with fluent/chainable intefaces:
List<Person> buyersSortedByAges = with(sales)
.retain(having(on(Sale.class).getValue(), greaterThan(50000)))
.extract(on(Sale.class).getBuyer())
.sort(on(Person.class).getAge());
Run Code Online (Sandbox Code Playgroud)或者您可能只是在寻找使用pureQuery查询内存中集合的本教程?
| 归档时间: |
|
| 查看次数: |
2067 次 |
| 最近记录: |