若有須要在內存進行搜索匹配,可使用cqengine來對java的集合進行高效檢索java
<dependency> <groupId>com.googlecode.cqengine</groupId> <artifactId>cqengine</artifactId> <version>2.9.2</version> </dependency>
IndexedCollection<Demo> demos = new ConcurrentIndexedCollection<Demo>(); demos.addAll(.....);
import static com.googlecode.cqengine.query.QueryFactory.attribute; final Attribute<Demo, String> NAME = attribute("name", Demo::getName); reportItems.addIndex(SuffixTreeIndex.onAttribute(NAME));
import static com.googlecode.cqengine.query.QueryFactory.contains; Query<Demo> query = contains(NAME,key); ResultSet<Demo> resultSet = demos.retrieve(query);