Comments (8)
Actually what you probably need is a NavigableIndex on price (i.e. not a HashIndex), and to request CQEngine to use the "index" ordering strategy. Take a look at: OrderingStrategies.md
If you need more help with this, feel free to open a new issue and we can continue discussing there. Hope that helps for now!
from cqengine.
Original comment by [email protected]
on 28 Aug 2013 at 4:57
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from cqengine.
Pagination would be a common requirement for large collection. In addition to
sequential paging as shown in the example, arbitrary start positions should be
supported: Pagination(results, 20, 20) [ start at position 20 (1 based) and
return 20 records).
Guava's Iterable and FluentIterable interfaces support such pagination and
could be used to wrap a ResultSet.
Original comment by [email protected]
on 22 Jan 2015 at 9:51
from cqengine.
Closing this issue as this problem is best solved by combining other libraries with CQEngine.
CQEngine's ResultSet implements the java.lang.Iterable interface, therefore results can be limited or paginated as follows:
- Guava's Iterables.limit()
- Convert the CQEngine ResultSet into a Java 8 Stream and call Stream.limit()
- Consider using a variety of open source pagination libraries.
from cqengine.
Please open this issue. Here is the reasoning:
Records: 100k
SQL:
SELECT * FROM Cars ORDER BY price LIMIT 10
cqengine will sort and return all 100k records (2+ seconds), and then other libraries should paginate.
If SQL parser considers LIMIT keyword and finds defined index (HashIndex on price), it would be natural to optimize response to top 10 results by HashIndex.
As a result, query will be in a ms instead of sec.
from cqengine.
Create a limitBy option, add it to the queryOptions. Create your own version of MaterializedOrderedResultSet that only sorts the top n of the resultSet and just appends the rest to the bottom of the data structure. Upon iterator(), read that limit and sort accordingly. This way you'll have a "list" of resultset.size where the top n are sorted (given that you don't care about n+1...) rather than using the treeSet to sort the entire result set. Any item that compares > to the nth item is just added to the bottom of the semi-sorted structure. You could also use a variation of the binary search to reduce the complexity of finding where to insert an item in the top n. Try it out by sloppily overriding MaterializedOrderedResultSet in your project path with hard-coded limits, if it works out for you build your own queryEngine etc
from cqengine.
great work btw @ npgall
from cqengine.
please someone give me a example how to achieve pagination
from cqengine.
Related Issues (20)
- Reenable cached hashCode
- Support for java.util.Optional
- [Question] How does CQEngine pick the appropriate index to query?
- most longest prefix value exist in the column value but it doesn't intersect with other columns values in the query that we need part of query retrieval HOT 7
- Support STRICT_REPLACEMENT in ObjectLockingIndexedCollection/ConcurrentIndexedCollection
- TransactionalIndexedCollection support for UniqueIndex is broken
- Support for attribute accessors for Java record type HOT 1
- Kryo generates InaccessibleObjectException - Make Dependencies "Java 17 compatible"
- Bug in AttributeOrdersComparator HOT 5
- Offheap cache visibility HOT 1
- Support for ANTLR 4.10.1 HOT 12
- Does it support SQL statistics queries HOT 3
- Thread blocked when using Materialized View Sort For the Longest Prefix for CSV that contain more than 11 K rows HOT 3
- Error while parsing SQL NOT LIKE query HOT 1
- Error while parsing SQL LIKE '%%%' query
- java.lang.IllegalStateException thrown in the getGenericType(Member member) method of AttributeBytecodeGenerator.java
- CQNGrammar Sources missing from master HOT 1
- What is use of sqlite-jdbc in cqengine HOT 2
- Index updated even though objectStore is not modified during IndexedCollection add HOT 2
- Does CQEngine compatible with Java 17 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cqengine.