Repository: kudu
Updated Branches:
  refs/heads/master 3ae7fe1c9 -> 9591957b8


KUDU-1904 Don't seek on empty RLE blocks

Seeking in RLE blocks enforces that the seek position is less than
the number of elements in the block. If the number of elements is 0,
as it is when the entire set of cells is NULL, this check will always
result in a crash.

This patch enforces that the block only seeks if there are elements
in the block.

Test coverage will be added in an upcoming commit.

Change-Id: I6d6bd95099c9f30aa923a0da1e76f92ed90ebd99
Reviewed-on: http://gerrit.cloudera.org:8080/6184
Reviewed-by: David Ribeiro Alves <[email protected]>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/79706b0a
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/79706b0a
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/79706b0a

Branch: refs/heads/master
Commit: 79706b0ab3e746f94519a1b49c8960c3c75fd36d
Parents: 3ae7fe1
Author: Andrew Wong <[email protected]>
Authored: Tue Feb 28 14:13:05 2017 -0800
Committer: Todd Lipcon <[email protected]>
Committed: Wed Mar 1 03:06:39 2017 +0000

----------------------------------------------------------------------
 src/kudu/cfile/rle_block.h | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/79706b0a/src/kudu/cfile/rle_block.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/rle_block.h b/src/kudu/cfile/rle_block.h
index c7702f1..c8ed76b 100644
--- a/src/kudu/cfile/rle_block.h
+++ b/src/kudu/cfile/rle_block.h
@@ -330,6 +330,10 @@ class RleIntBlockDecoder final : public BlockDecoder {
 
   virtual void SeekToPositionInBlock(uint pos) OVERRIDE {
     CHECK(parsed_) << "Must call ParseHeader()";
+    // If the block is empty (e.g. the column is filled with nulls), there is 
no data to seek.
+    if (PREDICT_FALSE(num_elems_ == 0)) {
+      return;
+    }
     CHECK_LT(pos, num_elems_)
         << "Tried to seek to " << pos << " which is >= number of elements ("
         << num_elems_ << ") in the block!.";

Reply via email to