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

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


The following commit(s) were added to refs/heads/master by this push:
     new d46546d56 [cfile] make WriterOptions* a constant member field
d46546d56 is described below

commit d46546d5631bca30520160716504ca521bf47631
Author: Alexey Serbin <[email protected]>
AuthorDate: Thu Aug 1 16:17:54 2024 -0700

    [cfile] make WriterOptions* a constant member field
    
    Since I'm preparing a series of patches to update files under
    src/kudu/cfile, this patch does a minor cleanup on the files,
    reflecting on the fact the WriteOptions* pointer field isn't
    changing in all of the affected classes, and the kMaxHeaderSize
    constant isn't used.
    
    This patch doesn't contain any functional modifications.
    
    Change-Id: I9a209194a15d9d49bbd42949223651b0fd17c7c0
    Reviewed-on: http://gerrit.cloudera.org:8080/21631
    Reviewed-by: Mahesh Reddy <[email protected]>
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Abhishek Chennaka <[email protected]>
---
 src/kudu/cfile/binary_dict_block.h    |  5 ++---
 src/kudu/cfile/binary_plain_block.cc  |  6 +++---
 src/kudu/cfile/binary_plain_block.h   |  5 ++---
 src/kudu/cfile/binary_prefix_block.cc |  6 +++---
 src/kudu/cfile/binary_prefix_block.h  | 10 +++-------
 src/kudu/cfile/index_btree.h          |  2 +-
 src/kudu/cfile/plain_bitmap_block.h   | 14 +++++---------
 src/kudu/cfile/plain_block.h          | 11 ++++-------
 src/kudu/cfile/rle_block.h            | 19 +++++++------------
 9 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/src/kudu/cfile/binary_dict_block.h 
b/src/kudu/cfile/binary_dict_block.h
index ef907ed34..80825ca3c 100644
--- a/src/kudu/cfile/binary_dict_block.h
+++ b/src/kudu/cfile/binary_dict_block.h
@@ -98,18 +98,17 @@ class BinaryDictBlockBuilder final : public BlockBuilder {
 
   Status GetLastKey(void* key) const override;
 
-  static const size_t kMaxHeaderSize = sizeof(uint32_t) * 1;
-
  private:
   int AddCodeWords(const uint8_t* vals, size_t count);
 
   ATTRIBUTE_COLD
   bool AddToDict(Slice val, uint32_t* codeword);
 
+  const WriterOptions* const options_;
+
   // Buffer used in Finish() for holding the encoded header.
   faststring header_buffer_;
   bool finished_;
-  const WriterOptions* options_;
 
   std::unique_ptr<BlockBuilder> data_builder_;
 
diff --git a/src/kudu/cfile/binary_plain_block.cc 
b/src/kudu/cfile/binary_plain_block.cc
index 2bd2670c9..bd1597d24 100644
--- a/src/kudu/cfile/binary_plain_block.cc
+++ b/src/kudu/cfile/binary_plain_block.cc
@@ -49,9 +49,9 @@ namespace kudu {
 namespace cfile {
 
 BinaryPlainBlockBuilder::BinaryPlainBlockBuilder(const WriterOptions *options)
-  : end_of_data_offset_(0),
-    size_estimate_(0),
-    options_(options) {
+  : options_(options),
+    end_of_data_offset_(0),
+    size_estimate_(0) {
   Reset();
 }
 BinaryPlainBlockBuilder::~BinaryPlainBlockBuilder() = default;
diff --git a/src/kudu/cfile/binary_plain_block.h 
b/src/kudu/cfile/binary_plain_block.h
index ab029890a..a65abae70 100644
--- a/src/kudu/cfile/binary_plain_block.h
+++ b/src/kudu/cfile/binary_plain_block.h
@@ -87,6 +87,8 @@ class BinaryPlainBlockBuilder final : public BlockBuilder {
   static constexpr size_t kHeaderSize = sizeof(uint32_t) * 3;
 
  private:
+  const WriterOptions* const options_;
+
   faststring buffer_;
 
   size_t end_of_data_offset_;
@@ -96,9 +98,6 @@ class BinaryPlainBlockBuilder final : public BlockBuilder {
   std::vector<uint32_t> offsets_;
 
   bool finished_;
-
-  const WriterOptions *options_;
-
 };
 
 class BinaryPlainBlockDecoder final : public BlockDecoder {
diff --git a/src/kudu/cfile/binary_prefix_block.cc 
b/src/kudu/cfile/binary_prefix_block.cc
index c79ed07db..9f2f85bec 100644
--- a/src/kudu/cfile/binary_prefix_block.cc
+++ b/src/kudu/cfile/binary_prefix_block.cc
@@ -74,10 +74,10 @@ static const uint8_t *DecodeEntryLengths(
 ////////////////////////////////////////////////////////////
 
 BinaryPrefixBlockBuilder::BinaryPrefixBlockBuilder(const WriterOptions 
*options)
-  : val_count_(0),
+  : options_(options),
+    val_count_(0),
     vals_since_restart_(0),
-    finished_(false),
-    options_(options) {
+    finished_(false) {
   Reset();
 }
 
diff --git a/src/kudu/cfile/binary_prefix_block.h 
b/src/kudu/cfile/binary_prefix_block.h
index bc411d459..ea47fde7a 100644
--- a/src/kudu/cfile/binary_prefix_block.h
+++ b/src/kudu/cfile/binary_prefix_block.h
@@ -14,8 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-#ifndef KUDU_CFILE_BINARY_PREFIX_BLOCK_H
-#define KUDU_CFILE_BINARY_PREFIX_BLOCK_H
+#pragma once
 
 #include <sys/types.h>
 
@@ -28,7 +27,6 @@
 #include "kudu/cfile/block_encodings.h"
 #include "kudu/cfile/block_handle.h"
 #include "kudu/common/rowid.h"
-#include "kudu/gutil/port.h"
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/util/faststring.h"
 #include "kudu/util/slice.h"
@@ -68,6 +66,8 @@ class BinaryPrefixBlockBuilder final : public BlockBuilder {
   Status GetLastKey(void *key) const override;
 
  private:
+  const WriterOptions* const options_;
+
   faststring header_buf_;
   faststring buffer_;
   faststring last_val_;
@@ -78,8 +78,6 @@ class BinaryPrefixBlockBuilder final : public BlockBuilder {
   int val_count_;
   int vals_since_restart_;
   bool finished_;
-
-  const WriterOptions *options_;
 };
 
 // Decoder for BINARY type, PREFIX encoding
@@ -162,5 +160,3 @@ class BinaryPrefixBlockDecoder final : public BlockDecoder {
 
 } // namespace cfile
 } // namespace kudu
-
-#endif // KUDU_CFILE_BINARY_PREFIX_BLOCK_H
diff --git a/src/kudu/cfile/index_btree.h b/src/kudu/cfile/index_btree.h
index 53340639e..0f5c8630c 100644
--- a/src/kudu/cfile/index_btree.h
+++ b/src/kudu/cfile/index_btree.h
@@ -65,7 +65,7 @@ class IndexTreeBuilder {
   // in 'written'.
   Status FinishAndWriteBlock(size_t level, BlockPointer* written);
 
-  const WriterOptions* options_;
+  const WriterOptions* const options_;
   CFileWriter* writer_;
 
   std::vector<std::unique_ptr<IndexBlockBuilder>> idx_blocks_;
diff --git a/src/kudu/cfile/plain_bitmap_block.h 
b/src/kudu/cfile/plain_bitmap_block.h
index 384a435a9..e272769db 100644
--- a/src/kudu/cfile/plain_bitmap_block.h
+++ b/src/kudu/cfile/plain_bitmap_block.h
@@ -14,9 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
-#ifndef KUDU_CFILE_PLAIN_BITMAP_BLOCK_H_
-#define KUDU_CFILE_PLAIN_BITMAP_BLOCK_H_
+#pragma once
 
 #include <algorithm>
 #include <string>
@@ -46,8 +44,8 @@ struct WriterOptions;
 class PlainBitMapBlockBuilder final : public BlockBuilder {
  public:
   explicit PlainBitMapBlockBuilder(const WriterOptions* options)
-      : writer_(&buf_),
-        options_(options) {
+      : options_(options),
+        writer_(&buf_) {
     Reset();
   }
 
@@ -97,11 +95,11 @@ class PlainBitMapBlockBuilder final : public BlockBuilder {
   }
 
  private:
+  const WriterOptions* const options_;
+
   faststring buf_;
   BitWriter writer_;
   size_t count_;
-
-  const WriterOptions* const options_;
 };
 
 
@@ -220,5 +218,3 @@ class PlainBitMapBlockDecoder final : public BlockDecoder {
 
 } // namespace cfile
 } // namespace kudu
-
-#endif
diff --git a/src/kudu/cfile/plain_block.h b/src/kudu/cfile/plain_block.h
index 4ab94864e..3b2d2b2aa 100644
--- a/src/kudu/cfile/plain_block.h
+++ b/src/kudu/cfile/plain_block.h
@@ -14,8 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-#ifndef KUDU_CFILE_PLAIN_BLOCK_H
-#define KUDU_CFILE_PLAIN_BLOCK_H
+#pragma once
 
 #include <algorithm>
 #include <string>
@@ -98,14 +97,14 @@ class PlainBlockBuilder final : public BlockBuilder {
   }
 
  private:
-  faststring buffer_;
-  const WriterOptions *options_;
-  size_t count_;
   typedef typename TypeTraits<Type>::cpp_type CppType;
   enum {
     kCppTypeSize = TypeTraits<Type>::size
   };
 
+  const WriterOptions* const options_;
+  faststring buffer_;
+  size_t count_;
 };
 
 //
@@ -244,5 +243,3 @@ class PlainBlockDecoder final : public BlockDecoder {
 
 } // namespace cfile
 } // namespace kudu
-
-#endif
diff --git a/src/kudu/cfile/rle_block.h b/src/kudu/cfile/rle_block.h
index ae5937baa..a33d9d621 100644
--- a/src/kudu/cfile/rle_block.h
+++ b/src/kudu/cfile/rle_block.h
@@ -14,9 +14,7 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-
-#ifndef KUDU_CFILE_RLE_BLOCK_H
-#define KUDU_CFILE_RLE_BLOCK_H
+#pragma once
 
 #include <algorithm>
 #include <string>
@@ -51,8 +49,8 @@ enum {
 class RleBitMapBlockBuilder final : public BlockBuilder {
  public:
   explicit RleBitMapBlockBuilder(const WriterOptions* options)
-      : encoder_(&buf_, 1),
-        options_(options) {
+      : options_(options),
+        encoder_(&buf_, 1) {
     Reset();
   }
 
@@ -100,9 +98,9 @@ class RleBitMapBlockBuilder final : public BlockBuilder {
   }
 
  private:
+  const WriterOptions* const options_;
   faststring buf_;
   RleEncoder<bool> encoder_;
-  const WriterOptions* const options_;
   size_t count_;
 };
 
@@ -227,8 +225,8 @@ template <DataType IntType>
 class RleIntBlockBuilder final : public BlockBuilder {
  public:
   explicit RleIntBlockBuilder(const WriterOptions* options)
-      : rle_encoder_(&buf_, kCppTypeSize * 8),
-        options_(options) {
+      : options_(options),
+        rle_encoder_(&buf_, kCppTypeSize * 8) {
     Reset();
   }
 
@@ -289,17 +287,16 @@ class RleIntBlockBuilder final : public BlockBuilder {
 
  private:
   typedef typename TypeTraits<IntType>::cpp_type CppType;
-
   enum {
     kCppTypeSize = TypeTraits<IntType>::size
   };
 
+  const WriterOptions* const options_;
   CppType first_key_;
   CppType last_key_;
   faststring buf_;
   size_t count_;
   RleEncoder<CppType> rle_encoder_;
-  const WriterOptions* const options_;
 };
 
 //
@@ -510,5 +507,3 @@ class RleIntBlockDecoder final : public BlockDecoder {
 
 } // namespace cfile
 } // namespace kudu
-
-#endif

Reply via email to