PIG-5355: Negative progress report by HBaseTableRecordReader (satishsaley via knoguchi)
git-svn-id: https://svn.apache.org/repos/asf/pig/trunk@1842134 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 61f62b8..16d4553 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -78,6 +78,8 @@
BUG FIXES
+PIG-5355: Negative progress report by HBaseTableRecordReader (satishsaley via knoguchi)
+
PIG-5341: PigStorage with -tagFile/-tagPath produces incorrect results with column pruning (knoguchi)
PIG-5335: Error message from range projection completely misleading (knoguchi)
diff --git a/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigRecordReader.java b/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigRecordReader.java
index d27bdc4..02174e4 100644
--- a/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigRecordReader.java
+++ b/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigRecordReader.java
@@ -162,7 +162,7 @@
// idx is always one past the current subsplit's true index.
subprogress = (long)(curReader.getProgress() * pigSplit.getLength(idx - 1));
}
- return Math.min(1.0f, (progress + subprogress)/(float)(pigSplit.getLength()));
+ return Math.max(0.0f, Math.min(1.0f, (progress + subprogress)/(float)(pigSplit.getLength())));
}
@Override
diff --git a/src/org/apache/pig/backend/hadoop/hbase/HBaseTableInputFormat.java b/src/org/apache/pig/backend/hadoop/hbase/HBaseTableInputFormat.java
index afbd823..e14d7fa 100644
--- a/src/org/apache/pig/backend/hadoop/hbase/HBaseTableInputFormat.java
+++ b/src/org/apache/pig/backend/hadoop/hbase/HBaseTableInputFormat.java
@@ -118,7 +118,7 @@
private byte[] startRow_;
private byte[] endRow_;
private transient byte[] currRow_;
-
+ private int maxRowLength;
private BigInteger bigStart_;
private BigInteger bigEnd_;
private BigDecimal bigRange_;
@@ -151,6 +151,7 @@
bigStart_ = new BigInteger(Bytes.add(prependHeader, startPadded));
bigEnd_ = new BigInteger(Bytes.add(prependHeader, endPadded));
bigRange_ = new BigDecimal(bigEnd_.subtract(bigStart_));
+ maxRowLength = endRow_.length > startRow_.length ? endRow_.length : startRow_.length;
LOG.info("setScan with ranges: " + bigStart_ + " - " + bigEnd_ + " ( " + bigRange_ + ")");
}
@@ -173,11 +174,8 @@
return 0;
}
byte[] lastPadded = currRow_;
- if (currRow_.length < endRow_.length) {
- lastPadded = Bytes.padTail(currRow_, endRow_.length - currRow_.length);
- }
- if (currRow_.length < startRow_.length) {
- lastPadded = Bytes.padTail(currRow_, startRow_.length - currRow_.length);
+ if(maxRowLength > currRow_.length) {
+ lastPadded = Bytes.padTail(currRow_, maxRowLength - currRow_.length);
}
byte [] prependHeader = {1, 0};
BigInteger bigLastRow = new BigInteger(Bytes.add(prependHeader, lastPadded));