HADOOP-1479 Fix NPE in HStore#get if store file only has keys < passed key.
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@546275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09cf0a100f
commit
3f5229c66f
|
@ -28,3 +28,4 @@ Trunk (unreleased changes)
|
||||||
15. HADOOP-1421 Failover detection, split log files.
|
15. HADOOP-1421 Failover detection, split log files.
|
||||||
For the files modified, also clean up javadoc, class, field and method
|
For the files modified, also clean up javadoc, class, field and method
|
||||||
visibility (HADOOP-1466)
|
visibility (HADOOP-1466)
|
||||||
|
16. HADOOP-1479 Fix NPE in HStore#get if store file only has keys < passed key.
|
||||||
|
|
|
@ -835,7 +835,7 @@ class HStore implements HConstants {
|
||||||
* If 'numVersions' is negative, the method returns all available versions.
|
* If 'numVersions' is negative, the method returns all available versions.
|
||||||
*/
|
*/
|
||||||
BytesWritable[] get(HStoreKey key, int numVersions) throws IOException {
|
BytesWritable[] get(HStoreKey key, int numVersions) throws IOException {
|
||||||
if(numVersions <= 0) {
|
if (numVersions <= 0) {
|
||||||
throw new IllegalArgumentException("Number of versions must be > 0");
|
throw new IllegalArgumentException("Number of versions must be > 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,15 +852,19 @@ class HStore implements HConstants {
|
||||||
BytesWritable readval = new BytesWritable();
|
BytesWritable readval = new BytesWritable();
|
||||||
map.reset();
|
map.reset();
|
||||||
HStoreKey readkey = (HStoreKey)map.getClosest(key, readval);
|
HStoreKey readkey = (HStoreKey)map.getClosest(key, readval);
|
||||||
|
if (readkey == null) {
|
||||||
if(readkey.matchesRowCol(key)) {
|
// map.getClosest returns null if the passed key is > than the
|
||||||
|
// last key in the map file. getClosest is a bit of a misnomer
|
||||||
|
// since it returns exact match or the next closest key AFTER not
|
||||||
|
// BEFORE.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (readkey.matchesRowCol(key)) {
|
||||||
results.add(readval);
|
results.add(readval);
|
||||||
readval = new BytesWritable();
|
readval = new BytesWritable();
|
||||||
|
|
||||||
while(map.next(readkey, readval) && readkey.matchesRowCol(key)) {
|
while(map.next(readkey, readval) && readkey.matchesRowCol(key)) {
|
||||||
if(numVersions > 0 && (results.size() >= numVersions)) {
|
if (numVersions > 0 && (results.size() >= numVersions)) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
results.add(readval);
|
results.add(readval);
|
||||||
readval = new BytesWritable();
|
readval = new BytesWritable();
|
||||||
|
|
Loading…
Reference in New Issue