Are you calling new RowIdIterator(scanner) multiple times for the same scanner?

The SortedKeyIterator is a step in the right direction because it ignores 
Values.  You could improve things further with a custom iterator that does a 
seek to the beginning of the next row whenever you call next().

Billie


On Sunday, May 20, 2012 12:48:25 PM, "David Medinets" 
<[email protected]> wrote:
> Seaching through the source for SortedKeyIterator shows that it is
> used in 15 files. The FindMax class seems to be a fine example of its
> use:
> 
> IteratorSetting cfg = new IteratorSetting(Integer.MAX_VALUE,
> SortedKeyIterator.class);
> scanner.addScanIterator(cfg);
> 
> That seems simple enough but when I change my code according I get a
> message:
> 
> Exception in thread "main" java.lang.IllegalArgumentException:
> Iterator name is already in use SKI98
> at
> org.apache.accumulo.core.client.impl.ScannerOptions.addScanIterator(ScannerOptions.java:67)
> at com.codebits.accumulo.RowIdIterator.<init>(RowIdIterator.java:22)
> 
> My code change was trivial:
> 
> Iterator<Entry<Key, Value>> iterator = null;
> 
> public RowIdIterator(Scanner scanner) {
> super();
> this.scanner = scanner;
> IteratorSetting cfg = new IteratorSetting(Integer.MAX_VALUE,
> "SKI98", SortedKeyIterator.class);
> 22 --> scanner.addScanIterator(cfg);
> this.iterator = scanner.iterator();
> }
> 
> @Override
> public String next() {
> Entry<Key, Value> entry = iterator.next();
> return entry.getKey().getRow().toString();
> }
> 
> As you can see its name is unlikely to be in use.

Reply via email to