Comments (5)
Also should consider adding support for literal yes() and no() queries.
Original comment by [email protected]
on 16 Jan 2014 at 4:03
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from cqengine.
I'll keep this issue open as it's still under consideration (although I'm not
sure how it could be implemented yet).
However just to add - the all() and none() queries can be used in a similar way
as the yes() and no() queries proposed above.
Original comment by [email protected]
on 20 Apr 2015 at 8:36
from cqengine.
Hi. I just ran into this while creating queries dynamically. (By parsing JSON-formatted MongoDB queries, by the way. It was surprisingly painless.) This restriction was easy to work around, but I thought I'd mention that the code is actually inconsistent with itself. There are versions of the and() and or() methods (for Java 6 compatibility) in the QueryFactory class that take a single Query argument. My vote would be to remove the restriction on the number of required subqueries, but otherwise I suppose that those single-argument methods ought to be removed.
from cqengine.
I've been thinking about this, and I agree. I will try to resolve this for the next release.
from cqengine.
I've decided to take the second option from earlier, which is to remove the QueryFactory methods which accept one parameter for and() or or() queries. These methods can safely be removed, because their previous behaviour was simply to throw an IllegalStateException.
Supporting single-parameter and() or or() queries would introduce too much complexity into the query engine, because and() and or() queries are evaluated recursively, unlike the child queries which they wrap. Supporting this might also introduce unnecessary complexity into indexes.
Applications which really do need single-parameter and() and or() queries, can easily work around this by defining their own single-parameter implementations of and() or or() as follows, and adding static imports wherever they are needed:
public static <O> Query<O> and(Query<O> query) {
return query;
}
public static <O> Query<O> or(Query<O> query) {
return query;
}
I did consider adding the workaround methods above into QueryFactory. However I'm pretty sure that if I did that, the next thing to occur would be people asking to allow zero-parameter and() and or() queries too.
There is a precedent for zero-parameter logical queries already: QueryFactory.in() does allows zero parameters. However a difference between in() queries, and and()/or() queries, is that it makes logical sense that a zero-parameter in() query should match no objects in the collection. Whereas it's not clear if a zero-parameter and() or or() query should match every object in the collection, or no objects in the collection. There is ambiguity there. Different people might expect different behaviour.
So to keep things simple (which in turn makes it easier to optimize performance internally too), I'd like to keep a general rule that and() and or() queries must have at least two child parameters. It's very easy for applications to work around these restrictions if they need to.
from cqengine.
Related Issues (20)
- 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
- Issues with Offheap Concurrent Index collection clear()
- Getting below error on jdk17.0.8.8.1 HOT 1
- Is CQEngine officially dead? HOT 6
- com/googlecode/concurrenttrees/radix/node/NodeFactory
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.