Java Collection Framework のメモリー内コレクションまたは複合 Java オブジェクトを照会するために、IBM pureQuery に代わるオープンソースの代替手段はありますか?
2 に答える
私のコメントで述べたように、あなたの質問を理解しているかどうかは完全にはわかりません.特にJava Collections Frameworkを含む、メモリ内コレクションで機能するOSSの代替案が必要です。
でも、がんばってみます…
永続層クエリ言語/フレームワーク
パーシスタンス レイヤーとのクエリベースの相互作用のためのオープン ソース ソフトウェアを探している場合、明白な解決策は非常に単純です。
- Java Persistence Query Language、
- Hibernate クエリ言語 (HQL ) 、
- Java データ オブジェクト( JDO) クエリ言語 (JDOQL)。
これらはインメモリ データベース (H2 や HSQLDb など) でも使用できることに注意してください。
コレクション クエリ言語/フレームワーク
ただし、コレクションをクエリする場合は、次のようなプロジェクトがいくつかあります。
Java Query Language (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);Java 用のスタックベースのクエリ言語 (sqbl4j)言語拡張:
List<Product> products = getProductList(); List<Product> expensiveInStockProducts = #{ products where unitsInStock > 0 and unitPrice > 3.00 };-
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 (); jxpath、XPath 式を使用した別のアプローチ:
Address address = (Address)JXPathContext .newContext(vendor) .getValue("locations[address/zipCode='90210']/address");filterJava の関数型プログラミング ライブラリは、基本的な関数構造、map、などにアクセスできるという点で、同様の機能を提供します。たとえば、次のようになりますcollect。transform-
Set<String> strings = buildSetStrings(); Collection<String> filteredStrings = Collections2.filter(strings, Predicates.containsPattern("^J")); -
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); ラムダJ :
// 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());
-
それとも、pureQuery を使用したメモリ内コレクションのクエリに関するこのチュートリアルを探していたのでしょうか?
また、インデックス作成とクエリをサポートする CQEngine: CQEngine。
背景の詳細については、同様の質問を参照してください: Java (基準/SQL のような) でオブジェクト コレクションを照会するにはどうすればよいですか?