HBASE-5821 Incorrect handling of null value in Coprocessor aggregation function min() (Maryann Xue)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1328030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-04-19 16:19:56 +00:00
parent ccdf0557ce
commit 4e0f6a27ab
2 changed files with 4 additions and 4 deletions

View File

@ -105,7 +105,7 @@ public class AggregationClient {
@Override @Override
public synchronized void update(byte[] region, byte[] row, R result) { public synchronized void update(byte[] region, byte[] row, R result) {
max = ci.compare(max, result) < 0 ? result : max; max = (max == null || (result != null && ci.compare(max, result) < 0)) ? result : max;
} }
} }
MaxCallBack aMaxCallBack = new MaxCallBack(); MaxCallBack aMaxCallBack = new MaxCallBack();
@ -155,7 +155,7 @@ public class AggregationClient {
@Override @Override
public synchronized void update(byte[] region, byte[] row, R result) { public synchronized void update(byte[] region, byte[] row, R result) {
min = (min == null || ci.compare(result, min) < 0) ? result : min; min = (min == null || (result != null && ci.compare(result, min) < 0)) ? result : min;
} }
} }
HTable table = new HTable(conf, tableName); HTable table = new HTable(conf, tableName);

View File

@ -72,7 +72,7 @@ public class AggregateImplementation extends BaseEndpointCoprocessor implements
hasMoreRows = scanner.next(results); hasMoreRows = scanner.next(results);
for (KeyValue kv : results) { for (KeyValue kv : results) {
temp = ci.getValue(colFamily, qualifier, kv); temp = ci.getValue(colFamily, qualifier, kv);
max = (max == null || ci.compare(temp, max) > 0) ? temp : max; max = (max == null || (temp != null && ci.compare(temp, max) > 0)) ? temp : max;
} }
results.clear(); results.clear();
} while (hasMoreRows); } while (hasMoreRows);
@ -101,7 +101,7 @@ public class AggregateImplementation extends BaseEndpointCoprocessor implements
hasMoreRows = scanner.next(results); hasMoreRows = scanner.next(results);
for (KeyValue kv : results) { for (KeyValue kv : results) {
temp = ci.getValue(colFamily, qualifier, kv); temp = ci.getValue(colFamily, qualifier, kv);
min = (min == null || ci.compare(temp, min) < 0) ? temp : min; min = (min == null || (temp != null && ci.compare(temp, min) < 0)) ? temp : min;
} }
results.clear(); results.clear();
} while (hasMoreRows); } while (hasMoreRows);