hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: InternalScanner seems in perpetual loop
Date Sat, 20 Jul 2013 22:55:38 GMT
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 <jcplerm@ameritech.net> 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();
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message