I'd like to be able to execute a count query on the data store rather than transfer a large collection over the network in order to do so in memory on the Java side. I've traced through the code a bit but am feeling a bit lost. I can see the COUNT is being recognized by the QUERY parser, but it's not clear when I would need to insert this.
My immediate thought is to introduce this into JPQLQuery's performExecute method. Here I could call getCompilation() to find the array of exprResults, look for COUNT and then use db.collection.count(selector) to get the count...but, I'm not quite sure.
I'm happy to take a crack at implementing this if you can point me in the right direction.