They can be reused, if they haven't been closed (they are AutoCloseable and should be closed when you're done with them). I wouldn't recommend it, though. While most of the work is done in the scanner's iterator() method, the close() method on the scanner API implicitly associates the scanner's resources with the entire scanner, and not just its iterator. This can be hard to reason about if you're trying to predict performance impact. It's probably better to think of each instance of scanner having one set of resources for one iterator/query. The behavior could also change between versions. (For example, regular, non-batch, scanners currently don't do anything in their close() method, but that is expected to change in future to help clean up unused server-side resources when a scan is finished).
In short: yes, they can be reused (if not closed), but I wouldn't do it; you'll probably not see much benefit, and there may be unintended consequences. On Mon, Jan 14, 2019 at 2:05 PM gtotsline <[email protected]> wrote: > > Hi - > > Can Scanners / Batch Scanners be reused? Is there any downside to reusing a > scanner (e.g. poorer performance)? I assume creating a scanner takes time, > so asking this question to see if I can avoid needlessly recreating a > BatchScanner every time I do a query. > > Thanks! > > > > -- > Sent from: http://apache-accumulo.1065345.n5.nabble.com/Developers-f3.html
