Which release are you using ? If you put the code below in non-endpoint class, would you have the same result ?
Cheers On Sat, Jul 20, 2013 at 3:27 PM, Julius <[email protected]> wrote: > I'm trying to implement an endpoint coprocessor that among other things, > does a scan on region rows. > > I understand an internalscanner should scan only the rows within its > region, > and that's what I want. > > However, the scanner seems to stay in a perpetual loop (the "do/while" > below), even though I tried to set start/end keys, max number of versions, > etc. > > If I just leave it running, it never returns. > I noticed that when I wrote trace messages to a file, saving just the keys > for the scanned rows, the longer I leave it running, the more duplicate > records for the same keys I get. > > Does anyone have any ideas? > > Thanks, > > Julius > > > regStartKey = env.getRegion().getStartKey(); > regEndKey = env.getRegion().getEndKey(); > > Scan scan = new Scan(regStartKey,regEndKey); > scan.addColumn("cf".getBytes(), "d".getBytes() ); > scan.setMaxVersions(1); > scan.setBatch(10000); > scan.setCaching(10000); > scan.setStartRow(regStartKey); > scan.setStopRow(regEndKey); > > InternalScanner scanner = env.getRegion().getScanner(scan); > > List<KeyValue> results = new ArrayList<KeyValue>(); > > results.clear(); > scanner.next(results); > KeyValue[] resultArray = {}; > > boolean hasMore = false; > > do { > results.clear(); > hasMore = scanner.next(results,1); > if (results.size()==0) break; > > resultArray = results.toArray(resultArray); > KeyValue kv = resultArray[0]; > byte[] thisKey = kv.getRow(); > bw.write( new String(thisKey) + "\n"); > nScannedRecs++; > > } while (hasMore); > scanner.close(); > > >
