You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/11/07 16:55:08 UTC

[kudu] 02/02: [cfile] not_null -> is_null

This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 5b182a356c5825f95a2956924e7143e27a0be2aa
Author: lingbin <li...@gmail.com>
AuthorDate: Thu Nov 7 14:10:20 2019 +0800

    [cfile] not_null -> is_null
    
    In a bitmap, we use `true` to represent `null`. So when we iterate
    over a bitmap, if it returns `true`, its meaning is "it is a null"
    
    In the original implementation, it was incorrectly named `not_null`
    
    Change-Id: I836ebce2eae6f8df18ec256b000fee23fd62ce3e
    Reviewed-on: http://gerrit.cloudera.org:8080/14651
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
 src/kudu/cfile/cfile_writer.cc | 20 ++++++++++----------
 src/kudu/cfile/cfile_writer.h  |  1 +
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/kudu/cfile/cfile_writer.cc b/src/kudu/cfile/cfile_writer.cc
index 32d7cc6..fce4b76 100644
--- a/src/kudu/cfile/cfile_writer.cc
+++ b/src/kudu/cfile/cfile_writer.cc
@@ -154,7 +154,7 @@ Status CFileWriter::Start() {
   if (compression_ != NO_COMPRESSION) {
     const CompressionCodec* codec;
     RETURN_NOT_OK(GetCompressionCodec(compression_, &codec));
-    block_compressor_ .reset(new CompressedBlockBuilder(codec));
+    block_compressor_.reset(new CompressedBlockBuilder(codec));
   }
 
   CFileHeaderPB header;
@@ -331,12 +331,12 @@ Status CFileWriter::AppendNullableEntries(const uint8_t *bitmap,
 
   const uint8_t *ptr = reinterpret_cast<const uint8_t *>(entries);
 
-  size_t nblock;
-  bool not_null = false;
+  size_t nitems;
+  bool is_null = false;
   BitmapIterator bmap_iter(bitmap, count);
-  while ((nblock = bmap_iter.Next(&not_null)) > 0) {
-    if (not_null) {
-      size_t rem = nblock;
+  while ((nitems = bmap_iter.Next(&is_null)) > 0) {
+    if (is_null) {
+      size_t rem = nitems;
       do {
         int n = data_block_->Add(ptr, rem);
         DCHECK_GE(n, 0);
@@ -352,9 +352,9 @@ Status CFileWriter::AppendNullableEntries(const uint8_t *bitmap,
 
       } while (rem > 0);
     } else {
-      null_bitmap_builder_->AddRun(false, nblock);
-      ptr += nblock * typeinfo_->size();
-      value_count_ += nblock;
+      null_bitmap_builder_->AddRun(false, nitems);
+      ptr += nitems * typeinfo_->size();
+      value_count_ += nitems;
     }
   }
 
@@ -373,7 +373,7 @@ Status CFileWriter::FinishCurDataBlock() {
 
   rowid_t first_elem_ord = value_count_ - num_elems_in_block;
   VLOG(1) << "Appending data block for values " <<
-    first_elem_ord << "-" << (first_elem_ord + num_elems_in_block);
+    first_elem_ord << "-" << value_count_;
 
   // The current data block is full, need to push it
   // into the file, and add to index
diff --git a/src/kudu/cfile/cfile_writer.h b/src/kudu/cfile/cfile_writer.h
index 191a073..9057138 100644
--- a/src/kudu/cfile/cfile_writer.h
+++ b/src/kudu/cfile/cfile_writer.h
@@ -78,6 +78,7 @@ class NullBitmapBuilder {
     return nitems_;
   }
 
+  // If value parameter is true, it means that all values in this run are null
   void AddRun(bool value, size_t run_length = 1) {
     nitems_ += run_length;
     rle_encoder_.Put(value, run_length);