You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/10/20 01:31:30 UTC
[4/4] git commit: fix progress counting in wide row iterator patch by
Piotr Koalczkowski; reviewed by jbellis for CASSANDRA-4803
fix progress counting in wide row iterator
patch by Piotr Koalczkowski; reviewed by jbellis for CASSANDRA-4803
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0bb3a064
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0bb3a064
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0bb3a064
Branch: refs/heads/cassandra-1.1
Commit: 0bb3a064f3dd34823145124360c049f5d29b91ad
Parents: 72dcc29
Author: Jonathan Ellis <jb...@apache.org>
Authored: Fri Oct 19 17:59:09 2012 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri Oct 19 18:00:25 2012 -0500
----------------------------------------------------------------------
.../cassandra/hadoop/ColumnFamilyRecordReader.java | 23 +++++++++++++-
1 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/0bb3a064/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
index fc90e5c..73f9786 100644
--- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
+++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
@@ -106,7 +106,9 @@ public class ColumnFamilyRecordReader extends RecordReader<ByteBuffer, SortedMap
public float getProgress()
{
- // TODO this is totally broken for wide rows
+ if (!iter.hasNext())
+ return 1.0F;
+
// the progress is likely to be reported slightly off the actual but close enough
float progress = ((float) iter.rowsRead() / totalRowCount);
return progress > 1.0F ? 1.0F : progress;
@@ -423,6 +425,7 @@ public class ColumnFamilyRecordReader extends RecordReader<ByteBuffer, SortedMap
{
private PeekingIterator<Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>>> wideColumns;
private ByteBuffer lastColumn = ByteBufferUtil.EMPTY_BYTE_BUFFER;
+ private ByteBuffer lastCountedKey = ByteBufferUtil.EMPTY_BYTE_BUFFER;
private void maybeInit()
{
@@ -476,12 +479,28 @@ public class ColumnFamilyRecordReader extends RecordReader<ByteBuffer, SortedMap
if (rows == null)
return endOfData();
- totalRead++;
Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>> next = wideColumns.next();
lastColumn = next.right.values().iterator().next().name();
+
+ maybeCountRow(next);
return next;
}
+
+ /**
+ * Increases the row counter only if we really moved to the next row.
+ * @param next just fetched row slice
+ */
+ private void maybeCountRow(Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>> next)
+ {
+ ByteBuffer currentKey = next.left;
+ if (!currentKey.equals(lastCountedKey))
+ {
+ totalRead++;
+ lastCountedKey = currentKey;
+ }
+ }
+
private class WideColumnIterator extends AbstractIterator<Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>>>
{
private final Iterator<KeySlice> rows;