Thanks dan.klco for sharing this.
When ResourceStream traverse resource or resource tree , is it using kind of index? I am just wondering if it is not using index while search then query should be costly as compare to JCR queries.
But it would be definitly nice, if you could give it some hints if you expect that this is a small subtree and you expect a lot of results, or if you rather have a large subtree with a unknown (possible zero) number of results in the stream.
At least there is the nodeCounter Mbean  which could be queried to get a rough estimation of the number of nodes in a certain subtree. Maybe just based on that you could say "with more than 10'000 nodes let's try a query instead of a traversal". Then you could construct a query and see if it's backed by an index (,). And if you also pass this you could do the query, which is then probably much faster than a traversal. Yes, you need at least OAK 1.6 (AEM 6.3) to have the chance to detect the existence of an index.
That's something which came to mind when I read about this. Because that's a huge bonus over rolling your own traversal.
 select * from [nt:unstructured] as n where n.someProperty = "value" option (traversal fail)
Yes, once you have a stream of resources you could perform a forEach action upon those resources. In this case you would probably commit your changes once complete rather than passing in the resolver and committing after every update.