Quantcast
Channel: Hortonworks » All Topics
Viewing all articles
Browse latest Browse all 5121

HBase InternalScanner scan seems to be stuck in endless loop

$
0
0

Replies: 0

I am trying to implement an endpoint coprocessor.
This current attempt simply tries to do a full scan on a region and stop when it reaches the last record in the region.
The problem is the internal scanner seems to be in endless loop, as if the scanner.next() always returns true.
I placed a test for “nScannedRecs”, so when it reaches a certain limit, the loop stops.
No matter how large I make that limit, the scanner keeps going.
I know for sure I don’t have more than 200million records in the table.
But even if I make the limit something like 999999999999, the scanner reaches that limit.
Any ideas?
Thanks, Julius

package com.wacme.extensions.coprocessor;

import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.coprocessor.*;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.regionserver.*;
import java.util.*;

public class ColocatedJoinEndpoint extends BaseEndpointCoprocessor implements
ColocatedJoinProtocol {

@Override
public String doWork(String param1) {

RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment)getEnvironment();

final byte[] startKey = ” “.getBytes();
final byte[] endKey = “zzzzzzzzzzzzzzzzzzzzz”.getBytes();

long nScannedRecs=0;
String keysListStr=”";

try {
Scan scan = new Scan(startKey);
scan.addColumn(“cf”.getBytes(), “d”.getBytes() );
scan.setMaxVersions(1);
InternalScanner scanner = env.getRegion().getScanner(scan);
long sum = 0;

List results = new ArrayList();
boolean hasMore = false;

do {
results.clear();
hasMore = scanner.next(results);
sum += results.size();
nScannedRecs += sum;
if (results.size()==0) break;

if (nScannedRecs > 999999999999l) break;
} while (hasMore);
scanner.close();
}
catch (Exception e) {
System.err.println(“Exception: ” + e.getMessage());
}

String regName = new String(env.getRegion().getRegionName());
return “(v4)Server doWork result: received: ” + param1 + ” returning: ” + regName + ” #recs scanned: ” + nScannedRecs + ” key list: ” + keysListStr;
}

}


Viewing all articles
Browse latest Browse all 5121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>