You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by ga...@apache.org on 2024/04/02 15:34:48 UTC
(orc) branch main updated: ORC-1658: [C++] Unify identifiers naming style
This is an automated email from the ASF dual-hosted git repository.
gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new 03ce308b5 ORC-1658: [C++] Unify identifiers naming style
03ce308b5 is described below
commit 03ce308b573f78c67aa7376a34361039ac0a2916
Author: ffacs <ff...@ffacs.top>
AuthorDate: Tue Apr 2 23:34:34 2024 +0800
ORC-1658: [C++] Unify identifiers naming style
### What changes were proposed in this pull request?
1. Add run_clang_tidy.py which comes from LLVM and clang-tidy configuration file.
2. Use clang-tidy to format the C++ code.
### Why are the changes needed?
To close https://github.com/apache/orc/issues/1845
### How was this patch tested?
UT passed
### Was this patch authored or co-authored using generative AI tooling?
NO
Closes #1855 from ffacs/NamingStyle.
Lead-authored-by: ffacs <ff...@ffacs.top>
Co-authored-by: ffacs <ff...@gmail.com>
Signed-off-by: Gang Wu <us...@gmail.com>
---
.clang-tidy | 33 ++
.gitignore | 1 +
c++/include/orc/Common.hh | 12 +-
c++/include/orc/Exceptions.hh | 16 +-
c++/include/orc/Int128.hh | 134 +++----
c++/include/orc/MemoryPool.hh | 26 +-
c++/include/orc/Reader.hh | 4 +-
c++/include/orc/Writer.hh | 2 +-
c++/include/orc/sargs/Literal.hh | 22 +-
c++/src/BlockBuffer.cc | 50 +--
c++/src/BlockBuffer.hh | 18 +-
c++/src/BloomFilter.cc | 81 ++--
c++/src/BloomFilter.hh | 8 +-
c++/src/BpackingDefault.cc | 154 ++++----
c++/src/BpackingDefault.hh | 2 +-
c++/src/ByteRLE.cc | 50 +--
c++/src/ColumnPrinter.cc | 216 +++++------
c++/src/ColumnReader.cc | 403 ++++++++++----------
c++/src/ColumnWriter.cc | 523 ++++++++++++-------------
c++/src/ColumnWriter.hh | 6 +-
c++/src/Common.cc | 4 +-
c++/src/Compression.cc | 162 ++++----
c++/src/ConvertColumnReader.cc | 184 ++++-----
c++/src/CpuInfoUtil.cc | 20 +-
c++/src/Exceptions.cc | 16 +-
c++/src/Int128.cc | 50 +--
c++/src/MemoryPool.cc | 162 ++++----
c++/src/Options.hh | 124 +++---
c++/src/OrcFile.cc | 88 ++---
c++/src/RLE.hh | 2 +-
c++/src/RLEv1.cc | 118 +++---
c++/src/RLEv1.hh | 22 +-
c++/src/RLEv2.hh | 80 ++--
c++/src/Reader.cc | 621 +++++++++++++++---------------
c++/src/Reader.hh | 104 ++---
c++/src/RleDecoderV2.cc | 174 ++++-----
c++/src/RleEncoderV2.cc | 152 ++++----
c++/src/SchemaEvolution.cc | 58 +--
c++/src/SchemaEvolution.hh | 8 +-
c++/src/Statistics.cc | 208 +++++-----
c++/src/Statistics.hh | 800 +++++++++++++++++++--------------------
c++/src/StripeStream.cc | 99 ++---
c++/src/StripeStream.hh | 113 +++---
c++/src/Timezone.cc | 284 +++++++-------
c++/src/TypeImpl.cc | 156 ++++----
c++/src/TypeImpl.hh | 22 +-
c++/src/Utils.hh | 32 +-
c++/src/Vector.cc | 18 +-
c++/src/Writer.cc | 324 ++++++++--------
c++/src/io/InputStream.cc | 110 +++---
c++/src/io/InputStream.hh | 30 +-
c++/src/io/OutputStream.cc | 60 +--
c++/src/io/OutputStream.hh | 24 +-
c++/src/sargs/ExpressionTree.cc | 75 ++--
c++/src/sargs/ExpressionTree.hh | 8 +-
c++/src/sargs/Literal.cc | 268 ++++++-------
c++/src/sargs/PredicateLeaf.cc | 176 ++++-----
c++/src/sargs/PredicateLeaf.hh | 16 +-
c++/src/sargs/SargsApplier.cc | 96 ++---
c++/src/sargs/SargsApplier.hh | 44 +--
c++/src/sargs/SearchArgument.cc | 66 ++--
c++/src/sargs/SearchArgument.hh | 10 +-
c++/test/MemoryInputStream.hh | 20 +-
c++/test/MemoryOutputStream.cc | 6 +-
c++/test/MemoryOutputStream.hh | 24 +-
c++/test/TestBloomFilter.cc | 10 +-
c++/test/TestDecompression.cc | 22 +-
run_clang_tidy.py | 343 +++++++++++++++++
tools/src/FileMemory.cc | 22 +-
tools/test/TestFileScan.cc | 4 +-
tools/test/TestMatch.cc | 36 +-
tools/test/gzip.cc | 64 ++--
tools/test/gzip.hh | 16 +-
73 files changed, 3951 insertions(+), 3565 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 000000000..bd995bca5
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+Checks: "-*,
+ readability-identifier-naming,
+"
+
+CheckOptions:
+ [
+ { key: readability-identifier-naming.PrivateMemberSuffix, value: "_" },
+ { key: readability-identifier-naming.ProtectedMemberSuffix, value: "" },
+ { key: readability-identifier-naming.PublicMemberSuffix, value: "" },
+ { key: readability-identifier-naming.ParameterCase, value: "camelBack" },
+ { key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-zA-Z]$" },
+ ]
+
+WarningsAsErrors: ''
+HeaderFilterRegex: '.*'
+FormatStyle: none
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index c0a4d44e0..2ff46e969 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ dependency-reduced-pom.xml
.java-version
java/bench/data
*.swp
+.cache/*
diff --git a/c++/include/orc/Common.hh b/c++/include/orc/Common.hh
index 9da67a3f1..f3cfc6433 100644
--- a/c++/include/orc/Common.hh
+++ b/c++/include/orc/Common.hh
@@ -29,32 +29,32 @@ namespace orc {
class FileVersion {
private:
- uint32_t majorVersion;
- uint32_t minorVersion;
+ uint32_t majorVersion_;
+ uint32_t minorVersion_;
public:
static const FileVersion& v_0_11();
static const FileVersion& v_0_12();
static const FileVersion& UNSTABLE_PRE_2_0();
- FileVersion(uint32_t major, uint32_t minor) : majorVersion(major), minorVersion(minor) {}
+ FileVersion(uint32_t major, uint32_t minor) : majorVersion_(major), minorVersion_(minor) {}
/**
* Get major version
*/
uint32_t getMajor() const {
- return this->majorVersion;
+ return this->majorVersion_;
}
/**
* Get minor version
*/
uint32_t getMinor() const {
- return this->minorVersion;
+ return this->minorVersion_;
}
bool operator==(const FileVersion& right) const {
- return this->majorVersion == right.getMajor() && this->minorVersion == right.getMinor();
+ return this->majorVersion_ == right.getMajor() && this->minorVersion_ == right.getMinor();
}
bool operator!=(const FileVersion& right) const {
diff --git a/c++/include/orc/Exceptions.hh b/c++/include/orc/Exceptions.hh
index 0536dbd16..97cf5d8a0 100644
--- a/c++/include/orc/Exceptions.hh
+++ b/c++/include/orc/Exceptions.hh
@@ -28,8 +28,8 @@ namespace orc {
class NotImplementedYet : public std::logic_error {
public:
- explicit NotImplementedYet(const std::string& what_arg);
- explicit NotImplementedYet(const char* what_arg);
+ explicit NotImplementedYet(const std::string& whatArg);
+ explicit NotImplementedYet(const char* whatArg);
~NotImplementedYet() noexcept override;
NotImplementedYet(const NotImplementedYet&);
@@ -39,8 +39,8 @@ namespace orc {
class ParseError : public std::runtime_error {
public:
- explicit ParseError(const std::string& what_arg);
- explicit ParseError(const char* what_arg);
+ explicit ParseError(const std::string& whatArg);
+ explicit ParseError(const char* whatArg);
~ParseError() noexcept override;
ParseError(const ParseError&);
@@ -50,8 +50,8 @@ namespace orc {
class InvalidArgument : public std::runtime_error {
public:
- explicit InvalidArgument(const std::string& what_arg);
- explicit InvalidArgument(const char* what_arg);
+ explicit InvalidArgument(const std::string& whatArg);
+ explicit InvalidArgument(const char* whatArg);
~InvalidArgument() noexcept override;
InvalidArgument(const InvalidArgument&);
@@ -61,8 +61,8 @@ namespace orc {
class SchemaEvolutionError : public std::logic_error {
public:
- explicit SchemaEvolutionError(const std::string& what_arg);
- explicit SchemaEvolutionError(const char* what_arg);
+ explicit SchemaEvolutionError(const std::string& whatArg);
+ explicit SchemaEvolutionError(const char* whatArg);
virtual ~SchemaEvolutionError() noexcept override;
SchemaEvolutionError(const SchemaEvolutionError&);
SchemaEvolutionError& operator=(const SchemaEvolutionError&) = delete;
diff --git a/c++/include/orc/Int128.hh b/c++/include/orc/Int128.hh
index bcb4a58e2..6954c771c 100644
--- a/c++/include/orc/Int128.hh
+++ b/c++/include/orc/Int128.hh
@@ -37,8 +37,8 @@ namespace orc {
class Int128 {
public:
Int128() {
- highbits = 0;
- lowbits = 0;
+ highbits_ = 0;
+ lowbits_ = 0;
}
/**
@@ -46,11 +46,11 @@ namespace orc {
*/
Int128(int64_t right) {
if (right >= 0) {
- highbits = 0;
- lowbits = static_cast<uint64_t>(right);
+ highbits_ = 0;
+ lowbits_ = static_cast<uint64_t>(right);
} else {
- highbits = -1;
- lowbits = static_cast<uint64_t>(right);
+ highbits_ = -1;
+ lowbits_ = static_cast<uint64_t>(right);
}
}
@@ -58,8 +58,8 @@ namespace orc {
* Create from the twos complement representation.
*/
Int128(int64_t high, uint64_t low) {
- highbits = high;
- lowbits = low;
+ highbits_ = high;
+ lowbits_ = low;
}
/**
@@ -78,16 +78,16 @@ namespace orc {
static Int128 minimumValue();
Int128& negate() {
- lowbits = ~lowbits + 1;
- highbits = ~highbits;
- if (lowbits == 0) {
- highbits += 1;
+ lowbits_ = ~lowbits_ + 1;
+ highbits_ = ~highbits_;
+ if (lowbits_ == 0) {
+ highbits_ += 1;
}
return *this;
}
Int128& abs() {
- if (highbits < 0) {
+ if (highbits_ < 0) {
negate();
}
return *this;
@@ -100,8 +100,8 @@ namespace orc {
}
Int128& invert() {
- lowbits = ~lowbits;
- highbits = ~highbits;
+ lowbits_ = ~lowbits_;
+ highbits_ = ~highbits_;
return *this;
}
@@ -111,12 +111,12 @@ namespace orc {
* @return *this
*/
Int128& operator+=(const Int128& right) {
- uint64_t sum = lowbits + right.lowbits;
- highbits += right.highbits;
- if (sum < lowbits) {
- highbits += 1;
+ uint64_t sum = lowbits_ + right.lowbits_;
+ highbits_ += right.highbits_;
+ if (sum < lowbits_) {
+ highbits_ += 1;
}
- lowbits = sum;
+ lowbits_ = sum;
return *this;
}
@@ -126,12 +126,12 @@ namespace orc {
* @return *this
*/
Int128& operator-=(const Int128& right) {
- uint64_t diff = lowbits - right.lowbits;
- highbits -= right.highbits;
- if (diff > lowbits) {
- highbits -= 1;
+ uint64_t diff = lowbits_ - right.lowbits_;
+ highbits_ -= right.highbits_;
+ if (diff > lowbits_) {
+ highbits_ -= 1;
}
- lowbits = diff;
+ lowbits_ = diff;
return *this;
}
@@ -162,8 +162,8 @@ namespace orc {
* @return *this
*/
Int128& operator|=(const Int128& right) {
- lowbits |= right.lowbits;
- highbits |= right.highbits;
+ lowbits_ |= right.lowbits_;
+ highbits_ |= right.highbits_;
return *this;
}
@@ -173,8 +173,8 @@ namespace orc {
* @return *this
*/
Int128& operator&=(const Int128& right) {
- lowbits &= right.lowbits;
- highbits &= right.highbits;
+ lowbits_ &= right.lowbits_;
+ highbits_ &= right.highbits_;
return *this;
}
@@ -196,15 +196,15 @@ namespace orc {
Int128& operator<<=(uint32_t bits) {
if (bits != 0) {
if (bits < 64) {
- highbits <<= bits;
- highbits |= (lowbits >> (64 - bits));
- lowbits <<= bits;
+ highbits_ <<= bits;
+ highbits_ |= (lowbits_ >> (64 - bits));
+ lowbits_ <<= bits;
} else if (bits < 128) {
- highbits = static_cast<int64_t>(lowbits) << (bits - 64);
- lowbits = 0;
+ highbits_ = static_cast<int64_t>(lowbits_) << (bits - 64);
+ lowbits_ = 0;
} else {
- highbits = 0;
- lowbits = 0;
+ highbits_ = 0;
+ lowbits_ = 0;
}
}
return *this;
@@ -217,74 +217,74 @@ namespace orc {
Int128& operator>>=(uint32_t bits) {
if (bits != 0) {
if (bits < 64) {
- lowbits >>= bits;
- lowbits |= static_cast<uint64_t>(highbits << (64 - bits));
- highbits = static_cast<int64_t>(static_cast<uint64_t>(highbits) >> bits);
+ lowbits_ >>= bits;
+ lowbits_ |= static_cast<uint64_t>(highbits_ << (64 - bits));
+ highbits_ = static_cast<int64_t>(static_cast<uint64_t>(highbits_) >> bits);
} else if (bits < 128) {
- lowbits = static_cast<uint64_t>(highbits >> (bits - 64));
- highbits = highbits >= 0 ? 0 : -1l;
+ lowbits_ = static_cast<uint64_t>(highbits_ >> (bits - 64));
+ highbits_ = highbits_ >= 0 ? 0 : -1l;
} else {
- highbits = highbits >= 0 ? 0 : -1l;
- lowbits = static_cast<uint64_t>(highbits);
+ highbits_ = highbits_ >= 0 ? 0 : -1l;
+ lowbits_ = static_cast<uint64_t>(highbits_);
}
}
return *this;
}
bool operator==(const Int128& right) const {
- return highbits == right.highbits && lowbits == right.lowbits;
+ return highbits_ == right.highbits_ && lowbits_ == right.lowbits_;
}
bool operator!=(const Int128& right) const {
- return highbits != right.highbits || lowbits != right.lowbits;
+ return highbits_ != right.highbits_ || lowbits_ != right.lowbits_;
}
bool operator<(const Int128& right) const {
- if (highbits == right.highbits) {
- return lowbits < right.lowbits;
+ if (highbits_ == right.highbits_) {
+ return lowbits_ < right.lowbits_;
} else {
- return highbits < right.highbits;
+ return highbits_ < right.highbits_;
}
}
bool operator<=(const Int128& right) const {
- if (highbits == right.highbits) {
- return lowbits <= right.lowbits;
+ if (highbits_ == right.highbits_) {
+ return lowbits_ <= right.lowbits_;
} else {
- return highbits <= right.highbits;
+ return highbits_ <= right.highbits_;
}
}
bool operator>(const Int128& right) const {
- if (highbits == right.highbits) {
- return lowbits > right.lowbits;
+ if (highbits_ == right.highbits_) {
+ return lowbits_ > right.lowbits_;
} else {
- return highbits > right.highbits;
+ return highbits_ > right.highbits_;
}
}
bool operator>=(const Int128& right) const {
- if (highbits == right.highbits) {
- return lowbits >= right.lowbits;
+ if (highbits_ == right.highbits_) {
+ return lowbits_ >= right.lowbits_;
} else {
- return highbits >= right.highbits;
+ return highbits_ >= right.highbits_;
}
}
uint32_t hash() const {
- return static_cast<uint32_t>(highbits >> 32) ^ static_cast<uint32_t>(highbits) ^
- static_cast<uint32_t>(lowbits >> 32) ^ static_cast<uint32_t>(lowbits);
+ return static_cast<uint32_t>(highbits_ >> 32) ^ static_cast<uint32_t>(highbits_) ^
+ static_cast<uint32_t>(lowbits_ >> 32) ^ static_cast<uint32_t>(lowbits_);
}
/**
* Does this value fit into a long?
*/
bool fitsInLong() const {
- switch (highbits) {
+ switch (highbits_) {
case 0:
- return 0 == (lowbits & LONG_SIGN_BIT);
+ return 0 == (lowbits_ & LONG_SIGN_BIT);
case -1:
- return 0 != (lowbits & LONG_SIGN_BIT);
+ return 0 != (lowbits_ & LONG_SIGN_BIT);
default:
return false;
}
@@ -295,7 +295,7 @@ namespace orc {
*/
int64_t toLong() const {
if (fitsInLong()) {
- return static_cast<int64_t>(lowbits);
+ return static_cast<int64_t>(lowbits_);
}
throw std::range_error("Int128 too large to convert to long");
}
@@ -331,14 +331,14 @@ namespace orc {
* Get the high bits of the twos complement representation of the number.
*/
int64_t getHighBits() const {
- return highbits;
+ return highbits_;
}
/**
* Get the low bits of the twos complement representation of the number.
*/
uint64_t getLowBits() const {
- return lowbits;
+ return lowbits_;
}
/**
@@ -352,8 +352,8 @@ namespace orc {
private:
static const uint64_t LONG_SIGN_BIT = 0x8000000000000000u;
- int64_t highbits;
- uint64_t lowbits;
+ int64_t highbits_;
+ uint64_t lowbits_;
};
/**
diff --git a/c++/include/orc/MemoryPool.hh b/c++/include/orc/MemoryPool.hh
index 6d999d3aa..a914e5f26 100644
--- a/c++/include/orc/MemoryPool.hh
+++ b/c++/include/orc/MemoryPool.hh
@@ -36,50 +36,50 @@ namespace orc {
template <class T>
class DataBuffer {
private:
- MemoryPool& memoryPool;
- T* buf;
+ MemoryPool& memoryPool_;
+ T* buf_;
// current size
- uint64_t currentSize;
+ uint64_t currentSize_;
// maximal capacity (actual allocated memory)
- uint64_t currentCapacity;
+ uint64_t currentCapacity_;
// not implemented
DataBuffer(DataBuffer& buffer);
DataBuffer& operator=(DataBuffer& buffer);
public:
- DataBuffer(MemoryPool& pool, uint64_t _size = 0);
+ DataBuffer(MemoryPool& pool, uint64_t size = 0);
DataBuffer(DataBuffer<T>&& buffer) noexcept;
virtual ~DataBuffer();
T* data() {
- return buf;
+ return buf_;
}
const T* data() const {
- return buf;
+ return buf_;
}
uint64_t size() const {
- return currentSize;
+ return currentSize_;
}
uint64_t capacity() const {
- return currentCapacity;
+ return currentCapacity_;
}
const T& operator[](uint64_t i) const {
- return buf[i];
+ return buf_[i];
}
T& operator[](uint64_t i) {
- return buf[i];
+ return buf_[i];
}
- void reserve(uint64_t _size);
- void resize(uint64_t _size);
+ void reserve(uint64_t size);
+ void resize(uint64_t size);
void zeroOut();
};
diff --git a/c++/include/orc/Reader.hh b/c++/include/orc/Reader.hh
index b631c2c6e..4b254593e 100644
--- a/c++/include/orc/Reader.hh
+++ b/c++/include/orc/Reader.hh
@@ -67,7 +67,7 @@ namespace orc {
*/
class ReaderOptions {
private:
- std::unique_ptr<ReaderOptionsPrivate> privateBits;
+ std::unique_ptr<ReaderOptionsPrivate> privateBits_;
public:
ReaderOptions();
@@ -145,7 +145,7 @@ namespace orc {
*/
class RowReaderOptions {
private:
- std::unique_ptr<RowReaderOptionsPrivate> privateBits;
+ std::unique_ptr<RowReaderOptionsPrivate> privateBits_;
public:
RowReaderOptions();
diff --git a/c++/include/orc/Writer.hh b/c++/include/orc/Writer.hh
index 047ee9ffc..7968fbce7 100644
--- a/c++/include/orc/Writer.hh
+++ b/c++/include/orc/Writer.hh
@@ -55,7 +55,7 @@ namespace orc {
*/
class WriterOptions {
private:
- std::unique_ptr<WriterOptionsPrivate> privateBits;
+ std::unique_ptr<WriterOptionsPrivate> privateBits_;
public:
WriterOptions();
diff --git a/c++/include/orc/sargs/Literal.hh b/c++/include/orc/sargs/Literal.hh
index 9ce958302..a681bc6bb 100644
--- a/c++/include/orc/sargs/Literal.hh
+++ b/c++/include/orc/sargs/Literal.hh
@@ -39,7 +39,7 @@ namespace orc {
Timestamp(const Timestamp&) = default;
Timestamp(Timestamp&&) = default;
~Timestamp() = default;
- Timestamp(int64_t second_, int32_t nanos_) : second(second_), nanos(nanos_) {
+ Timestamp(int64_t second, int32_t nanos) : second(second), nanos(nanos) {
// PASS
}
Timestamp& operator=(const Timestamp&) = default;
@@ -130,15 +130,15 @@ namespace orc {
* Check if a literal is null
*/
bool isNull() const {
- return mIsNull;
+ return mIsNull_;
}
PredicateDataType getType() const {
- return mType;
+ return mType_;
}
std::string toString() const;
size_t getHashCode() const {
- return mHashCode;
+ return mHashCode_;
}
private:
@@ -158,13 +158,13 @@ namespace orc {
};
private:
- LiteralVal mValue; // data value for this literal if not null
- PredicateDataType mType; // data type of the literal
- size_t mSize; // size of mValue if it is Buffer
- int32_t mPrecision; // precision of decimal type
- int32_t mScale; // scale of decimal type
- bool mIsNull; // whether this literal is null
- size_t mHashCode; // precomputed hash code for the literal
+ LiteralVal mValue_; // data value for this literal if not null
+ PredicateDataType mType_; // data type of the literal
+ size_t mSize_; // size of mValue if it is Buffer
+ int32_t mPrecision_; // precision of decimal type
+ int32_t mScale_; // scale of decimal type
+ bool mIsNull_; // whether this literal is null
+ size_t mHashCode_; // precomputed hash code for the literal
};
} // namespace orc
diff --git a/c++/src/BlockBuffer.cc b/c++/src/BlockBuffer.cc
index 1f7843fad..09bf078c8 100644
--- a/c++/src/BlockBuffer.cc
+++ b/c++/src/BlockBuffer.cc
@@ -24,56 +24,56 @@
namespace orc {
- BlockBuffer::BlockBuffer(MemoryPool& pool, uint64_t _blockSize)
- : memoryPool(pool), currentSize(0), currentCapacity(0), blockSize(_blockSize) {
- if (blockSize == 0) {
+ BlockBuffer::BlockBuffer(MemoryPool& pool, uint64_t blockSize)
+ : memoryPool_(pool), currentSize_(0), currentCapacity_(0), blockSize_(blockSize) {
+ if (blockSize_ == 0) {
throw std::logic_error("Block size cannot be zero");
}
- reserve(blockSize);
+ reserve(blockSize_);
}
BlockBuffer::~BlockBuffer() {
- for (size_t i = 0; i < blocks.size(); ++i) {
- memoryPool.free(blocks[i]);
+ for (size_t i = 0; i < blocks_.size(); ++i) {
+ memoryPool_.free(blocks_[i]);
}
- blocks.clear();
- currentSize = currentCapacity = 0;
+ blocks_.clear();
+ currentSize_ = currentCapacity_ = 0;
}
BlockBuffer::Block BlockBuffer::getBlock(uint64_t blockIndex) const {
if (blockIndex >= getBlockNumber()) {
throw std::out_of_range("Block index out of range");
}
- return Block(blocks[blockIndex], std::min(currentSize - blockIndex * blockSize, blockSize));
+ return Block(blocks_[blockIndex], std::min(currentSize_ - blockIndex * blockSize_, blockSize_));
}
BlockBuffer::Block BlockBuffer::getNextBlock() {
- if (currentSize < currentCapacity) {
- Block emptyBlock(blocks[currentSize / blockSize] + currentSize % blockSize,
- blockSize - currentSize % blockSize);
- currentSize = (currentSize / blockSize + 1) * blockSize;
+ if (currentSize_ < currentCapacity_) {
+ Block emptyBlock(blocks_[currentSize_ / blockSize_] + currentSize_ % blockSize_,
+ blockSize_ - currentSize_ % blockSize_);
+ currentSize_ = (currentSize_ / blockSize_ + 1) * blockSize_;
return emptyBlock;
} else {
- resize(currentSize + blockSize);
- return Block(blocks.back(), blockSize);
+ resize(currentSize_ + blockSize_);
+ return Block(blocks_.back(), blockSize_);
}
}
void BlockBuffer::resize(uint64_t size) {
reserve(size);
- if (currentCapacity >= size) {
- currentSize = size;
+ if (currentCapacity_ >= size) {
+ currentSize_ = size;
} else {
throw std::logic_error("Block buffer resize error");
}
}
void BlockBuffer::reserve(uint64_t newCapacity) {
- while (currentCapacity < newCapacity) {
- char* newBlockPtr = memoryPool.malloc(blockSize);
+ while (currentCapacity_ < newCapacity) {
+ char* newBlockPtr = memoryPool_.malloc(blockSize_);
if (newBlockPtr != nullptr) {
- blocks.push_back(newBlockPtr);
- currentCapacity += blockSize;
+ blocks_.push_back(newBlockPtr);
+ currentCapacity_ += blockSize_;
} else {
break;
}
@@ -81,7 +81,7 @@ namespace orc {
}
void BlockBuffer::writeTo(OutputStream* output, WriterMetrics* metrics) {
- if (currentSize == 0) {
+ if (currentSize_ == 0) {
return;
}
static uint64_t MAX_CHUNK_SIZE = 1024 * 1024 * 1024;
@@ -92,12 +92,12 @@ namespace orc {
uint64_t ioCount = 0;
uint64_t blockNumber = getBlockNumber();
// if only exists one block, currentSize is equal to first block size
- if (blockNumber == 1 && currentSize <= chunkSize) {
+ if (blockNumber == 1 && currentSize_ <= chunkSize) {
Block block = getBlock(0);
output->write(block.data, block.size);
++ioCount;
} else {
- char* chunk = memoryPool.malloc(chunkSize);
+ char* chunk = memoryPool_.malloc(chunkSize);
uint64_t chunkOffset = 0;
for (uint64_t i = 0; i < blockNumber; ++i) {
Block block = getBlock(i);
@@ -121,7 +121,7 @@ namespace orc {
output->write(chunk, chunkOffset);
++ioCount;
}
- memoryPool.free(chunk);
+ memoryPool_.free(chunk);
}
if (metrics != nullptr) {
diff --git a/c++/src/BlockBuffer.hh b/c++/src/BlockBuffer.hh
index 0f5f78e3f..2faf38f7f 100644
--- a/c++/src/BlockBuffer.hh
+++ b/c++/src/BlockBuffer.hh
@@ -34,15 +34,15 @@ namespace orc {
*/
class BlockBuffer {
private:
- MemoryPool& memoryPool;
+ MemoryPool& memoryPool_;
// current buffer size
- uint64_t currentSize;
+ uint64_t currentSize_;
// maximal capacity (actual allocated memory)
- uint64_t currentCapacity;
+ uint64_t currentCapacity_;
// unit for buffer expansion
- const uint64_t blockSize;
+ const uint64_t blockSize_;
// pointers to the start of each block
- std::vector<char*> blocks;
+ std::vector<char*> blocks_;
// non-copy-constructible
BlockBuffer(BlockBuffer& buffer) = delete;
@@ -66,7 +66,7 @@ namespace orc {
uint64_t size;
Block() : data(nullptr), size(0) {}
- Block(char* _data, uint64_t _size) : data(_data), size(_size) {}
+ Block(char* data, uint64_t size) : data(data), size(size) {}
Block(const Block& block) = default;
~Block() = default;
};
@@ -94,15 +94,15 @@ namespace orc {
* Get the number of blocks that are fully or partially occupied
*/
uint64_t getBlockNumber() const {
- return (currentSize + blockSize - 1) / blockSize;
+ return (currentSize_ + blockSize_ - 1) / blockSize_;
}
uint64_t size() const {
- return currentSize;
+ return currentSize_;
}
uint64_t capacity() const {
- return currentCapacity;
+ return currentCapacity_;
}
void resize(uint64_t size);
diff --git a/c++/src/BloomFilter.cc b/c++/src/BloomFilter.cc
index 882c6f425..faaa8bb4d 100644
--- a/c++/src/BloomFilter.cc
+++ b/c++/src/BloomFilter.cc
@@ -37,50 +37,50 @@ namespace orc {
* Implementation of BitSet
*/
BitSet::BitSet(uint64_t numBits) {
- mData.resize(static_cast<size_t>(ceil(static_cast<double>(numBits) / BITS_OF_LONG)), 0);
+ mData_.resize(static_cast<size_t>(ceil(static_cast<double>(numBits) / BITS_OF_LONG)), 0);
}
BitSet::BitSet(const uint64_t* bits, uint64_t numBits) {
// caller should make sure numBits is multiple of 64
- mData.resize(numBits >> SHIFT_6_BITS, 0);
- memcpy(mData.data(), bits, numBits >> SHIFT_3_BITS);
+ mData_.resize(numBits >> SHIFT_6_BITS, 0);
+ memcpy(mData_.data(), bits, numBits >> SHIFT_3_BITS);
}
void BitSet::set(uint64_t index) {
- mData[index >> SHIFT_6_BITS] |= (1ULL << (index % BITS_OF_LONG));
+ mData_[index >> SHIFT_6_BITS] |= (1ULL << (index % BITS_OF_LONG));
}
bool BitSet::get(uint64_t index) {
- return (mData[index >> SHIFT_6_BITS] & (1ULL << (index % BITS_OF_LONG))) != 0;
+ return (mData_[index >> SHIFT_6_BITS] & (1ULL << (index % BITS_OF_LONG))) != 0;
}
uint64_t BitSet::bitSize() {
- return mData.size() << SHIFT_6_BITS;
+ return mData_.size() << SHIFT_6_BITS;
}
void BitSet::merge(const BitSet& other) {
- if (mData.size() != other.mData.size()) {
+ if (mData_.size() != other.mData_.size()) {
std::stringstream ss;
- ss << "BitSet must be of equal length (" << mData.size() << " != " << other.mData.size()
+ ss << "BitSet must be of equal length (" << mData_.size() << " != " << other.mData_.size()
<< ")";
throw std::logic_error(ss.str());
}
- for (size_t i = 0; i != mData.size(); i++) {
- mData[i] |= other.mData[i];
+ for (size_t i = 0; i != mData_.size(); i++) {
+ mData_[i] |= other.mData_[i];
}
}
void BitSet::clear() {
- memset(mData.data(), 0, sizeof(uint64_t) * mData.size());
+ memset(mData_.data(), 0, sizeof(uint64_t) * mData_.size());
}
const uint64_t* BitSet::getData() const {
- return mData.data();
+ return mData_.data();
}
bool BitSet::operator==(const BitSet& other) const {
- return mData == other.mData;
+ return mData_ == other.mData_;
}
/**
@@ -127,9 +127,9 @@ namespace orc {
uint64_t nb = static_cast<uint64_t>(optimalNumOfBits(expectedEntries, fpp));
// make 'mNumBits' multiple of 64
- mNumBits = nb + (BITS_OF_LONG - (nb % BITS_OF_LONG));
- mNumHashFunctions = optimalNumOfHashFunctions(expectedEntries, mNumBits);
- mBitSet.reset(new BitSet(mNumBits));
+ mNumBits_ = nb + (BITS_OF_LONG - (nb % BITS_OF_LONG));
+ mNumHashFunctions_ = optimalNumOfHashFunctions(expectedEntries, mNumBits_);
+ mBitSet_.reset(new BitSet(mNumBits_));
}
void BloomFilterImpl::addBytes(const char* data, int64_t length) {
@@ -155,11 +155,11 @@ namespace orc {
}
uint64_t BloomFilterImpl::getBitSize() const {
- return mBitSet->bitSize();
+ return mBitSet_->bitSize();
}
int32_t BloomFilterImpl::getNumHashFunctions() const {
- return mNumHashFunctions;
+ return mNumHashFunctions_;
}
DIAGNOSTIC_PUSH
@@ -175,17 +175,17 @@ namespace orc {
// caller should make sure input proto::BloomFilter is valid since
// no check will be performed in the following constructor
BloomFilterImpl::BloomFilterImpl(const proto::BloomFilter& bloomFilter) {
- mNumHashFunctions = static_cast<int32_t>(bloomFilter.num_hash_functions());
+ mNumHashFunctions_ = static_cast<int32_t>(bloomFilter.num_hash_functions());
const std::string& bitsetStr = bloomFilter.utf8bitset();
- mNumBits = bitsetStr.size() << SHIFT_3_BITS;
- checkArgument(mNumBits % BITS_OF_LONG == 0, "numBits should be multiple of 64!");
+ mNumBits_ = bitsetStr.size() << SHIFT_3_BITS;
+ checkArgument(mNumBits_ % BITS_OF_LONG == 0, "numBits should be multiple of 64!");
const uint64_t* bitset = reinterpret_cast<const uint64_t*>(bitsetStr.data());
if (isLittleEndian()) {
- mBitSet.reset(new BitSet(bitset, mNumBits));
+ mBitSet_.reset(new BitSet(bitset, mNumBits_));
} else {
- std::vector<uint64_t> longs(mNumBits >> SHIFT_6_BITS);
+ std::vector<uint64_t> longs(mNumBits_ >> SHIFT_6_BITS);
for (size_t i = 0; i != longs.size(); ++i) {
// convert little-endian to big-endian
const uint64_t src = bitset[i];
@@ -195,7 +195,7 @@ namespace orc {
}
}
- mBitSet.reset(new BitSet(longs.data(), mNumBits));
+ mBitSet_.reset(new BitSet(longs.data(), mNumBits_));
}
}
@@ -215,14 +215,14 @@ namespace orc {
// So we cast hash64 to uint64_t here for an unsigned right shift.
int32_t hash2 = static_cast<int32_t>(static_cast<uint64_t>(hash64) >> 32);
- for (int32_t i = 1; i <= mNumHashFunctions; ++i) {
+ for (int32_t i = 1; i <= mNumHashFunctions_; ++i) {
int32_t combinedHash = hash1 + i * hash2;
// hashcode should be positive, flip all the bits if it's negative
if (combinedHash < 0) {
combinedHash = ~combinedHash;
}
- uint64_t pos = static_cast<uint64_t>(combinedHash) % mNumBits;
- mBitSet->set(pos);
+ uint64_t pos = static_cast<uint64_t>(combinedHash) % mNumBits_;
+ mBitSet_->set(pos);
}
}
@@ -232,14 +232,14 @@ namespace orc {
// So we cast hash64 to uint64_t here for an unsigned right shift.
int32_t hash2 = static_cast<int32_t>(static_cast<uint64_t>(hash64) >> 32);
- for (int32_t i = 1; i <= mNumHashFunctions; ++i) {
+ for (int32_t i = 1; i <= mNumHashFunctions_; ++i) {
int32_t combinedHash = hash1 + i * hash2;
// hashcode should be positive, flip all the bits if it's negative
if (combinedHash < 0) {
combinedHash = ~combinedHash;
}
- uint64_t pos = static_cast<uint64_t>(combinedHash) % mNumBits;
- if (!mBitSet->get(pos)) {
+ uint64_t pos = static_cast<uint64_t>(combinedHash) % mNumBits_;
+ if (!mBitSet_->get(pos)) {
return false;
}
}
@@ -247,33 +247,34 @@ namespace orc {
}
void BloomFilterImpl::merge(const BloomFilterImpl& other) {
- if (mNumBits != other.mNumBits || mNumHashFunctions != other.mNumHashFunctions) {
+ if (mNumBits_ != other.mNumBits_ || mNumHashFunctions_ != other.mNumHashFunctions_) {
std::stringstream ss;
ss << "BloomFilters are not compatible for merging: "
- << "this: numBits:" << mNumBits << ",numHashFunctions:" << mNumHashFunctions
- << ", that: numBits:" << other.mNumBits << ",numHashFunctions:" << other.mNumHashFunctions;
+ << "this: numBits:" << mNumBits_ << ",numHashFunctions:" << mNumHashFunctions_
+ << ", that: numBits:" << other.mNumBits_
+ << ",numHashFunctions:" << other.mNumHashFunctions_;
throw std::logic_error(ss.str());
}
- mBitSet->merge(*other.mBitSet);
+ mBitSet_->merge(*other.mBitSet_);
}
void BloomFilterImpl::reset() {
- mBitSet->clear();
+ mBitSet_->clear();
}
void BloomFilterImpl::serialize(proto::BloomFilter& bloomFilter) const {
- bloomFilter.set_num_hash_functions(static_cast<uint32_t>(mNumHashFunctions));
+ bloomFilter.set_num_hash_functions(static_cast<uint32_t>(mNumHashFunctions_));
// According to ORC standard, the encoding is a sequence of bytes with
// a little endian encoding in the utf8bitset field.
if (isLittleEndian()) {
// bytes are already organized in little endian; thus no conversion needed
- const char* bitset = reinterpret_cast<const char*>(mBitSet->getData());
+ const char* bitset = reinterpret_cast<const char*>(mBitSet_->getData());
bloomFilter.set_utf8bitset(bitset, sizeInBytes());
} else {
std::vector<uint64_t> bitset(sizeInBytes() / sizeof(uint64_t), 0);
- const uint64_t* longs = mBitSet->getData();
+ const uint64_t* longs = mBitSet_->getData();
for (size_t i = 0; i != bitset.size(); ++i) {
uint64_t& dst = bitset[i];
const uint64_t src = longs[i];
@@ -287,8 +288,8 @@ namespace orc {
}
bool BloomFilterImpl::operator==(const BloomFilterImpl& other) const {
- return mNumBits == other.mNumBits && mNumHashFunctions == other.mNumHashFunctions &&
- *mBitSet == *other.mBitSet;
+ return mNumBits_ == other.mNumBits_ && mNumHashFunctions_ == other.mNumHashFunctions_ &&
+ *mBitSet_ == *other.mBitSet_;
}
BloomFilter::~BloomFilter() {
diff --git a/c++/src/BloomFilter.hh b/c++/src/BloomFilter.hh
index d72961a83..e8d78663b 100644
--- a/c++/src/BloomFilter.hh
+++ b/c++/src/BloomFilter.hh
@@ -90,7 +90,7 @@ namespace orc {
bool operator==(const BitSet& other) const;
private:
- std::vector<uint64_t> mData;
+ std::vector<uint64_t> mData_;
};
/**
@@ -174,9 +174,9 @@ namespace orc {
private:
static constexpr double DEFAULT_FPP = 0.05;
- uint64_t mNumBits;
- int32_t mNumHashFunctions;
- std::unique_ptr<BitSet> mBitSet;
+ uint64_t mNumBits_;
+ int32_t mNumHashFunctions_;
+ std::unique_ptr<BitSet> mBitSet_;
};
struct BloomFilterUTF8Utils {
diff --git a/c++/src/BpackingDefault.cc b/c++/src/BpackingDefault.cc
index 5a80bc6fb..401a217d3 100644
--- a/c++/src/BpackingDefault.cc
+++ b/c++/src/BpackingDefault.cc
@@ -22,7 +22,7 @@
namespace orc {
- UnpackDefault::UnpackDefault(RleDecoderV2* dec) : decoder(dec) {
+ UnpackDefault::UnpackDefault(RleDecoderV2* dec) : decoder_(dec) {
// PASS
}
@@ -34,17 +34,17 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Make sure bitsLeft is 0 before the loop. bitsLeft can only be 0, 4, or 8.
- while (decoder->getBitsLeft() > 0 && curIdx < offset + len) {
- decoder->setBitsLeft(decoder->getBitsLeft() - 4);
- data[curIdx++] = (decoder->getCurByte() >> decoder->getBitsLeft()) & 15;
+ while (decoder_->getBitsLeft() > 0 && curIdx < offset + len) {
+ decoder_->setBitsLeft(decoder_->getBitsLeft() - 4);
+ data[curIdx++] = (decoder_->getCurByte() >> decoder_->getBitsLeft()) & 15;
}
if (curIdx == offset + len) return;
// Exhaust the buffer
uint64_t numGroups = (offset + len - curIdx) / 2;
- numGroups = std::min(numGroups, static_cast<uint64_t>(decoder->bufLength()));
+ numGroups = std::min(numGroups, static_cast<uint64_t>(decoder_->bufLength()));
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
uint32_t localByte;
for (uint64_t i = 0; i < numGroups; ++i) {
localByte = *buffer++;
@@ -52,12 +52,12 @@ namespace orc {
data[curIdx + 1] = localByte & 15;
curIdx += 2;
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// readByte() will update 'bufferStart' and 'bufferEnd'
- decoder->setCurByte(decoder->readByte());
- decoder->setBitsLeft(8);
+ decoder_->setCurByte(decoder_->readByte());
+ decoder_->setBitsLeft(8);
}
}
@@ -65,18 +65,18 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength();
+ int64_t bufferNum = decoder_->bufLength();
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
data[curIdx++] = *buffer++;
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// readByte() will update 'bufferStart' and 'bufferEnd'.
- data[curIdx++] = decoder->readByte();
+ data[curIdx++] = decoder_->readByte();
}
}
@@ -84,23 +84,23 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 2;
+ int64_t bufferNum = decoder_->bufLength() / 2;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint16_t b0, b1;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint16_t>(*buffer);
b1 = static_cast<uint16_t>(*(buffer + 1));
buffer += 2;
data[curIdx++] = (b0 << 8) | b1;
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
data[curIdx++] = (b0 << 8) | b1;
}
}
@@ -109,11 +109,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 3;
+ int64_t bufferNum = decoder_->bufLength() / 3;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint32_t b0, b1, b2;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -122,13 +122,13 @@ namespace orc {
data[curIdx++] = static_cast<int64_t>((b0 << 16) | (b1 << 8) | b2);
}
//////decoder->bufferStart += bufferNum * 3;
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
data[curIdx++] = static_cast<int64_t>((b0 << 16) | (b1 << 8) | b2);
}
}
@@ -137,11 +137,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 4;
+ int64_t bufferNum = decoder_->bufLength() / 4;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint32_t b0, b1, b2, b3;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -150,14 +150,14 @@ namespace orc {
buffer += 4;
data[curIdx++] = static_cast<int64_t>((b0 << 24) | (b1 << 16) | (b2 << 8) | b3);
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
- b3 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
+ b3 = decoder_->readByte();
data[curIdx++] = static_cast<int64_t>((b0 << 24) | (b1 << 16) | (b2 << 8) | b3);
}
}
@@ -166,11 +166,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 5;
+ int64_t bufferNum = decoder_->bufLength() / 5;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint64_t b0, b1, b2, b3, b4;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -181,15 +181,15 @@ namespace orc {
data[curIdx++] =
static_cast<int64_t>((b0 << 32) | (b1 << 24) | (b2 << 16) | (b3 << 8) | b4);
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
- b3 = decoder->readByte();
- b4 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
+ b3 = decoder_->readByte();
+ b4 = decoder_->readByte();
data[curIdx++] = static_cast<int64_t>((b0 << 32) | (b1 << 24) | (b2 << 16) | (b3 << 8) | b4);
}
}
@@ -198,11 +198,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 6;
+ int64_t bufferNum = decoder_->bufLength() / 6;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint64_t b0, b1, b2, b3, b4, b5;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -214,16 +214,16 @@ namespace orc {
data[curIdx++] = static_cast<int64_t>((b0 << 40) | (b1 << 32) | (b2 << 24) | (b3 << 16) |
(b4 << 8) | b5);
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
- b3 = decoder->readByte();
- b4 = decoder->readByte();
- b5 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
+ b3 = decoder_->readByte();
+ b4 = decoder_->readByte();
+ b5 = decoder_->readByte();
data[curIdx++] =
static_cast<int64_t>((b0 << 40) | (b1 << 32) | (b2 << 24) | (b3 << 16) | (b4 << 8) | b5);
}
@@ -233,11 +233,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 7;
+ int64_t bufferNum = decoder_->bufLength() / 7;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint64_t b0, b1, b2, b3, b4, b5, b6;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -250,17 +250,17 @@ namespace orc {
data[curIdx++] = static_cast<int64_t>((b0 << 48) | (b1 << 40) | (b2 << 32) | (b3 << 24) |
(b4 << 16) | (b5 << 8) | b6);
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
- b3 = decoder->readByte();
- b4 = decoder->readByte();
- b5 = decoder->readByte();
- b6 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
+ b3 = decoder_->readByte();
+ b4 = decoder_->readByte();
+ b5 = decoder_->readByte();
+ b6 = decoder_->readByte();
data[curIdx++] = static_cast<int64_t>((b0 << 48) | (b1 << 40) | (b2 << 32) | (b3 << 24) |
(b4 << 16) | (b5 << 8) | b6);
}
@@ -270,11 +270,11 @@ namespace orc {
uint64_t curIdx = offset;
while (curIdx < offset + len) {
// Exhaust the buffer
- int64_t bufferNum = decoder->bufLength() / 8;
+ int64_t bufferNum = decoder_->bufLength() / 8;
bufferNum = std::min(bufferNum, static_cast<int64_t>(offset + len - curIdx));
uint64_t b0, b1, b2, b3, b4, b5, b6, b7;
// Avoid updating 'bufferStart' inside the loop.
- auto* buffer = reinterpret_cast<unsigned char*>(decoder->getBufStart());
+ auto* buffer = reinterpret_cast<unsigned char*>(decoder_->getBufStart());
for (int i = 0; i < bufferNum; ++i) {
b0 = static_cast<uint32_t>(*buffer);
b1 = static_cast<uint32_t>(*(buffer + 1));
@@ -288,18 +288,18 @@ namespace orc {
data[curIdx++] = static_cast<int64_t>((b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) |
(b4 << 24) | (b5 << 16) | (b6 << 8) | b7);
}
- decoder->setBufStart(reinterpret_cast<char*>(buffer));
+ decoder_->setBufStart(reinterpret_cast<char*>(buffer));
if (curIdx == offset + len) return;
// One of the following readByte() will update 'bufferStart' and 'bufferEnd'.
- b0 = decoder->readByte();
- b1 = decoder->readByte();
- b2 = decoder->readByte();
- b3 = decoder->readByte();
- b4 = decoder->readByte();
- b5 = decoder->readByte();
- b6 = decoder->readByte();
- b7 = decoder->readByte();
+ b0 = decoder_->readByte();
+ b1 = decoder_->readByte();
+ b2 = decoder_->readByte();
+ b3 = decoder_->readByte();
+ b4 = decoder_->readByte();
+ b5 = decoder_->readByte();
+ b6 = decoder_->readByte();
+ b7 = decoder_->readByte();
data[curIdx++] = static_cast<int64_t>((b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32) |
(b4 << 24) | (b5 << 16) | (b6 << 8) | b7);
}
@@ -309,19 +309,19 @@ namespace orc {
for (uint64_t i = offset; i < (offset + len); i++) {
uint64_t result = 0;
uint64_t bitsLeftToRead = fbs;
- while (bitsLeftToRead > decoder->getBitsLeft()) {
- result <<= decoder->getBitsLeft();
- result |= decoder->getCurByte() & ((1 << decoder->getBitsLeft()) - 1);
- bitsLeftToRead -= decoder->getBitsLeft();
- decoder->setCurByte(decoder->readByte());
- decoder->setBitsLeft(8);
+ while (bitsLeftToRead > decoder_->getBitsLeft()) {
+ result <<= decoder_->getBitsLeft();
+ result |= decoder_->getCurByte() & ((1 << decoder_->getBitsLeft()) - 1);
+ bitsLeftToRead -= decoder_->getBitsLeft();
+ decoder_->setCurByte(decoder_->readByte());
+ decoder_->setBitsLeft(8);
}
// handle the left over bits
if (bitsLeftToRead > 0) {
result <<= bitsLeftToRead;
- decoder->setBitsLeft(decoder->getBitsLeft() - static_cast<uint32_t>(bitsLeftToRead));
- result |= (decoder->getCurByte() >> decoder->getBitsLeft()) & ((1 << bitsLeftToRead) - 1);
+ decoder_->setBitsLeft(decoder_->getBitsLeft() - static_cast<uint32_t>(bitsLeftToRead));
+ result |= (decoder_->getCurByte() >> decoder_->getBitsLeft()) & ((1 << bitsLeftToRead) - 1);
}
data[i] = static_cast<int64_t>(result);
}
diff --git a/c++/src/BpackingDefault.hh b/c++/src/BpackingDefault.hh
index 0a5823449..bbd785126 100644
--- a/c++/src/BpackingDefault.hh
+++ b/c++/src/BpackingDefault.hh
@@ -45,7 +45,7 @@ namespace orc {
void plainUnpackLongs(int64_t* data, uint64_t offset, uint64_t len, uint64_t fbs);
private:
- RleDecoderV2* decoder;
+ RleDecoderV2* decoder_;
};
class BitUnpackDefault : public BitUnpack {
diff --git a/c++/src/ByteRLE.cc b/c++/src/ByteRLE.cc
index b81d282e3..bdbaad1da 100644
--- a/c++/src/ByteRLE.cc
+++ b/c++/src/ByteRLE.cc
@@ -244,14 +244,14 @@ namespace orc {
virtual void suppress() override;
private:
- int bitsRemained;
- char current;
+ int bitsRemained_;
+ char current_;
};
BooleanRleEncoderImpl::BooleanRleEncoderImpl(std::unique_ptr<BufferedOutputStream> output)
: ByteRleEncoderImpl(std::move(output)) {
- bitsRemained = 8;
- current = static_cast<char>(0);
+ bitsRemained_ = 8;
+ current_ = static_cast<char>(0);
}
BooleanRleEncoderImpl::~BooleanRleEncoderImpl() {
@@ -260,43 +260,43 @@ namespace orc {
void BooleanRleEncoderImpl::add(const char* data, uint64_t numValues, const char* notNull) {
for (uint64_t i = 0; i < numValues; ++i) {
- if (bitsRemained == 0) {
- write(current);
- current = static_cast<char>(0);
- bitsRemained = 8;
+ if (bitsRemained_ == 0) {
+ write(current_);
+ current_ = static_cast<char>(0);
+ bitsRemained_ = 8;
}
if (!notNull || notNull[i]) {
if (!data || data[i]) {
- current = static_cast<char>(current | (0x80 >> (8 - bitsRemained)));
+ current_ = static_cast<char>(current_ | (0x80 >> (8 - bitsRemained_)));
}
- --bitsRemained;
+ --bitsRemained_;
}
}
- if (bitsRemained == 0) {
- write(current);
- current = static_cast<char>(0);
- bitsRemained = 8;
+ if (bitsRemained_ == 0) {
+ write(current_);
+ current_ = static_cast<char>(0);
+ bitsRemained_ = 8;
}
}
uint64_t BooleanRleEncoderImpl::flush() {
- if (bitsRemained != 8) {
- write(current);
+ if (bitsRemained_ != 8) {
+ write(current_);
}
- bitsRemained = 8;
- current = static_cast<char>(0);
+ bitsRemained_ = 8;
+ current_ = static_cast<char>(0);
return ByteRleEncoderImpl::flush();
}
void BooleanRleEncoderImpl::recordPosition(PositionRecorder* recorder) const {
ByteRleEncoderImpl::recordPosition(recorder);
- recorder->add(static_cast<uint64_t>(8 - bitsRemained));
+ recorder->add(static_cast<uint64_t>(8 - bitsRemained_));
}
void BooleanRleEncoderImpl::suppress() {
ByteRleEncoderImpl::suppress();
- bitsRemained = 8;
- current = static_cast<char>(0);
+ bitsRemained_ = 8;
+ current_ = static_cast<char>(0);
}
std::unique_ptr<ByteRleEncoder> createBooleanRleEncoder(
@@ -386,8 +386,8 @@ namespace orc {
}
ByteRleDecoderImpl::ByteRleDecoderImpl(std::unique_ptr<SeekableInputStream> input,
- ReaderMetrics* _metrics)
- : metrics(_metrics) {
+ ReaderMetrics* metrics)
+ : metrics(metrics) {
inputStream = std::move(input);
reset();
}
@@ -526,8 +526,8 @@ namespace orc {
};
BooleanRleDecoderImpl::BooleanRleDecoderImpl(std::unique_ptr<SeekableInputStream> input,
- ReaderMetrics* _metrics)
- : ByteRleDecoderImpl(std::move(input), _metrics) {
+ ReaderMetrics* metrics)
+ : ByteRleDecoderImpl(std::move(input), metrics) {
remainingBits = 0;
lastByte = 0;
}
diff --git a/c++/src/ColumnPrinter.cc b/c++/src/ColumnPrinter.cc
index 5297f8037..f7d248fe8 100644
--- a/c++/src/ColumnPrinter.cc
+++ b/c++/src/ColumnPrinter.cc
@@ -43,7 +43,7 @@ namespace orc {
class BooleanColumnPrinter : public ColumnPrinter {
private:
- const int64_t* data;
+ const int64_t* data_;
public:
BooleanColumnPrinter(std::string&);
@@ -54,7 +54,7 @@ namespace orc {
class LongColumnPrinter : public ColumnPrinter {
private:
- const int64_t* data;
+ const int64_t* data_;
public:
LongColumnPrinter(std::string&);
@@ -65,8 +65,8 @@ namespace orc {
class DoubleColumnPrinter : public ColumnPrinter {
private:
- const double* data;
- const bool isFloat;
+ const double* data_;
+ const bool isFloat_;
public:
DoubleColumnPrinter(std::string&, const Type& type);
@@ -77,8 +77,8 @@ namespace orc {
class TimestampColumnPrinter : public ColumnPrinter {
private:
- const int64_t* seconds;
- const int64_t* nanoseconds;
+ const int64_t* seconds_;
+ const int64_t* nanoseconds_;
public:
TimestampColumnPrinter(std::string&);
@@ -89,7 +89,7 @@ namespace orc {
class DateColumnPrinter : public ColumnPrinter {
private:
- const int64_t* data;
+ const int64_t* data_;
public:
DateColumnPrinter(std::string&);
@@ -100,8 +100,8 @@ namespace orc {
class Decimal64ColumnPrinter : public ColumnPrinter {
private:
- const int64_t* data;
- int32_t scale;
+ const int64_t* data_;
+ int32_t scale_;
public:
Decimal64ColumnPrinter(std::string&);
@@ -112,8 +112,8 @@ namespace orc {
class Decimal128ColumnPrinter : public ColumnPrinter {
private:
- const Int128* data;
- int32_t scale;
+ const Int128* data_;
+ int32_t scale_;
public:
Decimal128ColumnPrinter(std::string&);
@@ -124,8 +124,8 @@ namespace orc {
class StringColumnPrinter : public ColumnPrinter {
private:
- const char* const* start;
- const int64_t* length;
+ const char* const* start_;
+ const int64_t* length_;
public:
StringColumnPrinter(std::string&);
@@ -136,8 +136,8 @@ namespace orc {
class BinaryColumnPrinter : public ColumnPrinter {
private:
- const char* const* start;
- const int64_t* length;
+ const char* const* start_;
+ const int64_t* length_;
public:
BinaryColumnPrinter(std::string&);
@@ -148,8 +148,8 @@ namespace orc {
class ListColumnPrinter : public ColumnPrinter {
private:
- const int64_t* offsets;
- std::unique_ptr<ColumnPrinter> elementPrinter;
+ const int64_t* offsets_;
+ std::unique_ptr<ColumnPrinter> elementPrinter_;
public:
ListColumnPrinter(std::string&, const Type& type);
@@ -160,9 +160,9 @@ namespace orc {
class MapColumnPrinter : public ColumnPrinter {
private:
- const int64_t* offsets;
- std::unique_ptr<ColumnPrinter> keyPrinter;
- std::unique_ptr<ColumnPrinter> elementPrinter;
+ const int64_t* offsets_;
+ std::unique_ptr<ColumnPrinter> keyPrinter_;
+ std::unique_ptr<ColumnPrinter> elementPrinter_;
public:
MapColumnPrinter(std::string&, const Type& type);
@@ -173,9 +173,9 @@ namespace orc {
class UnionColumnPrinter : public ColumnPrinter {
private:
- const unsigned char* tags;
- const uint64_t* offsets;
- std::vector<std::unique_ptr<ColumnPrinter>> fieldPrinter;
+ const unsigned char* tags_;
+ const uint64_t* offsets_;
+ std::vector<std::unique_ptr<ColumnPrinter>> fieldPrinter_;
public:
UnionColumnPrinter(std::string&, const Type& type);
@@ -185,8 +185,8 @@ namespace orc {
class StructColumnPrinter : public ColumnPrinter {
private:
- std::vector<std::unique_ptr<ColumnPrinter>> fieldPrinter;
- std::vector<std::string> fieldNames;
+ std::vector<std::unique_ptr<ColumnPrinter>> fieldPrinter_;
+ std::vector<std::string> fieldNames_;
public:
StructColumnPrinter(std::string&, const Type& type);
@@ -203,7 +203,7 @@ namespace orc {
file.append(ptr, len);
}
- ColumnPrinter::ColumnPrinter(std::string& _buffer) : buffer(_buffer) {
+ ColumnPrinter::ColumnPrinter(std::string& buffer) : buffer(buffer) {
notNull = nullptr;
hasNulls = false;
}
@@ -293,7 +293,7 @@ namespace orc {
return result;
}
- VoidColumnPrinter::VoidColumnPrinter(std::string& _buffer) : ColumnPrinter(_buffer) {
+ VoidColumnPrinter::VoidColumnPrinter(std::string& buffer) : ColumnPrinter(buffer) {
// PASS
}
@@ -305,33 +305,33 @@ namespace orc {
writeString(buffer, "null");
}
- LongColumnPrinter::LongColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), data(nullptr) {
+ LongColumnPrinter::LongColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), data_(nullptr) {
// PASS
}
void LongColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const LongVectorBatch&>(batch).data.data();
+ data_ = dynamic_cast<const LongVectorBatch&>(batch).data.data();
}
void LongColumnPrinter::printRow(uint64_t rowId) {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- const auto numBuffer = std::to_string(static_cast<int64_t>(data[rowId]));
+ const auto numBuffer = std::to_string(static_cast<int64_t>(data_[rowId]));
writeString(buffer, numBuffer.c_str());
}
}
- DoubleColumnPrinter::DoubleColumnPrinter(std::string& _buffer, const Type& type)
- : ColumnPrinter(_buffer), data(nullptr), isFloat(type.getKind() == FLOAT) {
+ DoubleColumnPrinter::DoubleColumnPrinter(std::string& buffer, const Type& type)
+ : ColumnPrinter(buffer), data_(nullptr), isFloat_(type.getKind() == FLOAT) {
// PASS
}
void DoubleColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const DoubleVectorBatch&>(batch).data.data();
+ data_ = dynamic_cast<const DoubleVectorBatch&>(batch).data.data();
}
void DoubleColumnPrinter::printRow(uint64_t rowId) {
@@ -339,20 +339,20 @@ namespace orc {
writeString(buffer, "null");
} else {
char numBuffer[64];
- snprintf(numBuffer, sizeof(numBuffer), isFloat ? "%.7g" : "%.14g", data[rowId]);
+ snprintf(numBuffer, sizeof(numBuffer), isFloat_ ? "%.7g" : "%.14g", data_[rowId]);
writeString(buffer, numBuffer);
}
}
- Decimal64ColumnPrinter::Decimal64ColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), data(nullptr), scale(0) {
+ Decimal64ColumnPrinter::Decimal64ColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), data_(nullptr), scale_(0) {
// PASS
}
void Decimal64ColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const Decimal64VectorBatch&>(batch).values.data();
- scale = dynamic_cast<const Decimal64VectorBatch&>(batch).scale;
+ data_ = dynamic_cast<const Decimal64VectorBatch&>(batch).values.data();
+ scale_ = dynamic_cast<const Decimal64VectorBatch&>(batch).scale;
}
std::string toDecimalString(int64_t value, int32_t scale) {
@@ -387,38 +387,38 @@ namespace orc {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- writeString(buffer, toDecimalString(data[rowId], scale).c_str());
+ writeString(buffer, toDecimalString(data_[rowId], scale_).c_str());
}
}
- Decimal128ColumnPrinter::Decimal128ColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), data(nullptr), scale(0) {
+ Decimal128ColumnPrinter::Decimal128ColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), data_(nullptr), scale_(0) {
// PASS
}
void Decimal128ColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const Decimal128VectorBatch&>(batch).values.data();
- scale = dynamic_cast<const Decimal128VectorBatch&>(batch).scale;
+ data_ = dynamic_cast<const Decimal128VectorBatch&>(batch).values.data();
+ scale_ = dynamic_cast<const Decimal128VectorBatch&>(batch).scale;
}
void Decimal128ColumnPrinter::printRow(uint64_t rowId) {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- writeString(buffer, data[rowId].toDecimalString(scale).c_str());
+ writeString(buffer, data_[rowId].toDecimalString(scale_).c_str());
}
}
- StringColumnPrinter::StringColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), start(nullptr), length(nullptr) {
+ StringColumnPrinter::StringColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), start_(nullptr), length_(nullptr) {
// PASS
}
void StringColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- start = dynamic_cast<const StringVectorBatch&>(batch).data.data();
- length = dynamic_cast<const StringVectorBatch&>(batch).length.data();
+ start_ = dynamic_cast<const StringVectorBatch&>(batch).data.data();
+ length_ = dynamic_cast<const StringVectorBatch&>(batch).length.data();
}
void StringColumnPrinter::printRow(uint64_t rowId) {
@@ -426,8 +426,8 @@ namespace orc {
writeString(buffer, "null");
} else {
writeChar(buffer, '"');
- for (int64_t i = 0; i < length[rowId]; ++i) {
- char ch = static_cast<char>(start[rowId][i]);
+ for (int64_t i = 0; i < length_[rowId]; ++i) {
+ char ch = static_cast<char>(start_[rowId][i]);
switch (ch) {
case '\\':
writeString(buffer, "\\\\");
@@ -459,15 +459,15 @@ namespace orc {
}
}
- ListColumnPrinter::ListColumnPrinter(std::string& _buffer, const Type& type)
- : ColumnPrinter(_buffer), offsets(nullptr) {
- elementPrinter = createColumnPrinter(buffer, type.getSubtype(0));
+ ListColumnPrinter::ListColumnPrinter(std::string& buffer, const Type& type)
+ : ColumnPrinter(buffer), offsets_(nullptr) {
+ elementPrinter_ = createColumnPrinter(buffer, type.getSubtype(0));
}
void ListColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- offsets = dynamic_cast<const ListVectorBatch&>(batch).offsets.data();
- elementPrinter->reset(*dynamic_cast<const ListVectorBatch&>(batch).elements);
+ offsets_ = dynamic_cast<const ListVectorBatch&>(batch).offsets.data();
+ elementPrinter_->reset(*dynamic_cast<const ListVectorBatch&>(batch).elements);
}
void ListColumnPrinter::printRow(uint64_t rowId) {
@@ -475,28 +475,28 @@ namespace orc {
writeString(buffer, "null");
} else {
writeChar(buffer, '[');
- for (int64_t i = offsets[rowId]; i < offsets[rowId + 1]; ++i) {
- if (i != offsets[rowId]) {
+ for (int64_t i = offsets_[rowId]; i < offsets_[rowId + 1]; ++i) {
+ if (i != offsets_[rowId]) {
writeString(buffer, ", ");
}
- elementPrinter->printRow(static_cast<uint64_t>(i));
+ elementPrinter_->printRow(static_cast<uint64_t>(i));
}
writeChar(buffer, ']');
}
}
- MapColumnPrinter::MapColumnPrinter(std::string& _buffer, const Type& type)
- : ColumnPrinter(_buffer), offsets(nullptr) {
- keyPrinter = createColumnPrinter(buffer, type.getSubtype(0));
- elementPrinter = createColumnPrinter(buffer, type.getSubtype(1));
+ MapColumnPrinter::MapColumnPrinter(std::string& buffer, const Type& type)
+ : ColumnPrinter(buffer), offsets_(nullptr) {
+ keyPrinter_ = createColumnPrinter(buffer, type.getSubtype(0));
+ elementPrinter_ = createColumnPrinter(buffer, type.getSubtype(1));
}
void MapColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
const MapVectorBatch& myBatch = dynamic_cast<const MapVectorBatch&>(batch);
- offsets = myBatch.offsets.data();
- keyPrinter->reset(*myBatch.keys);
- elementPrinter->reset(*myBatch.elements);
+ offsets_ = myBatch.offsets.data();
+ keyPrinter_->reset(*myBatch.keys);
+ elementPrinter_->reset(*myBatch.elements);
}
void MapColumnPrinter::printRow(uint64_t rowId) {
@@ -504,34 +504,34 @@ namespace orc {
writeString(buffer, "null");
} else {
writeChar(buffer, '[');
- for (int64_t i = offsets[rowId]; i < offsets[rowId + 1]; ++i) {
- if (i != offsets[rowId]) {
+ for (int64_t i = offsets_[rowId]; i < offsets_[rowId + 1]; ++i) {
+ if (i != offsets_[rowId]) {
writeString(buffer, ", ");
}
writeString(buffer, "{\"key\": ");
- keyPrinter->printRow(static_cast<uint64_t>(i));
+ keyPrinter_->printRow(static_cast<uint64_t>(i));
writeString(buffer, ", \"value\": ");
- elementPrinter->printRow(static_cast<uint64_t>(i));
+ elementPrinter_->printRow(static_cast<uint64_t>(i));
writeChar(buffer, '}');
}
writeChar(buffer, ']');
}
}
- UnionColumnPrinter::UnionColumnPrinter(std::string& _buffer, const Type& type)
- : ColumnPrinter(_buffer), tags(nullptr), offsets(nullptr) {
+ UnionColumnPrinter::UnionColumnPrinter(std::string& buffer, const Type& type)
+ : ColumnPrinter(buffer), tags_(nullptr), offsets_(nullptr) {
for (unsigned int i = 0; i < type.getSubtypeCount(); ++i) {
- fieldPrinter.push_back(createColumnPrinter(buffer, type.getSubtype(i)));
+ fieldPrinter_.push_back(createColumnPrinter(buffer, type.getSubtype(i)));
}
}
void UnionColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
const UnionVectorBatch& unionBatch = dynamic_cast<const UnionVectorBatch&>(batch);
- tags = unionBatch.tags.data();
- offsets = unionBatch.offsets.data();
- for (size_t i = 0; i < fieldPrinter.size(); ++i) {
- fieldPrinter[i]->reset(*(unionBatch.children[i]));
+ tags_ = unionBatch.tags.data();
+ offsets_ = unionBatch.offsets.data();
+ for (size_t i = 0; i < fieldPrinter_.size(); ++i) {
+ fieldPrinter_[i]->reset(*(unionBatch.children[i]));
}
}
@@ -540,27 +540,27 @@ namespace orc {
writeString(buffer, "null");
} else {
writeString(buffer, "{\"tag\": ");
- const auto numBuffer = std::to_string(static_cast<int64_t>(tags[rowId]));
+ const auto numBuffer = std::to_string(static_cast<int64_t>(tags_[rowId]));
writeString(buffer, numBuffer.c_str());
writeString(buffer, ", \"value\": ");
- fieldPrinter[tags[rowId]]->printRow(offsets[rowId]);
+ fieldPrinter_[tags_[rowId]]->printRow(offsets_[rowId]);
writeChar(buffer, '}');
}
}
- StructColumnPrinter::StructColumnPrinter(std::string& _buffer, const Type& type)
- : ColumnPrinter(_buffer) {
+ StructColumnPrinter::StructColumnPrinter(std::string& buffer, const Type& type)
+ : ColumnPrinter(buffer) {
for (unsigned int i = 0; i < type.getSubtypeCount(); ++i) {
- fieldNames.push_back(type.getFieldName(i));
- fieldPrinter.push_back(createColumnPrinter(buffer, type.getSubtype(i)));
+ fieldNames_.push_back(type.getFieldName(i));
+ fieldPrinter_.push_back(createColumnPrinter(buffer, type.getSubtype(i)));
}
}
void StructColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
const StructVectorBatch& structBatch = dynamic_cast<const StructVectorBatch&>(batch);
- for (size_t i = 0; i < fieldPrinter.size(); ++i) {
- fieldPrinter[i]->reset(*(structBatch.fields[i]));
+ for (size_t i = 0; i < fieldPrinter_.size(); ++i) {
+ fieldPrinter_[i]->reset(*(structBatch.fields[i]));
}
}
@@ -569,21 +569,21 @@ namespace orc {
writeString(buffer, "null");
} else {
writeChar(buffer, '{');
- for (unsigned int i = 0; i < fieldPrinter.size(); ++i) {
+ for (unsigned int i = 0; i < fieldPrinter_.size(); ++i) {
if (i != 0) {
writeString(buffer, ", ");
}
writeChar(buffer, '"');
- writeString(buffer, fieldNames[i].c_str());
+ writeString(buffer, fieldNames_[i].c_str());
writeString(buffer, "\": ");
- fieldPrinter[i]->printRow(rowId);
+ fieldPrinter_[i]->printRow(rowId);
}
writeChar(buffer, '}');
}
}
- DateColumnPrinter::DateColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), data(nullptr) {
+ DateColumnPrinter::DateColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), data_(nullptr) {
// PASS
}
@@ -591,7 +591,7 @@ namespace orc {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- const time_t timeValue = data[rowId] * 24 * 60 * 60;
+ const time_t timeValue = data_[rowId] * 24 * 60 * 60;
struct tm tmValue;
gmtime_r(&timeValue, &tmValue);
char timeBuffer[11];
@@ -604,11 +604,11 @@ namespace orc {
void DateColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const LongVectorBatch&>(batch).data.data();
+ data_ = dynamic_cast<const LongVectorBatch&>(batch).data.data();
}
- BooleanColumnPrinter::BooleanColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), data(nullptr) {
+ BooleanColumnPrinter::BooleanColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), data_(nullptr) {
// PASS
}
@@ -616,17 +616,17 @@ namespace orc {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- writeString(buffer, (data[rowId] ? "true" : "false"));
+ writeString(buffer, (data_[rowId] ? "true" : "false"));
}
}
void BooleanColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- data = dynamic_cast<const LongVectorBatch&>(batch).data.data();
+ data_ = dynamic_cast<const LongVectorBatch&>(batch).data.data();
}
- BinaryColumnPrinter::BinaryColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), start(nullptr), length(nullptr) {
+ BinaryColumnPrinter::BinaryColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), start_(nullptr), length_(nullptr) {
// PASS
}
@@ -635,11 +635,11 @@ namespace orc {
writeString(buffer, "null");
} else {
writeChar(buffer, '[');
- for (int64_t i = 0; i < length[rowId]; ++i) {
+ for (int64_t i = 0; i < length_[rowId]; ++i) {
if (i != 0) {
writeString(buffer, ", ");
}
- const auto numBuffer = std::to_string(static_cast<int>(start[rowId][i]) & 0xff);
+ const auto numBuffer = std::to_string(static_cast<int>(start_[rowId][i]) & 0xff);
writeString(buffer, numBuffer.c_str());
}
writeChar(buffer, ']');
@@ -648,12 +648,12 @@ namespace orc {
void BinaryColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
- start = dynamic_cast<const StringVectorBatch&>(batch).data.data();
- length = dynamic_cast<const StringVectorBatch&>(batch).length.data();
+ start_ = dynamic_cast<const StringVectorBatch&>(batch).data.data();
+ length_ = dynamic_cast<const StringVectorBatch&>(batch).length.data();
}
- TimestampColumnPrinter::TimestampColumnPrinter(std::string& _buffer)
- : ColumnPrinter(_buffer), seconds(nullptr), nanoseconds(nullptr) {
+ TimestampColumnPrinter::TimestampColumnPrinter(std::string& buffer)
+ : ColumnPrinter(buffer), seconds_(nullptr), nanoseconds_(nullptr) {
// PASS
}
@@ -662,8 +662,8 @@ namespace orc {
if (hasNulls && !notNull[rowId]) {
writeString(buffer, "null");
} else {
- int64_t nanos = nanoseconds[rowId];
- time_t secs = static_cast<time_t>(seconds[rowId]);
+ int64_t nanos = nanoseconds_[rowId];
+ time_t secs = static_cast<time_t>(seconds_[rowId]);
struct tm tmValue;
gmtime_r(&secs, &tmValue);
char timeBuffer[20];
@@ -694,7 +694,7 @@ namespace orc {
void TimestampColumnPrinter::reset(const ColumnVectorBatch& batch) {
ColumnPrinter::reset(batch);
const TimestampVectorBatch& ts = dynamic_cast<const TimestampVectorBatch&>(batch);
- seconds = ts.data.data();
- nanoseconds = ts.nanoseconds.data();
+ seconds_ = ts.data.data();
+ nanoseconds_ = ts.nanoseconds.data();
}
} // namespace orc
diff --git a/c++/src/ColumnReader.cc b/c++/src/ColumnReader.cc
index e9cd88260..e70f916ff 100644
--- a/c++/src/ColumnReader.cc
+++ b/c++/src/ColumnReader.cc
@@ -138,7 +138,7 @@ namespace orc {
template <typename BatchType>
class BooleanColumnReader : public ColumnReader {
private:
- std::unique_ptr<orc::ByteRleDecoder> rle;
+ std::unique_ptr<orc::ByteRleDecoder> rle_;
public:
BooleanColumnReader(const Type& type, StripeStreams& stipe);
@@ -157,7 +157,7 @@ namespace orc {
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
if (stream == nullptr) throw ParseError("DATA stream not found in Boolean column");
- rle = createBooleanRleDecoder(std::move(stream), metrics);
+ rle_ = createBooleanRleDecoder(std::move(stream), metrics);
}
template <typename BatchType>
@@ -168,7 +168,7 @@ namespace orc {
template <typename BatchType>
uint64_t BooleanColumnReader<BatchType>::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- rle->skip(numValues);
+ rle_->skip(numValues);
return numValues;
}
@@ -180,8 +180,8 @@ namespace orc {
// LongVectorBatch with long*. We cheat here in that case and use the long*
// and then expand it in a second pass..
auto* ptr = dynamic_cast<BatchType&>(rowBatch).data.data();
- rle->next(reinterpret_cast<char*>(ptr), numValues,
- rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr);
+ rle_->next(reinterpret_cast<char*>(ptr), numValues,
+ rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr);
expandBytesToIntegers(ptr, numValues);
}
@@ -189,27 +189,27 @@ namespace orc {
void BooleanColumnReader<BatchType>::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
+ rle_->seek(positions.at(columnId));
}
template <typename BatchType>
class ByteColumnReader : public ColumnReader {
private:
- std::unique_ptr<orc::ByteRleDecoder> rle;
+ std::unique_ptr<orc::ByteRleDecoder> rle_;
public:
ByteColumnReader(const Type& type, StripeStreams& stripe) : ColumnReader(type, stripe) {
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
if (stream == nullptr) throw ParseError("DATA stream not found in Byte column");
- rle = createByteRleDecoder(std::move(stream), metrics);
+ rle_ = createByteRleDecoder(std::move(stream), metrics);
}
~ByteColumnReader() override = default;
uint64_t skip(uint64_t numValues) override {
numValues = ColumnReader::skip(numValues);
- rle->skip(numValues);
+ rle_->skip(numValues);
return numValues;
}
@@ -218,14 +218,14 @@ namespace orc {
// Since the byte rle places the output in a char* instead of long*,
// we cheat here and use the long* and then expand it in a second pass.
auto* ptr = dynamic_cast<BatchType&>(rowBatch).data.data();
- rle->next(reinterpret_cast<char*>(ptr), numValues,
- rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr);
+ rle_->next(reinterpret_cast<char*>(ptr), numValues,
+ rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr);
expandBytesToIntegers(ptr, numValues);
}
void seekToRowGroup(std::unordered_map<uint64_t, PositionProvider>& positions) override {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
+ rle_->seek(positions.at(columnId));
}
};
@@ -267,12 +267,12 @@ namespace orc {
class TimestampColumnReader : public ColumnReader {
private:
- std::unique_ptr<orc::RleDecoder> secondsRle;
- std::unique_ptr<orc::RleDecoder> nanoRle;
- const Timezone* writerTimezone;
- const Timezone* readerTimezone;
- const int64_t epochOffset;
- const bool sameTimezone;
+ std::unique_ptr<orc::RleDecoder> secondsRle_;
+ std::unique_ptr<orc::RleDecoder> nanoRle_;
+ const Timezone* writerTimezone_;
+ const Timezone* readerTimezone_;
+ const int64_t epochOffset_;
+ const bool sameTimezone_;
public:
TimestampColumnReader(const Type& type, StripeStreams& stripe, bool isInstantType);
@@ -288,18 +288,18 @@ namespace orc {
TimestampColumnReader::TimestampColumnReader(const Type& type, StripeStreams& stripe,
bool isInstantType)
: ColumnReader(type, stripe),
- writerTimezone(isInstantType ? &getTimezoneByName("GMT") : &stripe.getWriterTimezone()),
- readerTimezone(isInstantType ? &getTimezoneByName("GMT") : &stripe.getReaderTimezone()),
- epochOffset(writerTimezone->getEpoch()),
- sameTimezone(writerTimezone == readerTimezone) {
+ writerTimezone_(isInstantType ? &getTimezoneByName("GMT") : &stripe.getWriterTimezone()),
+ readerTimezone_(isInstantType ? &getTimezoneByName("GMT") : &stripe.getReaderTimezone()),
+ epochOffset_(writerTimezone_->getEpoch()),
+ sameTimezone_(writerTimezone_ == readerTimezone_) {
RleVersion vers = convertRleVersion(stripe.getEncoding(columnId).kind());
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
if (stream == nullptr) throw ParseError("DATA stream not found in Timestamp column");
- secondsRle = createRleDecoder(std::move(stream), true, vers, memoryPool, metrics);
+ secondsRle_ = createRleDecoder(std::move(stream), true, vers, memoryPool, metrics);
stream = stripe.getStream(columnId, proto::Stream_Kind_SECONDARY, true);
if (stream == nullptr) throw ParseError("SECONDARY stream not found in Timestamp column");
- nanoRle = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
+ nanoRle_ = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
}
TimestampColumnReader::~TimestampColumnReader() {
@@ -308,8 +308,8 @@ namespace orc {
uint64_t TimestampColumnReader::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- secondsRle->skip(numValues);
- nanoRle->skip(numValues);
+ secondsRle_->skip(numValues);
+ nanoRle_->skip(numValues);
return numValues;
}
@@ -318,9 +318,9 @@ namespace orc {
notNull = rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr;
TimestampVectorBatch& timestampBatch = dynamic_cast<TimestampVectorBatch&>(rowBatch);
int64_t* secsBuffer = timestampBatch.data.data();
- secondsRle->next(secsBuffer, numValues, notNull);
+ secondsRle_->next(secsBuffer, numValues, notNull);
int64_t* nanoBuffer = timestampBatch.nanoseconds.data();
- nanoRle->next(nanoBuffer, numValues, notNull);
+ nanoRle_->next(nanoBuffer, numValues, notNull);
// Construct the values
for (uint64_t i = 0; i < numValues; i++) {
@@ -332,17 +332,17 @@ namespace orc {
nanoBuffer[i] *= 10;
}
}
- int64_t writerTime = secsBuffer[i] + epochOffset;
- if (!sameTimezone) {
+ int64_t writerTime = secsBuffer[i] + epochOffset_;
+ if (!sameTimezone_) {
// adjust timestamp value to same wall clock time if writer and reader
// time zones have different rules, which is required for Apache Orc.
- const auto& wv = writerTimezone->getVariant(writerTime);
- const auto& rv = readerTimezone->getVariant(writerTime);
+ const auto& wv = writerTimezone_->getVariant(writerTime);
+ const auto& rv = readerTimezone_->getVariant(writerTime);
if (!wv.hasSameTzRule(rv)) {
// If the timezone adjustment moves the millis across a DST boundary,
// we need to reevaluate the offsets.
int64_t adjustedTime = writerTime + wv.gmtOffset - rv.gmtOffset;
- const auto& adjustedReader = readerTimezone->getVariant(adjustedTime);
+ const auto& adjustedReader = readerTimezone_->getVariant(adjustedTime);
writerTime = writerTime + wv.gmtOffset - adjustedReader.gmtOffset;
}
}
@@ -357,8 +357,8 @@ namespace orc {
void TimestampColumnReader::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- secondsRle->seek(positions.at(columnId));
- nanoRle->seek(positions.at(columnId));
+ secondsRle_->seek(positions.at(columnId));
+ nanoRle_->seek(positions.at(columnId));
}
template <TypeKind columnKind, bool isLittleEndian, typename ValueType, typename BatchType>
@@ -374,39 +374,39 @@ namespace orc {
void seekToRowGroup(std::unordered_map<uint64_t, PositionProvider>& positions) override;
private:
- std::unique_ptr<SeekableInputStream> inputStream;
- const uint64_t bytesPerValue = (columnKind == FLOAT) ? 4 : 8;
- const char* bufferPointer;
- const char* bufferEnd;
+ std::unique_ptr<SeekableInputStream> inputStream_;
+ const uint64_t bytesPerValue_ = (columnKind == FLOAT) ? 4 : 8;
+ const char* bufferPointer_;
+ const char* bufferEnd_;
unsigned char readByte() {
- if (bufferPointer == bufferEnd) {
+ if (bufferPointer_ == bufferEnd_) {
int length;
- if (!inputStream->Next(reinterpret_cast<const void**>(&bufferPointer), &length)) {
+ if (!inputStream_->Next(reinterpret_cast<const void**>(&bufferPointer_), &length)) {
throw ParseError("bad read in DoubleColumnReader::next()");
}
- bufferEnd = bufferPointer + length;
+ bufferEnd_ = bufferPointer_ + length;
}
- return static_cast<unsigned char>(*(bufferPointer++));
+ return static_cast<unsigned char>(*(bufferPointer_++));
}
template <typename FloatType>
FloatType readDouble() {
int64_t bits = 0;
- if (bufferEnd - bufferPointer >= 8) {
+ if (bufferEnd_ - bufferPointer_ >= 8) {
if (isLittleEndian) {
- bits = *(reinterpret_cast<const int64_t*>(bufferPointer));
+ bits = *(reinterpret_cast<const int64_t*>(bufferPointer_));
} else {
- bits = static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[0]));
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[1])) << 8;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[2])) << 16;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[3])) << 24;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[4])) << 32;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[5])) << 40;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[6])) << 48;
- bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[7])) << 56;
+ bits = static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[0]));
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[1])) << 8;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[2])) << 16;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[3])) << 24;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[4])) << 32;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[5])) << 40;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[6])) << 48;
+ bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer_[7])) << 56;
}
- bufferPointer += 8;
+ bufferPointer_ += 8;
} else {
for (uint64_t i = 0; i < 8; i++) {
bits |= static_cast<int64_t>(readByte()) << (i * 8);
@@ -419,16 +419,16 @@ namespace orc {
template <typename FloatType>
FloatType readFloat() {
int32_t bits = 0;
- if (bufferEnd - bufferPointer >= 4) {
+ if (bufferEnd_ - bufferPointer_ >= 4) {
if (isLittleEndian) {
- bits = *(reinterpret_cast<const int32_t*>(bufferPointer));
+ bits = *(reinterpret_cast<const int32_t*>(bufferPointer_));
} else {
- bits = static_cast<unsigned char>(bufferPointer[0]);
- bits |= static_cast<unsigned char>(bufferPointer[1]) << 8;
- bits |= static_cast<unsigned char>(bufferPointer[2]) << 16;
- bits |= static_cast<unsigned char>(bufferPointer[3]) << 24;
+ bits = static_cast<unsigned char>(bufferPointer_[0]);
+ bits |= static_cast<unsigned char>(bufferPointer_[1]) << 8;
+ bits |= static_cast<unsigned char>(bufferPointer_[2]) << 16;
+ bits |= static_cast<unsigned char>(bufferPointer_[3]) << 24;
}
- bufferPointer += 4;
+ bufferPointer_ += 4;
} else {
for (uint64_t i = 0; i < 4; i++) {
bits |= readByte() << (i * 8);
@@ -445,9 +445,9 @@ namespace orc {
template <TypeKind columnKind, bool isLittleEndian, typename ValueType, typename BatchType>
DoubleColumnReader<columnKind, isLittleEndian, ValueType, BatchType>::DoubleColumnReader(
const Type& type, StripeStreams& stripe)
- : ColumnReader(type, stripe), bufferPointer(nullptr), bufferEnd(nullptr) {
- inputStream = stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
- if (inputStream == nullptr) throw ParseError("DATA stream not found in Double column");
+ : ColumnReader(type, stripe), bufferPointer_(nullptr), bufferEnd_(nullptr) {
+ inputStream_ = stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
+ if (inputStream_ == nullptr) throw ParseError("DATA stream not found in Double column");
}
template <TypeKind columnKind, bool isLittleEndian, typename ValueType, typename BatchType>
@@ -455,19 +455,19 @@ namespace orc {
uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- if (static_cast<size_t>(bufferEnd - bufferPointer) >= bytesPerValue * numValues) {
- bufferPointer += bytesPerValue * numValues;
+ if (static_cast<size_t>(bufferEnd_ - bufferPointer_) >= bytesPerValue_ * numValues) {
+ bufferPointer_ += bytesPerValue_ * numValues;
} else {
size_t sizeToSkip =
- bytesPerValue * numValues - static_cast<size_t>(bufferEnd - bufferPointer);
+ bytesPerValue_ * numValues - static_cast<size_t>(bufferEnd_ - bufferPointer_);
const size_t cap = static_cast<size_t>(std::numeric_limits<int>::max());
while (sizeToSkip != 0) {
size_t step = sizeToSkip > cap ? cap : sizeToSkip;
- inputStream->Skip(static_cast<int>(step));
+ inputStream_->Skip(static_cast<int>(step));
sizeToSkip -= step;
}
- bufferEnd = nullptr;
- bufferPointer = nullptr;
+ bufferEnd_ = nullptr;
+ bufferPointer_ = nullptr;
}
return numValues;
@@ -506,11 +506,11 @@ namespace orc {
// Only viable when the machine is little-endian.
uint64_t bufferNum = 0;
if (isLittleEndian) {
- bufferNum =
- std::min(numValues, static_cast<size_t>(bufferEnd - bufferPointer) / bytesPerValue);
- uint64_t bufferBytes = bufferNum * bytesPerValue;
- memcpy(outArray, bufferPointer, bufferBytes);
- bufferPointer += bufferBytes;
+ bufferNum = std::min(numValues,
+ static_cast<size_t>(bufferEnd_ - bufferPointer_) / bytesPerValue_);
+ uint64_t bufferBytes = bufferNum * bytesPerValue_;
+ memcpy(outArray, bufferPointer_, bufferBytes);
+ bufferPointer_ += bufferBytes;
}
for (size_t i = bufferNum; i < numValues; ++i) {
outArray[i] = readDouble<ValueType>();
@@ -523,10 +523,10 @@ namespace orc {
void DoubleColumnReader<columnKind, isLittleEndian, ValueType, BatchType>::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- inputStream->seek(positions.at(columnId));
+ inputStream_->seek(positions.at(columnId));
// clear buffer state after seek
- bufferEnd = nullptr;
- bufferPointer = nullptr;
+ bufferEnd_ = nullptr;
+ bufferPointer_ = nullptr;
}
void readFully(char* buffer, int64_t bufferSize, SeekableInputStream* stream) {
@@ -547,8 +547,8 @@ namespace orc {
class StringDictionaryColumnReader : public ColumnReader {
private:
- std::shared_ptr<StringDictionary> dictionary;
- std::unique_ptr<RleDecoder> rle;
+ std::shared_ptr<StringDictionary> dictionary_;
+ std::unique_ptr<RleDecoder> rle_;
public:
StringDictionaryColumnReader(const Type& type, StripeStreams& stipe);
@@ -565,7 +565,7 @@ namespace orc {
StringDictionaryColumnReader::StringDictionaryColumnReader(const Type& type,
StripeStreams& stripe)
- : ColumnReader(type, stripe), dictionary(new StringDictionary(stripe.getMemoryPool())) {
+ : ColumnReader(type, stripe), dictionary_(new StringDictionary(stripe.getMemoryPool())) {
RleVersion rleVersion = convertRleVersion(stripe.getEncoding(columnId).kind());
uint32_t dictSize = stripe.getEncoding(columnId).dictionary_size();
std::unique_ptr<SeekableInputStream> stream =
@@ -573,15 +573,15 @@ namespace orc {
if (stream == nullptr) {
throw ParseError("DATA stream not found in StringDictionaryColumn");
}
- rle = createRleDecoder(std::move(stream), false, rleVersion, memoryPool, metrics);
+ rle_ = createRleDecoder(std::move(stream), false, rleVersion, memoryPool, metrics);
stream = stripe.getStream(columnId, proto::Stream_Kind_LENGTH, false);
if (dictSize > 0 && stream == nullptr) {
throw ParseError("LENGTH stream not found in StringDictionaryColumn");
}
std::unique_ptr<RleDecoder> lengthDecoder =
createRleDecoder(std::move(stream), false, rleVersion, memoryPool, metrics);
- dictionary->dictionaryOffset.resize(dictSize + 1);
- int64_t* lengthArray = dictionary->dictionaryOffset.data();
+ dictionary_->dictionaryOffset.resize(dictSize + 1);
+ int64_t* lengthArray = dictionary_->dictionaryOffset.data();
lengthDecoder->next(lengthArray + 1, dictSize, nullptr);
lengthArray[0] = 0;
for (uint32_t i = 1; i < dictSize + 1; ++i) {
@@ -591,13 +591,13 @@ namespace orc {
lengthArray[i] += lengthArray[i - 1];
}
int64_t blobSize = lengthArray[dictSize];
- dictionary->dictionaryBlob.resize(static_cast<uint64_t>(blobSize));
+ dictionary_->dictionaryBlob.resize(static_cast<uint64_t>(blobSize));
std::unique_ptr<SeekableInputStream> blobStream =
stripe.getStream(columnId, proto::Stream_Kind_DICTIONARY_DATA, false);
if (blobSize > 0 && blobStream == nullptr) {
throw ParseError("DICTIONARY_DATA stream not found in StringDictionaryColumn");
}
- readFully(dictionary->dictionaryBlob.data(), blobSize, blobStream.get());
+ readFully(dictionary_->dictionaryBlob.data(), blobSize, blobStream.get());
}
StringDictionaryColumnReader::~StringDictionaryColumnReader() {
@@ -606,7 +606,7 @@ namespace orc {
uint64_t StringDictionaryColumnReader::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- rle->skip(numValues);
+ rle_->skip(numValues);
return numValues;
}
@@ -616,12 +616,12 @@ namespace orc {
// update the notNull from the parent class
notNull = rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr;
StringVectorBatch& byteBatch = dynamic_cast<StringVectorBatch&>(rowBatch);
- char* blob = dictionary->dictionaryBlob.data();
- int64_t* dictionaryOffsets = dictionary->dictionaryOffset.data();
+ char* blob = dictionary_->dictionaryBlob.data();
+ int64_t* dictionaryOffsets = dictionary_->dictionaryOffset.data();
char** outputStarts = byteBatch.data.data();
int64_t* outputLengths = byteBatch.length.data();
- rle->next(outputLengths, numValues, notNull);
- uint64_t dictionaryCount = dictionary->dictionaryOffset.size() - 1;
+ rle_->next(outputLengths, numValues, notNull);
+ uint64_t dictionaryCount = dictionary_->dictionaryOffset.size() - 1;
if (notNull) {
for (uint64_t i = 0; i < numValues; ++i) {
if (notNull[i]) {
@@ -652,24 +652,24 @@ namespace orc {
rowBatch.isEncoded = true;
EncodedStringVectorBatch& batch = dynamic_cast<EncodedStringVectorBatch&>(rowBatch);
- batch.dictionary = this->dictionary;
+ batch.dictionary = this->dictionary_;
// Length buffer is reused to save dictionary entry ids
- rle->next(batch.index.data(), numValues, notNull);
+ rle_->next(batch.index.data(), numValues, notNull);
}
void StringDictionaryColumnReader::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
+ rle_->seek(positions.at(columnId));
}
class StringDirectColumnReader : public ColumnReader {
private:
- std::unique_ptr<RleDecoder> lengthRle;
- std::unique_ptr<SeekableInputStream> blobStream;
- const char* lastBuffer;
- size_t lastBufferLength;
+ std::unique_ptr<RleDecoder> lengthRle_;
+ std::unique_ptr<SeekableInputStream> blobStream_;
+ const char* lastBuffer_;
+ size_t lastBufferLength_;
/**
* Compute the total length of the values.
@@ -697,11 +697,11 @@ namespace orc {
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_LENGTH, true);
if (stream == nullptr) throw ParseError("LENGTH stream not found in StringDirectColumn");
- lengthRle = createRleDecoder(std::move(stream), false, rleVersion, memoryPool, metrics);
- blobStream = stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
- if (blobStream == nullptr) throw ParseError("DATA stream not found in StringDirectColumn");
- lastBuffer = nullptr;
- lastBufferLength = 0;
+ lengthRle_ = createRleDecoder(std::move(stream), false, rleVersion, memoryPool, metrics);
+ blobStream_ = stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
+ if (blobStream_ == nullptr) throw ParseError("DATA stream not found in StringDirectColumn");
+ lastBuffer_ = nullptr;
+ lastBufferLength_ = 0;
}
StringDirectColumnReader::~StringDirectColumnReader() {
@@ -717,25 +717,25 @@ namespace orc {
// read the lengths, so we know haw many bytes to skip
while (done < numValues) {
uint64_t step = std::min(BUFFER_SIZE, static_cast<size_t>(numValues - done));
- lengthRle->next(buffer, step, nullptr);
+ lengthRle_->next(buffer, step, nullptr);
totalBytes += computeSize(buffer, nullptr, step);
done += step;
}
- if (totalBytes <= lastBufferLength) {
+ if (totalBytes <= lastBufferLength_) {
// subtract the needed bytes from the ones left over
- lastBufferLength -= totalBytes;
- lastBuffer += totalBytes;
+ lastBufferLength_ -= totalBytes;
+ lastBuffer_ += totalBytes;
} else {
// move the stream forward after accounting for the buffered bytes
- totalBytes -= lastBufferLength;
+ totalBytes -= lastBufferLength_;
const size_t cap = static_cast<size_t>(std::numeric_limits<int>::max());
while (totalBytes != 0) {
size_t step = totalBytes > cap ? cap : totalBytes;
- blobStream->Skip(static_cast<int>(step));
+ blobStream_->Skip(static_cast<int>(step));
totalBytes -= step;
}
- lastBufferLength = 0;
- lastBuffer = nullptr;
+ lastBufferLength_ = 0;
+ lastBuffer_ = nullptr;
}
return numValues;
}
@@ -767,7 +767,7 @@ namespace orc {
int64_t* lengthPtr = byteBatch.length.data();
// read the length vector
- lengthRle->next(lengthPtr, numValues, notNull);
+ lengthRle_->next(lengthPtr, numValues, notNull);
// figure out the total length of data we need from the blob stream
const size_t totalLength = computeSize(lengthPtr, notNull, numValues);
@@ -777,23 +777,23 @@ namespace orc {
size_t bytesBuffered = 0;
byteBatch.blob.resize(totalLength);
char* ptr = byteBatch.blob.data();
- while (bytesBuffered + lastBufferLength < totalLength) {
- memcpy(ptr + bytesBuffered, lastBuffer, lastBufferLength);
- bytesBuffered += lastBufferLength;
+ while (bytesBuffered + lastBufferLength_ < totalLength) {
+ memcpy(ptr + bytesBuffered, lastBuffer_, lastBufferLength_);
+ bytesBuffered += lastBufferLength_;
const void* readBuffer;
int readLength;
- if (!blobStream->Next(&readBuffer, &readLength)) {
+ if (!blobStream_->Next(&readBuffer, &readLength)) {
throw ParseError("failed to read in StringDirectColumnReader.next");
}
- lastBuffer = static_cast<const char*>(readBuffer);
- lastBufferLength = static_cast<size_t>(readLength);
+ lastBuffer_ = static_cast<const char*>(readBuffer);
+ lastBufferLength_ = static_cast<size_t>(readLength);
}
if (bytesBuffered < totalLength) {
size_t moreBytes = totalLength - bytesBuffered;
- memcpy(ptr + bytesBuffered, lastBuffer, moreBytes);
- lastBuffer += moreBytes;
- lastBufferLength -= moreBytes;
+ memcpy(ptr + bytesBuffered, lastBuffer_, moreBytes);
+ lastBuffer_ += moreBytes;
+ lastBufferLength_ -= moreBytes;
}
size_t filledSlots = 0;
@@ -818,16 +818,16 @@ namespace orc {
void StringDirectColumnReader::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- blobStream->seek(positions.at(columnId));
- lengthRle->seek(positions.at(columnId));
+ blobStream_->seek(positions.at(columnId));
+ lengthRle_->seek(positions.at(columnId));
// clear buffer state after seek
- lastBuffer = nullptr;
- lastBufferLength = 0;
+ lastBuffer_ = nullptr;
+ lastBufferLength_ = 0;
}
class StructColumnReader : public ColumnReader {
private:
- std::vector<std::unique_ptr<ColumnReader>> children;
+ std::vector<std::unique_ptr<ColumnReader>> children_;
public:
StructColumnReader(const Type& type, StripeStreams& stripe, bool useTightNumericVector = false,
@@ -857,7 +857,7 @@ namespace orc {
for (unsigned int i = 0; i < type.getSubtypeCount(); ++i) {
const Type& child = *type.getSubtype(i);
if (selectedColumns[static_cast<uint64_t>(child.getColumnId())]) {
- children.push_back(
+ children_.push_back(
buildReader(child, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow));
}
}
@@ -872,7 +872,7 @@ namespace orc {
uint64_t StructColumnReader::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- for (auto& ptr : children) {
+ for (auto& ptr : children_) {
ptr->skip(numValues);
}
return numValues;
@@ -893,7 +893,7 @@ namespace orc {
ColumnReader::next(rowBatch, numValues, notNull);
uint64_t i = 0;
notNull = rowBatch.hasNulls ? rowBatch.notNull.data() : nullptr;
- for (auto iter = children.begin(); iter != children.end(); ++iter, ++i) {
+ for (auto iter = children_.begin(); iter != children_.end(); ++iter, ++i) {
if (encoded) {
(*iter)->nextEncoded(*(dynamic_cast<StructVectorBatch&>(rowBatch).fields[i]), numValues,
notNull);
@@ -907,15 +907,15 @@ namespace orc {
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- for (auto& ptr : children) {
+ for (auto& ptr : children_) {
ptr->seekToRowGroup(positions);
}
}
class ListColumnReader : public ColumnReader {
private:
- std::unique_ptr<ColumnReader> child;
- std::unique_ptr<RleDecoder> rle;
+ std::unique_ptr<ColumnReader> child_;
+ std::unique_ptr<RleDecoder> rle_;
public:
ListColumnReader(const Type& type, StripeStreams& stipe, bool useTightNumericVector = false,
@@ -945,10 +945,11 @@ namespace orc {
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_LENGTH, true);
if (stream == nullptr) throw ParseError("LENGTH stream not found in List column");
- rle = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
+ rle_ = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
const Type& childType = *type.getSubtype(0);
if (selectedColumns[static_cast<uint64_t>(childType.getColumnId())]) {
- child = buildReader(childType, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow);
+ child_ =
+ buildReader(childType, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow);
}
}
@@ -958,7 +959,7 @@ namespace orc {
uint64_t ListColumnReader::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- ColumnReader* childReader = child.get();
+ ColumnReader* childReader = child_.get();
if (childReader) {
const uint64_t BUFFER_SIZE = 1024;
int64_t buffer[BUFFER_SIZE];
@@ -966,7 +967,7 @@ namespace orc {
uint64_t lengthsRead = 0;
while (lengthsRead < numValues) {
uint64_t chunk = std::min(numValues - lengthsRead, BUFFER_SIZE);
- rle->next(buffer, chunk, nullptr);
+ rle_->next(buffer, chunk, nullptr);
for (size_t i = 0; i < chunk; ++i) {
childrenElements += static_cast<size_t>(buffer[i]);
}
@@ -974,7 +975,7 @@ namespace orc {
}
childReader->skip(childrenElements);
} else {
- rle->skip(numValues);
+ rle_->skip(numValues);
}
return numValues;
}
@@ -995,7 +996,7 @@ namespace orc {
ListVectorBatch& listBatch = dynamic_cast<ListVectorBatch&>(rowBatch);
int64_t* offsets = listBatch.offsets.data();
notNull = listBatch.hasNulls ? listBatch.notNull.data() : nullptr;
- rle->next(offsets, numValues, notNull);
+ rle_->next(offsets, numValues, notNull);
uint64_t totalChildren = 0;
if (notNull) {
for (size_t i = 0; i < numValues; ++i) {
@@ -1015,7 +1016,7 @@ namespace orc {
}
}
offsets[numValues] = static_cast<int64_t>(totalChildren);
- ColumnReader* childReader = child.get();
+ ColumnReader* childReader = child_.get();
if (childReader) {
if (encoded) {
childReader->nextEncoded(*(listBatch.elements.get()), totalChildren, nullptr);
@@ -1027,17 +1028,17 @@ namespace orc {
void ListColumnReader::seekToRowGroup(std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
- if (child.get()) {
- child->seekToRowGroup(positions);
+ rle_->seek(positions.at(columnId));
+ if (child_.get()) {
+ child_->seekToRowGroup(positions);
}
}
class MapColumnReader : public ColumnReader {
private:
- std::unique_ptr<ColumnReader> keyReader;
- std::unique_ptr<ColumnReader> elementReader;
- std::unique_ptr<RleDecoder> rle;
+ std::unique_ptr<ColumnReader> keyReader_;
+ std::unique_ptr<ColumnReader> elementReader_;
+ std::unique_ptr<RleDecoder> rle_;
public:
MapColumnReader(const Type& type, StripeStreams& stipe, bool useTightNumericVector = false,
@@ -1066,15 +1067,15 @@ namespace orc {
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_LENGTH, true);
if (stream == nullptr) throw ParseError("LENGTH stream not found in Map column");
- rle = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
+ rle_ = createRleDecoder(std::move(stream), false, vers, memoryPool, metrics);
const Type& keyType = *type.getSubtype(0);
if (selectedColumns[static_cast<uint64_t>(keyType.getColumnId())]) {
- keyReader =
+ keyReader_ =
buildReader(keyType, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow);
}
const Type& elementType = *type.getSubtype(1);
if (selectedColumns[static_cast<uint64_t>(elementType.getColumnId())]) {
- elementReader =
+ elementReader_ =
buildReader(elementType, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow);
}
}
@@ -1085,8 +1086,8 @@ namespace orc {
uint64_t MapColumnReader::skip(uint64_t numValues) {
numValues = ColumnReader::skip(numValues);
- ColumnReader* rawKeyReader = keyReader.get();
- ColumnReader* rawElementReader = elementReader.get();
+ ColumnReader* rawKeyReader = keyReader_.get();
+ ColumnReader* rawElementReader = elementReader_.get();
if (rawKeyReader || rawElementReader) {
const uint64_t BUFFER_SIZE = 1024;
int64_t buffer[BUFFER_SIZE];
@@ -1094,7 +1095,7 @@ namespace orc {
uint64_t lengthsRead = 0;
while (lengthsRead < numValues) {
uint64_t chunk = std::min(numValues - lengthsRead, BUFFER_SIZE);
- rle->next(buffer, chunk, nullptr);
+ rle_->next(buffer, chunk, nullptr);
for (size_t i = 0; i < chunk; ++i) {
childrenElements += static_cast<size_t>(buffer[i]);
}
@@ -1107,7 +1108,7 @@ namespace orc {
rawElementReader->skip(childrenElements);
}
} else {
- rle->skip(numValues);
+ rle_->skip(numValues);
}
return numValues;
}
@@ -1128,7 +1129,7 @@ namespace orc {
MapVectorBatch& mapBatch = dynamic_cast<MapVectorBatch&>(rowBatch);
int64_t* offsets = mapBatch.offsets.data();
notNull = mapBatch.hasNulls ? mapBatch.notNull.data() : nullptr;
- rle->next(offsets, numValues, notNull);
+ rle_->next(offsets, numValues, notNull);
uint64_t totalChildren = 0;
if (notNull) {
for (size_t i = 0; i < numValues; ++i) {
@@ -1148,7 +1149,7 @@ namespace orc {
}
}
offsets[numValues] = static_cast<int64_t>(totalChildren);
- ColumnReader* rawKeyReader = keyReader.get();
+ ColumnReader* rawKeyReader = keyReader_.get();
if (rawKeyReader) {
if (encoded) {
rawKeyReader->nextEncoded(*(mapBatch.keys.get()), totalChildren, nullptr);
@@ -1156,7 +1157,7 @@ namespace orc {
rawKeyReader->next(*(mapBatch.keys.get()), totalChildren, nullptr);
}
}
- ColumnReader* rawElementReader = elementReader.get();
+ ColumnReader* rawElementReader = elementReader_.get();
if (rawElementReader) {
if (encoded) {
rawElementReader->nextEncoded(*(mapBatch.elements.get()), totalChildren, nullptr);
@@ -1168,21 +1169,21 @@ namespace orc {
void MapColumnReader::seekToRowGroup(std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
- if (keyReader.get()) {
- keyReader->seekToRowGroup(positions);
+ rle_->seek(positions.at(columnId));
+ if (keyReader_.get()) {
+ keyReader_->seekToRowGroup(positions);
}
- if (elementReader.get()) {
- elementReader->seekToRowGroup(positions);
+ if (elementReader_.get()) {
+ elementReader_->seekToRowGroup(positions);
}
}
class UnionColumnReader : public ColumnReader {
private:
- std::unique_ptr<ByteRleDecoder> rle;
- std::vector<std::unique_ptr<ColumnReader>> childrenReader;
- std::vector<int64_t> childrenCounts;
- uint64_t numChildren;
+ std::unique_ptr<ByteRleDecoder> rle_;
+ std::vector<std::unique_ptr<ColumnReader>> childrenReader_;
+ std::vector<int64_t> childrenCounts_;
+ uint64_t numChildren_;
public:
UnionColumnReader(const Type& type, StripeStreams& stipe, bool useTightNumericVector = false,
@@ -1205,20 +1206,20 @@ namespace orc {
bool useTightNumericVector,
bool throwOnSchemaEvolutionOverflow)
: ColumnReader(type, stripe) {
- numChildren = type.getSubtypeCount();
- childrenReader.resize(numChildren);
- childrenCounts.resize(numChildren);
+ numChildren_ = type.getSubtypeCount();
+ childrenReader_.resize(numChildren_);
+ childrenCounts_.resize(numChildren_);
std::unique_ptr<SeekableInputStream> stream =
stripe.getStream(columnId, proto::Stream_Kind_DATA, true);
if (stream == nullptr) throw ParseError("LENGTH stream not found in Union column");
- rle = createByteRleDecoder(std::move(stream), metrics);
+ rle_ = createByteRleDecoder(std::move(stream), metrics);
// figure out which types are selected
const std::vector<bool> selectedColumns = stripe.getSelectedColumns();
- for (unsigned int i = 0; i < numChildren; ++i) {
+ for (unsigned int i = 0; i < numChildren_; ++i) {
const Type& child = *type.getSubtype(i);
if (selectedColumns[static_cast<size_t>(child.getColumnId())]) {
- childrenReader[i] =
+ childrenReader_[i] =
buildReader(child, stripe, useTightNumericVector, throwOnSchemaEvolutionOverflow);
}
}
@@ -1229,19 +1230,19 @@ namespace orc {
const uint64_t BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
uint64_t lengthsRead = 0;
- int64_t* counts = childrenCounts.data();
- memset(counts, 0, sizeof(int64_t) * numChildren);
+ int64_t* counts = childrenCounts_.data();
+ memset(counts, 0, sizeof(int64_t) * numChildren_);
while (lengthsRead < numValues) {
uint64_t chunk = std::min(numValues - lengthsRead, BUFFER_SIZE);
- rle->next(buffer, chunk, nullptr);
+ rle_->next(buffer, chunk, nullptr);
for (size_t i = 0; i < chunk; ++i) {
counts[static_cast<size_t>(buffer[i])] += 1;
}
lengthsRead += chunk;
}
- for (size_t i = 0; i < numChildren; ++i) {
- if (counts[i] != 0 && childrenReader[i] != nullptr) {
- childrenReader[i]->skip(static_cast<uint64_t>(counts[i]));
+ for (size_t i = 0; i < numChildren_; ++i) {
+ if (counts[i] != 0 && childrenReader_[i] != nullptr) {
+ childrenReader_[i]->skip(static_cast<uint64_t>(counts[i]));
}
}
return numValues;
@@ -1262,11 +1263,11 @@ namespace orc {
ColumnReader::next(rowBatch, numValues, notNull);
UnionVectorBatch& unionBatch = dynamic_cast<UnionVectorBatch&>(rowBatch);
uint64_t* offsets = unionBatch.offsets.data();
- int64_t* counts = childrenCounts.data();
- memset(counts, 0, sizeof(int64_t) * numChildren);
+ int64_t* counts = childrenCounts_.data();
+ memset(counts, 0, sizeof(int64_t) * numChildren_);
unsigned char* tags = unionBatch.tags.data();
notNull = unionBatch.hasNulls ? unionBatch.notNull.data() : nullptr;
- rle->next(reinterpret_cast<char*>(tags), numValues, notNull);
+ rle_->next(reinterpret_cast<char*>(tags), numValues, notNull);
// set the offsets for each row
if (notNull) {
for (size_t i = 0; i < numValues; ++i) {
@@ -1280,14 +1281,14 @@ namespace orc {
}
}
// read the right number of each child column
- for (size_t i = 0; i < numChildren; ++i) {
- if (childrenReader[i] != nullptr) {
+ for (size_t i = 0; i < numChildren_; ++i) {
+ if (childrenReader_[i] != nullptr) {
if (encoded) {
- childrenReader[i]->nextEncoded(*(unionBatch.children[i]),
- static_cast<uint64_t>(counts[i]), nullptr);
+ childrenReader_[i]->nextEncoded(*(unionBatch.children[i]),
+ static_cast<uint64_t>(counts[i]), nullptr);
} else {
- childrenReader[i]->next(*(unionBatch.children[i]), static_cast<uint64_t>(counts[i]),
- nullptr);
+ childrenReader_[i]->next(*(unionBatch.children[i]), static_cast<uint64_t>(counts[i]),
+ nullptr);
}
}
}
@@ -1296,10 +1297,10 @@ namespace orc {
void UnionColumnReader::seekToRowGroup(
std::unordered_map<uint64_t, PositionProvider>& positions) {
ColumnReader::seekToRowGroup(positions);
- rle->seek(positions.at(columnId));
- for (size_t i = 0; i < numChildren; ++i) {
- if (childrenReader[i] != nullptr) {
- childrenReader[i]->seekToRowGroup(positions);
+ rle_->seek(positions.at(columnId));
+ for (size_t i = 0; i < numChildren_; ++i) {
+ if (childrenReader_[i] != nullptr) {
+ childrenReader_[i]->seekToRowGroup(positions);
}
}
}
@@ -1597,8 +1598,8 @@ namespace orc {
class DecimalHive11ColumnReader : public Decimal64ColumnReader {
private:
- bool throwOnOverflow;
- std::ostream* errorStream;
+ bool throwOnOverflow_;
+ std::ostream* errorStream_;
/**
* Read an Int128 from the stream and correct it to the desired scale.
@@ -1647,8 +1648,8 @@ namespace orc {
DecimalHive11ColumnReader::DecimalHive11ColumnReader(const Type& type, StripeStreams& stripe)
: Decimal64ColumnReader(type, stripe) {
scale = stripe.getForcedScaleOnHive11Decimal();
- throwOnOverflow = stripe.getThrowOnHive11DecimalOverflow();
- errorStream = stripe.getErrorStream();
+ throwOnOverflow_ = stripe.getThrowOnHive11DecimalOverflow();
+ errorStream_ = stripe.getErrorStream();
}
DecimalHive11ColumnReader::~DecimalHive11ColumnReader() {
@@ -1672,12 +1673,12 @@ namespace orc {
for (size_t i = 0; i < numValues; ++i) {
if (notNull[i]) {
if (!readInt128(values[i], static_cast<int32_t>(scaleBuffer[i]))) {
- if (throwOnOverflow) {
+ if (throwOnOverflow_) {
throw ParseError("Hive 0.11 decimal was more than 38 digits.");
} else {
- *errorStream << "Warning: "
- << "Hive 0.11 decimal with more than 38 digits "
- << "replaced by NULL.\n";
+ *errorStream_ << "Warning: "
+ << "Hive 0.11 decimal with more than 38 digits "
+ << "replaced by NULL.\n";
notNull[i] = false;
}
}
@@ -1686,12 +1687,12 @@ namespace orc {
} else {
for (size_t i = 0; i < numValues; ++i) {
if (!readInt128(values[i], static_cast<int32_t>(scaleBuffer[i]))) {
- if (throwOnOverflow) {
+ if (throwOnOverflow_) {
throw ParseError("Hive 0.11 decimal was more than 38 digits.");
} else {
- *errorStream << "Warning: "
- << "Hive 0.11 decimal with more than 38 digits "
- << "replaced by NULL.\n";
+ *errorStream_ << "Warning: "
+ << "Hive 0.11 decimal with more than 38 digits "
+ << "replaced by NULL.\n";
batch.hasNulls = true;
batch.notNull[i] = false;
}
diff --git a/c++/src/ColumnWriter.cc b/c++/src/ColumnWriter.cc
index f24be1f0b..86e30ce90 100644
--- a/c++/src/ColumnWriter.cc
+++ b/c++/src/ColumnWriter.cc
@@ -33,24 +33,25 @@ namespace orc {
class StreamsFactoryImpl : public StreamsFactory {
public:
StreamsFactoryImpl(const WriterOptions& writerOptions, OutputStream* outputStream)
- : options(writerOptions), outStream(outputStream) {}
+ : options_(writerOptions), outStream_(outputStream) {}
virtual std::unique_ptr<BufferedOutputStream> createStream(
proto::Stream_Kind kind) const override;
private:
- const WriterOptions& options;
- OutputStream* outStream;
+ const WriterOptions& options_;
+ OutputStream* outStream_;
};
std::unique_ptr<BufferedOutputStream> StreamsFactoryImpl::createStream(proto::Stream_Kind) const {
// In the future, we can decide compression strategy and modifier
// based on stream kind. But for now we just use the setting from
// WriterOption
- return createCompressor(options.getCompression(), outStream, options.getCompressionStrategy(),
+ return createCompressor(options_.getCompression(), outStream_,
+ options_.getCompressionStrategy(),
// BufferedOutputStream initial capacity
- options.getOutputBufferCapacity(), options.getCompressionBlockSize(),
- *options.getMemoryPool(), options.getWriterMetrics());
+ options_.getOutputBufferCapacity(), options_.getCompressionBlockSize(),
+ *options_.getMemoryPool(), options_.getWriterMetrics());
}
std::unique_ptr<StreamsFactory> createStreamsFactory(const WriterOptions& options,
@@ -282,7 +283,7 @@ namespace orc {
virtual void reset() override;
private:
- std::vector<std::unique_ptr<ColumnWriter>> children;
+ std::vector<std::unique_ptr<ColumnWriter>> children_;
};
StructColumnWriter::StructColumnWriter(const Type& type, const StreamsFactory& factory,
@@ -290,7 +291,7 @@ namespace orc {
: ColumnWriter(type, factory, options) {
for (unsigned int i = 0; i < type.getSubtypeCount(); ++i) {
const Type& child = *type.getSubtype(i);
- children.push_back(buildWriter(child, factory, options));
+ children_.push_back(buildWriter(child, factory, options));
}
if (enableIndex) {
@@ -307,8 +308,8 @@ namespace orc {
ColumnWriter::add(rowBatch, offset, numValues, incomingMask);
const char* notNull = structBatch->hasNulls ? structBatch->notNull.data() + offset : nullptr;
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->add(*structBatch->fields[i], offset, numValues, notNull);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->add(*structBatch->fields[i], offset, numValues, notNull);
}
// update stats
@@ -330,22 +331,22 @@ namespace orc {
void StructColumnWriter::flush(std::vector<proto::Stream>& streams) {
ColumnWriter::flush(streams);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->flush(streams);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->flush(streams);
}
}
void StructColumnWriter::writeIndex(std::vector<proto::Stream>& streams) const {
ColumnWriter::writeIndex(streams);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->writeIndex(streams);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->writeIndex(streams);
}
}
uint64_t StructColumnWriter::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- for (uint32_t i = 0; i < children.size(); ++i) {
- size += children[i]->getEstimatedSize();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ size += children_[i]->getEstimatedSize();
}
return size;
}
@@ -355,62 +356,62 @@ namespace orc {
encoding.set_kind(proto::ColumnEncoding_Kind_DIRECT);
encoding.set_dictionary_size(0);
encodings.push_back(encoding);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getColumnEncoding(encodings);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getColumnEncoding(encodings);
}
}
void StructColumnWriter::getStripeStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getStripeStatistics(stats);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getStripeStatistics(stats);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getStripeStatistics(stats);
}
}
void StructColumnWriter::mergeStripeStatsIntoFileStats() {
ColumnWriter::mergeStripeStatsIntoFileStats();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->mergeStripeStatsIntoFileStats();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->mergeStripeStatsIntoFileStats();
}
}
void StructColumnWriter::getFileStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getFileStatistics(stats);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getFileStatistics(stats);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getFileStatistics(stats);
}
}
void StructColumnWriter::mergeRowGroupStatsIntoStripeStats() {
ColumnWriter::mergeRowGroupStatsIntoStripeStats();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->mergeRowGroupStatsIntoStripeStats();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->mergeRowGroupStatsIntoStripeStats();
}
}
void StructColumnWriter::createRowIndexEntry() {
ColumnWriter::createRowIndexEntry();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->createRowIndexEntry();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->createRowIndexEntry();
}
}
void StructColumnWriter::reset() {
ColumnWriter::reset();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->reset();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->reset();
}
}
void StructColumnWriter::writeDictionary() {
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->writeDictionary();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->writeDictionary();
}
}
@@ -435,17 +436,17 @@ namespace orc {
std::unique_ptr<RleEncoder> rleEncoder;
private:
- RleVersion rleVersion;
+ RleVersion rleVersion_;
};
template <typename BatchType>
IntegerColumnWriter<BatchType>::IntegerColumnWriter(const Type& type,
const StreamsFactory& factory,
const WriterOptions& options)
- : ColumnWriter(type, factory, options), rleVersion(options.getRleVersion()) {
+ : ColumnWriter(type, factory, options), rleVersion_(options.getRleVersion()) {
std::unique_ptr<BufferedOutputStream> dataStream =
factory.createStream(proto::Stream_Kind_DATA);
- rleEncoder = createRleEncoder(std::move(dataStream), true, rleVersion, memPool,
+ rleEncoder = createRleEncoder(std::move(dataStream), true, rleVersion_, memPool,
options.getAlignedBitpacking());
if (enableIndex) {
@@ -512,7 +513,7 @@ namespace orc {
void IntegerColumnWriter<BatchType>::getColumnEncoding(
std::vector<proto::ColumnEncoding>& encodings) const {
proto::ColumnEncoding encoding;
- encoding.set_kind(RleVersionMapper(rleVersion));
+ encoding.set_kind(RleVersionMapper(rleVersion_));
encoding.set_dictionary_size(0);
if (enableBloomFilter) {
encoding.set_bloom_encoding(BloomFilterVersion::UTF8);
@@ -543,7 +544,7 @@ namespace orc {
virtual void recordPosition() const override;
private:
- std::unique_ptr<ByteRleEncoder> byteRleEncoder;
+ std::unique_ptr<ByteRleEncoder> byteRleEncoder_;
};
template <typename BatchType>
@@ -552,7 +553,7 @@ namespace orc {
: ColumnWriter(type, factory, options) {
std::unique_ptr<BufferedOutputStream> dataStream =
factory.createStream(proto::Stream_Kind_DATA);
- byteRleEncoder = createByteRleEncoder(std::move(dataStream));
+ byteRleEncoder_ = createByteRleEncoder(std::move(dataStream));
if (enableIndex) {
recordPosition();
@@ -581,7 +582,7 @@ namespace orc {
for (uint64_t i = 0; i < numValues; ++i) {
byteData[i] = static_cast<char>(data[i]);
}
- byteRleEncoder->add(byteData, numValues, notNull);
+ byteRleEncoder_->add(byteData, numValues, notNull);
uint64_t count = 0;
for (uint64_t i = 0; i < numValues; ++i) {
@@ -606,14 +607,14 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_DATA);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(byteRleEncoder->flush());
+ stream.set_length(byteRleEncoder_->flush());
streams.push_back(stream);
}
template <typename BatchType>
uint64_t ByteColumnWriter<BatchType>::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- size += byteRleEncoder->getBufferSize();
+ size += byteRleEncoder_->getBufferSize();
return size;
}
@@ -632,7 +633,7 @@ namespace orc {
template <typename BatchType>
void ByteColumnWriter<BatchType>::recordPosition() const {
ColumnWriter::recordPosition();
- byteRleEncoder->recordPosition(rowIndexPosition.get());
+ byteRleEncoder_->recordPosition(rowIndexPosition.get());
}
template <typename BatchType>
@@ -653,7 +654,7 @@ namespace orc {
virtual void recordPosition() const override;
private:
- std::unique_ptr<ByteRleEncoder> rleEncoder;
+ std::unique_ptr<ByteRleEncoder> rleEncoder_;
};
template <typename BatchType>
@@ -663,7 +664,7 @@ namespace orc {
: ColumnWriter(type, factory, options) {
std::unique_ptr<BufferedOutputStream> dataStream =
factory.createStream(proto::Stream_Kind_DATA);
- rleEncoder = createBooleanRleEncoder(std::move(dataStream));
+ rleEncoder_ = createBooleanRleEncoder(std::move(dataStream));
if (enableIndex) {
recordPosition();
@@ -694,7 +695,7 @@ namespace orc {
for (uint64_t i = 0; i < numValues; ++i) {
byteData[i] = static_cast<char>(data[i]);
}
- rleEncoder->add(byteData, numValues, notNull);
+ rleEncoder_->add(byteData, numValues, notNull);
uint64_t count = 0;
for (uint64_t i = 0; i < numValues; ++i) {
@@ -719,14 +720,14 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_DATA);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(rleEncoder->flush());
+ stream.set_length(rleEncoder_->flush());
streams.push_back(stream);
}
template <typename BatchType>
uint64_t BooleanColumnWriter<BatchType>::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- size += rleEncoder->getBufferSize();
+ size += rleEncoder_->getBufferSize();
return size;
}
@@ -745,7 +746,7 @@ namespace orc {
template <typename BatchType>
void BooleanColumnWriter<BatchType>::recordPosition() const {
ColumnWriter::recordPosition();
- rleEncoder->recordPosition(rowIndexPosition.get());
+ rleEncoder_->recordPosition(rowIndexPosition.get());
}
template <typename ValueType, typename BatchType>
@@ -766,9 +767,9 @@ namespace orc {
virtual void recordPosition() const override;
private:
- bool isFloat;
- std::unique_ptr<AppendOnlyBufferedStream> dataStream;
- DataBuffer<char> buffer;
+ bool isFloat_;
+ std::unique_ptr<AppendOnlyBufferedStream> dataStream_;
+ DataBuffer<char> buffer_;
};
template <typename ValueType, typename BatchType>
@@ -777,10 +778,10 @@ namespace orc {
const WriterOptions& options,
bool isFloatType)
: ColumnWriter(type, factory, options),
- isFloat(isFloatType),
- buffer(*options.getMemoryPool()) {
- dataStream.reset(new AppendOnlyBufferedStream(factory.createStream(proto::Stream_Kind_DATA)));
- buffer.resize(isFloat ? 4 : 8);
+ isFloat_(isFloatType),
+ buffer_(*options.getMemoryPool()) {
+ dataStream_.reset(new AppendOnlyBufferedStream(factory.createStream(proto::Stream_Kind_DATA)));
+ buffer_.resize(isFloat_ ? 4 : 8);
if (enableIndex) {
recordPosition();
@@ -816,17 +817,17 @@ namespace orc {
const ValueType* doubleData = dblBatch->data.data() + offset;
const char* notNull = dblBatch->hasNulls ? dblBatch->notNull.data() + offset : nullptr;
- size_t bytes = isFloat ? 4 : 8;
- char* data = buffer.data();
+ size_t bytes = isFloat_ ? 4 : 8;
+ char* data = buffer_.data();
uint64_t count = 0;
for (uint64_t i = 0; i < numValues; ++i) {
if (!notNull || notNull[i]) {
- if (isFloat) {
+ if (isFloat_) {
encodeFloatNum<float, int32_t>(static_cast<float>(doubleData[i]), data);
} else {
encodeFloatNum<double, int64_t>(static_cast<double>(doubleData[i]), data);
}
- dataStream->write(data, bytes);
+ dataStream_->write(data, bytes);
++count;
if (enableBloomFilter) {
bloomFilter->addDouble(static_cast<double>(doubleData[i]));
@@ -847,14 +848,14 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_DATA);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(dataStream->flush());
+ stream.set_length(dataStream_->flush());
streams.push_back(stream);
}
template <typename ValueType, typename BatchType>
uint64_t FloatingColumnWriter<ValueType, BatchType>::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- size += dataStream->getSize();
+ size += dataStream_->getSize();
return size;
}
@@ -873,7 +874,7 @@ namespace orc {
template <typename ValueType, typename BatchType>
void FloatingColumnWriter<ValueType, BatchType>::recordPosition() const {
ColumnWriter::recordPosition();
- dataStream->recordPosition(rowIndexPosition.get());
+ dataStream_->recordPosition(rowIndexPosition.get());
}
/**
@@ -887,7 +888,7 @@ namespace orc {
size_t length;
};
- SortedStringDictionary() : totalLength(0) {}
+ SortedStringDictionary() : totalLength_(0) {}
// insert a new string into dictionary, return its insertion order
size_t insert(const char* data, size_t len);
@@ -920,29 +921,29 @@ namespace orc {
}
};
- std::map<DictEntry, size_t, LessThan> dict;
- std::vector<std::vector<char>> data;
- uint64_t totalLength;
+ std::map<DictEntry, size_t, LessThan> dict_;
+ std::vector<std::vector<char>> data_;
+ uint64_t totalLength_;
// use friend class here to avoid being bothered by const function calls
friend class StringColumnWriter;
friend class CharColumnWriter;
friend class VarCharColumnWriter;
// store indexes of insertion order in the dictionary for not-null rows
- std::vector<int64_t> idxInDictBuffer;
+ std::vector<int64_t> idxInDictBuffer_;
};
// insert a new string into dictionary, return its insertion order
size_t SortedStringDictionary::insert(const char* str, size_t len) {
- auto ret = dict.insert({DictEntry(str, len), dict.size()});
+ auto ret = dict_.insert({DictEntry(str, len), dict_.size()});
if (ret.second) {
// make a copy to internal storage
- data.push_back(std::vector<char>(len));
- memcpy(data.back().data(), str, len);
+ data_.push_back(std::vector<char>(len));
+ memcpy(data_.back().data(), str, len);
// update dictionary entry to link pointer to internal storage
DictEntry* entry = const_cast<DictEntry*>(&(ret.first->first));
- entry->data = data.back().data();
- totalLength += len;
+ entry->data = data_.back().data();
+ totalLength_ += len;
}
return ret.first->second;
}
@@ -950,7 +951,7 @@ namespace orc {
// write dictionary data & length to output buffer
void SortedStringDictionary::flush(AppendOnlyBufferedStream* dataStream,
RleEncoder* lengthEncoder) const {
- for (auto it = dict.cbegin(); it != dict.cend(); ++it) {
+ for (auto it = dict_.cbegin(); it != dict_.cend(); ++it) {
dataStream->write(it->first.data, it->first.length);
lengthEncoder->write(static_cast<int64_t>(it->first.length));
}
@@ -968,9 +969,9 @@ namespace orc {
*/
void SortedStringDictionary::reorder(std::vector<int64_t>& idxBuffer) const {
// iterate the dictionary to get mapping from insertion order to value order
- std::vector<size_t> mapping(dict.size());
+ std::vector<size_t> mapping(dict_.size());
size_t dictIdx = 0;
- for (auto it = dict.cbegin(); it != dict.cend(); ++it) {
+ for (auto it = dict_.cbegin(); it != dict_.cend(); ++it) {
mapping[it->second] = dictIdx++;
}
@@ -983,26 +984,26 @@ namespace orc {
// get dict entries in insertion order
void SortedStringDictionary::getEntriesInInsertionOrder(
std::vector<const DictEntry*>& entries) const {
- entries.resize(dict.size());
- for (auto it = dict.cbegin(); it != dict.cend(); ++it) {
+ entries.resize(dict_.size());
+ for (auto it = dict_.cbegin(); it != dict_.cend(); ++it) {
entries[it->second] = &(it->first);
}
}
// return count of entries
size_t SortedStringDictionary::size() const {
- return dict.size();
+ return dict_.size();
}
// return total length of strings in the dictioanry
uint64_t SortedStringDictionary::length() const {
- return totalLength;
+ return totalLength_;
}
void SortedStringDictionary::clear() {
- totalLength = 0;
- data.clear();
- dict.clear();
+ totalLength_ = 0;
+ data_.clear();
+ dict_.clear();
}
class StringColumnWriter : public ColumnWriter {
@@ -1123,7 +1124,7 @@ namespace orc {
const size_t len = static_cast<size_t>(length[i]);
if (useDictionary) {
size_t index = dictionary.insert(data[i], len);
- dictionary.idxInDictBuffer.push_back(static_cast<int64_t>(index));
+ dictionary.idxInDictBuffer_.push_back(static_cast<int64_t>(index));
} else {
directDataStream->write(data[i], len);
}
@@ -1184,7 +1185,7 @@ namespace orc {
} else {
size += dictionary.length();
size += dictionary.size() * sizeof(int32_t);
- size += dictionary.idxInDictBuffer.size() * sizeof(int32_t);
+ size += dictionary.idxInDictBuffer_.size() * sizeof(int32_t);
if (useCompression) {
size /= 3; // estimated ratio is 3:1
}
@@ -1215,7 +1216,7 @@ namespace orc {
directLengthEncoder->recordPosition(rowIndexPosition.get());
} else {
if (enableIndex) {
- startOfRowGroups.push_back(dictionary.idxInDictBuffer.size());
+ startOfRowGroups.push_back(dictionary.idxInDictBuffer_.size());
}
}
}
@@ -1223,7 +1224,7 @@ namespace orc {
bool StringColumnWriter::checkDictionaryKeyRatio() {
if (!doneDictionaryCheck) {
useDictionary = dictionary.size() <=
- static_cast<size_t>(static_cast<double>(dictionary.idxInDictBuffer.size()) *
+ static_cast<size_t>(static_cast<double>(dictionary.idxInDictBuffer_.size()) *
dictSizeThreshold);
doneDictionaryCheck = true;
}
@@ -1244,7 +1245,7 @@ namespace orc {
ColumnWriter::reset();
dictionary.clear();
- dictionary.idxInDictBuffer.resize(0);
+ dictionary.idxInDictBuffer_.resize(0);
startOfRowGroups.clear();
startOfRowGroups.push_back(0);
}
@@ -1277,7 +1278,7 @@ namespace orc {
dictStream.reset(nullptr);
dictionary.clear();
- dictionary.idxInDictBuffer.clear();
+ dictionary.idxInDictBuffer_.clear();
startOfRowGroups.clear();
}
@@ -1295,10 +1296,10 @@ namespace orc {
dictionary.flush(dictStream.get(), dictLengthEncoder.get());
// convert index from insertion order to dictionary order
- dictionary.reorder(dictionary.idxInDictBuffer);
+ dictionary.reorder(dictionary.idxInDictBuffer_);
// write data sequences
- int64_t* data = dictionary.idxInDictBuffer.data();
+ int64_t* data = dictionary.idxInDictBuffer_.data();
if (enableIndex) {
size_t prevOffset = 0;
for (size_t i = 0; i < startOfRowGroups.size(); ++i) {
@@ -1319,10 +1320,10 @@ namespace orc {
prevOffset = offset;
}
- dictDataEncoder->add(data + prevOffset, dictionary.idxInDictBuffer.size() - prevOffset,
+ dictDataEncoder->add(data + prevOffset, dictionary.idxInDictBuffer_.size() - prevOffset,
nullptr);
} else {
- dictDataEncoder->add(data, dictionary.idxInDictBuffer.size(), nullptr);
+ dictDataEncoder->add(data, dictionary.idxInDictBuffer_.size(), nullptr);
}
}
}
@@ -1345,9 +1346,9 @@ namespace orc {
// store each length of the data into a vector
const SortedStringDictionary::DictEntry* dictEntry = nullptr;
- for (uint64_t i = 0; i != dictionary.idxInDictBuffer.size(); ++i) {
+ for (uint64_t i = 0; i != dictionary.idxInDictBuffer_.size(); ++i) {
// write one row data in direct encoding
- dictEntry = entries[static_cast<size_t>(dictionary.idxInDictBuffer[i])];
+ dictEntry = entries[static_cast<size_t>(dictionary.idxInDictBuffer_[i])];
directDataStream->write(dictEntry->data, dictEntry->length);
directLengthEncoder->write(static_cast<int64_t>(dictEntry->length));
}
@@ -1428,18 +1429,18 @@ namespace orc {
public:
CharColumnWriter(const Type& type, const StreamsFactory& factory, const WriterOptions& options)
: StringColumnWriter(type, factory, options),
- maxLength(type.getMaximumLength()),
- padBuffer(*options.getMemoryPool()) {
+ maxLength_(type.getMaximumLength()),
+ padBuffer_(*options.getMemoryPool()) {
// utf-8 is currently 4 bytes long, but it could be up to 6
- padBuffer.resize(maxLength * 6);
+ padBuffer_.resize(maxLength_ * 6);
}
virtual void add(ColumnVectorBatch& rowBatch, uint64_t offset, uint64_t numValues,
const char* incomingMask) override;
private:
- uint64_t maxLength;
- DataBuffer<char> padBuffer;
+ uint64_t maxLength_;
+ DataBuffer<char> padBuffer_;
};
void CharColumnWriter::add(ColumnVectorBatch& rowBatch, uint64_t offset, uint64_t numValues,
@@ -1467,22 +1468,22 @@ namespace orc {
const char* charData = nullptr;
uint64_t originLength = static_cast<uint64_t>(length[i]);
uint64_t charLength = Utf8Utils::charLength(data[i], originLength);
- if (charLength >= maxLength) {
+ if (charLength >= maxLength_) {
charData = data[i];
length[i] =
- static_cast<int64_t>(Utf8Utils::truncateBytesTo(maxLength, data[i], originLength));
+ static_cast<int64_t>(Utf8Utils::truncateBytesTo(maxLength_, data[i], originLength));
} else {
- charData = padBuffer.data();
+ charData = padBuffer_.data();
// the padding is exactly 1 byte per char
- length[i] = length[i] + static_cast<int64_t>(maxLength - charLength);
- memcpy(padBuffer.data(), data[i], originLength);
- memset(padBuffer.data() + originLength, ' ',
+ length[i] = length[i] + static_cast<int64_t>(maxLength_ - charLength);
+ memcpy(padBuffer_.data(), data[i], originLength);
+ memset(padBuffer_.data() + originLength, ' ',
static_cast<size_t>(length[i]) - originLength);
}
if (useDictionary) {
size_t index = dictionary.insert(charData, static_cast<size_t>(length[i]));
- dictionary.idxInDictBuffer.push_back(static_cast<int64_t>(index));
+ dictionary.idxInDictBuffer_.push_back(static_cast<int64_t>(index));
} else {
directDataStream->write(charData, static_cast<size_t>(length[i]));
}
@@ -1509,7 +1510,7 @@ namespace orc {
public:
VarCharColumnWriter(const Type& type, const StreamsFactory& factory,
const WriterOptions& options)
- : StringColumnWriter(type, factory, options), maxLength(type.getMaximumLength()) {
+ : StringColumnWriter(type, factory, options), maxLength_(type.getMaximumLength()) {
// PASS
}
@@ -1517,7 +1518,7 @@ namespace orc {
const char* incomingMask) override;
private:
- uint64_t maxLength;
+ uint64_t maxLength_;
};
void VarCharColumnWriter::add(ColumnVectorBatch& rowBatch, uint64_t offset, uint64_t numValues,
@@ -1543,12 +1544,12 @@ namespace orc {
for (uint64_t i = 0; i < numValues; ++i) {
if (!notNull || notNull[i]) {
uint64_t itemLength =
- Utf8Utils::truncateBytesTo(maxLength, data[i], static_cast<uint64_t>(length[i]));
+ Utf8Utils::truncateBytesTo(maxLength_, data[i], static_cast<uint64_t>(length[i]));
length[i] = static_cast<int64_t>(itemLength);
if (useDictionary) {
size_t index = dictionary.insert(data[i], static_cast<size_t>(length[i]));
- dictionary.idxInDictBuffer.push_back(static_cast<int64_t>(index));
+ dictionary.idxInDictBuffer_.push_back(static_cast<int64_t>(index));
} else {
directDataStream->write(data[i], static_cast<size_t>(length[i]));
}
@@ -1642,24 +1643,24 @@ namespace orc {
std::unique_ptr<RleEncoder> secRleEncoder, nanoRleEncoder;
private:
- RleVersion rleVersion;
- const Timezone* timezone;
- const bool isUTC;
+ RleVersion rleVersion_;
+ const Timezone* timezone_;
+ const bool isUTC_;
};
TimestampColumnWriter::TimestampColumnWriter(const Type& type, const StreamsFactory& factory,
const WriterOptions& options, bool isInstantType)
: ColumnWriter(type, factory, options),
- rleVersion(options.getRleVersion()),
- timezone(isInstantType ? &getTimezoneByName("GMT") : &options.getTimezone()),
- isUTC(isInstantType || options.getTimezoneName() == "GMT") {
+ rleVersion_(options.getRleVersion()),
+ timezone_(isInstantType ? &getTimezoneByName("GMT") : &options.getTimezone()),
+ isUTC_(isInstantType || options.getTimezoneName() == "GMT") {
std::unique_ptr<BufferedOutputStream> dataStream =
factory.createStream(proto::Stream_Kind_DATA);
std::unique_ptr<BufferedOutputStream> secondaryStream =
factory.createStream(proto::Stream_Kind_SECONDARY);
- secRleEncoder = createRleEncoder(std::move(dataStream), true, rleVersion, memPool,
+ secRleEncoder = createRleEncoder(std::move(dataStream), true, rleVersion_, memPool,
options.getAlignedBitpacking());
- nanoRleEncoder = createRleEncoder(std::move(secondaryStream), false, rleVersion, memPool,
+ nanoRleEncoder = createRleEncoder(std::move(secondaryStream), false, rleVersion_, memPool,
options.getAlignedBitpacking());
if (enableIndex) {
@@ -1712,8 +1713,8 @@ namespace orc {
if (notNull == nullptr || notNull[i]) {
// TimestampVectorBatch already stores data in UTC
int64_t millsUTC = secs[i] * 1000 + nanos[i] / 1000000;
- if (!isUTC) {
- millsUTC = timezone->convertToUTC(secs[i]) * 1000 + nanos[i] / 1000000;
+ if (!isUTC_) {
+ millsUTC = timezone_->convertToUTC(secs[i]) * 1000 + nanos[i] / 1000000;
}
++count;
if (enableBloomFilter) {
@@ -1725,7 +1726,7 @@ namespace orc {
secs[i] += 1;
}
- secs[i] -= timezone->getEpoch();
+ secs[i] -= timezone_->getEpoch();
nanos[i] = formatNano(nanos[i]);
}
}
@@ -1764,7 +1765,7 @@ namespace orc {
void TimestampColumnWriter::getColumnEncoding(
std::vector<proto::ColumnEncoding>& encodings) const {
proto::ColumnEncoding encoding;
- encoding.set_kind(RleVersionMapper(rleVersion));
+ encoding.set_kind(RleVersionMapper(rleVersion_));
encoding.set_dictionary_size(0);
if (enableBloomFilter) {
encoding.set_bloom_encoding(BloomFilterVersion::UTF8);
@@ -1855,7 +1856,7 @@ namespace orc {
std::unique_ptr<RleEncoder> scaleEncoder;
private:
- char buffer[10];
+ char buffer_[10];
};
Decimal64ColumnWriter::Decimal64ColumnWriter(const Type& type, const StreamsFactory& factory,
@@ -1897,7 +1898,7 @@ namespace orc {
for (uint64_t i = 0; i < numValues; ++i) {
if (!notNull || notNull[i]) {
int64_t val = zigZag(values[i]);
- char* data = buffer;
+ char* data = buffer_;
while (true) {
if ((val & ~0x7f) == 0) {
*(data++) = (static_cast<char>(val));
@@ -1908,7 +1909,7 @@ namespace orc {
val = (static_cast<uint64_t>(val) >> 7);
}
}
- valueStream->write(buffer, static_cast<size_t>(data - buffer));
+ valueStream->write(buffer_, static_cast<size_t>(data - buffer_));
++count;
if (enableBloomFilter) {
std::string decimal = Decimal(values[i], static_cast<int32_t>(scale)).toString(true);
@@ -2080,7 +2081,7 @@ namespace orc {
const char* incomingMask) override;
private:
- char buffer[20];
+ char buffer_[20];
};
Decimal128ColumnWriter::Decimal128ColumnWriter(const Type& type, const StreamsFactory& factory,
@@ -2126,7 +2127,7 @@ namespace orc {
for (uint64_t i = 0; i < numValues; ++i) {
if (!notNull || notNull[i]) {
Int128 val = zigZagInt128(values[i]);
- char* data = buffer;
+ char* data = buffer_;
while (true) {
if ((val & ~0x7f) == 0) {
*(data++) = (static_cast<char>(val.getLowBits()));
@@ -2136,7 +2137,7 @@ namespace orc {
val >>= 7;
}
}
- valueStream->write(buffer, static_cast<size_t>(data - buffer));
+ valueStream->write(buffer_, static_cast<size_t>(data - buffer_));
++count;
if (enableBloomFilter) {
@@ -2187,21 +2188,21 @@ namespace orc {
virtual void reset() override;
private:
- std::unique_ptr<RleEncoder> lengthEncoder;
- RleVersion rleVersion;
- std::unique_ptr<ColumnWriter> child;
+ std::unique_ptr<RleEncoder> lengthEncoder_;
+ RleVersion rleVersion_;
+ std::unique_ptr<ColumnWriter> child_;
};
ListColumnWriter::ListColumnWriter(const Type& type, const StreamsFactory& factory,
const WriterOptions& options)
- : ColumnWriter(type, factory, options), rleVersion(options.getRleVersion()) {
+ : ColumnWriter(type, factory, options), rleVersion_(options.getRleVersion()) {
std::unique_ptr<BufferedOutputStream> lengthStream =
factory.createStream(proto::Stream_Kind_LENGTH);
- lengthEncoder = createRleEncoder(std::move(lengthStream), false, rleVersion, memPool,
- options.getAlignedBitpacking());
+ lengthEncoder_ = createRleEncoder(std::move(lengthStream), false, rleVersion_, memPool,
+ options.getAlignedBitpacking());
if (type.getSubtypeCount() == 1) {
- child = buildWriter(*type.getSubtype(0), factory, options);
+ child_ = buildWriter(*type.getSubtype(0), factory, options);
}
if (enableIndex) {
@@ -2239,10 +2240,10 @@ namespace orc {
}
// unnecessary to deal with null as elements are packed together
- if (child.get()) {
- child->add(*listBatch->elements, elemOffset, totalNumValues, nullptr);
+ if (child_.get()) {
+ child_->add(*listBatch->elements, elemOffset, totalNumValues, nullptr);
}
- lengthEncoder->add(offsets, numValues, notNull);
+ lengthEncoder_->add(offsets, numValues, notNull);
if (enableIndex) {
if (!notNull) {
@@ -2272,93 +2273,93 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_LENGTH);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(lengthEncoder->flush());
+ stream.set_length(lengthEncoder_->flush());
streams.push_back(stream);
- if (child.get()) {
- child->flush(streams);
+ if (child_.get()) {
+ child_->flush(streams);
}
}
void ListColumnWriter::writeIndex(std::vector<proto::Stream>& streams) const {
ColumnWriter::writeIndex(streams);
- if (child.get()) {
- child->writeIndex(streams);
+ if (child_.get()) {
+ child_->writeIndex(streams);
}
}
uint64_t ListColumnWriter::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- if (child.get()) {
- size += lengthEncoder->getBufferSize();
- size += child->getEstimatedSize();
+ if (child_.get()) {
+ size += lengthEncoder_->getBufferSize();
+ size += child_->getEstimatedSize();
}
return size;
}
void ListColumnWriter::getColumnEncoding(std::vector<proto::ColumnEncoding>& encodings) const {
proto::ColumnEncoding encoding;
- encoding.set_kind(RleVersionMapper(rleVersion));
+ encoding.set_kind(RleVersionMapper(rleVersion_));
encoding.set_dictionary_size(0);
if (enableBloomFilter) {
encoding.set_bloom_encoding(BloomFilterVersion::UTF8);
}
encodings.push_back(encoding);
- if (child.get()) {
- child->getColumnEncoding(encodings);
+ if (child_.get()) {
+ child_->getColumnEncoding(encodings);
}
}
void ListColumnWriter::getStripeStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getStripeStatistics(stats);
- if (child.get()) {
- child->getStripeStatistics(stats);
+ if (child_.get()) {
+ child_->getStripeStatistics(stats);
}
}
void ListColumnWriter::mergeStripeStatsIntoFileStats() {
ColumnWriter::mergeStripeStatsIntoFileStats();
- if (child.get()) {
- child->mergeStripeStatsIntoFileStats();
+ if (child_.get()) {
+ child_->mergeStripeStatsIntoFileStats();
}
}
void ListColumnWriter::getFileStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getFileStatistics(stats);
- if (child.get()) {
- child->getFileStatistics(stats);
+ if (child_.get()) {
+ child_->getFileStatistics(stats);
}
}
void ListColumnWriter::mergeRowGroupStatsIntoStripeStats() {
ColumnWriter::mergeRowGroupStatsIntoStripeStats();
- if (child.get()) {
- child->mergeRowGroupStatsIntoStripeStats();
+ if (child_.get()) {
+ child_->mergeRowGroupStatsIntoStripeStats();
}
}
void ListColumnWriter::createRowIndexEntry() {
ColumnWriter::createRowIndexEntry();
- if (child.get()) {
- child->createRowIndexEntry();
+ if (child_.get()) {
+ child_->createRowIndexEntry();
}
}
void ListColumnWriter::recordPosition() const {
ColumnWriter::recordPosition();
- lengthEncoder->recordPosition(rowIndexPosition.get());
+ lengthEncoder_->recordPosition(rowIndexPosition.get());
}
void ListColumnWriter::reset() {
ColumnWriter::reset();
- if (child) {
- child->reset();
+ if (child_) {
+ child_->reset();
}
}
void ListColumnWriter::writeDictionary() {
- if (child) {
- child->writeDictionary();
+ if (child_) {
+ child_->writeDictionary();
}
}
@@ -2395,26 +2396,26 @@ namespace orc {
virtual void reset() override;
private:
- std::unique_ptr<ColumnWriter> keyWriter;
- std::unique_ptr<ColumnWriter> elemWriter;
- std::unique_ptr<RleEncoder> lengthEncoder;
- RleVersion rleVersion;
+ std::unique_ptr<ColumnWriter> keyWriter_;
+ std::unique_ptr<ColumnWriter> elemWriter_;
+ std::unique_ptr<RleEncoder> lengthEncoder_;
+ RleVersion rleVersion_;
};
MapColumnWriter::MapColumnWriter(const Type& type, const StreamsFactory& factory,
const WriterOptions& options)
- : ColumnWriter(type, factory, options), rleVersion(options.getRleVersion()) {
+ : ColumnWriter(type, factory, options), rleVersion_(options.getRleVersion()) {
std::unique_ptr<BufferedOutputStream> lengthStream =
factory.createStream(proto::Stream_Kind_LENGTH);
- lengthEncoder = createRleEncoder(std::move(lengthStream), false, rleVersion, memPool,
- options.getAlignedBitpacking());
+ lengthEncoder_ = createRleEncoder(std::move(lengthStream), false, rleVersion_, memPool,
+ options.getAlignedBitpacking());
if (type.getSubtypeCount() > 0) {
- keyWriter = buildWriter(*type.getSubtype(0), factory, options);
+ keyWriter_ = buildWriter(*type.getSubtype(0), factory, options);
}
if (type.getSubtypeCount() > 1) {
- elemWriter = buildWriter(*type.getSubtype(1), factory, options);
+ elemWriter_ = buildWriter(*type.getSubtype(1), factory, options);
}
if (enableIndex) {
@@ -2451,14 +2452,14 @@ namespace orc {
offsets[i] = offsets[i + 1] - offsets[i];
}
- lengthEncoder->add(offsets, numValues, notNull);
+ lengthEncoder_->add(offsets, numValues, notNull);
// unnecessary to deal with null as keys and values are packed together
- if (keyWriter.get()) {
- keyWriter->add(*mapBatch->keys, elemOffset, totalNumValues, nullptr);
+ if (keyWriter_.get()) {
+ keyWriter_->add(*mapBatch->keys, elemOffset, totalNumValues, nullptr);
}
- if (elemWriter.get()) {
- elemWriter->add(*mapBatch->elements, elemOffset, totalNumValues, nullptr);
+ if (elemWriter_.get()) {
+ elemWriter_->add(*mapBatch->elements, elemOffset, totalNumValues, nullptr);
}
if (enableIndex) {
@@ -2489,126 +2490,126 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_LENGTH);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(lengthEncoder->flush());
+ stream.set_length(lengthEncoder_->flush());
streams.push_back(stream);
- if (keyWriter.get()) {
- keyWriter->flush(streams);
+ if (keyWriter_.get()) {
+ keyWriter_->flush(streams);
}
- if (elemWriter.get()) {
- elemWriter->flush(streams);
+ if (elemWriter_.get()) {
+ elemWriter_->flush(streams);
}
}
void MapColumnWriter::writeIndex(std::vector<proto::Stream>& streams) const {
ColumnWriter::writeIndex(streams);
- if (keyWriter.get()) {
- keyWriter->writeIndex(streams);
+ if (keyWriter_.get()) {
+ keyWriter_->writeIndex(streams);
}
- if (elemWriter.get()) {
- elemWriter->writeIndex(streams);
+ if (elemWriter_.get()) {
+ elemWriter_->writeIndex(streams);
}
}
uint64_t MapColumnWriter::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- size += lengthEncoder->getBufferSize();
- if (keyWriter.get()) {
- size += keyWriter->getEstimatedSize();
+ size += lengthEncoder_->getBufferSize();
+ if (keyWriter_.get()) {
+ size += keyWriter_->getEstimatedSize();
}
- if (elemWriter.get()) {
- size += elemWriter->getEstimatedSize();
+ if (elemWriter_.get()) {
+ size += elemWriter_->getEstimatedSize();
}
return size;
}
void MapColumnWriter::getColumnEncoding(std::vector<proto::ColumnEncoding>& encodings) const {
proto::ColumnEncoding encoding;
- encoding.set_kind(RleVersionMapper(rleVersion));
+ encoding.set_kind(RleVersionMapper(rleVersion_));
encoding.set_dictionary_size(0);
if (enableBloomFilter) {
encoding.set_bloom_encoding(BloomFilterVersion::UTF8);
}
encodings.push_back(encoding);
- if (keyWriter.get()) {
- keyWriter->getColumnEncoding(encodings);
+ if (keyWriter_.get()) {
+ keyWriter_->getColumnEncoding(encodings);
}
- if (elemWriter.get()) {
- elemWriter->getColumnEncoding(encodings);
+ if (elemWriter_.get()) {
+ elemWriter_->getColumnEncoding(encodings);
}
}
void MapColumnWriter::getStripeStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getStripeStatistics(stats);
- if (keyWriter.get()) {
- keyWriter->getStripeStatistics(stats);
+ if (keyWriter_.get()) {
+ keyWriter_->getStripeStatistics(stats);
}
- if (elemWriter.get()) {
- elemWriter->getStripeStatistics(stats);
+ if (elemWriter_.get()) {
+ elemWriter_->getStripeStatistics(stats);
}
}
void MapColumnWriter::mergeStripeStatsIntoFileStats() {
ColumnWriter::mergeStripeStatsIntoFileStats();
- if (keyWriter.get()) {
- keyWriter->mergeStripeStatsIntoFileStats();
+ if (keyWriter_.get()) {
+ keyWriter_->mergeStripeStatsIntoFileStats();
}
- if (elemWriter.get()) {
- elemWriter->mergeStripeStatsIntoFileStats();
+ if (elemWriter_.get()) {
+ elemWriter_->mergeStripeStatsIntoFileStats();
}
}
void MapColumnWriter::getFileStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getFileStatistics(stats);
- if (keyWriter.get()) {
- keyWriter->getFileStatistics(stats);
+ if (keyWriter_.get()) {
+ keyWriter_->getFileStatistics(stats);
}
- if (elemWriter.get()) {
- elemWriter->getFileStatistics(stats);
+ if (elemWriter_.get()) {
+ elemWriter_->getFileStatistics(stats);
}
}
void MapColumnWriter::mergeRowGroupStatsIntoStripeStats() {
ColumnWriter::mergeRowGroupStatsIntoStripeStats();
- if (keyWriter.get()) {
- keyWriter->mergeRowGroupStatsIntoStripeStats();
+ if (keyWriter_.get()) {
+ keyWriter_->mergeRowGroupStatsIntoStripeStats();
}
- if (elemWriter.get()) {
- elemWriter->mergeRowGroupStatsIntoStripeStats();
+ if (elemWriter_.get()) {
+ elemWriter_->mergeRowGroupStatsIntoStripeStats();
}
}
void MapColumnWriter::createRowIndexEntry() {
ColumnWriter::createRowIndexEntry();
- if (keyWriter.get()) {
- keyWriter->createRowIndexEntry();
+ if (keyWriter_.get()) {
+ keyWriter_->createRowIndexEntry();
}
- if (elemWriter.get()) {
- elemWriter->createRowIndexEntry();
+ if (elemWriter_.get()) {
+ elemWriter_->createRowIndexEntry();
}
}
void MapColumnWriter::recordPosition() const {
ColumnWriter::recordPosition();
- lengthEncoder->recordPosition(rowIndexPosition.get());
+ lengthEncoder_->recordPosition(rowIndexPosition.get());
}
void MapColumnWriter::reset() {
ColumnWriter::reset();
- if (keyWriter) {
- keyWriter->reset();
+ if (keyWriter_) {
+ keyWriter_->reset();
}
- if (elemWriter) {
- elemWriter->reset();
+ if (elemWriter_) {
+ elemWriter_->reset();
}
}
void MapColumnWriter::writeDictionary() {
- if (keyWriter) {
- keyWriter->writeDictionary();
+ if (keyWriter_) {
+ keyWriter_->writeDictionary();
}
- if (elemWriter) {
- elemWriter->writeDictionary();
+ if (elemWriter_) {
+ elemWriter_->writeDictionary();
}
}
@@ -2645,8 +2646,8 @@ namespace orc {
virtual void reset() override;
private:
- std::unique_ptr<ByteRleEncoder> rleEncoder;
- std::vector<std::unique_ptr<ColumnWriter>> children;
+ std::unique_ptr<ByteRleEncoder> rleEncoder_;
+ std::vector<std::unique_ptr<ColumnWriter>> children_;
};
UnionColumnWriter::UnionColumnWriter(const Type& type, const StreamsFactory& factory,
@@ -2654,10 +2655,10 @@ namespace orc {
: ColumnWriter(type, factory, options) {
std::unique_ptr<BufferedOutputStream> dataStream =
factory.createStream(proto::Stream_Kind_DATA);
- rleEncoder = createByteRleEncoder(std::move(dataStream));
+ rleEncoder_ = createByteRleEncoder(std::move(dataStream));
for (uint64_t i = 0; i != type.getSubtypeCount(); ++i) {
- children.push_back(buildWriter(*type.getSubtype(i), factory, options));
+ children_.push_back(buildWriter(*type.getSubtype(i), factory, options));
}
if (enableIndex) {
@@ -2678,8 +2679,8 @@ namespace orc {
unsigned char* tags = unionBatch->tags.data() + offset;
uint64_t* offsets = unionBatch->offsets.data() + offset;
- std::vector<int64_t> childOffset(children.size(), -1);
- std::vector<uint64_t> childLength(children.size(), 0);
+ std::vector<int64_t> childOffset(children_.size(), -1);
+ std::vector<uint64_t> childLength(children_.size(), 0);
for (uint64_t i = 0; i != numValues; ++i) {
if (childOffset[tags[i]] == -1) {
@@ -2688,12 +2689,12 @@ namespace orc {
++childLength[tags[i]];
}
- rleEncoder->add(reinterpret_cast<char*>(tags), numValues, notNull);
+ rleEncoder_->add(reinterpret_cast<char*>(tags), numValues, notNull);
- for (uint32_t i = 0; i < children.size(); ++i) {
+ for (uint32_t i = 0; i < children_.size(); ++i) {
if (childLength[i] > 0) {
- children[i]->add(*unionBatch->children[i], static_cast<uint64_t>(childOffset[i]),
- childLength[i], nullptr);
+ children_[i]->add(*unionBatch->children[i], static_cast<uint64_t>(childOffset[i]),
+ childLength[i], nullptr);
}
}
@@ -2725,26 +2726,26 @@ namespace orc {
proto::Stream stream;
stream.set_kind(proto::Stream_Kind_DATA);
stream.set_column(static_cast<uint32_t>(columnId));
- stream.set_length(rleEncoder->flush());
+ stream.set_length(rleEncoder_->flush());
streams.push_back(stream);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->flush(streams);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->flush(streams);
}
}
void UnionColumnWriter::writeIndex(std::vector<proto::Stream>& streams) const {
ColumnWriter::writeIndex(streams);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->writeIndex(streams);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->writeIndex(streams);
}
}
uint64_t UnionColumnWriter::getEstimatedSize() const {
uint64_t size = ColumnWriter::getEstimatedSize();
- size += rleEncoder->getBufferSize();
- for (uint32_t i = 0; i < children.size(); ++i) {
- size += children[i]->getEstimatedSize();
+ size += rleEncoder_->getBufferSize();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ size += children_[i]->getEstimatedSize();
}
return size;
}
@@ -2757,61 +2758,61 @@ namespace orc {
encoding.set_bloom_encoding(BloomFilterVersion::UTF8);
}
encodings.push_back(encoding);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getColumnEncoding(encodings);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getColumnEncoding(encodings);
}
}
void UnionColumnWriter::getStripeStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getStripeStatistics(stats);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getStripeStatistics(stats);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getStripeStatistics(stats);
}
}
void UnionColumnWriter::mergeStripeStatsIntoFileStats() {
ColumnWriter::mergeStripeStatsIntoFileStats();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->mergeStripeStatsIntoFileStats();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->mergeStripeStatsIntoFileStats();
}
}
void UnionColumnWriter::getFileStatistics(std::vector<proto::ColumnStatistics>& stats) const {
ColumnWriter::getFileStatistics(stats);
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->getFileStatistics(stats);
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->getFileStatistics(stats);
}
}
void UnionColumnWriter::mergeRowGroupStatsIntoStripeStats() {
ColumnWriter::mergeRowGroupStatsIntoStripeStats();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->mergeRowGroupStatsIntoStripeStats();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->mergeRowGroupStatsIntoStripeStats();
}
}
void UnionColumnWriter::createRowIndexEntry() {
ColumnWriter::createRowIndexEntry();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->createRowIndexEntry();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->createRowIndexEntry();
}
}
void UnionColumnWriter::recordPosition() const {
ColumnWriter::recordPosition();
- rleEncoder->recordPosition(rowIndexPosition.get());
+ rleEncoder_->recordPosition(rowIndexPosition.get());
}
void UnionColumnWriter::reset() {
ColumnWriter::reset();
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->reset();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->reset();
}
}
void UnionColumnWriter::writeDictionary() {
- for (uint32_t i = 0; i < children.size(); ++i) {
- children[i]->writeDictionary();
+ for (uint32_t i = 0; i < children_.size(); ++i) {
+ children_[i]->writeDictionary();
}
}
diff --git a/c++/src/ColumnWriter.hh b/c++/src/ColumnWriter.hh
index f21ffd6f8..8afd1eb72 100644
--- a/c++/src/ColumnWriter.hh
+++ b/c++/src/ColumnWriter.hh
@@ -53,14 +53,14 @@ namespace orc {
public:
virtual ~RowIndexPositionRecorder() override;
- RowIndexPositionRecorder(proto::RowIndexEntry& entry) : rowIndexEntry(entry) {}
+ RowIndexPositionRecorder(proto::RowIndexEntry& entry) : rowIndexEntry_(entry) {}
virtual void add(uint64_t pos) override {
- rowIndexEntry.add_positions(pos);
+ rowIndexEntry_.add_positions(pos);
}
private:
- proto::RowIndexEntry& rowIndexEntry;
+ proto::RowIndexEntry& rowIndexEntry_;
};
/**
diff --git a/c++/src/Common.cc b/c++/src/Common.cc
index cf2ff27ef..52efa12d9 100644
--- a/c++/src/Common.cc
+++ b/c++/src/Common.cc
@@ -133,11 +133,11 @@ namespace orc {
}
std::string FileVersion::toString() const {
- if (majorVersion == 1 && minorVersion == 9999) {
+ if (majorVersion_ == 1 && minorVersion_ == 9999) {
return "UNSTABLE-PRE-2.0";
}
std::stringstream ss;
- ss << majorVersion << '.' << minorVersion;
+ ss << majorVersion_ << '.' << minorVersion_;
return ss.str();
}
diff --git a/c++/src/Compression.cc b/c++/src/Compression.cc
index 94be774ab..4002276e1 100644
--- a/c++/src/Compression.cc
+++ b/c++/src/Compression.cc
@@ -245,7 +245,7 @@ namespace orc {
private:
void init();
void end();
- z_stream strm;
+ z_stream strm_;
};
ZlibCompressionStream::ZlibCompressionStream(OutputStream* outStream, int compressionLevel,
@@ -256,12 +256,12 @@ namespace orc {
}
uint64_t ZlibCompressionStream::doStreamingCompression() {
- if (deflateReset(&strm) != Z_OK) {
+ if (deflateReset(&strm_) != Z_OK) {
throw std::runtime_error("Failed to reset inflate.");
}
- strm.avail_in = static_cast<unsigned int>(bufferSize);
- strm.next_in = rawInputBuffer.data();
+ strm_.avail_in = static_cast<unsigned int>(bufferSize);
+ strm_.next_in = rawInputBuffer.data();
do {
if (outputPosition >= outputSize) {
@@ -270,11 +270,11 @@ namespace orc {
}
outputPosition = 0;
}
- strm.next_out = reinterpret_cast<unsigned char*>(outputBuffer + outputPosition);
- strm.avail_out = static_cast<unsigned int>(outputSize - outputPosition);
+ strm_.next_out = reinterpret_cast<unsigned char*>(outputBuffer + outputPosition);
+ strm_.avail_out = static_cast<unsigned int>(outputSize - outputPosition);
- int ret = deflate(&strm, Z_FINISH);
- outputPosition = outputSize - static_cast<int>(strm.avail_out);
+ int ret = deflate(&strm_, Z_FINISH);
+ outputPosition = outputSize - static_cast<int>(strm_.avail_out);
if (ret == Z_STREAM_END) {
break;
@@ -283,9 +283,9 @@ namespace orc {
} else {
throw std::runtime_error("Failed to deflate input data.");
}
- } while (strm.avail_out == 0);
+ } while (strm_.avail_out == 0);
- return strm.total_out;
+ return strm_.total_out;
}
std::string ZlibCompressionStream::getName() const {
@@ -299,18 +299,18 @@ namespace orc {
#endif
void ZlibCompressionStream::init() {
- strm.zalloc = nullptr;
- strm.zfree = nullptr;
- strm.opaque = nullptr;
- strm.next_in = nullptr;
+ strm_.zalloc = nullptr;
+ strm_.zfree = nullptr;
+ strm_.opaque = nullptr;
+ strm_.next_in = nullptr;
- if (deflateInit2(&strm, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
+ if (deflateInit2(&strm_, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
throw std::runtime_error("Error while calling deflateInit2() for zlib.");
}
}
void ZlibCompressionStream::end() {
- (void)deflateEnd(&strm);
+ (void)deflateEnd(&strm_);
}
DIAGNOSTIC_PUSH
@@ -399,9 +399,9 @@ namespace orc {
};
DecompressionStream::DecompressionStream(std::unique_ptr<SeekableInputStream> inStream,
- size_t bufferSize, MemoryPool& _pool,
- ReaderMetrics* _metrics)
- : pool(_pool),
+ size_t bufferSize, MemoryPool& pool,
+ ReaderMetrics* metrics)
+ : pool(pool),
input(std::move(inStream)),
outputDataBuffer(pool, bufferSize),
state(DECOMPRESS_HEADER),
@@ -416,7 +416,7 @@ namespace orc {
headerPosition(0),
inputBufferStartPosition(0),
bytesReturned(0),
- metrics(_metrics) {}
+ metrics(metrics) {}
std::string DecompressionStream::getStreamName() const {
return input->getName();
@@ -622,7 +622,7 @@ namespace orc {
virtual void NextDecompress(const void** data, int* size, size_t availableSize) override;
private:
- z_stream zstream;
+ z_stream zstream_;
};
DIAGNOSTIC_PUSH
@@ -632,17 +632,17 @@ namespace orc {
#endif
ZlibDecompressionStream::ZlibDecompressionStream(std::unique_ptr<SeekableInputStream> inStream,
- size_t bufferSize, MemoryPool& _pool,
- ReaderMetrics* _metrics)
- : DecompressionStream(std::move(inStream), bufferSize, _pool, _metrics) {
- zstream.next_in = nullptr;
- zstream.avail_in = 0;
- zstream.zalloc = nullptr;
- zstream.zfree = nullptr;
- zstream.opaque = nullptr;
- zstream.next_out = reinterpret_cast<Bytef*>(outputDataBuffer.data());
- zstream.avail_out = static_cast<uInt>(outputDataBuffer.capacity());
- int64_t result = inflateInit2(&zstream, -15);
+ size_t bufferSize, MemoryPool& pool,
+ ReaderMetrics* metrics)
+ : DecompressionStream(std::move(inStream), bufferSize, pool, metrics) {
+ zstream_.next_in = nullptr;
+ zstream_.avail_in = 0;
+ zstream_.zalloc = nullptr;
+ zstream_.zfree = nullptr;
+ zstream_.opaque = nullptr;
+ zstream_.next_out = reinterpret_cast<Bytef*>(outputDataBuffer.data());
+ zstream_.avail_out = static_cast<uInt>(outputDataBuffer.capacity());
+ int64_t result = inflateInit2(&zstream_, -15);
switch (result) {
case Z_OK:
break;
@@ -660,7 +660,7 @@ namespace orc {
DIAGNOSTIC_POP
ZlibDecompressionStream::~ZlibDecompressionStream() {
- int64_t result = inflateEnd(&zstream);
+ int64_t result = inflateEnd(&zstream_);
if (result != Z_OK) {
// really can't throw in destructors
std::cout << "Error in ~ZlibDecompressionStream() " << result << "\n";
@@ -668,19 +668,19 @@ namespace orc {
}
void ZlibDecompressionStream::NextDecompress(const void** data, int* size, size_t availableSize) {
- zstream.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer));
- zstream.avail_in = static_cast<uInt>(availableSize);
+ zstream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer));
+ zstream_.avail_in = static_cast<uInt>(availableSize);
outputBuffer = outputDataBuffer.data();
- zstream.next_out = reinterpret_cast<Bytef*>(const_cast<char*>(outputBuffer));
- zstream.avail_out = static_cast<uInt>(outputDataBuffer.capacity());
- if (inflateReset(&zstream) != Z_OK) {
+ zstream_.next_out = reinterpret_cast<Bytef*>(const_cast<char*>(outputBuffer));
+ zstream_.avail_out = static_cast<uInt>(outputDataBuffer.capacity());
+ if (inflateReset(&zstream_) != Z_OK) {
throw std::logic_error(
"Bad inflateReset in "
"ZlibDecompressionStream::NextDecompress");
}
int64_t result;
do {
- result = inflate(&zstream, availableSize == remainingLength ? Z_FINISH : Z_SYNC_FLUSH);
+ result = inflate(&zstream_, availableSize == remainingLength ? Z_FINISH : Z_SYNC_FLUSH);
switch (result) {
case Z_OK:
remainingLength -= availableSize;
@@ -688,8 +688,8 @@ namespace orc {
readBuffer(true);
availableSize =
std::min(static_cast<size_t>(inputBufferEnd - inputBuffer), remainingLength);
- zstream.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer));
- zstream.avail_in = static_cast<uInt>(availableSize);
+ zstream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer));
+ zstream_.avail_in = static_cast<uInt>(availableSize);
break;
case Z_STREAM_END:
break;
@@ -711,7 +711,7 @@ namespace orc {
"ZlibDecompressionStream::NextDecompress");
}
} while (result != Z_STREAM_END);
- *size = static_cast<int>(outputDataBuffer.capacity() - zstream.avail_out);
+ *size = static_cast<int>(outputDataBuffer.capacity() - zstream_.avail_out);
*data = outputBuffer;
outputBufferLength = 0;
outputBuffer += *size;
@@ -742,14 +742,14 @@ namespace orc {
private:
// may need to stitch together multiple input buffers;
// to give snappy a contiguous block
- DataBuffer<char> inputDataBuffer;
+ DataBuffer<char> inputDataBuffer_;
};
BlockDecompressionStream::BlockDecompressionStream(std::unique_ptr<SeekableInputStream> inStream,
- size_t blockSize, MemoryPool& _pool,
- ReaderMetrics* _metrics)
- : DecompressionStream(std::move(inStream), blockSize, _pool, _metrics),
- inputDataBuffer(pool, blockSize) {}
+ size_t blockSize, MemoryPool& pool,
+ ReaderMetrics* metrics)
+ : DecompressionStream(std::move(inStream), blockSize, pool, metrics),
+ inputDataBuffer_(pool, blockSize) {}
void BlockDecompressionStream::NextDecompress(const void** data, int* size,
size_t availableSize) {
@@ -759,18 +759,18 @@ namespace orc {
inputBuffer += availableSize;
} else {
// Did not read enough from input.
- if (inputDataBuffer.capacity() < remainingLength) {
- inputDataBuffer.resize(remainingLength);
+ if (inputDataBuffer_.capacity() < remainingLength) {
+ inputDataBuffer_.resize(remainingLength);
}
- ::memcpy(inputDataBuffer.data(), inputBuffer, availableSize);
+ ::memcpy(inputDataBuffer_.data(), inputBuffer, availableSize);
inputBuffer += availableSize;
- compressed = inputDataBuffer.data();
+ compressed = inputDataBuffer_.data();
for (size_t pos = availableSize; pos < remainingLength;) {
readBuffer(true);
size_t avail =
std::min(static_cast<size_t>(inputBufferEnd - inputBuffer), remainingLength - pos);
- ::memcpy(inputDataBuffer.data() + pos, inputBuffer, avail);
+ ::memcpy(inputDataBuffer_.data() + pos, inputBuffer, avail);
pos += avail;
inputBuffer += avail;
}
@@ -788,8 +788,8 @@ namespace orc {
class SnappyDecompressionStream : public BlockDecompressionStream {
public:
SnappyDecompressionStream(std::unique_ptr<SeekableInputStream> inStream, size_t blockSize,
- MemoryPool& _pool, ReaderMetrics* _metrics)
- : BlockDecompressionStream(std::move(inStream), blockSize, _pool, _metrics) {
+ MemoryPool& pool, ReaderMetrics* metrics)
+ : BlockDecompressionStream(std::move(inStream), blockSize, pool, metrics) {
// PASS
}
@@ -804,10 +804,10 @@ namespace orc {
size_t maxOutputLength) override;
};
- uint64_t SnappyDecompressionStream::decompress(const char* _input, uint64_t length, char* output,
+ uint64_t SnappyDecompressionStream::decompress(const char* input, uint64_t length, char* output,
size_t maxOutputLength) {
size_t outLength;
- if (!snappy::GetUncompressedLength(_input, length, &outLength)) {
+ if (!snappy::GetUncompressedLength(input, length, &outLength)) {
throw ParseError("SnappyDecompressionStream choked on corrupt input");
}
@@ -815,7 +815,7 @@ namespace orc {
throw std::logic_error("Snappy length exceeds block size");
}
- if (!snappy::RawUncompress(_input, length, output)) {
+ if (!snappy::RawUncompress(input, length, output)) {
throw ParseError("SnappyDecompressionStream choked on corrupt input");
}
return outLength;
@@ -824,8 +824,8 @@ namespace orc {
class LzoDecompressionStream : public BlockDecompressionStream {
public:
LzoDecompressionStream(std::unique_ptr<SeekableInputStream> inStream, size_t blockSize,
- MemoryPool& _pool, ReaderMetrics* _metrics)
- : BlockDecompressionStream(std::move(inStream), blockSize, _pool, _metrics) {
+ MemoryPool& pool, ReaderMetrics* metrics)
+ : BlockDecompressionStream(std::move(inStream), blockSize, pool, metrics) {
// PASS
}
@@ -848,8 +848,8 @@ namespace orc {
class Lz4DecompressionStream : public BlockDecompressionStream {
public:
Lz4DecompressionStream(std::unique_ptr<SeekableInputStream> inStream, size_t blockSize,
- MemoryPool& _pool, ReaderMetrics* _metrics)
- : BlockDecompressionStream(std::move(inStream), blockSize, _pool, _metrics) {
+ MemoryPool& pool, ReaderMetrics* metrics)
+ : BlockDecompressionStream(std::move(inStream), blockSize, pool, metrics) {
// PASS
}
@@ -967,12 +967,12 @@ namespace orc {
private:
void init();
void end();
- LZ4_stream_t* state;
+ LZ4_stream_t* state_;
};
uint64_t Lz4CompressionSteam::doBlockCompression() {
int result = LZ4_compress_fast_extState(
- static_cast<void*>(state), reinterpret_cast<const char*>(rawInputBuffer.data()),
+ static_cast<void*>(state_), reinterpret_cast<const char*>(rawInputBuffer.data()),
reinterpret_cast<char*>(compressorBuffer.data()), bufferSize,
static_cast<int>(compressorBuffer.size()), level);
if (result == 0) {
@@ -982,15 +982,15 @@ namespace orc {
}
void Lz4CompressionSteam::init() {
- state = LZ4_createStream();
- if (!state) {
+ state_ = LZ4_createStream();
+ if (!state_) {
throw std::runtime_error("Error while allocating state for lz4.");
}
}
void Lz4CompressionSteam::end() {
- (void)LZ4_freeStream(state);
- state = nullptr;
+ (void)LZ4_freeStream(state_);
+ state_ = nullptr;
}
/**
@@ -1055,11 +1055,11 @@ namespace orc {
private:
void init();
void end();
- ZSTD_CCtx* cctx;
+ ZSTD_CCtx* cctx_;
};
uint64_t ZSTDCompressionStream::doBlockCompression() {
- return ZSTD_compressCCtx(cctx, compressorBuffer.data(), compressorBuffer.size(),
+ return ZSTD_compressCCtx(cctx_, compressorBuffer.data(), compressorBuffer.size(),
rawInputBuffer.data(), static_cast<size_t>(bufferSize), level);
}
@@ -1070,15 +1070,15 @@ namespace orc {
#endif
void ZSTDCompressionStream::init() {
- cctx = ZSTD_createCCtx();
- if (!cctx) {
+ cctx_ = ZSTD_createCCtx();
+ if (!cctx_) {
throw std::runtime_error("Error while calling ZSTD_createCCtx() for zstd.");
}
}
void ZSTDCompressionStream::end() {
- (void)ZSTD_freeCCtx(cctx);
- cctx = nullptr;
+ (void)ZSTD_freeCCtx(cctx_);
+ cctx_ = nullptr;
}
DIAGNOSTIC_PUSH
@@ -1089,8 +1089,8 @@ namespace orc {
class ZSTDDecompressionStream : public BlockDecompressionStream {
public:
ZSTDDecompressionStream(std::unique_ptr<SeekableInputStream> inStream, size_t blockSize,
- MemoryPool& _pool, ReaderMetrics* _metrics)
- : BlockDecompressionStream(std::move(inStream), blockSize, _pool, _metrics) {
+ MemoryPool& pool, ReaderMetrics* metrics)
+ : BlockDecompressionStream(std::move(inStream), blockSize, pool, metrics) {
this->init();
}
@@ -1111,13 +1111,13 @@ namespace orc {
private:
void init();
void end();
- ZSTD_DCtx* dctx;
+ ZSTD_DCtx* dctx_;
};
uint64_t ZSTDDecompressionStream::decompress(const char* inputPtr, uint64_t length, char* output,
size_t maxOutputLength) {
return static_cast<uint64_t>(
- ZSTD_decompressDCtx(dctx, output, maxOutputLength, inputPtr, length));
+ ZSTD_decompressDCtx(dctx_, output, maxOutputLength, inputPtr, length));
}
DIAGNOSTIC_PUSH
@@ -1127,15 +1127,15 @@ namespace orc {
#endif
void ZSTDDecompressionStream::init() {
- dctx = ZSTD_createDCtx();
- if (!dctx) {
+ dctx_ = ZSTD_createDCtx();
+ if (!dctx_) {
throw std::runtime_error("Error while calling ZSTD_createDCtx() for zstd.");
}
}
void ZSTDDecompressionStream::end() {
- (void)ZSTD_freeDCtx(dctx);
- dctx = nullptr;
+ (void)ZSTD_freeDCtx(dctx_);
+ dctx_ = nullptr;
}
DIAGNOSTIC_PUSH
diff --git a/c++/src/ConvertColumnReader.cc b/c++/src/ConvertColumnReader.cc
index d94d1861a..67ee6d6c4 100644
--- a/c++/src/ConvertColumnReader.cc
+++ b/c++/src/ConvertColumnReader.cc
@@ -23,9 +23,9 @@ namespace orc {
// Assume that we are using tight numeric vector batch
using BooleanVectorBatch = ByteVectorBatch;
- ConvertColumnReader::ConvertColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ColumnReader(_readType, stripe), readType(_readType), throwOnOverflow(_throwOnOverflow) {
+ ConvertColumnReader::ConvertColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ColumnReader(readType, stripe), readType(readType), throwOnOverflow(throwOnOverflow) {
reader = buildReader(fileType, stripe, /*useTightNumericVector=*/true,
/*throwOnOverflow=*/false, /*convertToReadType*/ false);
data =
@@ -135,9 +135,9 @@ namespace orc {
template <typename FileTypeBatch, typename ReadTypeBatch, typename ReadType>
class NumericConvertColumnReader : public ConvertColumnReader {
public:
- NumericConvertColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ NumericConvertColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
ConvertColumnReader::next(rowBatch, numValues, notNull);
@@ -164,9 +164,9 @@ namespace orc {
class NumericConvertColumnReader<FileTypeBatch, BooleanVectorBatch, bool>
: public ConvertColumnReader {
public:
- NumericConvertColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ NumericConvertColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
ConvertColumnReader::next(rowBatch, numValues, notNull);
@@ -188,9 +188,9 @@ namespace orc {
class ConvertToStringVariantColumnReader : public ConvertColumnReader {
public:
- ConvertToStringVariantColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ ConvertToStringVariantColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override;
@@ -225,19 +225,19 @@ namespace orc {
class BooleanToStringVariantColumnReader : public ConvertToStringVariantColumnReader {
public:
- BooleanToStringVariantColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertToStringVariantColumnReader(_readType, fileType, stripe, _throwOnOverflow) {
- trueValue = "TRUE";
- falseValue = "FALSE";
+ BooleanToStringVariantColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertToStringVariantColumnReader(readType, fileType, stripe, throwOnOverflow) {
+ trueValue_ = "TRUE";
+ falseValue_ = "FALSE";
if (readType.getKind() == CHAR || readType.getKind() == VARCHAR) {
if (readType.getMaximumLength() < 5) {
throw SchemaEvolutionError("Invalid maximum length for boolean type: " +
std::to_string(readType.getMaximumLength()));
}
if (readType.getKind() == CHAR) {
- trueValue.resize(readType.getMaximumLength(), ' ');
- falseValue.resize(readType.getMaximumLength(), ' ');
+ trueValue_.resize(readType.getMaximumLength(), ' ');
+ falseValue_.resize(readType.getMaximumLength(), ' ');
}
}
}
@@ -245,8 +245,8 @@ namespace orc {
uint64_t convertToStrBuffer(ColumnVectorBatch& rowBatch, uint64_t numValues) override;
private:
- std::string trueValue;
- std::string falseValue;
+ std::string trueValue_;
+ std::string falseValue_;
};
uint64_t BooleanToStringVariantColumnReader::convertToStrBuffer(ColumnVectorBatch& rowBatch,
@@ -257,7 +257,7 @@ namespace orc {
// cast the bool value to string
for (uint64_t i = 0; i < numValues; ++i) {
if (!rowBatch.hasNulls || rowBatch.notNull[i]) {
- strBuffer[i] = (srcBatch.data[i] ? trueValue : falseValue);
+ strBuffer[i] = (srcBatch.data[i] ? trueValue_ : falseValue_);
size += strBuffer[i].size();
}
}
@@ -267,9 +267,9 @@ namespace orc {
template <typename FileTypeBatch>
class NumericToStringVariantColumnReader : public ConvertToStringVariantColumnReader {
public:
- NumericToStringVariantColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertToStringVariantColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ NumericToStringVariantColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertToStringVariantColumnReader(readType, fileType, stripe, throwOnOverflow) {}
uint64_t convertToStrBuffer(ColumnVectorBatch& rowBatch, uint64_t numValues) override;
};
@@ -321,13 +321,13 @@ namespace orc {
template <typename FileTypeBatch, typename ReadTypeBatch, bool isFloatingFileType>
class NumericToDecimalColumnReader : public ConvertColumnReader {
public:
- NumericToDecimalColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {
- precision = static_cast<int32_t>(readType.getPrecision());
- scale = static_cast<int32_t>(readType.getScale());
+ NumericToDecimalColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {
+ precision_ = static_cast<int32_t>(readType.getPrecision());
+ scale_ = static_cast<int32_t>(readType.getScale());
bool overflow = false;
- upperBound = scaleUpInt128ByPowerOfTen(1, precision, overflow);
+ upperBound_ = scaleUpInt128ByPowerOfTen(1, precision_, overflow);
}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
@@ -335,8 +335,8 @@ namespace orc {
const auto& srcBatch = *SafeCastBatchTo<const FileTypeBatch*>(data.get());
auto& dstBatch = *SafeCastBatchTo<ReadTypeBatch*>(&rowBatch);
- dstBatch.precision = precision;
- dstBatch.scale = scale;
+ dstBatch.precision = precision_;
+ dstBatch.scale = scale_;
for (uint64_t i = 0; i < numValues; ++i) {
if (!rowBatch.hasNulls || rowBatch.notNull[i]) {
if constexpr (isFloatingFileType) {
@@ -351,7 +351,7 @@ namespace orc {
private:
template <typename SrcType>
void convertDoubleToDecimal(ReadTypeBatch& dstBatch, uint64_t idx, SrcType value) {
- const auto result = convertDecimal(value, precision, scale);
+ const auto result = convertDecimal(value, precision_, scale_);
Int128 i128 = result.second;
if (result.first) {
handleOverflow<SrcType, decltype(dstBatch.values[idx])>(dstBatch, idx, throwOnOverflow);
@@ -372,7 +372,7 @@ namespace orc {
template <typename SrcType>
void convertIntegerToDecimal(ReadTypeBatch& dstBatch, uint64_t idx, SrcType value) {
int fromScale = 0;
- auto result = convertDecimal(value, fromScale, precision, scale);
+ auto result = convertDecimal(value, fromScale, precision_, scale_);
if (result.first) {
handleOverflow<SrcType, decltype(dstBatch.values[idx])>(dstBatch, idx, throwOnOverflow);
} else {
@@ -388,17 +388,17 @@ namespace orc {
}
}
- int32_t precision;
- int32_t scale;
- int64_t scaleMultiplier;
- Int128 upperBound;
+ int32_t precision_;
+ int32_t scale_;
+ int64_t scaleMultiplier_;
+ Int128 upperBound_;
};
class ConvertToTimestampColumnReader : public ConvertColumnReader {
public:
- ConvertToTimestampColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow),
+ ConvertToTimestampColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow),
readerTimezone(readType.getKind() == TIMESTAMP_INSTANT ? &getTimezoneByName("GMT")
: &stripe.getReaderTimezone()),
needConvertTimezone(readerTimezone != &getTimezoneByName("GMT")) {}
@@ -419,9 +419,9 @@ namespace orc {
template <typename FileTypeBatch>
class NumericToTimestampColumnReader : public ConvertToTimestampColumnReader {
public:
- NumericToTimestampColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertToTimestampColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ NumericToTimestampColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertToTimestampColumnReader(readType, fileType, stripe, throwOnOverflow) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
ConvertToTimestampColumnReader::next(rowBatch, numValues, notNull);
@@ -469,14 +469,14 @@ namespace orc {
template <typename FileTypeBatch, typename ReadTypeBatch, typename ReadType>
class DecimalToNumericColumnReader : public ConvertColumnReader {
public:
- DecimalToNumericColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {
- precision = fileType.getPrecision();
- scale = fileType.getScale();
- factor = 1;
- for (int i = 0; i < scale; i++) {
- factor *= 10;
+ DecimalToNumericColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {
+ precision_ = fileType.getPrecision();
+ scale_ = fileType.getScale();
+ factor_ = 1;
+ for (int i = 0; i < scale_; i++) {
+ factor_ *= 10;
}
}
@@ -500,7 +500,7 @@ namespace orc {
void convertDecimalToInteger(ReadTypeBatch& dstBatch, uint64_t idx,
const FileTypeBatch& srcBatch) {
using FileType = decltype(srcBatch.values[idx]);
- Int128 result = scaleDownInt128ByPowerOfTen(srcBatch.values[idx], scale);
+ Int128 result = scaleDownInt128ByPowerOfTen(srcBatch.values[idx], scale_);
if (!result.fitsInLong()) {
handleOverflow<FileType, ReadType>(dstBatch, idx, throwOnOverflow);
return;
@@ -512,21 +512,21 @@ namespace orc {
void convertDecimalToDouble(ReadTypeBatch& dstBatch, uint64_t idx,
const FileTypeBatch& srcBatch) {
double doubleValue = Int128(srcBatch.values[idx]).toDouble();
- dstBatch.data[idx] = static_cast<ReadType>(doubleValue) / static_cast<ReadType>(factor);
+ dstBatch.data[idx] = static_cast<ReadType>(doubleValue) / static_cast<ReadType>(factor_);
}
- int32_t precision;
- int32_t scale;
- int64_t factor;
+ int32_t precision_;
+ int32_t scale_;
+ int64_t factor_;
};
template <typename FileTypeBatch>
class DecimalToNumericColumnReader<FileTypeBatch, BooleanVectorBatch, bool>
: public ConvertColumnReader {
public:
- DecimalToNumericColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {}
+ DecimalToNumericColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
ConvertColumnReader::next(rowBatch, numValues, notNull);
@@ -544,13 +544,13 @@ namespace orc {
template <typename FileTypeBatch, typename ReadTypeBatch>
class DecimalConvertColumnReader : public ConvertColumnReader {
public:
- DecimalConvertColumnReader(const Type& _readType, const Type& fileType, StripeStreams& stripe,
- bool _throwOnOverflow)
- : ConvertColumnReader(_readType, fileType, stripe, _throwOnOverflow) {
- fromPrecision = fileType.getPrecision();
- fromScale = fileType.getScale();
- toPrecision = _readType.getPrecision();
- toScale = _readType.getScale();
+ DecimalConvertColumnReader(const Type& readType, const Type& fileType, StripeStreams& stripe,
+ bool throwOnOverflow)
+ : ConvertColumnReader(readType, fileType, stripe, throwOnOverflow) {
+ fromPrecision_ = fileType.getPrecision();
+ fromScale_ = fileType.getScale();
+ toPrecision_ = readType.getPrecision();
+ toScale_ = readType.getScale();
}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
@@ -572,7 +572,7 @@ namespace orc {
using ReadType = decltype(dstBatch.values[idx]);
auto [overflows, resultI128] =
- convertDecimal(srcBatch.values[idx], fromScale, toPrecision, toScale);
+ convertDecimal(srcBatch.values[idx], fromScale_, toPrecision_, toScale_);
if (overflows) {
handleOverflow<FileType, ReadType>(dstBatch, idx, throwOnOverflow);
}
@@ -587,20 +587,20 @@ namespace orc {
}
}
- int32_t fromPrecision;
- int32_t fromScale;
- int32_t toPrecision;
- int32_t toScale;
+ int32_t fromPrecision_;
+ int32_t fromScale_;
+ int32_t toPrecision_;
+ int32_t toScale_;
};
template <typename FileTypeBatch>
class DecimalToTimestampColumnReader : public ConvertToTimestampColumnReader {
public:
- DecimalToTimestampColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertToTimestampColumnReader(_readType, fileType, stripe, _throwOnOverflow),
- precision(static_cast<int32_t>(fileType.getPrecision())),
- scale(static_cast<int32_t>(fileType.getScale())) {}
+ DecimalToTimestampColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertToTimestampColumnReader(readType, fileType, stripe, throwOnOverflow),
+ precision_(static_cast<int32_t>(fileType.getPrecision())),
+ scale_(static_cast<int32_t>(fileType.getScale())) {}
void next(ColumnVectorBatch& rowBatch, uint64_t numValues, char* notNull) override {
ConvertColumnReader::next(rowBatch, numValues, notNull);
@@ -626,18 +626,18 @@ namespace orc {
bool overflow = false;
Int128 i128(srcBatch.values[idx]);
- Int128 integerPortion = scaleDownInt128ByPowerOfTen(i128, scale);
+ Int128 integerPortion = scaleDownInt128ByPowerOfTen(i128, scale_);
if (integerPortion < MIN_EPOCH_SECONDS || integerPortion > MAX_EPOCH_SECONDS) {
handleOverflow<Decimal, int64_t>(dstBatch, idx, throwOnOverflow);
return;
}
- i128 -= scaleUpInt128ByPowerOfTen(integerPortion, scale, overflow);
+ i128 -= scaleUpInt128ByPowerOfTen(integerPortion, scale_, overflow);
Int128 fractionPortion = std::move(i128);
- if (scale < SecondToNanoFactor) {
+ if (scale_ < SecondToNanoFactor) {
fractionPortion =
- scaleUpInt128ByPowerOfTen(fractionPortion, SecondToNanoFactor - scale, overflow);
+ scaleUpInt128ByPowerOfTen(fractionPortion, SecondToNanoFactor - scale_, overflow);
} else {
- fractionPortion = scaleDownInt128ByPowerOfTen(fractionPortion, scale - SecondToNanoFactor);
+ fractionPortion = scaleDownInt128ByPowerOfTen(fractionPortion, scale_ - SecondToNanoFactor);
}
if (fractionPortion < 0) {
fractionPortion += 1e9;
@@ -652,17 +652,17 @@ namespace orc {
}
}
- const int32_t precision;
- const int32_t scale;
+ const int32_t precision_;
+ const int32_t scale_;
};
template <typename FileTypeBatch>
class DecimalToStringVariantColumnReader : public ConvertToStringVariantColumnReader {
public:
- DecimalToStringVariantColumnReader(const Type& _readType, const Type& fileType,
- StripeStreams& stripe, bool _throwOnOverflow)
- : ConvertToStringVariantColumnReader(_readType, fileType, stripe, _throwOnOverflow),
- scale(fileType.getScale()) {}
+ DecimalToStringVariantColumnReader(const Type& readType, const Type& fileType,
+ StripeStreams& stripe, bool throwOnOverflow)
+ : ConvertToStringVariantColumnReader(readType, fileType, stripe, throwOnOverflow),
+ scale_(fileType.getScale()) {}
uint64_t convertToStrBuffer(ColumnVectorBatch& rowBatch, uint64_t numValues) override {
uint64_t size = 0;
@@ -671,7 +671,7 @@ namespace orc {
if (readType.getKind() == STRING) {
for (uint64_t i = 0; i < rowBatch.numElements; ++i) {
if (!rowBatch.hasNulls || rowBatch.notNull[i]) {
- strBuffer[i] = Int128(srcBatch.values[i]).toDecimalString(scale, true);
+ strBuffer[i] = Int128(srcBatch.values[i]).toDecimalString(scale_, true);
size += strBuffer[i].size();
}
}
@@ -679,7 +679,7 @@ namespace orc {
const auto maxLength = readType.getMaximumLength();
for (uint64_t i = 0; i < rowBatch.numElements; ++i) {
if (!rowBatch.hasNulls || rowBatch.notNull[i]) {
- strBuffer[i] = Int128(srcBatch.values[i]).toDecimalString(scale, true);
+ strBuffer[i] = Int128(srcBatch.values[i]).toDecimalString(scale_, true);
}
if (strBuffer[i].size() > maxLength) {
strBuffer[i].resize(maxLength);
@@ -691,7 +691,7 @@ namespace orc {
}
private:
- const int32_t scale;
+ const int32_t scale_;
};
#define DEFINE_NUMERIC_CONVERT_READER(FROM, TO, TYPE) \
diff --git a/c++/src/CpuInfoUtil.cc b/c++/src/CpuInfoUtil.cc
index 7e6958dee..82669de20 100644
--- a/c++/src/CpuInfoUtil.cc
+++ b/c++/src/CpuInfoUtil.cc
@@ -375,11 +375,11 @@ namespace orc {
return flags;
}
- void OsRetrieveCacheSize(std::array<int64_t, kCacheLevels>* cache_sizes) {
+ void OsRetrieveCacheSize(std::array<int64_t, kCacheLevels>* cacheSizes) {
for (int i = 0; i < kCacheLevels; ++i) {
const int64_t cache_size = LinuxGetCacheSize(i);
if (cache_size > 0) {
- (*cache_sizes)[i] = cache_size;
+ (*cacheSizes)[i] = cache_size;
}
}
}
@@ -403,8 +403,8 @@ namespace orc {
}
// Read from /proc/cpuinfo
- void OsRetrieveCpuInfo(int64_t* hardware_flags, CpuInfo::Vendor* vendor,
- std::string* model_name) {
+ void OsRetrieveCpuInfo(int64_t* hardwareFlags, CpuInfo::Vendor* vendor,
+ std::string* modelName) {
std::ifstream cpuinfo("/proc/cpuinfo", std::ios::in);
while (cpuinfo) {
std::string line;
@@ -414,9 +414,9 @@ namespace orc {
const std::string name = TrimString(line.substr(0, colon - 1));
const std::string value = TrimString(line.substr(colon + 1, std::string::npos));
if (name.compare("flags") == 0 || name.compare("Features") == 0) {
- *hardware_flags |= LinuxParseCpuFlags(value);
+ *hardwareFlags |= LinuxParseCpuFlags(value);
} else if (name.compare("model name") == 0) {
- *model_name = value;
+ *modelName = value;
} else if (name.compare("vendor_id") == 0) {
if (value.compare("GenuineIntel") == 0) {
*vendor = CpuInfo::Vendor::Intel;
@@ -433,7 +433,7 @@ namespace orc {
#if defined(CPUINFO_ARCH_X86)
//------------------------------ X86_64 ------------------------------//
- bool ArchParseUserSimdLevel(const std::string& simd_level, int64_t* hardware_flags) {
+ bool ArchParseUserSimdLevel(const std::string& simdLevel, int64_t* hardwareFlags) {
enum {
USER_SIMD_NONE,
USER_SIMD_AVX512,
@@ -442,9 +442,9 @@ namespace orc {
int level = USER_SIMD_MAX;
// Parse the level
- if (simd_level == "AVX512") {
+ if (simdLevel == "AVX512") {
level = USER_SIMD_AVX512;
- } else if (simd_level == "NONE") {
+ } else if (simdLevel == "NONE") {
level = USER_SIMD_NONE;
} else {
return false;
@@ -452,7 +452,7 @@ namespace orc {
// Disable feature as the level
if (level < USER_SIMD_AVX512) {
- *hardware_flags &= ~CpuInfo::AVX512;
+ *hardwareFlags &= ~CpuInfo::AVX512;
}
return true;
}
diff --git a/c++/src/Exceptions.cc b/c++/src/Exceptions.cc
index 23703ff32..30ecf7dc7 100644
--- a/c++/src/Exceptions.cc
+++ b/c++/src/Exceptions.cc
@@ -20,11 +20,11 @@
namespace orc {
- NotImplementedYet::NotImplementedYet(const std::string& what_arg) : logic_error(what_arg) {
+ NotImplementedYet::NotImplementedYet(const std::string& whatArg) : logic_error(whatArg) {
// PASS
}
- NotImplementedYet::NotImplementedYet(const char* what_arg) : logic_error(what_arg) {
+ NotImplementedYet::NotImplementedYet(const char* whatArg) : logic_error(whatArg) {
// PASS
}
@@ -36,11 +36,11 @@ namespace orc {
// PASS
}
- ParseError::ParseError(const std::string& what_arg) : runtime_error(what_arg) {
+ ParseError::ParseError(const std::string& whatArg) : runtime_error(whatArg) {
// PASS
}
- ParseError::ParseError(const char* what_arg) : runtime_error(what_arg) {
+ ParseError::ParseError(const char* whatArg) : runtime_error(whatArg) {
// PASS
}
@@ -52,11 +52,11 @@ namespace orc {
// PASS
}
- InvalidArgument::InvalidArgument(const std::string& what_arg) : runtime_error(what_arg) {
+ InvalidArgument::InvalidArgument(const std::string& whatArg) : runtime_error(whatArg) {
// PASS
}
- InvalidArgument::InvalidArgument(const char* what_arg) : runtime_error(what_arg) {
+ InvalidArgument::InvalidArgument(const char* whatArg) : runtime_error(whatArg) {
// PASS
}
@@ -68,11 +68,11 @@ namespace orc {
// PASS
}
- SchemaEvolutionError::SchemaEvolutionError(const std::string& what_arg) : logic_error(what_arg) {
+ SchemaEvolutionError::SchemaEvolutionError(const std::string& whatArg) : logic_error(whatArg) {
// PASS
}
- SchemaEvolutionError::SchemaEvolutionError(const char* what_arg) : logic_error(what_arg) {
+ SchemaEvolutionError::SchemaEvolutionError(const char* whatArg) : logic_error(whatArg) {
// PASS
}
diff --git a/c++/src/Int128.cc b/c++/src/Int128.cc
index 3c159f377..4a1d0b763 100644
--- a/c++/src/Int128.cc
+++ b/c++/src/Int128.cc
@@ -35,8 +35,8 @@ namespace orc {
}
Int128::Int128(const std::string& str) {
- lowbits = 0;
- highbits = 0;
+ lowbits_ = 0;
+ highbits_ = 0;
size_t length = str.length();
if (length > 0) {
bool isNegative = str[0] == '-';
@@ -64,30 +64,30 @@ namespace orc {
// Break the left and right numbers into 32 bit chunks
// so that we can multiply them without overflow.
- uint64_t L0 = static_cast<uint64_t>(highbits) >> 32;
- uint64_t L1 = static_cast<uint64_t>(highbits) & INT_MASK;
- uint64_t L2 = lowbits >> 32;
- uint64_t L3 = lowbits & INT_MASK;
- uint64_t R0 = static_cast<uint64_t>(right.highbits) >> 32;
- uint64_t R1 = static_cast<uint64_t>(right.highbits) & INT_MASK;
- uint64_t R2 = right.lowbits >> 32;
- uint64_t R3 = right.lowbits & INT_MASK;
+ uint64_t L0 = static_cast<uint64_t>(highbits_) >> 32;
+ uint64_t L1 = static_cast<uint64_t>(highbits_) & INT_MASK;
+ uint64_t L2 = lowbits_ >> 32;
+ uint64_t L3 = lowbits_ & INT_MASK;
+ uint64_t R0 = static_cast<uint64_t>(right.highbits_) >> 32;
+ uint64_t R1 = static_cast<uint64_t>(right.highbits_) & INT_MASK;
+ uint64_t R2 = right.lowbits_ >> 32;
+ uint64_t R3 = right.lowbits_ & INT_MASK;
uint64_t product = L3 * R3;
- lowbits = product & INT_MASK;
+ lowbits_ = product & INT_MASK;
uint64_t sum = product >> 32;
product = L2 * R3;
sum += product;
- highbits = sum < product ? CARRY_BIT : 0;
+ highbits_ = sum < product ? CARRY_BIT : 0;
product = L3 * R2;
sum += product;
if (sum < product) {
- highbits += CARRY_BIT;
+ highbits_ += CARRY_BIT;
}
- lowbits += sum << 32;
- highbits += static_cast<int64_t>(sum >> 32);
- highbits += L1 * R3 + L2 * R2 + L3 * R1;
- highbits += (L0 * R3 + L1 * R2 + L2 * R1 + L3 * R0) << 32;
+ lowbits_ += sum << 32;
+ highbits_ += static_cast<int64_t>(sum >> 32);
+ highbits_ += L1 * R3 + L2 * R2 + L3 * R1;
+ highbits_ += (L0 * R3 + L1 * R2 + L2 * R1 + L3 * R0) << 32;
return *this;
}
@@ -103,16 +103,16 @@ namespace orc {
int64_t Int128::fillInArray(uint32_t* array, bool& wasNegative) const {
uint64_t high;
uint64_t low;
- if (highbits < 0) {
- low = ~lowbits + 1;
- high = static_cast<uint64_t>(~highbits);
+ if (highbits_ < 0) {
+ low = ~lowbits_ + 1;
+ high = static_cast<uint64_t>(~highbits_);
if (low == 0) {
high += 1;
}
wasNegative = true;
} else {
- low = lowbits;
- high = static_cast<uint64_t>(highbits);
+ low = lowbits_;
+ high = static_cast<uint64_t>(highbits_);
wasNegative = false;
}
if (high != 0) {
@@ -430,8 +430,8 @@ namespace orc {
std::string Int128::toHexString() const {
std::stringstream buf;
- buf << std::hex << "0x" << std::setw(16) << std::setfill('0') << highbits << std::setw(16)
- << std::setfill('0') << lowbits;
+ buf << std::hex << "0x" << std::setw(16) << std::setfill('0') << highbits_ << std::setw(16)
+ << std::setfill('0') << lowbits_;
return buf.str();
}
@@ -439,7 +439,7 @@ namespace orc {
if (fitsInLong()) {
return static_cast<double>(toLong());
}
- return static_cast<double>(lowbits) + std::ldexp(static_cast<double>(highbits), 64);
+ return static_cast<double>(lowbits_) + std::ldexp(static_cast<double>(highbits_), 64);
}
const static int32_t MAX_PRECISION_64 = 18;
diff --git a/c++/src/MemoryPool.cc b/c++/src/MemoryPool.cc
index 8c8837aa6..ed7fee737 100644
--- a/c++/src/MemoryPool.cc
+++ b/c++/src/MemoryPool.cc
@@ -53,72 +53,72 @@ namespace orc {
template <class T>
DataBuffer<T>::DataBuffer(MemoryPool& pool, uint64_t newSize)
- : memoryPool(pool), buf(nullptr), currentSize(0), currentCapacity(0) {
+ : memoryPool_(pool), buf_(nullptr), currentSize_(0), currentCapacity_(0) {
reserve(newSize);
- currentSize = newSize;
+ currentSize_ = newSize;
}
template <class T>
DataBuffer<T>::DataBuffer(DataBuffer<T>&& buffer) noexcept
- : memoryPool(buffer.memoryPool),
- buf(buffer.buf),
- currentSize(buffer.currentSize),
- currentCapacity(buffer.currentCapacity) {
- buffer.buf = nullptr;
- buffer.currentSize = 0;
- buffer.currentCapacity = 0;
+ : memoryPool_(buffer.memoryPool_),
+ buf_(buffer.buf_),
+ currentSize_(buffer.currentSize_),
+ currentCapacity_(buffer.currentCapacity_) {
+ buffer.buf_ = nullptr;
+ buffer.currentSize_ = 0;
+ buffer.currentCapacity_ = 0;
}
template <class T>
DataBuffer<T>::~DataBuffer() {
- for (uint64_t i = currentSize; i > 0; --i) {
- (buf + i - 1)->~T();
+ for (uint64_t i = currentSize_; i > 0; --i) {
+ (buf_ + i - 1)->~T();
}
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <class T>
void DataBuffer<T>::resize(uint64_t newSize) {
reserve(newSize);
- if (currentSize > newSize) {
- for (uint64_t i = currentSize; i > newSize; --i) {
- (buf + i - 1)->~T();
+ if (currentSize_ > newSize) {
+ for (uint64_t i = currentSize_; i > newSize; --i) {
+ (buf_ + i - 1)->~T();
}
- } else if (newSize > currentSize) {
- for (uint64_t i = currentSize; i < newSize; ++i) {
- new (buf + i) T();
+ } else if (newSize > currentSize_) {
+ for (uint64_t i = currentSize_; i < newSize; ++i) {
+ new (buf_ + i) T();
}
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
template <class T>
void DataBuffer<T>::reserve(uint64_t newCapacity) {
- if (newCapacity > currentCapacity || !buf) {
- if (buf) {
- T* buf_old = buf;
- buf = reinterpret_cast<T*>(memoryPool.malloc(sizeof(T) * newCapacity));
- memcpy(buf, buf_old, sizeof(T) * currentSize);
- memoryPool.free(reinterpret_cast<char*>(buf_old));
+ if (newCapacity > currentCapacity_ || !buf_) {
+ if (buf_) {
+ T* buf_old = buf_;
+ buf_ = reinterpret_cast<T*>(memoryPool_.malloc(sizeof(T) * newCapacity));
+ memcpy(buf_, buf_old, sizeof(T) * currentSize_);
+ memoryPool_.free(reinterpret_cast<char*>(buf_old));
} else {
- buf = reinterpret_cast<T*>(memoryPool.malloc(sizeof(T) * newCapacity));
+ buf_ = reinterpret_cast<T*>(memoryPool_.malloc(sizeof(T) * newCapacity));
}
- currentCapacity = newCapacity;
+ currentCapacity_ = newCapacity;
}
}
template <class T>
void DataBuffer<T>::zeroOut() {
- memset(buf, 0, sizeof(T) * currentCapacity);
+ memset(buf_, 0, sizeof(T) * currentCapacity_);
}
// Specializations for Int128
template <>
void DataBuffer<Int128>::zeroOut() {
- for (uint64_t i = 0; i < currentCapacity; ++i) {
- new (buf + i) Int128();
+ for (uint64_t i = 0; i < currentCapacity_; ++i) {
+ new (buf_ + i) Int128();
}
}
@@ -126,180 +126,180 @@ namespace orc {
template <>
DataBuffer<char>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<char>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, newSize - currentSize);
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, newSize - currentSize_);
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for char*
template <>
DataBuffer<char*>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<char*>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(char*));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(char*));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for double
template <>
DataBuffer<double>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<double>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(double));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(double));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for float
template <>
DataBuffer<float>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<float>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(float));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(float));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for int64_t
template <>
DataBuffer<int64_t>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<int64_t>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(int64_t));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(int64_t));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for int32_t
template <>
DataBuffer<int32_t>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<int32_t>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(int32_t));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(int32_t));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for int16_t
template <>
DataBuffer<int16_t>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<int16_t>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(int16_t));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(int16_t));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for int8_t
template <>
DataBuffer<int8_t>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<int8_t>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(int8_t));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(int8_t));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for uint64_t
template <>
DataBuffer<uint64_t>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<uint64_t>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, (newSize - currentSize) * sizeof(uint64_t));
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, (newSize - currentSize_) * sizeof(uint64_t));
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
// Specializations for unsigned char
template <>
DataBuffer<unsigned char>::~DataBuffer() {
- if (buf) {
- memoryPool.free(reinterpret_cast<char*>(buf));
+ if (buf_) {
+ memoryPool_.free(reinterpret_cast<char*>(buf_));
}
}
template <>
void DataBuffer<unsigned char>::resize(uint64_t newSize) {
reserve(newSize);
- if (newSize > currentSize) {
- memset(buf + currentSize, 0, newSize - currentSize);
+ if (newSize > currentSize_) {
+ memset(buf_ + currentSize_, 0, newSize - currentSize_);
}
- currentSize = newSize;
+ currentSize_ = newSize;
}
#ifdef __clang__
diff --git a/c++/src/Options.hh b/c++/src/Options.hh
index 51cd8efd6..daf9d52e1 100644
--- a/c++/src/Options.hh
+++ b/c++/src/Options.hh
@@ -52,23 +52,23 @@ namespace orc {
}
};
- ReaderOptions::ReaderOptions() : privateBits(std::make_unique<ReaderOptionsPrivate>()) {
+ ReaderOptions::ReaderOptions() : privateBits_(std::make_unique<ReaderOptionsPrivate>()) {
// PASS
}
ReaderOptions::ReaderOptions(const ReaderOptions& rhs)
- : privateBits(std::make_unique<ReaderOptionsPrivate>(*(rhs.privateBits.get()))) {
+ : privateBits_(std::make_unique<ReaderOptionsPrivate>(*(rhs.privateBits_.get()))) {
// PASS
}
ReaderOptions::ReaderOptions(ReaderOptions& rhs) {
// swap privateBits with rhs
- privateBits.swap(rhs.privateBits);
+ privateBits_.swap(rhs.privateBits_);
}
ReaderOptions& ReaderOptions::operator=(const ReaderOptions& rhs) {
if (this != &rhs) {
- privateBits.reset(new ReaderOptionsPrivate(*(rhs.privateBits.get())));
+ privateBits_.reset(new ReaderOptionsPrivate(*(rhs.privateBits_.get())));
}
return *this;
}
@@ -78,48 +78,48 @@ namespace orc {
}
ReaderOptions& ReaderOptions::setMemoryPool(MemoryPool& pool) {
- privateBits->memoryPool = &pool;
+ privateBits_->memoryPool = &pool;
return *this;
}
MemoryPool* ReaderOptions::getMemoryPool() const {
- return privateBits->memoryPool;
+ return privateBits_->memoryPool;
}
ReaderOptions& ReaderOptions::setReaderMetrics(ReaderMetrics* metrics) {
- privateBits->metrics = metrics;
+ privateBits_->metrics = metrics;
return *this;
}
ReaderMetrics* ReaderOptions::getReaderMetrics() const {
- return privateBits->metrics;
+ return privateBits_->metrics;
}
ReaderOptions& ReaderOptions::setTailLocation(uint64_t offset) {
- privateBits->tailLocation = offset;
+ privateBits_->tailLocation = offset;
return *this;
}
uint64_t ReaderOptions::getTailLocation() const {
- return privateBits->tailLocation;
+ return privateBits_->tailLocation;
}
ReaderOptions& ReaderOptions::setSerializedFileTail(const std::string& value) {
- privateBits->serializedTail = value;
+ privateBits_->serializedTail = value;
return *this;
}
std::string ReaderOptions::getSerializedFileTail() const {
- return privateBits->serializedTail;
+ return privateBits_->serializedTail;
}
ReaderOptions& ReaderOptions::setErrorStream(std::ostream& stream) {
- privateBits->errorStream = &stream;
+ privateBits_->errorStream = &stream;
return *this;
}
std::ostream* ReaderOptions::getErrorStream() const {
- return privateBits->errorStream;
+ return privateBits_->errorStream;
}
/**
@@ -155,23 +155,23 @@ namespace orc {
}
};
- RowReaderOptions::RowReaderOptions() : privateBits(std::make_unique<RowReaderOptionsPrivate>()) {
+ RowReaderOptions::RowReaderOptions() : privateBits_(std::make_unique<RowReaderOptionsPrivate>()) {
// PASS
}
RowReaderOptions::RowReaderOptions(const RowReaderOptions& rhs)
- : privateBits(std::make_unique<RowReaderOptionsPrivate>(*(rhs.privateBits.get()))) {
+ : privateBits_(std::make_unique<RowReaderOptionsPrivate>(*(rhs.privateBits_.get()))) {
// PASS
}
RowReaderOptions::RowReaderOptions(RowReaderOptions& rhs) {
// swap privateBits with rhs
- privateBits.swap(rhs.privateBits);
+ privateBits_.swap(rhs.privateBits_);
}
RowReaderOptions& RowReaderOptions::operator=(const RowReaderOptions& rhs) {
if (this != &rhs) {
- privateBits.reset(new RowReaderOptionsPrivate(*(rhs.privateBits.get())));
+ privateBits_.reset(new RowReaderOptionsPrivate(*(rhs.privateBits_.get())));
}
return *this;
}
@@ -181,150 +181,150 @@ namespace orc {
}
RowReaderOptions& RowReaderOptions::include(const std::list<uint64_t>& include) {
- privateBits->selection = ColumnSelection_FIELD_IDS;
- privateBits->includedColumnIndexes.assign(include.begin(), include.end());
- privateBits->includedColumnNames.clear();
- privateBits->idReadIntentMap.clear();
+ privateBits_->selection = ColumnSelection_FIELD_IDS;
+ privateBits_->includedColumnIndexes.assign(include.begin(), include.end());
+ privateBits_->includedColumnNames.clear();
+ privateBits_->idReadIntentMap.clear();
return *this;
}
RowReaderOptions& RowReaderOptions::include(const std::list<std::string>& include) {
- privateBits->selection = ColumnSelection_NAMES;
- privateBits->includedColumnNames.assign(include.begin(), include.end());
- privateBits->includedColumnIndexes.clear();
- privateBits->idReadIntentMap.clear();
+ privateBits_->selection = ColumnSelection_NAMES;
+ privateBits_->includedColumnNames.assign(include.begin(), include.end());
+ privateBits_->includedColumnIndexes.clear();
+ privateBits_->idReadIntentMap.clear();
return *this;
}
RowReaderOptions& RowReaderOptions::includeTypes(const std::list<uint64_t>& types) {
- privateBits->selection = ColumnSelection_TYPE_IDS;
- privateBits->includedColumnIndexes.assign(types.begin(), types.end());
- privateBits->includedColumnNames.clear();
- privateBits->idReadIntentMap.clear();
+ privateBits_->selection = ColumnSelection_TYPE_IDS;
+ privateBits_->includedColumnIndexes.assign(types.begin(), types.end());
+ privateBits_->includedColumnNames.clear();
+ privateBits_->idReadIntentMap.clear();
return *this;
}
RowReaderOptions& RowReaderOptions::includeTypesWithIntents(
const IdReadIntentMap& idReadIntentMap) {
- privateBits->selection = ColumnSelection_TYPE_IDS;
- privateBits->includedColumnIndexes.clear();
- privateBits->idReadIntentMap.clear();
+ privateBits_->selection = ColumnSelection_TYPE_IDS;
+ privateBits_->includedColumnIndexes.clear();
+ privateBits_->idReadIntentMap.clear();
for (const auto& typeIntentPair : idReadIntentMap) {
- privateBits->idReadIntentMap[typeIntentPair.first] = typeIntentPair.second;
- privateBits->includedColumnIndexes.push_back(typeIntentPair.first);
+ privateBits_->idReadIntentMap[typeIntentPair.first] = typeIntentPair.second;
+ privateBits_->includedColumnIndexes.push_back(typeIntentPair.first);
}
- privateBits->includedColumnNames.clear();
+ privateBits_->includedColumnNames.clear();
return *this;
}
RowReaderOptions& RowReaderOptions::range(uint64_t offset, uint64_t length) {
- privateBits->dataStart = offset;
- privateBits->dataLength = length;
+ privateBits_->dataStart = offset;
+ privateBits_->dataLength = length;
return *this;
}
bool RowReaderOptions::getIndexesSet() const {
- return privateBits->selection == ColumnSelection_FIELD_IDS;
+ return privateBits_->selection == ColumnSelection_FIELD_IDS;
}
bool RowReaderOptions::getTypeIdsSet() const {
- return privateBits->selection == ColumnSelection_TYPE_IDS;
+ return privateBits_->selection == ColumnSelection_TYPE_IDS;
}
const std::list<uint64_t>& RowReaderOptions::getInclude() const {
- return privateBits->includedColumnIndexes;
+ return privateBits_->includedColumnIndexes;
}
bool RowReaderOptions::getNamesSet() const {
- return privateBits->selection == ColumnSelection_NAMES;
+ return privateBits_->selection == ColumnSelection_NAMES;
}
const std::list<std::string>& RowReaderOptions::getIncludeNames() const {
- return privateBits->includedColumnNames;
+ return privateBits_->includedColumnNames;
}
uint64_t RowReaderOptions::getOffset() const {
- return privateBits->dataStart;
+ return privateBits_->dataStart;
}
uint64_t RowReaderOptions::getLength() const {
- return privateBits->dataLength;
+ return privateBits_->dataLength;
}
RowReaderOptions& RowReaderOptions::throwOnHive11DecimalOverflow(bool shouldThrow) {
- privateBits->throwOnHive11DecimalOverflow = shouldThrow;
+ privateBits_->throwOnHive11DecimalOverflow = shouldThrow;
return *this;
}
bool RowReaderOptions::getThrowOnHive11DecimalOverflow() const {
- return privateBits->throwOnHive11DecimalOverflow;
+ return privateBits_->throwOnHive11DecimalOverflow;
}
RowReaderOptions& RowReaderOptions::throwOnSchemaEvolutionOverflow(bool shouldThrow) {
- privateBits->throwOnSchemaEvolutionOverflow = shouldThrow;
+ privateBits_->throwOnSchemaEvolutionOverflow = shouldThrow;
return *this;
}
bool RowReaderOptions::getThrowOnSchemaEvolutionOverflow() const {
- return privateBits->throwOnSchemaEvolutionOverflow;
+ return privateBits_->throwOnSchemaEvolutionOverflow;
}
RowReaderOptions& RowReaderOptions::forcedScaleOnHive11Decimal(int32_t forcedScale) {
- privateBits->forcedScaleOnHive11Decimal = forcedScale;
+ privateBits_->forcedScaleOnHive11Decimal = forcedScale;
return *this;
}
int32_t RowReaderOptions::getForcedScaleOnHive11Decimal() const {
- return privateBits->forcedScaleOnHive11Decimal;
+ return privateBits_->forcedScaleOnHive11Decimal;
}
bool RowReaderOptions::getEnableLazyDecoding() const {
- return privateBits->enableLazyDecoding;
+ return privateBits_->enableLazyDecoding;
}
RowReaderOptions& RowReaderOptions::setEnableLazyDecoding(bool enable) {
- privateBits->enableLazyDecoding = enable;
+ privateBits_->enableLazyDecoding = enable;
return *this;
}
RowReaderOptions& RowReaderOptions::searchArgument(std::unique_ptr<SearchArgument> sargs) {
- privateBits->sargs = std::move(sargs);
+ privateBits_->sargs = std::move(sargs);
return *this;
}
std::shared_ptr<SearchArgument> RowReaderOptions::getSearchArgument() const {
- return privateBits->sargs;
+ return privateBits_->sargs;
}
RowReaderOptions& RowReaderOptions::setTimezoneName(const std::string& zoneName) {
- privateBits->readerTimezone = zoneName;
+ privateBits_->readerTimezone = zoneName;
return *this;
}
const std::string& RowReaderOptions::getTimezoneName() const {
- return privateBits->readerTimezone;
+ return privateBits_->readerTimezone;
}
const RowReaderOptions::IdReadIntentMap RowReaderOptions::getIdReadIntentMap() const {
- return privateBits->idReadIntentMap;
+ return privateBits_->idReadIntentMap;
}
RowReaderOptions& RowReaderOptions::setUseTightNumericVector(bool useTightNumericVector) {
- privateBits->useTightNumericVector = useTightNumericVector;
+ privateBits_->useTightNumericVector = useTightNumericVector;
return *this;
}
bool RowReaderOptions::getUseTightNumericVector() const {
- return privateBits->useTightNumericVector;
+ return privateBits_->useTightNumericVector;
}
RowReaderOptions& RowReaderOptions::setReadType(std::shared_ptr<Type> type) {
- privateBits->readType = std::move(type);
+ privateBits_->readType = std::move(type);
return *this;
}
std::shared_ptr<Type>& RowReaderOptions::getReadType() const {
- return privateBits->readType;
+ return privateBits_->readType;
}
} // namespace orc
diff --git a/c++/src/OrcFile.cc b/c++/src/OrcFile.cc
index d4b6a86e2..8899299d3 100644
--- a/c++/src/OrcFile.cc
+++ b/c++/src/OrcFile.cc
@@ -49,29 +49,29 @@ namespace orc {
class FileInputStream : public InputStream {
private:
- std::string filename;
- int file;
- uint64_t totalLength;
- ReaderMetrics* metrics;
+ std::string filename_;
+ int file_;
+ uint64_t totalLength_;
+ ReaderMetrics* metrics_;
public:
- FileInputStream(std::string _filename, ReaderMetrics* _metrics)
- : filename(_filename), metrics(_metrics) {
- file = open(filename.c_str(), O_BINARY | O_RDONLY);
- if (file == -1) {
- throw ParseError("Can't open " + filename);
+ FileInputStream(std::string filename, ReaderMetrics* metrics)
+ : filename_(filename), metrics_(metrics) {
+ file_ = open(filename_.c_str(), O_BINARY | O_RDONLY);
+ if (file_ == -1) {
+ throw ParseError("Can't open " + filename_);
}
struct stat fileStat;
- if (fstat(file, &fileStat) == -1) {
- throw ParseError("Can't stat " + filename);
+ if (fstat(file_, &fileStat) == -1) {
+ throw ParseError("Can't stat " + filename_);
}
- totalLength = static_cast<uint64_t>(fileStat.st_size);
+ totalLength_ = static_cast<uint64_t>(fileStat.st_size);
}
~FileInputStream() override;
uint64_t getLength() const override {
- return totalLength;
+ return totalLength_;
}
uint64_t getNaturalReadSize() const override {
@@ -83,23 +83,23 @@ namespace orc {
if (!buf) {
throw ParseError("Buffer is null");
}
- ssize_t bytesRead = pread(file, buf, length, static_cast<off_t>(offset));
+ ssize_t bytesRead = pread(file_, buf, length, static_cast<off_t>(offset));
if (bytesRead == -1) {
- throw ParseError("Bad read of " + filename);
+ throw ParseError("Bad read of " + filename_);
}
if (static_cast<uint64_t>(bytesRead) != length) {
- throw ParseError("Short read of " + filename);
+ throw ParseError("Short read of " + filename_);
}
}
const std::string& getName() const override {
- return filename;
+ return filename_;
}
};
FileInputStream::~FileInputStream() {
- close(file);
+ close(file_);
}
std::unique_ptr<InputStream> readFile(const std::string& path, ReaderMetrics* metrics) {
@@ -126,26 +126,26 @@ namespace orc {
class FileOutputStream : public OutputStream {
private:
- std::string filename;
- int file;
- uint64_t bytesWritten;
- bool closed;
+ std::string filename_;
+ int file_;
+ uint64_t bytesWritten_;
+ bool closed_;
public:
- FileOutputStream(std::string _filename) {
- bytesWritten = 0;
- filename = _filename;
- closed = false;
- file = open(filename.c_str(), O_BINARY | O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
- if (file == -1) {
- throw ParseError("Can't open " + filename);
+ FileOutputStream(std::string filename) {
+ bytesWritten_ = 0;
+ filename_ = filename;
+ closed_ = false;
+ file_ = open(filename_.c_str(), O_BINARY | O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
+ if (file_ == -1) {
+ throw ParseError("Can't open " + filename_);
}
}
~FileOutputStream() override;
uint64_t getLength() const override {
- return bytesWritten;
+ return bytesWritten_;
}
uint64_t getNaturalWriteSize() const override {
@@ -153,41 +153,41 @@ namespace orc {
}
void write(const void* buf, size_t length) override {
- if (closed) {
+ if (closed_) {
throw std::logic_error("Cannot write to closed stream.");
}
- ssize_t bytesWrite = ::write(file, buf, length);
+ ssize_t bytesWrite = ::write(file_, buf, length);
if (bytesWrite == -1) {
- throw ParseError("Bad write of " + filename);
+ throw ParseError("Bad write of " + filename_);
}
if (static_cast<uint64_t>(bytesWrite) != length) {
- throw ParseError("Short write of " + filename);
+ throw ParseError("Short write of " + filename_);
}
- bytesWritten += static_cast<uint64_t>(bytesWrite);
+ bytesWritten_ += static_cast<uint64_t>(bytesWrite);
}
const std::string& getName() const override {
- return filename;
+ return filename_;
}
void close() override {
- if (!closed) {
- ::close(file);
- closed = true;
+ if (!closed_) {
+ ::close(file_);
+ closed_ = true;
}
}
void flush() override {
- if (!closed) {
- ::fsync(file);
+ if (!closed_) {
+ ::fsync(file_);
}
}
};
FileOutputStream::~FileOutputStream() {
- if (!closed) {
- ::close(file);
- closed = true;
+ if (!closed_) {
+ ::close(file_);
+ closed_ = true;
}
}
diff --git a/c++/src/RLE.hh b/c++/src/RLE.hh
index 51f9b6f58..a45b4056b 100644
--- a/c++/src/RLE.hh
+++ b/c++/src/RLE.hh
@@ -105,7 +105,7 @@ namespace orc {
// must be non-inline!
virtual ~RleDecoder();
- RleDecoder(ReaderMetrics* _metrics) : metrics(_metrics) {
+ RleDecoder(ReaderMetrics* metrics) : metrics(metrics) {
// pass
}
diff --git a/c++/src/RLEv1.cc b/c++/src/RLEv1.cc
index b221e8b8a..5d6f60066 100644
--- a/c++/src/RLEv1.cc
+++ b/c++/src/RLEv1.cc
@@ -38,9 +38,9 @@ namespace orc {
RleEncoderV1::RleEncoderV1(std::unique_ptr<BufferedOutputStream> outStream, bool hasSigned)
: RleEncoder(std::move(outStream), hasSigned) {
literals = new int64_t[MAX_LITERAL_SIZE];
- delta = 0;
- repeat = false;
- tailRunLength = 0;
+ delta_ = 0;
+ repeat_ = false;
+ tailRunLength_ = 0;
}
RleEncoderV1::~RleEncoderV1() {
@@ -49,9 +49,9 @@ namespace orc {
void RleEncoderV1::writeValues() {
if (numLiterals != 0) {
- if (repeat) {
+ if (repeat_) {
writeByte(static_cast<char>(static_cast<uint64_t>(numLiterals) - MINIMUM_REPEAT));
- writeByte(static_cast<char>(delta));
+ writeByte(static_cast<char>(delta_));
if (isSigned) {
writeVslong(literals[0]);
} else {
@@ -67,9 +67,9 @@ namespace orc {
}
}
}
- repeat = false;
+ repeat_ = false;
numLiterals = 0;
- tailRunLength = 0;
+ tailRunLength_ = 0;
}
}
@@ -84,9 +84,9 @@ namespace orc {
void RleEncoderV1::write(int64_t value) {
if (numLiterals == 0) {
literals[numLiterals++] = value;
- tailRunLength = 1;
- } else if (repeat) {
- if (value == literals[0] + delta * static_cast<int64_t>(numLiterals)) {
+ tailRunLength_ = 1;
+ } else if (repeat_) {
+ if (value == literals[0] + delta_ * static_cast<int64_t>(numLiterals)) {
numLiterals += 1;
if (numLiterals == MAXIMUM_REPEAT) {
writeValues();
@@ -94,36 +94,36 @@ namespace orc {
} else {
writeValues();
literals[numLiterals++] = value;
- tailRunLength = 1;
+ tailRunLength_ = 1;
}
} else {
- if (tailRunLength == 1) {
- delta = value - literals[numLiterals - 1];
- if (delta < MIN_DELTA || delta > MAX_DELTA) {
- tailRunLength = 1;
+ if (tailRunLength_ == 1) {
+ delta_ = value - literals[numLiterals - 1];
+ if (delta_ < MIN_DELTA || delta_ > MAX_DELTA) {
+ tailRunLength_ = 1;
} else {
- tailRunLength = 2;
+ tailRunLength_ = 2;
}
- } else if (value == literals[numLiterals - 1] + delta) {
- tailRunLength += 1;
+ } else if (value == literals[numLiterals - 1] + delta_) {
+ tailRunLength_ += 1;
} else {
- delta = value - literals[numLiterals - 1];
- if (delta < MIN_DELTA || delta > MAX_DELTA) {
- tailRunLength = 1;
+ delta_ = value - literals[numLiterals - 1];
+ if (delta_ < MIN_DELTA || delta_ > MAX_DELTA) {
+ tailRunLength_ = 1;
} else {
- tailRunLength = 2;
+ tailRunLength_ = 2;
}
}
- if (tailRunLength == MINIMUM_REPEAT) {
+ if (tailRunLength_ == MINIMUM_REPEAT) {
if (numLiterals + 1 == MINIMUM_REPEAT) {
- repeat = true;
+ repeat_ = true;
numLiterals += 1;
} else {
numLiterals -= static_cast<int>(MINIMUM_REPEAT - 1);
int64_t base = literals[numLiterals];
writeValues();
literals[0] = base;
- repeat = true;
+ repeat_ = true;
numLiterals = MINIMUM_REPEAT;
}
} else {
@@ -137,16 +137,16 @@ namespace orc {
signed char RleDecoderV1::readByte() {
SCOPED_MINUS_STOPWATCH(metrics, DecodingLatencyUs);
- if (bufferStart == bufferEnd) {
+ if (bufferStart_ == bufferEnd_) {
int bufferLength;
const void* bufferPointer;
- if (!inputStream->Next(&bufferPointer, &bufferLength)) {
+ if (!inputStream_->Next(&bufferPointer, &bufferLength)) {
throw ParseError("bad read in readByte");
}
- bufferStart = static_cast<const char*>(bufferPointer);
- bufferEnd = bufferStart + bufferLength;
+ bufferStart_ = static_cast<const char*>(bufferPointer);
+ bufferEnd_ = bufferStart_ + bufferLength;
}
- return static_cast<signed char>(*(bufferStart++));
+ return static_cast<signed char>(*(bufferStart_++));
}
uint64_t RleDecoderV1::readLong() {
@@ -177,34 +177,34 @@ namespace orc {
void RleDecoderV1::readHeader() {
signed char ch = readByte();
if (ch < 0) {
- remainingValues = static_cast<uint64_t>(-ch);
- repeating = false;
+ remainingValues_ = static_cast<uint64_t>(-ch);
+ repeating_ = false;
} else {
- remainingValues = static_cast<uint64_t>(ch) + MINIMUM_REPEAT;
- repeating = true;
- delta = readByte();
- value = isSigned ? unZigZag(readLong()) : static_cast<int64_t>(readLong());
+ remainingValues_ = static_cast<uint64_t>(ch) + MINIMUM_REPEAT;
+ repeating_ = true;
+ delta_ = readByte();
+ value_ = isSigned_ ? unZigZag(readLong()) : static_cast<int64_t>(readLong());
}
}
void RleDecoderV1::reset() {
- remainingValues = 0;
- value = 0;
- bufferStart = nullptr;
- bufferEnd = nullptr;
- delta = 0;
- repeating = false;
+ remainingValues_ = 0;
+ value_ = 0;
+ bufferStart_ = nullptr;
+ bufferEnd_ = nullptr;
+ delta_ = 0;
+ repeating_ = false;
}
RleDecoderV1::RleDecoderV1(std::unique_ptr<SeekableInputStream> input, bool hasSigned,
- ReaderMetrics* _metrics)
- : RleDecoder(_metrics), inputStream(std::move(input)), isSigned(hasSigned) {
+ ReaderMetrics* metrics)
+ : RleDecoder(metrics), inputStream_(std::move(input)), isSigned_(hasSigned) {
reset();
}
void RleDecoderV1::seek(PositionProvider& location) {
// move the input stream
- inputStream->seek(location);
+ inputStream_->seek(location);
// reset the decoder status and lazily call readHeader()
reset();
// skip ahead the given number of records
@@ -213,14 +213,14 @@ namespace orc {
void RleDecoderV1::skip(uint64_t numValues) {
while (numValues > 0) {
- if (remainingValues == 0) {
+ if (remainingValues_ == 0) {
readHeader();
}
- uint64_t count = std::min(numValues, remainingValues);
- remainingValues -= count;
+ uint64_t count = std::min(numValues, remainingValues_);
+ remainingValues_ -= count;
numValues -= count;
- if (repeating) {
- value += delta * static_cast<int64_t>(count);
+ if (repeating_) {
+ value_ += delta_ * static_cast<int64_t>(count);
} else {
skipLongs(count);
}
@@ -240,38 +240,38 @@ namespace orc {
}
while (position < numValues) {
// If we are out of values, read more.
- if (remainingValues == 0) {
+ if (remainingValues_ == 0) {
readHeader();
}
// How many do we read out of this block?
- uint64_t count = std::min(numValues - position, remainingValues);
+ uint64_t count = std::min(numValues - position, remainingValues_);
uint64_t consumed = 0;
- if (repeating) {
+ if (repeating_) {
if (notNull) {
for (uint64_t i = 0; i < count; ++i) {
if (notNull[position + i]) {
- data[position + i] = static_cast<T>(value + static_cast<int64_t>(consumed) * delta);
+ data[position + i] = static_cast<T>(value_ + static_cast<int64_t>(consumed) * delta_);
consumed += 1;
}
}
} else {
for (uint64_t i = 0; i < count; ++i) {
- data[position + i] = static_cast<T>(value + static_cast<int64_t>(i) * delta);
+ data[position + i] = static_cast<T>(value_ + static_cast<int64_t>(i) * delta_);
}
consumed = count;
}
- value += static_cast<int64_t>(consumed) * delta;
+ value_ += static_cast<int64_t>(consumed) * delta_;
} else {
if (notNull) {
for (uint64_t i = 0; i < count; ++i) {
if (notNull[position + i]) {
data[position + i] =
- isSigned ? static_cast<T>(unZigZag(readLong())) : static_cast<T>(readLong());
+ isSigned_ ? static_cast<T>(unZigZag(readLong())) : static_cast<T>(readLong());
++consumed;
}
}
} else {
- if (isSigned) {
+ if (isSigned_) {
for (uint64_t i = 0; i < count; ++i) {
data[position + i] = static_cast<T>(unZigZag(readLong()));
}
@@ -283,7 +283,7 @@ namespace orc {
consumed = count;
}
}
- remainingValues -= consumed;
+ remainingValues_ -= consumed;
position += count;
// skipNulls()
diff --git a/c++/src/RLEv1.hh b/c++/src/RLEv1.hh
index fbe6b0f9c..a2a00c930 100644
--- a/c++/src/RLEv1.hh
+++ b/c++/src/RLEv1.hh
@@ -39,9 +39,9 @@ namespace orc {
void write(int64_t val) override;
private:
- int64_t delta;
- bool repeat;
- uint64_t tailRunLength;
+ int64_t delta_;
+ bool repeat_;
+ uint64_t tailRunLength_;
void writeValues();
};
@@ -83,14 +83,14 @@ namespace orc {
inline void reset();
- const std::unique_ptr<SeekableInputStream> inputStream;
- const bool isSigned;
- uint64_t remainingValues;
- int64_t value;
- const char* bufferStart;
- const char* bufferEnd;
- int64_t delta;
- bool repeating;
+ const std::unique_ptr<SeekableInputStream> inputStream_;
+ const bool isSigned_;
+ uint64_t remainingValues_;
+ int64_t value_;
+ const char* bufferStart_;
+ const char* bufferEnd_;
+ int64_t delta_;
+ bool repeating_;
};
} // namespace orc
diff --git a/c++/src/RLEv2.hh b/c++/src/RLEv2.hh
index 1cee59d0a..a8e0340e7 100644
--- a/c++/src/RLEv2.hh
+++ b/c++/src/RLEv2.hh
@@ -96,10 +96,10 @@ namespace orc {
~RleEncoderV2() override {
delete[] literals;
- delete[] gapVsPatchList;
- delete[] zigzagLiterals;
- delete[] baseRedLiterals;
- delete[] adjDeltas;
+ delete[] gapVsPatchList_;
+ delete[] zigzagLiterals_;
+ delete[] baseRedLiterals_;
+ delete[] adjDeltas_;
}
/**
* Flushing underlying BufferedOutputStream
@@ -109,18 +109,18 @@ namespace orc {
void write(int64_t val) override;
private:
- const bool alignedBitPacking;
- uint32_t fixedRunLength;
- uint32_t variableRunLength;
- int64_t prevDelta;
- int32_t histgram[HIST_LEN];
+ const bool alignedBitPacking_;
+ uint32_t fixedRunLength_;
+ uint32_t variableRunLength_;
+ int64_t prevDelta_;
+ int32_t histgram_[HIST_LEN];
// The four list below should actually belong to EncodingOption since it only holds temporal
// values in write(int64_t val), it is move here for performance consideration.
- int64_t* gapVsPatchList;
- int64_t* zigzagLiterals;
- int64_t* baseRedLiterals;
- int64_t* adjDeltas;
+ int64_t* gapVsPatchList_;
+ int64_t* zigzagLiterals_;
+ int64_t* baseRedLiterals_;
+ int64_t* adjDeltas_;
uint32_t getOpCode(EncodingType encoding);
int64_t* prepareForDirectOrPatchedBase(EncodingOption& option);
@@ -169,39 +169,39 @@ namespace orc {
unsigned char readByte();
void setBufStart(const char* start) {
- bufferStart = const_cast<char*>(start);
+ bufferStart_ = const_cast<char*>(start);
}
char* getBufStart() {
- return bufferStart;
+ return bufferStart_;
}
void setBufEnd(const char* end) {
- bufferEnd = const_cast<char*>(end);
+ bufferEnd_ = const_cast<char*>(end);
}
char* getBufEnd() {
- return bufferEnd;
+ return bufferEnd_;
}
uint64_t bufLength() {
- return bufferEnd - bufferStart;
+ return bufferEnd_ - bufferStart_;
}
void setBitsLeft(const uint32_t bits) {
- bitsLeft = bits;
+ bitsLeft_ = bits;
}
void setCurByte(const uint32_t byte) {
- curByte = byte;
+ curByte_ = byte;
}
uint32_t getBitsLeft() {
- return bitsLeft;
+ return bitsLeft_;
}
uint32_t getCurByte() {
- return curByte;
+ return curByte_;
}
/**
@@ -225,8 +225,8 @@ namespace orc {
int64_t* resPatch, uint64_t* patchIdx);
void resetReadLongs() {
- bitsLeft = 0;
- curByte = 0;
+ bitsLeft_ = 0;
+ curByte_ = 0;
}
void resetRun() {
@@ -249,17 +249,17 @@ namespace orc {
template <typename T>
uint64_t copyDataFromBuffer(T* data, uint64_t offset, uint64_t numValues, const char* notNull);
- const std::unique_ptr<SeekableInputStream> inputStream;
- const bool isSigned;
- unsigned char firstByte;
- char* bufferStart;
- char* bufferEnd;
- uint64_t runLength; // Length of the current run
- uint64_t runRead; // Number of returned values of the current run
- uint32_t bitsLeft; // Used by readLongs when bitSize < 8
- uint32_t curByte; // Used by anything that uses readLongs
- DataBuffer<int64_t> unpackedPatch; // Used by PATCHED_BASE
- DataBuffer<int64_t> literals; // Values of the current run
+ const std::unique_ptr<SeekableInputStream> inputStream_;
+ const bool isSigned_;
+ unsigned char firstByte_;
+ char* bufferStart_;
+ char* bufferEnd_;
+ uint64_t runLength_; // Length of the current run
+ uint64_t runRead_; // Number of returned values of the current run
+ uint32_t bitsLeft_; // Used by readLongs when bitSize < 8
+ uint32_t curByte_; // Used by anything that uses readLongs
+ DataBuffer<int64_t> unpackedPatch_; // Used by PATCHED_BASE
+ DataBuffer<int64_t> literals_; // Values of the current run
};
inline void RleDecoderV2::resetBufferStart(uint64_t len, bool resetBuf, uint32_t backupByteLen) {
@@ -268,20 +268,20 @@ namespace orc {
const void* bufferPointer = nullptr;
if (backupByteLen != 0) {
- inputStream->BackUp(backupByteLen);
+ inputStream_->BackUp(backupByteLen);
}
if (len >= remainingLen && resetBuf) {
- if (!inputStream->Next(&bufferPointer, &bufferLength)) {
+ if (!inputStream_->Next(&bufferPointer, &bufferLength)) {
throw ParseError("bad read in RleDecoderV2::resetBufferStart");
}
}
if (bufferPointer == nullptr) {
- bufferStart += len;
+ bufferStart_ += len;
} else {
- bufferStart = const_cast<char*>(static_cast<const char*>(bufferPointer));
- bufferEnd = bufferStart + bufferLength;
+ bufferStart_ = const_cast<char*>(static_cast<const char*>(bufferPointer));
+ bufferEnd_ = bufferStart_ + bufferLength;
}
}
} // namespace orc
diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index 4e02f171a..8a43818a5 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -73,11 +73,11 @@ namespace orc {
}
std::string ColumnSelector::toDotColumnPath() {
- if (columns.empty()) {
+ if (columns_.empty()) {
return std::string();
}
std::ostringstream columnStream;
- std::copy(columns.begin(), columns.end(),
+ std::copy(columns_.begin(), columns_.end(),
std::ostream_iterator<std::string>(columnStream, "."));
std::string columnPath = columnStream.str();
return columnPath.substr(0, columnPath.length() - 1);
@@ -150,15 +150,15 @@ namespace orc {
*/
void ColumnSelector::buildTypeNameIdMap(const Type* type) {
// map<type_id, Type*>
- idTypeMap[type->getColumnId()] = type;
+ idTypeMap_[type->getColumnId()] = type;
if (STRUCT == type->getKind()) {
for (size_t i = 0; i < type->getSubtypeCount(); ++i) {
const std::string& fieldName = type->getFieldName(i);
- columns.push_back(fieldName);
- nameIdMap[toDotColumnPath()] = type->getSubtype(i)->getColumnId();
+ columns_.push_back(fieldName);
+ nameIdMap_[toDotColumnPath()] = type->getSubtype(i)->getColumnId();
buildTypeNameIdMap(type->getSubtype(i));
- columns.pop_back();
+ columns_.pop_back();
}
} else {
// other non-primitive type
@@ -170,13 +170,13 @@ namespace orc {
void ColumnSelector::updateSelected(std::vector<bool>& selectedColumns,
const RowReaderOptions& options) {
- selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), false);
- if (contents->schema->getKind() == STRUCT && options.getIndexesSet()) {
+ selectedColumns.assign(static_cast<size_t>(contents_->footer->types_size()), false);
+ if (contents_->schema->getKind() == STRUCT && options.getIndexesSet()) {
for (std::list<uint64_t>::const_iterator field = options.getInclude().begin();
field != options.getInclude().end(); ++field) {
updateSelectedByFieldId(selectedColumns, *field);
}
- } else if (contents->schema->getKind() == STRUCT && options.getNamesSet()) {
+ } else if (contents_->schema->getKind() == STRUCT && options.getNamesSet()) {
for (std::list<std::string>::const_iterator field = options.getIncludeNames().begin();
field != options.getIncludeNames().end(); ++field) {
updateSelectedByName(selectedColumns, *field);
@@ -191,18 +191,18 @@ namespace orc {
// default is to select all columns
std::fill(selectedColumns.begin(), selectedColumns.end(), true);
}
- selectParents(selectedColumns, *contents->schema.get());
+ selectParents(selectedColumns, *contents_->schema.get());
selectedColumns[0] = true; // column 0 is selected by default
}
void ColumnSelector::updateSelectedByFieldId(std::vector<bool>& selectedColumns,
uint64_t fieldId) {
- if (fieldId < contents->schema->getSubtypeCount()) {
- selectChildren(selectedColumns, *contents->schema->getSubtype(fieldId));
+ if (fieldId < contents_->schema->getSubtypeCount()) {
+ selectChildren(selectedColumns, *contents_->schema->getSubtype(fieldId));
} else {
std::stringstream buffer;
buffer << "Invalid column selected " << fieldId << " out of "
- << contents->schema->getSubtypeCount();
+ << contents_->schema->getSubtypeCount();
throw ParseError(buffer.str());
}
}
@@ -215,7 +215,7 @@ namespace orc {
std::vector<bool>& selectedColumns, uint64_t typeId,
const RowReaderOptions::IdReadIntentMap& idReadIntentMap) {
if (typeId < selectedColumns.size()) {
- const Type& type = *idTypeMap[typeId];
+ const Type& type = *idTypeMap_[typeId];
selectChildren(selectedColumns, type, idReadIntentMap);
} else {
std::stringstream buffer;
@@ -226,14 +226,14 @@ namespace orc {
void ColumnSelector::updateSelectedByName(std::vector<bool>& selectedColumns,
const std::string& fieldName) {
- std::map<std::string, uint64_t>::const_iterator ite = nameIdMap.find(fieldName);
- if (ite != nameIdMap.end()) {
+ std::map<std::string, uint64_t>::const_iterator ite = nameIdMap_.find(fieldName);
+ if (ite != nameIdMap_.end()) {
updateSelectedByTypeId(selectedColumns, ite->second);
} else {
bool first = true;
std::ostringstream ss;
ss << "Invalid column selected " << fieldName << ". Valid names are ";
- for (auto it = nameIdMap.begin(); it != nameIdMap.end(); ++it) {
+ for (auto it = nameIdMap_.begin(); it != nameIdMap_.end(); ++it) {
if (!first) ss << ", ";
ss << it->first;
first = false;
@@ -242,89 +242,88 @@ namespace orc {
}
}
- ColumnSelector::ColumnSelector(const FileContents* _contents) : contents(_contents) {
- buildTypeNameIdMap(contents->schema.get());
+ ColumnSelector::ColumnSelector(const FileContents* contents) : contents_(contents) {
+ buildTypeNameIdMap(contents_->schema.get());
}
- RowReaderImpl::RowReaderImpl(std::shared_ptr<FileContents> _contents,
- const RowReaderOptions& opts)
- : localTimezone(getLocalTimezone()),
- contents(_contents),
- throwOnHive11DecimalOverflow(opts.getThrowOnHive11DecimalOverflow()),
- forcedScaleOnHive11Decimal(opts.getForcedScaleOnHive11Decimal()),
- footer(contents->footer.get()),
- firstRowOfStripe(*contents->pool, 0),
- enableEncodedBlock(opts.getEnableLazyDecoding()),
- readerTimezone(getTimezoneByName(opts.getTimezoneName())),
- schemaEvolution(opts.getReadType(), contents->schema.get()) {
+ RowReaderImpl::RowReaderImpl(std::shared_ptr<FileContents> contents, const RowReaderOptions& opts)
+ : localTimezone_(getLocalTimezone()),
+ contents_(contents),
+ throwOnHive11DecimalOverflow_(opts.getThrowOnHive11DecimalOverflow()),
+ forcedScaleOnHive11Decimal_(opts.getForcedScaleOnHive11Decimal()),
+ footer_(contents_->footer.get()),
+ firstRowOfStripe_(*contents_->pool, 0),
+ enableEncodedBlock_(opts.getEnableLazyDecoding()),
+ readerTimezone_(getTimezoneByName(opts.getTimezoneName())),
+ schemaEvolution_(opts.getReadType(), contents_->schema.get()) {
uint64_t numberOfStripes;
- numberOfStripes = static_cast<uint64_t>(footer->stripes_size());
- currentStripe = numberOfStripes;
- lastStripe = 0;
- currentRowInStripe = 0;
- rowsInCurrentStripe = 0;
- numRowGroupsInStripeRange = 0;
- useTightNumericVector = opts.getUseTightNumericVector();
- throwOnSchemaEvolutionOverflow = opts.getThrowOnSchemaEvolutionOverflow();
+ numberOfStripes = static_cast<uint64_t>(footer_->stripes_size());
+ currentStripe_ = numberOfStripes;
+ lastStripe_ = 0;
+ currentRowInStripe_ = 0;
+ rowsInCurrentStripe_ = 0;
+ numRowGroupsInStripeRange_ = 0;
+ useTightNumericVector_ = opts.getUseTightNumericVector();
+ throwOnSchemaEvolutionOverflow_ = opts.getThrowOnSchemaEvolutionOverflow();
uint64_t rowTotal = 0;
- firstRowOfStripe.resize(numberOfStripes);
+ firstRowOfStripe_.resize(numberOfStripes);
for (size_t i = 0; i < numberOfStripes; ++i) {
- firstRowOfStripe[i] = rowTotal;
- proto::StripeInformation stripeInfo = footer->stripes(static_cast<int>(i));
+ firstRowOfStripe_[i] = rowTotal;
+ proto::StripeInformation stripeInfo = footer_->stripes(static_cast<int>(i));
rowTotal += stripeInfo.number_of_rows();
bool isStripeInRange = stripeInfo.offset() >= opts.getOffset() &&
stripeInfo.offset() < opts.getOffset() + opts.getLength();
if (isStripeInRange) {
- if (i < currentStripe) {
- currentStripe = i;
+ if (i < currentStripe_) {
+ currentStripe_ = i;
}
- if (i >= lastStripe) {
- lastStripe = i + 1;
+ if (i >= lastStripe_) {
+ lastStripe_ = i + 1;
}
- if (footer->row_index_stride() > 0) {
- numRowGroupsInStripeRange +=
- (stripeInfo.number_of_rows() + footer->row_index_stride() - 1) /
- footer->row_index_stride();
+ if (footer_->row_index_stride() > 0) {
+ numRowGroupsInStripeRange_ +=
+ (stripeInfo.number_of_rows() + footer_->row_index_stride() - 1) /
+ footer_->row_index_stride();
}
}
}
- firstStripe = currentStripe;
- processingStripe = lastStripe;
+ firstStripe_ = currentStripe_;
+ processingStripe_ = lastStripe_;
- if (currentStripe == 0) {
- previousRow = (std::numeric_limits<uint64_t>::max)();
- } else if (currentStripe == numberOfStripes) {
- previousRow = footer->number_of_rows();
+ if (currentStripe_ == 0) {
+ previousRow_ = (std::numeric_limits<uint64_t>::max)();
+ } else if (currentStripe_ == numberOfStripes) {
+ previousRow_ = footer_->number_of_rows();
} else {
- previousRow = firstRowOfStripe[firstStripe] - 1;
+ previousRow_ = firstRowOfStripe_[firstStripe_] - 1;
}
- ColumnSelector column_selector(contents.get());
- column_selector.updateSelected(selectedColumns, opts);
+ ColumnSelector column_selector(contents_.get());
+ column_selector.updateSelected(selectedColumns_, opts);
// prepare SargsApplier if SearchArgument is available
- if (opts.getSearchArgument() && footer->row_index_stride() > 0) {
- sargs = opts.getSearchArgument();
- sargsApplier.reset(
- new SargsApplier(*contents->schema, sargs.get(), footer->row_index_stride(),
- getWriterVersionImpl(_contents.get()), contents->readerMetrics));
+ if (opts.getSearchArgument() && footer_->row_index_stride() > 0) {
+ sargs_ = opts.getSearchArgument();
+ sargsApplier_.reset(
+ new SargsApplier(*contents_->schema, sargs_.get(), footer_->row_index_stride(),
+ getWriterVersionImpl(contents.get()), contents_->readerMetrics));
}
- skipBloomFilters = hasBadBloomFilters();
+ skipBloomFilters_ = hasBadBloomFilters();
}
// Check if the file has inconsistent bloom filters.
bool RowReaderImpl::hasBadBloomFilters() {
// Only C++ writer in old releases could have bad bloom filters.
- if (footer->writer() != ORC_CPP_WRITER) return false;
+ if (footer_->writer() != ORC_CPP_WRITER) return false;
// 'softwareVersion' is added in 1.5.13, 1.6.11, and 1.7.0.
// 1.6.x releases before 1.6.11 won't have it. On the other side, the C++ writer
// supports writing bloom filters since 1.6.0. So files written by the C++ writer
// and with 'softwareVersion' unset would have bad bloom filters.
- if (!footer->has_software_version()) return true;
+ if (!footer_->has_software_version()) return true;
- const std::string& fullVersion = footer->software_version();
+ const std::string& fullVersion = footer_->software_version();
std::string version;
// Deal with snapshot versions, e.g. 1.6.12-SNAPSHOT.
if (fullVersion.find('-') != std::string::npos) {
@@ -341,31 +340,31 @@ namespace orc {
}
CompressionKind RowReaderImpl::getCompression() const {
- return contents->compression;
+ return contents_->compression;
}
uint64_t RowReaderImpl::getCompressionSize() const {
- return contents->blockSize;
+ return contents_->blockSize;
}
const std::vector<bool> RowReaderImpl::getSelectedColumns() const {
- return selectedColumns;
+ return selectedColumns_;
}
const Type& RowReaderImpl::getSelectedType() const {
- if (selectedSchema.get() == nullptr) {
- selectedSchema = buildSelectedType(contents->schema.get(), selectedColumns);
+ if (selectedSchema_.get() == nullptr) {
+ selectedSchema_ = buildSelectedType(contents_->schema.get(), selectedColumns_);
}
- return *(selectedSchema.get());
+ return *(selectedSchema_.get());
}
uint64_t RowReaderImpl::getRowNumber() const {
- return previousRow;
+ return previousRow_;
}
void RowReaderImpl::seekToRow(uint64_t rowNumber) {
// Empty file
- if (lastStripe == 0) {
+ if (lastStripe_ == 0) {
return;
}
@@ -375,53 +374,53 @@ namespace orc {
// Implement this by setting previousRow to the number of rows in the file.
// seeking past lastStripe
- uint64_t num_stripes = static_cast<uint64_t>(footer->stripes_size());
- if ((lastStripe == num_stripes && rowNumber >= footer->number_of_rows()) ||
- (lastStripe < num_stripes && rowNumber >= firstRowOfStripe[lastStripe])) {
- currentStripe = num_stripes;
- previousRow = footer->number_of_rows();
+ uint64_t num_stripes = static_cast<uint64_t>(footer_->stripes_size());
+ if ((lastStripe_ == num_stripes && rowNumber >= footer_->number_of_rows()) ||
+ (lastStripe_ < num_stripes && rowNumber >= firstRowOfStripe_[lastStripe_])) {
+ currentStripe_ = num_stripes;
+ previousRow_ = footer_->number_of_rows();
return;
}
uint64_t seekToStripe = 0;
- while (seekToStripe + 1 < lastStripe && firstRowOfStripe[seekToStripe + 1] <= rowNumber) {
+ while (seekToStripe + 1 < lastStripe_ && firstRowOfStripe_[seekToStripe + 1] <= rowNumber) {
seekToStripe++;
}
// seeking before the first stripe
- if (seekToStripe < firstStripe) {
- currentStripe = num_stripes;
- previousRow = footer->number_of_rows();
+ if (seekToStripe < firstStripe_) {
+ currentStripe_ = num_stripes;
+ previousRow_ = footer_->number_of_rows();
return;
}
- previousRow = rowNumber;
- auto rowIndexStride = footer->row_index_stride();
- if (!isCurrentStripeInited() || currentStripe != seekToStripe || rowIndexStride == 0 ||
- currentStripeInfo.index_length() == 0) {
+ previousRow_ = rowNumber;
+ auto rowIndexStride = footer_->row_index_stride();
+ if (!isCurrentStripeInited() || currentStripe_ != seekToStripe || rowIndexStride == 0 ||
+ currentStripeInfo_.index_length() == 0) {
// current stripe is not initialized or
// target stripe is not current stripe or
// current stripe doesn't have row indexes
- currentStripe = seekToStripe;
- currentRowInStripe = rowNumber - firstRowOfStripe[currentStripe];
+ currentStripe_ = seekToStripe;
+ currentRowInStripe_ = rowNumber - firstRowOfStripe_[currentStripe_];
startNextStripe();
- if (currentStripe >= lastStripe) {
+ if (currentStripe_ >= lastStripe_) {
return;
}
} else {
- currentRowInStripe = rowNumber - firstRowOfStripe[currentStripe];
- if (sargsApplier) {
+ currentRowInStripe_ = rowNumber - firstRowOfStripe_[currentStripe_];
+ if (sargsApplier_) {
// advance to selected row group if predicate pushdown is enabled
- currentRowInStripe =
- advanceToNextRowGroup(currentRowInStripe, rowsInCurrentStripe,
- footer->row_index_stride(), sargsApplier->getNextSkippedRows());
+ currentRowInStripe_ =
+ advanceToNextRowGroup(currentRowInStripe_, rowsInCurrentStripe_,
+ footer_->row_index_stride(), sargsApplier_->getNextSkippedRows());
}
}
- uint64_t rowsToSkip = currentRowInStripe;
+ uint64_t rowsToSkip = currentRowInStripe_;
// seek to the target row group if row indexes exists
- if (rowIndexStride > 0 && currentStripeInfo.index_length() > 0) {
- if (rowIndexes.empty()) {
+ if (rowIndexStride > 0 && currentStripeInfo_.index_length() > 0) {
+ if (rowIndexes_.empty()) {
loadStripeIndex();
}
// TODO(ORC-1175): process the failures of loadStripeIndex() call
@@ -432,36 +431,36 @@ namespace orc {
// 'reader' is reset in startNextStripe(). It could be nullptr if 'rowsToSkip' is 0,
// e.g. when startNextStripe() skips all remaining rows of the file.
if (rowsToSkip > 0) {
- reader->skip(rowsToSkip);
+ reader_->skip(rowsToSkip);
}
}
void RowReaderImpl::loadStripeIndex() {
// reset all previous row indexes
- rowIndexes.clear();
- bloomFilterIndex.clear();
+ rowIndexes_.clear();
+ bloomFilterIndex_.clear();
// obtain row indexes for selected columns
- uint64_t offset = currentStripeInfo.offset();
- for (int i = 0; i < currentStripeFooter.streams_size(); ++i) {
- const proto::Stream& pbStream = currentStripeFooter.streams(i);
+ uint64_t offset = currentStripeInfo_.offset();
+ for (int i = 0; i < currentStripeFooter_.streams_size(); ++i) {
+ const proto::Stream& pbStream = currentStripeFooter_.streams(i);
uint64_t colId = pbStream.column();
- if (selectedColumns[colId] && pbStream.has_kind() &&
+ if (selectedColumns_[colId] && pbStream.has_kind() &&
(pbStream.kind() == proto::Stream_Kind_ROW_INDEX ||
pbStream.kind() == proto::Stream_Kind_BLOOM_FILTER_UTF8)) {
std::unique_ptr<SeekableInputStream> inStream = createDecompressor(
getCompression(),
std::unique_ptr<SeekableInputStream>(new SeekableFileInputStream(
- contents->stream.get(), offset, pbStream.length(), *contents->pool)),
- getCompressionSize(), *contents->pool, contents->readerMetrics);
+ contents_->stream.get(), offset, pbStream.length(), *contents_->pool)),
+ getCompressionSize(), *contents_->pool, contents_->readerMetrics);
if (pbStream.kind() == proto::Stream_Kind_ROW_INDEX) {
proto::RowIndex rowIndex;
if (!rowIndex.ParseFromZeroCopyStream(inStream.get())) {
throw ParseError("Failed to parse the row index");
}
- rowIndexes[colId] = rowIndex;
- } else if (!skipBloomFilters) { // Stream_Kind_BLOOM_FILTER_UTF8
+ rowIndexes_[colId] = rowIndex;
+ } else if (!skipBloomFilters_) { // Stream_Kind_BLOOM_FILTER_UTF8
proto::BloomFilterIndex pbBFIndex;
if (!pbBFIndex.ParseFromZeroCopyStream(inStream.get())) {
throw ParseError("Failed to parse bloom filter index");
@@ -469,11 +468,11 @@ namespace orc {
BloomFilterIndex bfIndex;
for (int j = 0; j < pbBFIndex.bloom_filter_size(); j++) {
bfIndex.entries.push_back(BloomFilterUTF8Utils::deserialize(
- pbStream.kind(), currentStripeFooter.columns(static_cast<int>(pbStream.column())),
+ pbStream.kind(), currentStripeFooter_.columns(static_cast<int>(pbStream.column())),
pbBFIndex.bloom_filter(j)));
}
// add bloom filters to result for one column
- bloomFilterIndex[pbStream.column()] = bfIndex;
+ bloomFilterIndex_[pbStream.column()] = bfIndex;
}
}
offset += pbStream.length();
@@ -486,7 +485,7 @@ namespace orc {
// store position providers for selected colimns
std::unordered_map<uint64_t, PositionProvider> positionProviders;
- for (auto rowIndex = rowIndexes.cbegin(); rowIndex != rowIndexes.cend(); ++rowIndex) {
+ for (auto rowIndex = rowIndexes_.cbegin(); rowIndex != rowIndexes_.cend(); ++rowIndex) {
uint64_t colId = rowIndex->first;
const proto::RowIndexEntry& entry =
rowIndex->second.entry(static_cast<int32_t>(rowGroupEntryId));
@@ -500,23 +499,23 @@ namespace orc {
positionProviders.insert(std::make_pair(colId, PositionProvider(position)));
}
- reader->seekToRowGroup(positionProviders);
+ reader_->seekToRowGroup(positionProviders);
}
const FileContents& RowReaderImpl::getFileContents() const {
- return *contents;
+ return *contents_;
}
bool RowReaderImpl::getThrowOnHive11DecimalOverflow() const {
- return throwOnHive11DecimalOverflow;
+ return throwOnHive11DecimalOverflow_;
}
bool RowReaderImpl::getIsDecimalAsLong() const {
- return contents->isDecimalAsLong;
+ return contents_->isDecimalAsLong;
}
int32_t RowReaderImpl::getForcedScaleOnHive11Decimal() const {
- return forcedScaleOnHive11Decimal;
+ return forcedScaleOnHive11Decimal_;
}
proto::StripeFooter getStripeFooter(const proto::StripeInformation& info,
@@ -542,29 +541,29 @@ namespace orc {
return result;
}
- ReaderImpl::ReaderImpl(std::shared_ptr<FileContents> _contents, const ReaderOptions& opts,
- uint64_t _fileLength, uint64_t _postscriptLength)
- : contents(std::move(_contents)),
- options(opts),
- fileLength(_fileLength),
- postscriptLength(_postscriptLength),
- footer(contents->footer.get()) {
- isMetadataLoaded = false;
+ ReaderImpl::ReaderImpl(std::shared_ptr<FileContents> contents, const ReaderOptions& opts,
+ uint64_t fileLength, uint64_t postscriptLength)
+ : contents_(std::move(contents)),
+ options_(opts),
+ fileLength_(fileLength),
+ postscriptLength_(postscriptLength),
+ footer_(contents_->footer.get()) {
+ isMetadataLoaded_ = false;
checkOrcVersion();
- numberOfStripes = static_cast<uint64_t>(footer->stripes_size());
- contents->schema = convertType(footer->types(0), *footer);
- contents->blockSize = getCompressionBlockSize(*contents->postscript);
- contents->compression = convertCompressionKind(*contents->postscript);
+ numberOfStripes_ = static_cast<uint64_t>(footer_->stripes_size());
+ contents_->schema = convertType(footer_->types(0), *footer_);
+ contents_->blockSize = getCompressionBlockSize(*contents_->postscript);
+ contents_->compression = convertCompressionKind(*contents_->postscript);
}
std::string ReaderImpl::getSerializedFileTail() const {
proto::FileTail tail;
proto::PostScript* mutable_ps = tail.mutable_postscript();
- mutable_ps->CopyFrom(*contents->postscript);
+ mutable_ps->CopyFrom(*contents_->postscript);
proto::Footer* mutableFooter = tail.mutable_footer();
- mutableFooter->CopyFrom(*footer);
- tail.set_file_length(fileLength);
- tail.set_postscript_length(postscriptLength);
+ mutableFooter->CopyFrom(*footer_);
+ tail.set_file_length(fileLength_);
+ tail.set_postscript_length(postscriptLength_);
std::string result;
if (!tail.SerializeToString(&result)) {
throw ParseError("Failed to serialize file tail");
@@ -573,56 +572,56 @@ namespace orc {
}
const ReaderOptions& ReaderImpl::getReaderOptions() const {
- return options;
+ return options_;
}
CompressionKind ReaderImpl::getCompression() const {
- return contents->compression;
+ return contents_->compression;
}
uint64_t ReaderImpl::getCompressionSize() const {
- return contents->blockSize;
+ return contents_->blockSize;
}
uint64_t ReaderImpl::getNumberOfStripes() const {
- return numberOfStripes;
+ return numberOfStripes_;
}
uint64_t ReaderImpl::getNumberOfStripeStatistics() const {
- if (!isMetadataLoaded) {
+ if (!isMetadataLoaded_) {
readMetadata();
}
- return contents->metadata == nullptr
+ return contents_->metadata == nullptr
? 0
- : static_cast<uint64_t>(contents->metadata->stripe_stats_size());
+ : static_cast<uint64_t>(contents_->metadata->stripe_stats_size());
}
std::unique_ptr<StripeInformation> ReaderImpl::getStripe(uint64_t stripeIndex) const {
if (stripeIndex > getNumberOfStripes()) {
throw std::logic_error("stripe index out of range");
}
- proto::StripeInformation stripeInfo = footer->stripes(static_cast<int>(stripeIndex));
+ proto::StripeInformation stripeInfo = footer_->stripes(static_cast<int>(stripeIndex));
return std::unique_ptr<StripeInformation>(new StripeInformationImpl(
stripeInfo.offset(), stripeInfo.index_length(), stripeInfo.data_length(),
- stripeInfo.footer_length(), stripeInfo.number_of_rows(), contents->stream.get(),
- *contents->pool, contents->compression, contents->blockSize, contents->readerMetrics));
+ stripeInfo.footer_length(), stripeInfo.number_of_rows(), contents_->stream.get(),
+ *contents_->pool, contents_->compression, contents_->blockSize, contents_->readerMetrics));
}
FileVersion ReaderImpl::getFormatVersion() const {
- if (contents->postscript->version_size() != 2) {
+ if (contents_->postscript->version_size() != 2) {
return FileVersion::v_0_11();
}
- return {contents->postscript->version(0), contents->postscript->version(1)};
+ return {contents_->postscript->version(0), contents_->postscript->version(1)};
}
uint64_t ReaderImpl::getNumberOfRows() const {
- return footer->number_of_rows();
+ return footer_->number_of_rows();
}
WriterId ReaderImpl::getWriterId() const {
- if (footer->has_writer()) {
- uint32_t id = footer->writer();
+ if (footer_->has_writer()) {
+ uint32_t id = footer_->writer();
if (id > WriterId::CUDF_WRITER) {
return WriterId::UNKNOWN_WRITER;
} else {
@@ -633,8 +632,8 @@ namespace orc {
}
uint32_t ReaderImpl::getWriterIdValue() const {
- if (footer->has_writer()) {
- return footer->writer();
+ if (footer_->has_writer()) {
+ return footer_->writer();
} else {
return WriterId::ORC_JAVA_WRITER;
}
@@ -643,56 +642,56 @@ namespace orc {
std::string ReaderImpl::getSoftwareVersion() const {
std::ostringstream buffer;
buffer << writerIdToString(getWriterIdValue());
- if (footer->has_software_version()) {
- buffer << " " << footer->software_version();
+ if (footer_->has_software_version()) {
+ buffer << " " << footer_->software_version();
}
return buffer.str();
}
WriterVersion ReaderImpl::getWriterVersion() const {
- return getWriterVersionImpl(contents.get());
+ return getWriterVersionImpl(contents_.get());
}
uint64_t ReaderImpl::getContentLength() const {
- return footer->content_length();
+ return footer_->content_length();
}
uint64_t ReaderImpl::getStripeStatisticsLength() const {
- return contents->postscript->metadata_length();
+ return contents_->postscript->metadata_length();
}
uint64_t ReaderImpl::getFileFooterLength() const {
- return contents->postscript->footer_length();
+ return contents_->postscript->footer_length();
}
uint64_t ReaderImpl::getFilePostscriptLength() const {
- return postscriptLength;
+ return postscriptLength_;
}
uint64_t ReaderImpl::getFileLength() const {
- return fileLength;
+ return fileLength_;
}
uint64_t ReaderImpl::getRowIndexStride() const {
- return footer->row_index_stride();
+ return footer_->row_index_stride();
}
const std::string& ReaderImpl::getStreamName() const {
- return contents->stream->getName();
+ return contents_->stream->getName();
}
std::list<std::string> ReaderImpl::getMetadataKeys() const {
std::list<std::string> result;
- for (int i = 0; i < footer->metadata_size(); ++i) {
- result.push_back(footer->metadata(i).name());
+ for (int i = 0; i < footer_->metadata_size(); ++i) {
+ result.push_back(footer_->metadata(i).name());
}
return result;
}
std::string ReaderImpl::getMetadataValue(const std::string& key) const {
- for (int i = 0; i < footer->metadata_size(); ++i) {
- if (footer->metadata(i).name() == key) {
- return footer->metadata(i).value();
+ for (int i = 0; i < footer_->metadata_size(); ++i) {
+ if (footer_->metadata(i).name() == key) {
+ return footer_->metadata(i).value();
}
}
throw std::range_error("key not found");
@@ -719,10 +718,10 @@ namespace orc {
throw ParseError(msg.str());
}
std::unique_ptr<SeekableInputStream> pbStream =
- createDecompressor(contents->compression,
+ createDecompressor(contents_->compression,
std::unique_ptr<SeekableInputStream>(new SeekableFileInputStream(
- contents->stream.get(), offset, length, *contents->pool)),
- contents->blockSize, *(contents->pool), contents->readerMetrics);
+ contents_->stream.get(), offset, length, *contents_->pool)),
+ contents_->blockSize, *(contents_->pool), contents_->readerMetrics);
proto::RowIndex rowIndex;
if (!rowIndex.ParseFromZeroCopyStream(pbStream.get())) {
@@ -740,8 +739,8 @@ namespace orc {
}
bool ReaderImpl::hasMetadataValue(const std::string& key) const {
- for (int i = 0; i < footer->metadata_size(); ++i) {
- if (footer->metadata(i).name() == key) {
+ for (int i = 0; i < footer_->metadata_size(); ++i) {
+ if (footer_->metadata(i).name() == key) {
return true;
}
}
@@ -749,22 +748,22 @@ namespace orc {
}
const Type& ReaderImpl::getType() const {
- return *(contents->schema.get());
+ return *(contents_->schema.get());
}
std::unique_ptr<StripeStatistics> ReaderImpl::getStripeStatistics(uint64_t stripeIndex) const {
- if (!isMetadataLoaded) {
+ if (!isMetadataLoaded_) {
readMetadata();
}
- if (contents->metadata == nullptr) {
+ if (contents_->metadata == nullptr) {
throw std::logic_error("No stripe statistics in file");
}
size_t num_cols = static_cast<size_t>(
- contents->metadata->stripe_stats(static_cast<int>(stripeIndex)).col_stats_size());
+ contents_->metadata->stripe_stats(static_cast<int>(stripeIndex)).col_stats_size());
std::vector<std::vector<proto::ColumnStatistics>> indexStats(num_cols);
- proto::StripeInformation currentStripeInfo = footer->stripes(static_cast<int>(stripeIndex));
- proto::StripeFooter currentStripeFooter = getStripeFooter(currentStripeInfo, *contents.get());
+ proto::StripeInformation currentStripeInfo = footer_->stripes(static_cast<int>(stripeIndex));
+ proto::StripeFooter currentStripeFooter = getStripeFooter(currentStripeInfo, *contents_.get());
getRowIndexStatistics(currentStripeInfo, stripeIndex, currentStripeFooter, &indexStats);
@@ -773,47 +772,47 @@ namespace orc {
: getLocalTimezone();
StatContext statContext(hasCorrectStatistics(), &writerTZ);
return std::make_unique<StripeStatisticsImpl>(
- contents->metadata->stripe_stats(static_cast<int>(stripeIndex)), indexStats, statContext);
+ contents_->metadata->stripe_stats(static_cast<int>(stripeIndex)), indexStats, statContext);
}
std::unique_ptr<Statistics> ReaderImpl::getStatistics() const {
StatContext statContext(hasCorrectStatistics());
- return std::make_unique<StatisticsImpl>(*footer, statContext);
+ return std::make_unique<StatisticsImpl>(*footer_, statContext);
}
std::unique_ptr<ColumnStatistics> ReaderImpl::getColumnStatistics(uint32_t index) const {
- if (index >= static_cast<uint64_t>(footer->statistics_size())) {
+ if (index >= static_cast<uint64_t>(footer_->statistics_size())) {
throw std::logic_error("column index out of range");
}
- proto::ColumnStatistics col = footer->statistics(static_cast<int32_t>(index));
+ proto::ColumnStatistics col = footer_->statistics(static_cast<int32_t>(index));
StatContext statContext(hasCorrectStatistics());
return std::unique_ptr<ColumnStatistics>(convertColumnStatistics(col, statContext));
}
void ReaderImpl::readMetadata() const {
- uint64_t metadataSize = contents->postscript->metadata_length();
- uint64_t footerLength = contents->postscript->footer_length();
- if (fileLength < metadataSize + footerLength + postscriptLength + 1) {
+ uint64_t metadataSize = contents_->postscript->metadata_length();
+ uint64_t footerLength = contents_->postscript->footer_length();
+ if (fileLength_ < metadataSize + footerLength + postscriptLength_ + 1) {
std::stringstream msg;
- msg << "Invalid Metadata length: fileLength=" << fileLength
+ msg << "Invalid Metadata length: fileLength=" << fileLength_
<< ", metadataLength=" << metadataSize << ", footerLength=" << footerLength
- << ", postscriptLength=" << postscriptLength;
+ << ", postscriptLength=" << postscriptLength_;
throw ParseError(msg.str());
}
- uint64_t metadataStart = fileLength - metadataSize - footerLength - postscriptLength - 1;
+ uint64_t metadataStart = fileLength_ - metadataSize - footerLength - postscriptLength_ - 1;
if (metadataSize != 0) {
std::unique_ptr<SeekableInputStream> pbStream = createDecompressor(
- contents->compression,
- std::make_unique<SeekableFileInputStream>(contents->stream.get(), metadataStart,
- metadataSize, *contents->pool),
- contents->blockSize, *contents->pool, contents->readerMetrics);
- contents->metadata.reset(new proto::Metadata());
- if (!contents->metadata->ParseFromZeroCopyStream(pbStream.get())) {
+ contents_->compression,
+ std::make_unique<SeekableFileInputStream>(contents_->stream.get(), metadataStart,
+ metadataSize, *contents_->pool),
+ contents_->blockSize, *contents_->pool, contents_->readerMetrics);
+ contents_->metadata.reset(new proto::Metadata());
+ if (!contents_->metadata->ParseFromZeroCopyStream(pbStream.get())) {
throw ParseError("Failed to parse the metadata");
}
}
- isMetadataLoaded = true;
+ isMetadataLoaded_ = true;
}
bool ReaderImpl::hasCorrectStatistics() const {
@@ -823,9 +822,9 @@ namespace orc {
void ReaderImpl::checkOrcVersion() {
FileVersion version = getFormatVersion();
if (version != FileVersion(0, 11) && version != FileVersion(0, 12)) {
- *(options.getErrorStream()) << "Warning: ORC file " << contents->stream->getName()
- << " was written in an unknown format version "
- << version.toString() << "\n";
+ *(options_.getErrorStream())
+ << "Warning: ORC file " << contents_->stream->getName()
+ << " was written in an unknown format version " << version.toString() << "\n";
}
}
@@ -835,11 +834,11 @@ namespace orc {
}
std::unique_ptr<RowReader> ReaderImpl::createRowReader(const RowReaderOptions& opts) const {
- if (opts.getSearchArgument() && !isMetadataLoaded) {
+ if (opts.getSearchArgument() && !isMetadataLoaded_) {
// load stripe statistics for PPD
readMetadata();
}
- return std::make_unique<RowReaderImpl>(contents, opts);
+ return std::make_unique<RowReaderImpl>(contents_, opts);
}
uint64_t maxStreamsForType(const proto::Type& type) {
@@ -874,15 +873,15 @@ namespace orc {
uint64_t ReaderImpl::getMemoryUse(int stripeIx) {
std::vector<bool> selectedColumns;
- selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), true);
+ selectedColumns.assign(static_cast<size_t>(contents_->footer->types_size()), true);
return getMemoryUse(stripeIx, selectedColumns);
}
uint64_t ReaderImpl::getMemoryUseByFieldId(const std::list<uint64_t>& include, int stripeIx) {
std::vector<bool> selectedColumns;
- selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), false);
- ColumnSelector column_selector(contents.get());
- if (contents->schema->getKind() == STRUCT && include.begin() != include.end()) {
+ selectedColumns.assign(static_cast<size_t>(contents_->footer->types_size()), false);
+ ColumnSelector column_selector(contents_.get());
+ if (contents_->schema->getKind() == STRUCT && include.begin() != include.end()) {
for (std::list<uint64_t>::const_iterator field = include.begin(); field != include.end();
++field) {
column_selector.updateSelectedByFieldId(selectedColumns, *field);
@@ -891,16 +890,16 @@ namespace orc {
// default is to select all columns
std::fill(selectedColumns.begin(), selectedColumns.end(), true);
}
- column_selector.selectParents(selectedColumns, *contents->schema.get());
+ column_selector.selectParents(selectedColumns, *contents_->schema.get());
selectedColumns[0] = true; // column 0 is selected by default
return getMemoryUse(stripeIx, selectedColumns);
}
uint64_t ReaderImpl::getMemoryUseByName(const std::list<std::string>& names, int stripeIx) {
std::vector<bool> selectedColumns;
- selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), false);
- ColumnSelector column_selector(contents.get());
- if (contents->schema->getKind() == STRUCT && names.begin() != names.end()) {
+ selectedColumns.assign(static_cast<size_t>(contents_->footer->types_size()), false);
+ ColumnSelector column_selector(contents_.get());
+ if (contents_->schema->getKind() == STRUCT && names.begin() != names.end()) {
for (std::list<std::string>::const_iterator field = names.begin(); field != names.end();
++field) {
column_selector.updateSelectedByName(selectedColumns, *field);
@@ -909,15 +908,15 @@ namespace orc {
// default is to select all columns
std::fill(selectedColumns.begin(), selectedColumns.end(), true);
}
- column_selector.selectParents(selectedColumns, *contents->schema.get());
+ column_selector.selectParents(selectedColumns, *contents_->schema.get());
selectedColumns[0] = true; // column 0 is selected by default
return getMemoryUse(stripeIx, selectedColumns);
}
uint64_t ReaderImpl::getMemoryUseByTypeId(const std::list<uint64_t>& include, int stripeIx) {
std::vector<bool> selectedColumns;
- selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), false);
- ColumnSelector column_selector(contents.get());
+ selectedColumns.assign(static_cast<size_t>(contents_->footer->types_size()), false);
+ ColumnSelector column_selector(contents_.get());
if (include.begin() != include.end()) {
for (std::list<uint64_t>::const_iterator field = include.begin(); field != include.end();
++field) {
@@ -927,7 +926,7 @@ namespace orc {
// default is to select all columns
std::fill(selectedColumns.begin(), selectedColumns.end(), true);
}
- column_selector.selectParents(selectedColumns, *contents->schema.get());
+ column_selector.selectParents(selectedColumns, *contents_->schema.get());
selectedColumns[0] = true; // column 0 is selected by default
return getMemoryUse(stripeIx, selectedColumns);
}
@@ -935,14 +934,14 @@ namespace orc {
uint64_t ReaderImpl::getMemoryUse(int stripeIx, std::vector<bool>& selectedColumns) {
uint64_t maxDataLength = 0;
- if (stripeIx >= 0 && stripeIx < footer->stripes_size()) {
- uint64_t stripe = footer->stripes(stripeIx).data_length();
+ if (stripeIx >= 0 && stripeIx < footer_->stripes_size()) {
+ uint64_t stripe = footer_->stripes(stripeIx).data_length();
if (maxDataLength < stripe) {
maxDataLength = stripe;
}
} else {
- for (int i = 0; i < footer->stripes_size(); i++) {
- uint64_t stripe = footer->stripes(i).data_length();
+ for (int i = 0; i < footer_->stripes_size(); i++) {
+ uint64_t stripe = footer_->stripes(i).data_length();
if (maxDataLength < stripe) {
maxDataLength = stripe;
}
@@ -951,9 +950,9 @@ namespace orc {
bool hasStringColumn = false;
uint64_t nSelectedStreams = 0;
- for (int i = 0; !hasStringColumn && i < footer->types_size(); i++) {
+ for (int i = 0; !hasStringColumn && i < footer_->types_size(); i++) {
if (selectedColumns[static_cast<size_t>(i)]) {
- const proto::Type& type = footer->types(i);
+ const proto::Type& type = footer_->types(i);
nSelectedStreams += maxStreamsForType(type);
switch (static_cast<int64_t>(type.kind())) {
case proto::Type_Kind_CHAR:
@@ -979,29 +978,29 @@ namespace orc {
uint64_t memory = hasStringColumn
? 2 * maxDataLength
: std::min(uint64_t(maxDataLength),
- nSelectedStreams * contents->stream->getNaturalReadSize());
+ nSelectedStreams * contents_->stream->getNaturalReadSize());
// Do we need even more memory to read the footer or the metadata?
- if (memory < contents->postscript->footer_length() + DIRECTORY_SIZE_GUESS) {
- memory = contents->postscript->footer_length() + DIRECTORY_SIZE_GUESS;
+ if (memory < contents_->postscript->footer_length() + DIRECTORY_SIZE_GUESS) {
+ memory = contents_->postscript->footer_length() + DIRECTORY_SIZE_GUESS;
}
- if (memory < contents->postscript->metadata_length()) {
- memory = contents->postscript->metadata_length();
+ if (memory < contents_->postscript->metadata_length()) {
+ memory = contents_->postscript->metadata_length();
}
// Account for firstRowOfStripe.
- memory += static_cast<uint64_t>(footer->stripes_size()) * sizeof(uint64_t);
+ memory += static_cast<uint64_t>(footer_->stripes_size()) * sizeof(uint64_t);
// Decompressors need buffers for each stream
uint64_t decompressorMemory = 0;
- if (contents->compression != CompressionKind_NONE) {
- for (int i = 0; i < footer->types_size(); i++) {
+ if (contents_->compression != CompressionKind_NONE) {
+ for (int i = 0; i < footer_->types_size(); i++) {
if (selectedColumns[static_cast<size_t>(i)]) {
- const proto::Type& type = footer->types(i);
- decompressorMemory += maxStreamsForType(type) * contents->blockSize;
+ const proto::Type& type = footer_->types(i);
+ decompressorMemory += maxStreamsForType(type) * contents_->blockSize;
}
}
- if (contents->compression == CompressionKind_SNAPPY) {
+ if (contents_->compression == CompressionKind_SNAPPY) {
decompressorMemory *= 2; // Snappy decompressor uses a second buffer
}
}
@@ -1011,69 +1010,70 @@ namespace orc {
// Update fields to indicate we've reached the end of file
void RowReaderImpl::markEndOfFile() {
- currentStripe = lastStripe;
- currentRowInStripe = 0;
- rowsInCurrentStripe = 0;
- if (lastStripe == 0) {
+ currentStripe_ = lastStripe_;
+ currentRowInStripe_ = 0;
+ rowsInCurrentStripe_ = 0;
+ if (lastStripe_ == 0) {
// Empty file
- previousRow = 0;
+ previousRow_ = 0;
} else {
- previousRow = firstRowOfStripe[lastStripe - 1] +
- footer->stripes(static_cast<int>(lastStripe - 1)).number_of_rows();
+ previousRow_ = firstRowOfStripe_[lastStripe_ - 1] +
+ footer_->stripes(static_cast<int>(lastStripe_ - 1)).number_of_rows();
}
}
void RowReaderImpl::startNextStripe() {
- reader.reset(); // ColumnReaders use lots of memory; free old memory first
- rowIndexes.clear();
- bloomFilterIndex.clear();
+ reader_.reset(); // ColumnReaders use lots of memory; free old memory first
+ rowIndexes_.clear();
+ bloomFilterIndex_.clear();
// evaluate file statistics if it exists
- if (sargsApplier && !sargsApplier->evaluateFileStatistics(*footer, numRowGroupsInStripeRange)) {
+ if (sargsApplier_ &&
+ !sargsApplier_->evaluateFileStatistics(*footer_, numRowGroupsInStripeRange_)) {
// skip the entire file
markEndOfFile();
return;
}
do {
- currentStripeInfo = footer->stripes(static_cast<int>(currentStripe));
- uint64_t fileLength = contents->stream->getLength();
- if (currentStripeInfo.offset() + currentStripeInfo.index_length() +
- currentStripeInfo.data_length() + currentStripeInfo.footer_length() >=
+ currentStripeInfo_ = footer_->stripes(static_cast<int>(currentStripe_));
+ uint64_t fileLength = contents_->stream->getLength();
+ if (currentStripeInfo_.offset() + currentStripeInfo_.index_length() +
+ currentStripeInfo_.data_length() + currentStripeInfo_.footer_length() >=
fileLength) {
std::stringstream msg;
- msg << "Malformed StripeInformation at stripe index " << currentStripe
+ msg << "Malformed StripeInformation at stripe index " << currentStripe_
<< ": fileLength=" << fileLength
- << ", StripeInfo=(offset=" << currentStripeInfo.offset()
- << ", indexLength=" << currentStripeInfo.index_length()
- << ", dataLength=" << currentStripeInfo.data_length()
- << ", footerLength=" << currentStripeInfo.footer_length() << ")";
+ << ", StripeInfo=(offset=" << currentStripeInfo_.offset()
+ << ", indexLength=" << currentStripeInfo_.index_length()
+ << ", dataLength=" << currentStripeInfo_.data_length()
+ << ", footerLength=" << currentStripeInfo_.footer_length() << ")";
throw ParseError(msg.str());
}
- rowsInCurrentStripe = currentStripeInfo.number_of_rows();
- processingStripe = currentStripe;
+ rowsInCurrentStripe_ = currentStripeInfo_.number_of_rows();
+ processingStripe_ = currentStripe_;
bool isStripeNeeded = true;
// If PPD enabled and stripe stats existed, evaulate it first
- if (sargsApplier && contents->metadata) {
+ if (sargsApplier_ && contents_->metadata) {
const auto& currentStripeStats =
- contents->metadata->stripe_stats(static_cast<int>(currentStripe));
+ contents_->metadata->stripe_stats(static_cast<int>(currentStripe_));
// skip this stripe after stats fail to satisfy sargs
uint64_t stripeRowGroupCount =
- (rowsInCurrentStripe + footer->row_index_stride() - 1) / footer->row_index_stride();
+ (rowsInCurrentStripe_ + footer_->row_index_stride() - 1) / footer_->row_index_stride();
isStripeNeeded =
- sargsApplier->evaluateStripeStatistics(currentStripeStats, stripeRowGroupCount);
+ sargsApplier_->evaluateStripeStatistics(currentStripeStats, stripeRowGroupCount);
}
if (isStripeNeeded) {
- currentStripeFooter = getStripeFooter(currentStripeInfo, *contents.get());
- if (sargsApplier) {
+ currentStripeFooter_ = getStripeFooter(currentStripeInfo_, *contents_.get());
+ if (sargsApplier_) {
// read row group statistics and bloom filters of current stripe
loadStripeIndex();
// select row groups to read in the current stripe
- sargsApplier->pickRowGroups(rowsInCurrentStripe, rowIndexes, bloomFilterIndex);
- if (sargsApplier->hasSelectedFrom(currentRowInStripe)) {
+ sargsApplier_->pickRowGroups(rowsInCurrentStripe_, rowIndexes_, bloomFilterIndex_);
+ if (sargsApplier_->hasSelectedFrom(currentRowInStripe_)) {
// current stripe has at least one row group matching the predicate
break;
}
@@ -1083,31 +1083,31 @@ namespace orc {
if (!isStripeNeeded) {
// advance to next stripe when current stripe has no matching rows
- currentStripe += 1;
- currentRowInStripe = 0;
+ currentStripe_ += 1;
+ currentRowInStripe_ = 0;
}
- } while (sargsApplier && currentStripe < lastStripe);
+ } while (sargsApplier_ && currentStripe_ < lastStripe_);
- if (currentStripe < lastStripe) {
+ if (currentStripe_ < lastStripe_) {
// get writer timezone info from stripe footer to help understand timestamp values.
const Timezone& writerTimezone =
- currentStripeFooter.has_writer_timezone()
- ? getTimezoneByName(currentStripeFooter.writer_timezone())
- : localTimezone;
- StripeStreamsImpl stripeStreams(*this, currentStripe, currentStripeInfo, currentStripeFooter,
- currentStripeInfo.offset(), *contents->stream, writerTimezone,
- readerTimezone);
- reader = buildReader(*contents->schema, stripeStreams, useTightNumericVector,
- throwOnSchemaEvolutionOverflow, /*convertToReadType=*/true);
-
- if (sargsApplier) {
+ currentStripeFooter_.has_writer_timezone()
+ ? getTimezoneByName(currentStripeFooter_.writer_timezone())
+ : localTimezone_;
+ StripeStreamsImpl stripeStreams(*this, currentStripe_, currentStripeInfo_,
+ currentStripeFooter_, currentStripeInfo_.offset(),
+ *contents_->stream, writerTimezone, readerTimezone_);
+ reader_ = buildReader(*contents_->schema, stripeStreams, useTightNumericVector_,
+ throwOnSchemaEvolutionOverflow_, /*convertToReadType=*/true);
+
+ if (sargsApplier_) {
// move to the 1st selected row group when PPD is enabled.
- currentRowInStripe =
- advanceToNextRowGroup(currentRowInStripe, rowsInCurrentStripe,
- footer->row_index_stride(), sargsApplier->getNextSkippedRows());
- previousRow = firstRowOfStripe[currentStripe] + currentRowInStripe - 1;
- if (currentRowInStripe > 0) {
- seekToRowGroup(static_cast<uint32_t>(currentRowInStripe / footer->row_index_stride()));
+ currentRowInStripe_ =
+ advanceToNextRowGroup(currentRowInStripe_, rowsInCurrentStripe_,
+ footer_->row_index_stride(), sargsApplier_->getNextSkippedRows());
+ previousRow_ = firstRowOfStripe_[currentStripe_] + currentRowInStripe_ - 1;
+ if (currentRowInStripe_ > 0) {
+ seekToRowGroup(static_cast<uint32_t>(currentRowInStripe_ / footer_->row_index_stride()));
}
}
} else {
@@ -1118,51 +1118,52 @@ namespace orc {
bool RowReaderImpl::next(ColumnVectorBatch& data) {
SCOPED_STOPWATCH(contents->readerMetrics, ReaderInclusiveLatencyUs, ReaderCall);
- if (currentStripe >= lastStripe) {
+ if (currentStripe_ >= lastStripe_) {
data.numElements = 0;
markEndOfFile();
return false;
}
- if (currentRowInStripe == 0) {
+ if (currentRowInStripe_ == 0) {
startNextStripe();
}
uint64_t rowsToRead =
- std::min(static_cast<uint64_t>(data.capacity), rowsInCurrentStripe - currentRowInStripe);
- if (sargsApplier && rowsToRead > 0) {
- rowsToRead = computeBatchSize(rowsToRead, currentRowInStripe, rowsInCurrentStripe,
- footer->row_index_stride(), sargsApplier->getNextSkippedRows());
+ std::min(static_cast<uint64_t>(data.capacity), rowsInCurrentStripe_ - currentRowInStripe_);
+ if (sargsApplier_ && rowsToRead > 0) {
+ rowsToRead =
+ computeBatchSize(rowsToRead, currentRowInStripe_, rowsInCurrentStripe_,
+ footer_->row_index_stride(), sargsApplier_->getNextSkippedRows());
}
data.numElements = rowsToRead;
if (rowsToRead == 0) {
markEndOfFile();
return false;
}
- if (enableEncodedBlock) {
- reader->nextEncoded(data, rowsToRead, nullptr);
+ if (enableEncodedBlock_) {
+ reader_->nextEncoded(data, rowsToRead, nullptr);
} else {
- reader->next(data, rowsToRead, nullptr);
+ reader_->next(data, rowsToRead, nullptr);
}
// update row number
- previousRow = firstRowOfStripe[currentStripe] + currentRowInStripe;
- currentRowInStripe += rowsToRead;
+ previousRow_ = firstRowOfStripe_[currentStripe_] + currentRowInStripe_;
+ currentRowInStripe_ += rowsToRead;
// check if we need to advance to next selected row group
- if (sargsApplier) {
+ if (sargsApplier_) {
uint64_t nextRowToRead =
- advanceToNextRowGroup(currentRowInStripe, rowsInCurrentStripe, footer->row_index_stride(),
- sargsApplier->getNextSkippedRows());
- if (currentRowInStripe != nextRowToRead) {
+ advanceToNextRowGroup(currentRowInStripe_, rowsInCurrentStripe_,
+ footer_->row_index_stride(), sargsApplier_->getNextSkippedRows());
+ if (currentRowInStripe_ != nextRowToRead) {
// it is guaranteed to be at start of a row group
- currentRowInStripe = nextRowToRead;
- if (currentRowInStripe < rowsInCurrentStripe) {
- seekToRowGroup(static_cast<uint32_t>(currentRowInStripe / footer->row_index_stride()));
+ currentRowInStripe_ = nextRowToRead;
+ if (currentRowInStripe_ < rowsInCurrentStripe_) {
+ seekToRowGroup(static_cast<uint32_t>(currentRowInStripe_ / footer_->row_index_stride()));
}
}
}
- if (currentRowInStripe >= rowsInCurrentStripe) {
- currentStripe += 1;
- currentRowInStripe = 0;
+ if (currentRowInStripe_ >= rowsInCurrentStripe_) {
+ currentStripe_ += 1;
+ currentRowInStripe_ = 0;
}
return rowsToRead != 0;
}
@@ -1221,9 +1222,9 @@ namespace orc {
std::unique_ptr<ColumnVectorBatch> RowReaderImpl::createRowBatch(uint64_t capacity) const {
// If the read type is specified, then check that the selected schema matches the read type
// on the first call to createRowBatch.
- if (schemaEvolution.getReadType() && selectedSchema.get() == nullptr) {
+ if (schemaEvolution_.getReadType() && selectedSchema_.get() == nullptr) {
auto fileSchema = &getSelectedType();
- auto readType = schemaEvolution.getReadType();
+ auto readType = schemaEvolution_.getReadType();
std::set<uint64_t> readColumns, fileColumns;
getColumnIds(readType, readColumns);
getColumnIds(fileSchema, fileColumns);
@@ -1235,9 +1236,9 @@ namespace orc {
}
}
const Type& readType =
- schemaEvolution.getReadType() ? *schemaEvolution.getReadType() : getSelectedType();
- return readType.createRowBatch(capacity, *contents->pool, enableEncodedBlock,
- useTightNumericVector);
+ schemaEvolution_.getReadType() ? *schemaEvolution_.getReadType() : getSelectedType();
+ return readType.createRowBatch(capacity, *contents_->pool, enableEncodedBlock_,
+ useTightNumericVector_);
}
void ensureOrcFooter(InputStream* stream, DataBuffer<char>* buffer, uint64_t postscriptLength) {
@@ -1426,13 +1427,13 @@ namespace orc {
std::map<uint32_t, BloomFilterIndex> ret;
// find stripe info
- if (stripeIndex >= static_cast<uint32_t>(footer->stripes_size())) {
+ if (stripeIndex >= static_cast<uint32_t>(footer_->stripes_size())) {
throw std::logic_error("Illegal stripe index: " +
to_string(static_cast<int64_t>(stripeIndex)));
}
const proto::StripeInformation currentStripeInfo =
- footer->stripes(static_cast<int>(stripeIndex));
- const proto::StripeFooter currentStripeFooter = getStripeFooter(currentStripeInfo, *contents);
+ footer_->stripes(static_cast<int>(stripeIndex));
+ const proto::StripeFooter currentStripeFooter = getStripeFooter(currentStripeInfo, *contents_);
// iterate stripe footer to get stream of bloom_filter
uint64_t offset = static_cast<uint64_t>(currentStripeInfo.offset());
@@ -1445,10 +1446,10 @@ namespace orc {
if (stream.kind() == proto::Stream_Kind_BLOOM_FILTER_UTF8 &&
(included.empty() || included.find(column) != included.end())) {
std::unique_ptr<SeekableInputStream> pbStream =
- createDecompressor(contents->compression,
+ createDecompressor(contents_->compression,
std::make_unique<SeekableFileInputStream>(
- contents->stream.get(), offset, length, *contents->pool),
- contents->blockSize, *(contents->pool), contents->readerMetrics);
+ contents_->stream.get(), offset, length, *contents_->pool),
+ contents_->blockSize, *(contents_->pool), contents_->readerMetrics);
proto::BloomFilterIndex pbBFIndex;
if (!pbBFIndex.ParseFromZeroCopyStream(pbStream.get())) {
diff --git a/c++/src/Reader.hh b/c++/src/Reader.hh
index a1367e4bd..630d812c3 100644
--- a/c++/src/Reader.hh
+++ b/c++/src/Reader.hh
@@ -39,17 +39,17 @@ namespace orc {
*/
class WriterVersionImpl {
private:
- WriterVersion version;
+ WriterVersion version_;
public:
// Known Versions with issues resolved
// The static method below is to fix global constructors Clang warning
static const WriterVersionImpl& VERSION_HIVE_8732();
- WriterVersionImpl(WriterVersion ver) : version(ver) {}
+ WriterVersionImpl(WriterVersion ver) : version_(ver) {}
bool compareGT(const WriterVersion other) const {
- return version > other;
+ return version_ > other;
}
};
@@ -80,10 +80,10 @@ namespace orc {
class ColumnSelector {
private:
- std::map<std::string, uint64_t> nameIdMap;
- std::map<uint64_t, const Type*> idTypeMap;
- const FileContents* contents;
- std::vector<std::string> columns;
+ std::map<std::string, uint64_t> nameIdMap_;
+ std::map<uint64_t, const Type*> idTypeMap_;
+ const FileContents* contents_;
+ std::vector<std::string> columns_;
// build map from type name and id, id to Type
void buildTypeNameIdMap(const Type* type);
@@ -127,54 +127,54 @@ namespace orc {
class RowReaderImpl : public RowReader {
private:
- const Timezone& localTimezone;
+ const Timezone& localTimezone_;
// contents
- std::shared_ptr<FileContents> contents;
- const bool throwOnHive11DecimalOverflow;
- const int32_t forcedScaleOnHive11Decimal;
+ std::shared_ptr<FileContents> contents_;
+ const bool throwOnHive11DecimalOverflow_;
+ const int32_t forcedScaleOnHive11Decimal_;
// inputs
- std::vector<bool> selectedColumns;
+ std::vector<bool> selectedColumns_;
// footer
- proto::Footer* footer;
- DataBuffer<uint64_t> firstRowOfStripe;
- mutable std::unique_ptr<Type> selectedSchema;
- bool skipBloomFilters;
+ proto::Footer* footer_;
+ DataBuffer<uint64_t> firstRowOfStripe_;
+ mutable std::unique_ptr<Type> selectedSchema_;
+ bool skipBloomFilters_;
// reading state
- uint64_t previousRow;
- uint64_t firstStripe;
- uint64_t currentStripe;
- uint64_t lastStripe; // the stripe AFTER the last one
- uint64_t processingStripe;
- uint64_t currentRowInStripe;
- uint64_t rowsInCurrentStripe;
+ uint64_t previousRow_;
+ uint64_t firstStripe_;
+ uint64_t currentStripe_;
+ uint64_t lastStripe_; // the stripe AFTER the last one
+ uint64_t processingStripe_;
+ uint64_t currentRowInStripe_;
+ uint64_t rowsInCurrentStripe_;
// number of row groups between first stripe and last stripe
- uint64_t numRowGroupsInStripeRange;
- proto::StripeInformation currentStripeInfo;
- proto::StripeFooter currentStripeFooter;
- std::unique_ptr<ColumnReader> reader;
-
- bool enableEncodedBlock;
- bool useTightNumericVector;
- bool throwOnSchemaEvolutionOverflow;
+ uint64_t numRowGroupsInStripeRange_;
+ proto::StripeInformation currentStripeInfo_;
+ proto::StripeFooter currentStripeFooter_;
+ std::unique_ptr<ColumnReader> reader_;
+
+ bool enableEncodedBlock_;
+ bool useTightNumericVector_;
+ bool throwOnSchemaEvolutionOverflow_;
// internal methods
void startNextStripe();
inline void markEndOfFile();
// row index of current stripe with column id as the key
- std::unordered_map<uint64_t, proto::RowIndex> rowIndexes;
- std::map<uint32_t, BloomFilterIndex> bloomFilterIndex;
- std::shared_ptr<SearchArgument> sargs;
- std::unique_ptr<SargsApplier> sargsApplier;
+ std::unordered_map<uint64_t, proto::RowIndex> rowIndexes_;
+ std::map<uint32_t, BloomFilterIndex> bloomFilterIndex_;
+ std::shared_ptr<SearchArgument> sargs_;
+ std::unique_ptr<SargsApplier> sargsApplier_;
// desired timezone to return data of timestamp types.
- const Timezone& readerTimezone;
+ const Timezone& readerTimezone_;
// match read and file types
- SchemaEvolution schemaEvolution;
+ SchemaEvolution schemaEvolution_;
// load stripe index if not done so
void loadStripeIndex();
@@ -196,7 +196,7 @@ namespace orc {
// whether the current stripe is initialized
inline bool isCurrentStripeInited() const {
- return currentStripe == processingStripe;
+ return currentStripe_ == processingStripe_;
}
/**
@@ -243,23 +243,23 @@ namespace orc {
int32_t getForcedScaleOnHive11Decimal() const;
const SchemaEvolution* getSchemaEvolution() const {
- return &schemaEvolution;
+ return &schemaEvolution_;
}
};
class ReaderImpl : public Reader {
private:
// FileContents
- std::shared_ptr<FileContents> contents;
+ std::shared_ptr<FileContents> contents_;
// inputs
- const ReaderOptions options;
- const uint64_t fileLength;
- const uint64_t postscriptLength;
+ const ReaderOptions options_;
+ const uint64_t fileLength_;
+ const uint64_t postscriptLength_;
// footer
- proto::Footer* footer;
- uint64_t numberOfStripes;
+ proto::Footer* footer_;
+ uint64_t numberOfStripes_;
uint64_t getMemoryUse(int stripeIx, std::vector<bool>& selectedColumns);
// internal methods
@@ -271,7 +271,7 @@ namespace orc {
std::vector<std::vector<proto::ColumnStatistics> >* indexStats) const;
// metadata
- mutable bool isMetadataLoaded;
+ mutable bool isMetadataLoaded_;
public:
/**
@@ -341,27 +341,27 @@ namespace orc {
bool hasCorrectStatistics() const override;
const ReaderMetrics* getReaderMetrics() const override {
- return contents->readerMetrics;
+ return contents_->readerMetrics;
}
const proto::PostScript* getPostscript() const {
- return contents->postscript.get();
+ return contents_->postscript.get();
}
uint64_t getBlockSize() const {
- return contents->blockSize;
+ return contents_->blockSize;
}
const proto::Footer* getFooter() const {
- return contents->footer.get();
+ return contents_->footer.get();
}
const Type* getSchema() const {
- return contents->schema.get();
+ return contents_->schema.get();
}
InputStream* getStream() const {
- return contents->stream.get();
+ return contents_->stream.get();
}
uint64_t getMemoryUse(int stripeIx = -1) override;
diff --git a/c++/src/RleDecoderV2.cc b/c++/src/RleDecoderV2.cc
index c03294ecf..f35dd4fe5 100644
--- a/c++/src/RleDecoderV2.cc
+++ b/c++/src/RleDecoderV2.cc
@@ -31,17 +31,17 @@ namespace orc {
unsigned char RleDecoderV2::readByte() {
SCOPED_MINUS_STOPWATCH(metrics, DecodingLatencyUs);
- if (bufferStart == bufferEnd) {
+ if (bufferStart_ == bufferEnd_) {
int bufferLength;
const void* bufferPointer;
- if (!inputStream->Next(&bufferPointer, &bufferLength)) {
+ if (!inputStream_->Next(&bufferPointer, &bufferLength)) {
throw ParseError("bad read in RleDecoderV2::readByte");
}
- bufferStart = const_cast<char*>(static_cast<const char*>(bufferPointer));
- bufferEnd = bufferStart + bufferLength;
+ bufferStart_ = const_cast<char*>(static_cast<const char*>(bufferPointer));
+ bufferEnd_ = bufferStart_ + bufferLength;
}
- unsigned char result = static_cast<unsigned char>(*bufferStart++);
+ unsigned char result = static_cast<unsigned char>(*bufferStart_++);
return result;
}
@@ -89,29 +89,29 @@ namespace orc {
return dispatch.func(this, data, offset, len, fbs);
}
- RleDecoderV2::RleDecoderV2(std::unique_ptr<SeekableInputStream> input, bool _isSigned,
- MemoryPool& pool, ReaderMetrics* _metrics)
- : RleDecoder(_metrics),
- inputStream(std::move(input)),
- isSigned(_isSigned),
- firstByte(0),
- bufferStart(nullptr),
- bufferEnd(bufferStart),
- runLength(0),
- runRead(0),
- bitsLeft(0),
- curByte(0),
- unpackedPatch(pool, 0),
- literals(pool, MAX_LITERAL_SIZE) {
+ RleDecoderV2::RleDecoderV2(std::unique_ptr<SeekableInputStream> input, bool isSigned,
+ MemoryPool& pool, ReaderMetrics* metrics)
+ : RleDecoder(metrics),
+ inputStream_(std::move(input)),
+ isSigned_(isSigned),
+ firstByte_(0),
+ bufferStart_(nullptr),
+ bufferEnd_(bufferStart_),
+ runLength_(0),
+ runRead_(0),
+ bitsLeft_(0),
+ curByte_(0),
+ unpackedPatch_(pool, 0),
+ literals_(pool, MAX_LITERAL_SIZE) {
// PASS
}
void RleDecoderV2::seek(PositionProvider& location) {
// move the input stream
- inputStream->seek(location);
+ inputStream_->seek(location);
// clear state
- bufferEnd = bufferStart = nullptr;
- runRead = runLength = 0;
+ bufferEnd_ = bufferStart_ = nullptr;
+ runRead_ = runLength_ = 0;
// skip ahead the given number of records
skip(location.next());
}
@@ -142,14 +142,14 @@ namespace orc {
}
}
- if (runRead == runLength) {
+ if (runRead_ == runLength_) {
resetRun();
- firstByte = readByte();
+ firstByte_ = readByte();
}
uint64_t offset = nRead, length = numValues - nRead;
- EncodingType enc = static_cast<EncodingType>((firstByte >> 6) & 0x03);
+ EncodingType enc = static_cast<EncodingType>((firstByte_ >> 6) & 0x03);
switch (static_cast<int64_t>(enc)) {
case SHORT_REPEAT:
nRead += nextShortRepeats(data, offset, length, notNull);
@@ -184,37 +184,37 @@ namespace orc {
template <typename T>
uint64_t RleDecoderV2::nextShortRepeats(T* const data, uint64_t offset, uint64_t numValues,
const char* const notNull) {
- if (runRead == runLength) {
+ if (runRead_ == runLength_) {
// extract the number of fixed bytes
- uint64_t byteSize = (firstByte >> 3) & 0x07;
+ uint64_t byteSize = (firstByte_ >> 3) & 0x07;
byteSize += 1;
- runLength = firstByte & 0x07;
+ runLength_ = firstByte_ & 0x07;
// run lengths values are stored only after MIN_REPEAT value is met
- runLength += MIN_REPEAT;
- runRead = 0;
+ runLength_ += MIN_REPEAT;
+ runRead_ = 0;
// read the repeated value which is store using fixed bytes
- literals[0] = readLongBE(byteSize);
+ literals_[0] = readLongBE(byteSize);
- if (isSigned) {
- literals[0] = unZigZag(static_cast<uint64_t>(literals[0]));
+ if (isSigned_) {
+ literals_[0] = unZigZag(static_cast<uint64_t>(literals_[0]));
}
}
- uint64_t nRead = std::min(runLength - runRead, numValues);
+ uint64_t nRead = std::min(runLength_ - runRead_, numValues);
if (notNull) {
for (uint64_t pos = offset; pos < offset + nRead; ++pos) {
if (notNull[pos]) {
- data[pos] = static_cast<T>(literals[0]);
- ++runRead;
+ data[pos] = static_cast<T>(literals_[0]);
+ ++runRead_;
}
}
} else {
for (uint64_t pos = offset; pos < offset + nRead; ++pos) {
- data[pos] = static_cast<T>(literals[0]);
- ++runRead;
+ data[pos] = static_cast<T>(literals_[0]);
+ ++runRead_;
}
}
@@ -224,22 +224,22 @@ namespace orc {
template <typename T>
uint64_t RleDecoderV2::nextDirect(T* const data, uint64_t offset, uint64_t numValues,
const char* const notNull) {
- if (runRead == runLength) {
+ if (runRead_ == runLength_) {
// extract the number of fixed bits
- unsigned char fbo = (firstByte >> 1) & 0x1f;
+ unsigned char fbo = (firstByte_ >> 1) & 0x1f;
uint32_t bitSize = decodeBitWidth(fbo);
// extract the run length
- runLength = static_cast<uint64_t>(firstByte & 0x01) << 8;
- runLength |= readByte();
+ runLength_ = static_cast<uint64_t>(firstByte_ & 0x01) << 8;
+ runLength_ |= readByte();
// runs are one off
- runLength += 1;
- runRead = 0;
+ runLength_ += 1;
+ runRead_ = 0;
- readLongs(literals.data(), 0, runLength, bitSize);
- if (isSigned) {
- for (uint64_t i = 0; i < runLength; ++i) {
- literals[i] = unZigZag(static_cast<uint64_t>(literals[i]));
+ readLongs(literals_.data(), 0, runLength_, bitSize);
+ if (isSigned_) {
+ for (uint64_t i = 0; i < runLength_; ++i) {
+ literals_[i] = unZigZag(static_cast<uint64_t>(literals_[i]));
}
}
}
@@ -250,8 +250,8 @@ namespace orc {
void RleDecoderV2::adjustGapAndPatch(uint32_t patchBitSize, int64_t patchMask, int64_t* resGap,
int64_t* resPatch, uint64_t* patchIdx) {
uint64_t idx = *patchIdx;
- uint64_t gap = static_cast<uint64_t>(unpackedPatch[idx]) >> patchBitSize;
- int64_t patch = unpackedPatch[idx] & patchMask;
+ uint64_t gap = static_cast<uint64_t>(unpackedPatch_[idx]) >> patchBitSize;
+ int64_t patch = unpackedPatch_[idx] & patchMask;
int64_t actualGap = 0;
// special case: gap is >255 then patch value will be 0.
@@ -259,8 +259,8 @@ namespace orc {
while (gap == 255 && patch == 0) {
actualGap += 255;
++idx;
- gap = static_cast<uint64_t>(unpackedPatch[idx]) >> patchBitSize;
- patch = unpackedPatch[idx] & patchMask;
+ gap = static_cast<uint64_t>(unpackedPatch_[idx]) >> patchBitSize;
+ patch = unpackedPatch_[idx] & patchMask;
}
// add the left over gap
actualGap += gap;
@@ -273,17 +273,17 @@ namespace orc {
template <typename T>
uint64_t RleDecoderV2::nextPatched(T* const data, uint64_t offset, uint64_t numValues,
const char* const notNull) {
- if (runRead == runLength) {
+ if (runRead_ == runLength_) {
// extract the number of fixed bits
- unsigned char fbo = (firstByte >> 1) & 0x1f;
+ unsigned char fbo = (firstByte_ >> 1) & 0x1f;
uint32_t bitSize = decodeBitWidth(fbo);
// extract the run length
- runLength = static_cast<uint64_t>(firstByte & 0x01) << 8;
- runLength |= readByte();
+ runLength_ = static_cast<uint64_t>(firstByte_ & 0x01) << 8;
+ runLength_ |= readByte();
// runs are one off
- runLength += 1;
- runRead = 0;
+ runLength_ += 1;
+ runRead_ = 0;
// extract the number of bytes occupied by base
uint64_t thirdByte = readByte();
@@ -316,12 +316,12 @@ namespace orc {
base = -base;
}
- readLongs(literals.data(), 0, runLength, bitSize);
+ readLongs(literals_.data(), 0, runLength_, bitSize);
// any remaining bits are thrown out
resetReadLongs();
// TODO: something more efficient than resize
- unpackedPatch.resize(pl);
+ unpackedPatch_.resize(pl);
// TODO: Skip corrupt?
// if ((patchBitSize + pgw) > 64 && !skipCorrupt) {
if ((patchBitSize + pgw) > 64) {
@@ -330,7 +330,7 @@ namespace orc {
"(patchBitSize + pgw > 64)!");
}
uint32_t cfb = getClosestFixedBits(patchBitSize + pgw);
- readLongs(unpackedPatch.data(), 0, pl, cfb);
+ readLongs(unpackedPatch_.data(), 0, pl, cfb);
// any remaining bits are thrown out
resetReadLongs();
@@ -342,21 +342,21 @@ namespace orc {
uint64_t patchIdx = 0;
adjustGapAndPatch(patchBitSize, patchMask, &gap, &patch, &patchIdx);
- for (uint64_t i = 0; i < runLength; ++i) {
+ for (uint64_t i = 0; i < runLength_; ++i) {
if (static_cast<int64_t>(i) != gap) {
// no patching required. add base to unpacked value to get final value
- literals[i] += base;
+ literals_[i] += base;
} else {
// extract the patch value
- int64_t patchedVal = literals[i] | (patch << bitSize);
+ int64_t patchedVal = literals_[i] | (patch << bitSize);
// add base to patched value
- literals[i] = base + patchedVal;
+ literals_[i] = base + patchedVal;
// increment the patch to point to next entry in patch list
++patchIdx;
- if (patchIdx < unpackedPatch.size()) {
+ if (patchIdx < unpackedPatch_.size()) {
adjustGapAndPatch(patchBitSize, patchMask, &gap, &patch, &patchIdx);
// next gap is relative to the current gap
@@ -372,9 +372,9 @@ namespace orc {
template <typename T>
uint64_t RleDecoderV2::nextDelta(T* const data, uint64_t offset, uint64_t numValues,
const char* const notNull) {
- if (runRead == runLength) {
+ if (runRead_ == runLength_) {
// extract the number of fixed bits
- unsigned char fbo = (firstByte >> 1) & 0x1f;
+ unsigned char fbo = (firstByte_ >> 1) & 0x1f;
uint32_t bitSize;
if (fbo != 0) {
bitSize = decodeBitWidth(fbo);
@@ -383,20 +383,20 @@ namespace orc {
}
// extract the run length
- runLength = static_cast<uint64_t>(firstByte & 0x01) << 8;
- runLength |= readByte();
- ++runLength; // account for first value
- runRead = 0;
+ runLength_ = static_cast<uint64_t>(firstByte_ & 0x01) << 8;
+ runLength_ |= readByte();
+ ++runLength_; // account for first value
+ runRead_ = 0;
int64_t prevValue;
// read the first value stored as vint
- if (isSigned) {
+ if (isSigned_) {
prevValue = readVslong();
} else {
prevValue = static_cast<int64_t>(readVulong());
}
- literals[0] = prevValue;
+ literals_[0] = prevValue;
// read the fixed delta value stored as vint (deltas can be negative even
// if all number are positive)
@@ -404,28 +404,28 @@ namespace orc {
if (bitSize == 0) {
// add fixed deltas to adjacent values
- for (uint64_t i = 1; i < runLength; ++i) {
- literals[i] = literals[i - 1] + deltaBase;
+ for (uint64_t i = 1; i < runLength_; ++i) {
+ literals_[i] = literals_[i - 1] + deltaBase;
}
} else {
- prevValue = literals[1] = prevValue + deltaBase;
- if (runLength < 2) {
+ prevValue = literals_[1] = prevValue + deltaBase;
+ if (runLength_ < 2) {
std::stringstream ss;
- ss << "Illegal run length for delta encoding: " << runLength;
+ ss << "Illegal run length for delta encoding: " << runLength_;
throw ParseError(ss.str());
}
// write the unpacked values, add it to previous value and store final
// value to result buffer. if the delta base value is negative then it
// is a decreasing sequence else an increasing sequence.
// read deltas using the literals buffer.
- readLongs(literals.data(), 2, runLength - 2, bitSize);
+ readLongs(literals_.data(), 2, runLength_ - 2, bitSize);
if (deltaBase < 0) {
- for (uint64_t i = 2; i < runLength; ++i) {
- prevValue = literals[i] = prevValue - literals[i];
+ for (uint64_t i = 2; i < runLength_; ++i) {
+ prevValue = literals_[i] = prevValue - literals_[i];
}
} else {
- for (uint64_t i = 2; i < runLength; ++i) {
- prevValue = literals[i] = prevValue + literals[i];
+ for (uint64_t i = 2; i < runLength_; ++i) {
+ prevValue = literals_[i] = prevValue + literals_[i];
}
}
}
@@ -437,16 +437,16 @@ namespace orc {
template <typename T>
uint64_t RleDecoderV2::copyDataFromBuffer(T* data, uint64_t offset, uint64_t numValues,
const char* notNull) {
- uint64_t nRead = std::min(runLength - runRead, numValues);
+ uint64_t nRead = std::min(runLength_ - runRead_, numValues);
if (notNull) {
for (uint64_t i = offset; i < (offset + nRead); ++i) {
if (notNull[i]) {
- data[i] = static_cast<T>(literals[runRead++]);
+ data[i] = static_cast<T>(literals_[runRead_++]);
}
}
} else {
for (uint64_t i = offset; i < (offset + nRead); ++i) {
- data[i] = static_cast<T>(literals[runRead++]);
+ data[i] = static_cast<T>(literals_[runRead_++]);
}
}
return nRead;
diff --git a/c++/src/RleEncoderV2.cc b/c++/src/RleEncoderV2.cc
index a75aeac2e..18c520025 100644
--- a/c++/src/RleEncoderV2.cc
+++ b/c++/src/RleEncoderV2.cc
@@ -41,11 +41,11 @@ namespace orc {
if (!reuseHist) {
// histogram that store the encoded bit requirement for each values.
// maximum number of bits that can encoded is 32 (refer FixedBitSizes)
- memset(histgram, 0, FixedBitSizes::SIZE * sizeof(int32_t));
+ memset(histgram_, 0, FixedBitSizes::SIZE * sizeof(int32_t));
// compute the histogram
for (size_t i = offset; i < (offset + length); i++) {
uint32_t idx = encodeBitWidth(findClosestNumBits(data[i]));
- histgram[idx] += 1;
+ histgram_[idx] += 1;
}
}
@@ -53,7 +53,7 @@ namespace orc {
// return the bits required by pth percentile length
for (int32_t i = HIST_LEN - 1; i >= 0; i--) {
- perLen -= histgram[i];
+ perLen -= histgram_[i];
if (perLen < 0) {
return decodeBitWidth(static_cast<uint32_t>(i));
}
@@ -64,13 +64,13 @@ namespace orc {
RleEncoderV2::RleEncoderV2(std::unique_ptr<BufferedOutputStream> outStream, bool hasSigned,
bool alignBitPacking)
: RleEncoder(std::move(outStream), hasSigned),
- alignedBitPacking(alignBitPacking),
- prevDelta(0) {
+ alignedBitPacking_(alignBitPacking),
+ prevDelta_(0) {
literals = new int64_t[MAX_LITERAL_SIZE];
- gapVsPatchList = new int64_t[MAX_LITERAL_SIZE];
- zigzagLiterals = hasSigned ? new int64_t[MAX_LITERAL_SIZE] : nullptr;
- baseRedLiterals = new int64_t[MAX_LITERAL_SIZE];
- adjDeltas = new int64_t[MAX_LITERAL_SIZE];
+ gapVsPatchList_ = new int64_t[MAX_LITERAL_SIZE];
+ zigzagLiterals_ = hasSigned ? new int64_t[MAX_LITERAL_SIZE] : nullptr;
+ baseRedLiterals_ = new int64_t[MAX_LITERAL_SIZE];
+ adjDeltas_ = new int64_t[MAX_LITERAL_SIZE];
}
void RleEncoderV2::write(int64_t val) {
@@ -80,39 +80,39 @@ namespace orc {
}
if (numLiterals == 1) {
- prevDelta = val - literals[0];
+ prevDelta_ = val - literals[0];
literals[numLiterals++] = val;
if (val == literals[0]) {
- fixedRunLength = 2;
- variableRunLength = 0;
+ fixedRunLength_ = 2;
+ variableRunLength_ = 0;
} else {
- fixedRunLength = 0;
- variableRunLength = 2;
+ fixedRunLength_ = 0;
+ variableRunLength_ = 2;
}
return;
}
int64_t currentDelta = val - literals[numLiterals - 1];
EncodingOption option = {};
- if (prevDelta == 0 && currentDelta == 0) {
+ if (prevDelta_ == 0 && currentDelta == 0) {
// case 1: fixed delta run
literals[numLiterals++] = val;
- if (variableRunLength > 0) {
+ if (variableRunLength_ > 0) {
// if variable run is non-zero then we are seeing repeating
// values at the end of variable run in which case fixed Run
// length is 2
- fixedRunLength = 2;
+ fixedRunLength_ = 2;
}
- fixedRunLength++;
+ fixedRunLength_++;
// if fixed run met the minimum condition and if variable
// run is non-zero then flush the variable run and shift the
// tail fixed runs to start of the buffer
- if (fixedRunLength >= MIN_REPEAT && variableRunLength > 0) {
+ if (fixedRunLength_ >= MIN_REPEAT && variableRunLength_ > 0) {
numLiterals -= MIN_REPEAT;
- variableRunLength -= (MIN_REPEAT - 1);
+ variableRunLength_ -= (MIN_REPEAT - 1);
determineEncoding(option);
writeValues(option);
@@ -124,7 +124,7 @@ namespace orc {
numLiterals = MIN_REPEAT;
}
- if (fixedRunLength == MAX_LITERAL_SIZE) {
+ if (fixedRunLength_ == MAX_LITERAL_SIZE) {
option.encoding = DELTA;
option.isFixedDelta = true;
writeValues(option);
@@ -137,8 +137,8 @@ namespace orc {
// if fixed run length is non-zero and if it satisfies the
// short repeat conditions then write the values as short repeats
// else use delta encoding
- if (fixedRunLength >= MIN_REPEAT) {
- if (fixedRunLength <= MAX_SHORT_REPEAT_LENGTH) {
+ if (fixedRunLength_ >= MIN_REPEAT) {
+ if (fixedRunLength_ <= MAX_SHORT_REPEAT_LENGTH) {
option.encoding = SHORT_REPEAT;
} else {
option.encoding = DELTA;
@@ -149,20 +149,20 @@ namespace orc {
// if fixed run length is <MIN_REPEAT and current value is
// different from previous then treat it as variable run
- if (fixedRunLength > 0 && fixedRunLength < MIN_REPEAT && val != literals[numLiterals - 1]) {
- variableRunLength = fixedRunLength;
- fixedRunLength = 0;
+ if (fixedRunLength_ > 0 && fixedRunLength_ < MIN_REPEAT && val != literals[numLiterals - 1]) {
+ variableRunLength_ = fixedRunLength_;
+ fixedRunLength_ = 0;
}
// after writing values re-initialize the variables
if (numLiterals == 0) {
initializeLiterals(val);
} else {
- prevDelta = val - literals[numLiterals - 1];
+ prevDelta_ = val - literals[numLiterals - 1];
literals[numLiterals++] = val;
- variableRunLength++;
+ variableRunLength_++;
- if (variableRunLength == MAX_LITERAL_SIZE) {
+ if (variableRunLength_ == MAX_LITERAL_SIZE) {
determineEncoding(option);
writeValues(option);
}
@@ -172,7 +172,7 @@ namespace orc {
void RleEncoderV2::computeZigZagLiterals(EncodingOption& option) {
assert(isSigned);
for (size_t i = 0; i < numLiterals; i++) {
- zigzagLiterals[option.zigzagLiteralsCount++] = zigZag(literals[i]);
+ zigzagLiterals_[option.zigzagLiteralsCount++] = zigZag(literals[i]);
}
}
@@ -207,7 +207,7 @@ namespace orc {
for (size_t i = 0; i < numLiterals; i++) {
// if value is above mask then create the patch and record the gap
- if (baseRedLiterals[i] > mask) {
+ if (baseRedLiterals_[i] > mask) {
size_t gap = i - prev;
if (gap > maxGap) {
maxGap = gap;
@@ -219,12 +219,12 @@ namespace orc {
gapIdx++;
// extract the most significant bits that are over mask bits
- int64_t patch = baseRedLiterals[i] >> option.brBits95p;
+ int64_t patch = baseRedLiterals_[i] >> option.brBits95p;
patchList.push_back(patch);
patchIdx++;
// strip off the MSB to enable safe bit packing
- baseRedLiterals[i] &= mask;
+ baseRedLiterals_[i] &= mask;
}
}
@@ -268,13 +268,13 @@ namespace orc {
int64_t g = gapList[gapIdx++];
int64_t p = patchList[patchIdx++];
while (g > 255) {
- gapVsPatchList[option.gapVsPatchListCount++] = (255L << option.patchWidth);
+ gapVsPatchList_[option.gapVsPatchListCount++] = (255L << option.patchWidth);
i++;
g -= 255;
}
// store patch value in LSBs and gap in MSBs
- gapVsPatchList[option.gapVsPatchListCount++] = ((g << option.patchWidth) | p);
+ gapVsPatchList_[option.gapVsPatchListCount++] = ((g << option.patchWidth) | p);
}
}
@@ -287,7 +287,7 @@ namespace orc {
if (isSigned) {
computeZigZagLiterals(option);
}
- int64_t* currentZigzagLiterals = isSigned ? zigzagLiterals : literals;
+ int64_t* currentZigzagLiterals = isSigned ? zigzagLiterals_ : literals;
option.zzBits100p = percentileBits(currentZigzagLiterals, 0, numLiterals, 1.0);
return currentZigzagLiterals;
}
@@ -318,7 +318,7 @@ namespace orc {
int64_t initialDelta = literals[1] - literals[0];
int64_t currDelta = 0;
int64_t deltaMax = 0;
- adjDeltas[option.adjDeltasCount++] = initialDelta;
+ adjDeltas_[option.adjDeltasCount++] = initialDelta;
for (size_t i = 1; i < numLiterals; i++) {
const int64_t l1 = literals[i];
@@ -332,8 +332,8 @@ namespace orc {
option.isFixedDelta &= (currDelta == initialDelta);
if (i > 1) {
- adjDeltas[option.adjDeltasCount++] = std::abs(currDelta);
- deltaMax = std::max(deltaMax, adjDeltas[i - 1]);
+ adjDeltas_[option.adjDeltasCount++] = std::abs(currDelta);
+ deltaMax = std::max(deltaMax, adjDeltas_[i - 1]);
}
}
@@ -407,15 +407,15 @@ namespace orc {
// patching is done only on base reduced values.
// remove base from literals
for (size_t i = 0; i < numLiterals; i++) {
- baseRedLiterals[option.baseRedLiteralsCount++] = (literals[i] - option.min);
+ baseRedLiterals_[option.baseRedLiteralsCount++] = (literals[i] - option.min);
}
// 95th percentile width is used to determine max allowed value
// after which patching will be done
- option.brBits95p = percentileBits(baseRedLiterals, 0, numLiterals, 0.95);
+ option.brBits95p = percentileBits(baseRedLiterals_, 0, numLiterals, 0.95);
// 100th percentile is used to compute the max patch width
- option.brBits100p = percentileBits(baseRedLiterals, 0, numLiterals, 1.0, true);
+ option.brBits100p = percentileBits(baseRedLiterals_, 0, numLiterals, 1.0, true);
// after base reducing the values, if the difference in bits between
// 95th percentile and 100th percentile value is zero then there
@@ -442,16 +442,16 @@ namespace orc {
uint64_t RleEncoderV2::flush() {
if (numLiterals != 0) {
EncodingOption option = {};
- if (variableRunLength != 0) {
+ if (variableRunLength_ != 0) {
determineEncoding(option);
writeValues(option);
- } else if (fixedRunLength != 0) {
- if (fixedRunLength < MIN_REPEAT) {
- variableRunLength = fixedRunLength;
- fixedRunLength = 0;
+ } else if (fixedRunLength_ != 0) {
+ if (fixedRunLength_ < MIN_REPEAT) {
+ variableRunLength_ = fixedRunLength_;
+ fixedRunLength_ = 0;
determineEncoding(option);
writeValues(option);
- } else if (fixedRunLength >= MIN_REPEAT && fixedRunLength <= MAX_SHORT_REPEAT_LENGTH) {
+ } else if (fixedRunLength_ >= MIN_REPEAT && fixedRunLength_ <= MAX_SHORT_REPEAT_LENGTH) {
option.encoding = SHORT_REPEAT;
writeValues(option);
} else {
@@ -488,7 +488,7 @@ namespace orc {
}
numLiterals = 0;
- prevDelta = 0;
+ prevDelta_ = 0;
}
}
@@ -506,8 +506,8 @@ namespace orc {
uint32_t header = getOpCode(SHORT_REPEAT);
- fixedRunLength -= MIN_REPEAT;
- header |= fixedRunLength;
+ fixedRunLength_ -= MIN_REPEAT;
+ header |= fixedRunLength_;
header |= ((numBytesRepeatVal - 1) << 3);
writeByte(static_cast<char>(header));
@@ -517,40 +517,40 @@ namespace orc {
writeByte(static_cast<char>(b));
}
- fixedRunLength = 0;
+ fixedRunLength_ = 0;
}
void RleEncoderV2::writeDirectValues(EncodingOption& option) {
// write the number of fixed bits required in next 5 bits
uint32_t fb = option.zzBits100p;
- if (alignedBitPacking) {
+ if (alignedBitPacking_) {
fb = getClosestAlignedFixedBits(fb);
}
const uint32_t efb = encodeBitWidth(fb) << 1;
// adjust variable run length
- variableRunLength -= 1;
+ variableRunLength_ -= 1;
// extract the 9th bit of run length
- const uint32_t tailBits = (variableRunLength & 0x100) >> 8;
+ const uint32_t tailBits = (variableRunLength_ & 0x100) >> 8;
// create first byte of the header
const char headerFirstByte = static_cast<char>(getOpCode(DIRECT) | efb | tailBits);
// second byte of the header stores the remaining 8 bits of runlength
- const char headerSecondByte = static_cast<char>(variableRunLength & 0xff);
+ const char headerSecondByte = static_cast<char>(variableRunLength_ & 0xff);
// write header
writeByte(headerFirstByte);
writeByte(headerSecondByte);
// bit packing the zigzag encoded literals
- int64_t* currentZigzagLiterals = isSigned ? zigzagLiterals : literals;
+ int64_t* currentZigzagLiterals = isSigned ? zigzagLiterals_ : literals;
writeInts(currentZigzagLiterals, 0, numLiterals, fb);
// reset run length
- variableRunLength = 0;
+ variableRunLength_ = 0;
}
void RleEncoderV2::writePatchedBasedValues(EncodingOption& option) {
@@ -565,16 +565,16 @@ namespace orc {
const uint32_t efb = encodeBitWidth(option.brBits95p) << 1;
// adjust variable run length, they are one off
- variableRunLength -= 1;
+ variableRunLength_ -= 1;
// extract the 9th bit of run length
- const uint32_t tailBits = (variableRunLength & 0x100) >> 8;
+ const uint32_t tailBits = (variableRunLength_ & 0x100) >> 8;
// create first byte of the header
const char headerFirstByte = static_cast<char>(getOpCode(PATCHED_BASE) | efb | tailBits);
// second byte of the header stores the remaining 8 bits of runlength
- const char headerSecondByte = static_cast<char>(variableRunLength & 0xff);
+ const char headerSecondByte = static_cast<char>(variableRunLength_ & 0xff);
// if the min value is negative toggle the sign
const bool isNegative = (option.min < 0);
@@ -618,15 +618,15 @@ namespace orc {
// base reduced literals are bit packed
uint32_t closestFixedBits = getClosestFixedBits(option.brBits95p);
- writeInts(baseRedLiterals, 0, numLiterals, closestFixedBits);
+ writeInts(baseRedLiterals_, 0, numLiterals, closestFixedBits);
// write patch list
closestFixedBits = getClosestFixedBits(option.patchGapWidth + option.patchWidth);
- writeInts(gapVsPatchList, 0, option.patchLength, closestFixedBits);
+ writeInts(gapVsPatchList_, 0, option.patchLength, closestFixedBits);
// reset run length
- variableRunLength = 0;
+ variableRunLength_ = 0;
}
void RleEncoderV2::writeDeltaValues(EncodingOption& option) {
@@ -634,7 +634,7 @@ namespace orc {
uint32_t fb = option.bitsDeltaMax;
uint32_t efb = 0;
- if (alignedBitPacking) {
+ if (alignedBitPacking_) {
fb = getClosestAlignedFixedBits(fb);
}
@@ -642,14 +642,14 @@ namespace orc {
// if fixed run length is greater than threshold then it will be fixed
// delta sequence with delta value 0 else fixed delta sequence with
// non-zero delta value
- if (fixedRunLength > MIN_REPEAT) {
+ if (fixedRunLength_ > MIN_REPEAT) {
// ex. sequence: 2 2 2 2 2 2 2 2
- len = fixedRunLength - 1;
- fixedRunLength = 0;
+ len = fixedRunLength_ - 1;
+ fixedRunLength_ = 0;
} else {
// ex. sequence: 4 6 8 10 12 14 16
- len = variableRunLength - 1;
- variableRunLength = 0;
+ len = variableRunLength_ - 1;
+ variableRunLength_ = 0;
}
} else {
// fixed width 0 is used for long repeating values.
@@ -658,8 +658,8 @@ namespace orc {
fb = 2;
}
efb = encodeBitWidth(fb) << 1;
- len = variableRunLength - 1;
- variableRunLength = 0;
+ len = variableRunLength_ - 1;
+ variableRunLength_ = 0;
}
// extract the 9th bit of run length
@@ -687,13 +687,13 @@ namespace orc {
writeVslong(option.fixedDelta);
} else {
// store the first value as delta value using zigzag encoding
- writeVslong(adjDeltas[0]);
+ writeVslong(adjDeltas_[0]);
// adjacent delta values are bit packed. The length of adjDeltas array is
// always one less than the number of literals (delta difference for n
// elements is n-1). We have already written one element, write the
// remaining numLiterals - 2 elements here
- writeInts(adjDeltas, 1, numLiterals - 2, fb);
+ writeInts(adjDeltas_, 1, numLiterals - 2, fb);
}
}
@@ -776,7 +776,7 @@ namespace orc {
void RleEncoderV2::initializeLiterals(int64_t val) {
literals[numLiterals++] = val;
- fixedRunLength = 1;
- variableRunLength = 1;
+ fixedRunLength_ = 1;
+ variableRunLength_ = 1;
}
} // namespace orc
diff --git a/c++/src/SchemaEvolution.cc b/c++/src/SchemaEvolution.cc
index dc30e6118..4099818ff 100644
--- a/c++/src/SchemaEvolution.cc
+++ b/c++/src/SchemaEvolution.cc
@@ -21,20 +21,20 @@
namespace orc {
- SchemaEvolution::SchemaEvolution(const std::shared_ptr<Type>& _readType, const Type* fileType)
- : readType(_readType) {
- if (readType) {
- buildConversion(readType.get(), fileType);
+ SchemaEvolution::SchemaEvolution(const std::shared_ptr<Type>& readType, const Type* fileType)
+ : readType_(readType) {
+ if (readType_) {
+ buildConversion(readType_.get(), fileType);
} else {
for (uint64_t i = 0; i <= fileType->getMaximumColumnId(); ++i) {
- safePPDConversionMap.insert(i);
+ safePPDConversionMap_.insert(i);
}
}
}
const Type* SchemaEvolution::getReadType(const Type& fileType) const {
- auto ret = readTypeMap.find(fileType.getColumnId());
- return ret == readTypeMap.cend() ? &fileType : ret->second;
+ auto ret = readTypeMap_.find(fileType.getColumnId());
+ return ret == readTypeMap_.cend() ? &fileType : ret->second;
}
inline void invalidConversion(const Type* readType, const Type* fileType) {
@@ -127,22 +127,22 @@ namespace orc {
return ret;
}
- void SchemaEvolution::buildConversion(const Type* _readType, const Type* fileType) {
+ void SchemaEvolution::buildConversion(const Type* readType, const Type* fileType) {
if (fileType == nullptr) {
- throw SchemaEvolutionError("File does not have " + _readType->toString());
+ throw SchemaEvolutionError("File does not have " + readType->toString());
}
- auto [valid, convert] = checkConversion(*_readType, *fileType);
+ auto [valid, convert] = checkConversion(*readType, *fileType);
if (!valid) {
- invalidConversion(_readType, fileType);
+ invalidConversion(readType, fileType);
}
- readTypeMap.emplace(_readType->getColumnId(), convert ? _readType : fileType);
+ readTypeMap_.emplace(readType->getColumnId(), convert ? readType : fileType);
// check whether PPD conversion is safe
- buildSafePPDConversionMap(_readType, fileType);
+ buildSafePPDConversionMap(readType, fileType);
- for (uint64_t i = 0; i < _readType->getSubtypeCount(); ++i) {
- auto subType = _readType->getSubtype(i);
+ for (uint64_t i = 0; i < readType->getSubtypeCount(); ++i) {
+ auto subType = readType->getSubtype(i);
if (subType) {
// null subType means that this is a sub column of map/list type
// and it does not exist in the file. simply skip it.
@@ -165,20 +165,20 @@ namespace orc {
return kind != STRUCT && kind != MAP && kind != LIST && kind != UNION;
}
- void SchemaEvolution::buildSafePPDConversionMap(const Type* _readType, const Type* fileType) {
- if (_readType == nullptr || !isPrimitive(_readType) || fileType == nullptr ||
+ void SchemaEvolution::buildSafePPDConversionMap(const Type* readType, const Type* fileType) {
+ if (readType == nullptr || !isPrimitive(readType) || fileType == nullptr ||
!isPrimitive(fileType)) {
return;
}
bool isSafe = false;
- if (_readType == fileType) {
+ if (readType == fileType) {
// short cut for same type
isSafe = true;
- } else if (_readType->getKind() == DECIMAL && fileType->getKind() == DECIMAL) {
+ } else if (readType->getKind() == DECIMAL && fileType->getKind() == DECIMAL) {
// for decimals alone do equality check to not mess up with precision change
- if (fileType->getPrecision() == readType->getPrecision() &&
- fileType->getScale() == readType->getScale()) {
+ if (fileType->getPrecision() == readType_->getPrecision() &&
+ fileType->getScale() == readType_->getScale()) {
isSafe = true;
}
} else {
@@ -196,32 +196,32 @@ namespace orc {
// as ORC stores char with padded spaces in its internal index.
switch (fileType->getKind()) {
case BYTE: {
- if (readType->getKind() == SHORT || readType->getKind() == INT ||
- readType->getKind() == LONG) {
+ if (readType_->getKind() == SHORT || readType_->getKind() == INT ||
+ readType_->getKind() == LONG) {
isSafe = true;
}
break;
}
case SHORT: {
- if (readType->getKind() == INT || readType->getKind() == LONG) {
+ if (readType_->getKind() == INT || readType_->getKind() == LONG) {
isSafe = true;
}
break;
}
case INT: {
- if (readType->getKind() == LONG) {
+ if (readType_->getKind() == LONG) {
isSafe = true;
}
break;
}
case STRING: {
- if (readType->getKind() == VARCHAR) {
+ if (readType_->getKind() == VARCHAR) {
isSafe = true;
}
break;
}
case VARCHAR: {
- if (readType->getKind() == STRING) {
+ if (readType_->getKind() == STRING) {
isSafe = true;
}
break;
@@ -245,12 +245,12 @@ namespace orc {
}
if (isSafe) {
- safePPDConversionMap.insert(fileType->getColumnId());
+ safePPDConversionMap_.insert(fileType->getColumnId());
}
}
bool SchemaEvolution::isSafePPDConversion(uint64_t columnId) const {
- return safePPDConversionMap.find(columnId) != safePPDConversionMap.cend();
+ return safePPDConversionMap_.find(columnId) != safePPDConversionMap_.cend();
}
} // namespace orc
diff --git a/c++/src/SchemaEvolution.hh b/c++/src/SchemaEvolution.hh
index ef9020eba..c3deff723 100644
--- a/c++/src/SchemaEvolution.hh
+++ b/c++/src/SchemaEvolution.hh
@@ -46,7 +46,7 @@ namespace orc {
// return selected read type
const Type* getReadType() const {
- return readType.get();
+ return readType_.get();
}
private:
@@ -54,9 +54,9 @@ namespace orc {
void buildSafePPDConversionMap(const Type* readType, const Type* fileType);
private:
- const std::shared_ptr<Type> readType;
- std::unordered_map<uint64_t, const Type*> readTypeMap;
- std::unordered_set<uint64_t> safePPDConversionMap;
+ const std::shared_ptr<Type> readType_;
+ std::unordered_map<uint64_t, const Type*> readTypeMap_;
+ std::unordered_set<uint64_t> safePPDConversionMap_;
};
} // namespace orc
diff --git a/c++/src/Statistics.cc b/c++/src/Statistics.cc
index 8ed29d0e7..f9581215b 100644
--- a/c++/src/Statistics.cc
+++ b/c++/src/Statistics.cc
@@ -52,18 +52,18 @@ namespace orc {
StatisticsImpl::StatisticsImpl(const proto::StripeStatistics& stripeStats,
const StatContext& statContext) {
for (int i = 0; i < stripeStats.col_stats_size(); i++) {
- colStats.push_back(convertColumnStatistics(stripeStats.col_stats(i), statContext));
+ colStats_.push_back(convertColumnStatistics(stripeStats.col_stats(i), statContext));
}
}
StatisticsImpl::StatisticsImpl(const proto::Footer& footer, const StatContext& statContext) {
for (int i = 0; i < footer.statistics_size(); i++) {
- colStats.push_back(convertColumnStatistics(footer.statistics(i), statContext));
+ colStats_.push_back(convertColumnStatistics(footer.statistics(i), statContext));
}
}
StatisticsImpl::~StatisticsImpl() {
- for (std::vector<ColumnStatistics*>::iterator ptr = colStats.begin(); ptr != colStats.end();
+ for (std::vector<ColumnStatistics*>::iterator ptr = colStats_.begin(); ptr != colStats_.end();
++ptr) {
delete *ptr;
}
@@ -85,11 +85,11 @@ namespace orc {
const proto::StripeStatistics& stripeStats,
std::vector<std::vector<proto::ColumnStatistics> >& indexStats,
const StatContext& statContext) {
- columnStats = std::make_unique<StatisticsImpl>(stripeStats, statContext);
- rowIndexStats.resize(indexStats.size());
- for (size_t i = 0; i < rowIndexStats.size(); i++) {
+ columnStats_ = std::make_unique<StatisticsImpl>(stripeStats, statContext);
+ rowIndexStats_.resize(indexStats.size());
+ for (size_t i = 0; i < rowIndexStats_.size(); i++) {
for (size_t j = 0; j < indexStats[i].size(); j++) {
- rowIndexStats[i].push_back(std::shared_ptr<const ColumnStatistics>(
+ rowIndexStats_[i].push_back(std::shared_ptr<const ColumnStatistics>(
convertColumnStatistics(indexStats[i][j], statContext)));
}
}
@@ -180,205 +180,205 @@ namespace orc {
}
ColumnStatisticsImpl::ColumnStatisticsImpl(const proto::ColumnStatistics& pb) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
}
BinaryColumnStatisticsImpl::BinaryColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (pb.has_binary_statistics() && statContext.correctStats) {
- _stats.setHasTotalLength(pb.binary_statistics().has_sum());
- _stats.setTotalLength(static_cast<uint64_t>(pb.binary_statistics().sum()));
+ stats_.setHasTotalLength(pb.binary_statistics().has_sum());
+ stats_.setTotalLength(static_cast<uint64_t>(pb.binary_statistics().sum()));
}
}
BooleanColumnStatisticsImpl::BooleanColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (pb.has_bucket_statistics() && statContext.correctStats) {
- _hasCount = true;
- _trueCount = pb.bucket_statistics().count(0);
+ hasCount_ = true;
+ trueCount_ = pb.bucket_statistics().count(0);
} else {
- _hasCount = false;
- _trueCount = 0;
+ hasCount_ = false;
+ trueCount_ = 0;
}
}
DateColumnStatisticsImpl::DateColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_date_statistics() || !statContext.correctStats) {
// hasMinimum_ is false by default;
// hasMaximum_ is false by default;
- _stats.setMinimum(0);
- _stats.setMaximum(0);
+ stats_.setMinimum(0);
+ stats_.setMaximum(0);
} else {
- _stats.setHasMinimum(pb.date_statistics().has_minimum());
- _stats.setHasMaximum(pb.date_statistics().has_maximum());
- _stats.setMinimum(pb.date_statistics().minimum());
- _stats.setMaximum(pb.date_statistics().maximum());
+ stats_.setHasMinimum(pb.date_statistics().has_minimum());
+ stats_.setHasMaximum(pb.date_statistics().has_maximum());
+ stats_.setMinimum(pb.date_statistics().minimum());
+ stats_.setMaximum(pb.date_statistics().maximum());
}
}
DecimalColumnStatisticsImpl::DecimalColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (pb.has_decimal_statistics() && statContext.correctStats) {
const proto::DecimalStatistics& stats = pb.decimal_statistics();
- _stats.setHasMinimum(stats.has_minimum());
- _stats.setHasMaximum(stats.has_maximum());
- _stats.setHasSum(stats.has_sum());
+ stats_.setHasMinimum(stats.has_minimum());
+ stats_.setHasMaximum(stats.has_maximum());
+ stats_.setHasSum(stats.has_sum());
- _stats.setMinimum(Decimal(stats.minimum()));
- _stats.setMaximum(Decimal(stats.maximum()));
- _stats.setSum(Decimal(stats.sum()));
+ stats_.setMinimum(Decimal(stats.minimum()));
+ stats_.setMaximum(Decimal(stats.maximum()));
+ stats_.setSum(Decimal(stats.sum()));
}
}
DoubleColumnStatisticsImpl::DoubleColumnStatisticsImpl(const proto::ColumnStatistics& pb) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_double_statistics()) {
- _stats.setMinimum(0);
- _stats.setMaximum(0);
- _stats.setSum(0);
+ stats_.setMinimum(0);
+ stats_.setMaximum(0);
+ stats_.setSum(0);
} else {
const proto::DoubleStatistics& stats = pb.double_statistics();
- _stats.setHasMinimum(stats.has_minimum());
- _stats.setHasMaximum(stats.has_maximum());
- _stats.setHasSum(stats.has_sum());
+ stats_.setHasMinimum(stats.has_minimum());
+ stats_.setHasMaximum(stats.has_maximum());
+ stats_.setHasSum(stats.has_sum());
- _stats.setMinimum(stats.minimum());
- _stats.setMaximum(stats.maximum());
- _stats.setSum(stats.sum());
+ stats_.setMinimum(stats.minimum());
+ stats_.setMaximum(stats.maximum());
+ stats_.setSum(stats.sum());
}
}
IntegerColumnStatisticsImpl::IntegerColumnStatisticsImpl(const proto::ColumnStatistics& pb) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_int_statistics()) {
- _stats.setMinimum(0);
- _stats.setMaximum(0);
- _stats.setSum(0);
+ stats_.setMinimum(0);
+ stats_.setMaximum(0);
+ stats_.setSum(0);
} else {
const proto::IntegerStatistics& stats = pb.int_statistics();
- _stats.setHasMinimum(stats.has_minimum());
- _stats.setHasMaximum(stats.has_maximum());
- _stats.setHasSum(stats.has_sum());
+ stats_.setHasMinimum(stats.has_minimum());
+ stats_.setHasMaximum(stats.has_maximum());
+ stats_.setHasSum(stats.has_sum());
- _stats.setMinimum(stats.minimum());
- _stats.setMaximum(stats.maximum());
- _stats.setSum(stats.sum());
+ stats_.setMinimum(stats.minimum());
+ stats_.setMaximum(stats.maximum());
+ stats_.setSum(stats.sum());
}
}
StringColumnStatisticsImpl::StringColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_string_statistics() || !statContext.correctStats) {
- _stats.setTotalLength(0);
+ stats_.setTotalLength(0);
} else {
const proto::StringStatistics& stats = pb.string_statistics();
- _stats.setHasMinimum(stats.has_minimum());
- _stats.setHasMaximum(stats.has_maximum());
- _stats.setHasTotalLength(stats.has_sum());
+ stats_.setHasMinimum(stats.has_minimum());
+ stats_.setHasMaximum(stats.has_maximum());
+ stats_.setHasTotalLength(stats.has_sum());
- _stats.setMinimum(stats.minimum());
- _stats.setMaximum(stats.maximum());
- _stats.setTotalLength(static_cast<uint64_t>(stats.sum()));
+ stats_.setMinimum(stats.minimum());
+ stats_.setMaximum(stats.maximum());
+ stats_.setTotalLength(static_cast<uint64_t>(stats.sum()));
}
}
TimestampColumnStatisticsImpl::TimestampColumnStatisticsImpl(const proto::ColumnStatistics& pb,
const StatContext& statContext) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_timestamp_statistics() || !statContext.correctStats) {
- _stats.setMinimum(0);
- _stats.setMaximum(0);
- _lowerBound = 0;
- _upperBound = 0;
- _minimumNanos = DEFAULT_MIN_NANOS;
- _maximumNanos = DEFAULT_MAX_NANOS;
+ stats_.setMinimum(0);
+ stats_.setMaximum(0);
+ lowerBound_ = 0;
+ upperBound_ = 0;
+ minimumNanos_ = DEFAULT_MIN_NANOS;
+ maximumNanos_ = DEFAULT_MAX_NANOS;
} else {
const proto::TimestampStatistics& stats = pb.timestamp_statistics();
- _stats.setHasMinimum(stats.has_minimum_utc() ||
+ stats_.setHasMinimum(stats.has_minimum_utc() ||
(stats.has_minimum() && (statContext.writerTimezone != nullptr)));
- _stats.setHasMaximum(stats.has_maximum_utc() ||
+ stats_.setHasMaximum(stats.has_maximum_utc() ||
(stats.has_maximum() && (statContext.writerTimezone != nullptr)));
- _hasLowerBound = stats.has_minimum_utc() || stats.has_minimum();
- _hasUpperBound = stats.has_maximum_utc() || stats.has_maximum();
+ hasLowerBound_ = stats.has_minimum_utc() || stats.has_minimum();
+ hasUpperBound_ = stats.has_maximum_utc() || stats.has_maximum();
// to be consistent with java side, non-default minimum_nanos and maximum_nanos
// are added by one in their serialized form.
- _minimumNanos = stats.has_minimum_nanos() ? stats.minimum_nanos() - 1 : DEFAULT_MIN_NANOS;
- _maximumNanos = stats.has_maximum_nanos() ? stats.maximum_nanos() - 1 : DEFAULT_MAX_NANOS;
+ minimumNanos_ = stats.has_minimum_nanos() ? stats.minimum_nanos() - 1 : DEFAULT_MIN_NANOS;
+ maximumNanos_ = stats.has_maximum_nanos() ? stats.maximum_nanos() - 1 : DEFAULT_MAX_NANOS;
// Timestamp stats are stored in milliseconds
if (stats.has_minimum_utc()) {
int64_t minimum = stats.minimum_utc();
- _stats.setMinimum(minimum);
- _lowerBound = minimum;
+ stats_.setMinimum(minimum);
+ lowerBound_ = minimum;
} else if (statContext.writerTimezone) {
int64_t writerTimeSec = stats.minimum() / 1000;
// multiply the offset by 1000 to convert to millisecond
int64_t minimum = stats.minimum() +
(statContext.writerTimezone->getVariant(writerTimeSec).gmtOffset) * 1000;
- _stats.setMinimum(minimum);
- _lowerBound = minimum;
+ stats_.setMinimum(minimum);
+ lowerBound_ = minimum;
} else {
- _stats.setMinimum(0);
+ stats_.setMinimum(0);
// subtract 1 day 1 hour (25 hours) in milliseconds to handle unknown
// TZ and daylight savings
- _lowerBound = stats.minimum() - (25 * SECONDS_PER_HOUR * 1000);
+ lowerBound_ = stats.minimum() - (25 * SECONDS_PER_HOUR * 1000);
}
// Timestamp stats are stored in milliseconds
if (stats.has_maximum_utc()) {
int64_t maximum = stats.maximum_utc();
- _stats.setMaximum(maximum);
- _upperBound = maximum;
+ stats_.setMaximum(maximum);
+ upperBound_ = maximum;
} else if (statContext.writerTimezone) {
int64_t writerTimeSec = stats.maximum() / 1000;
// multiply the offset by 1000 to convert to millisecond
int64_t maximum = stats.maximum() +
(statContext.writerTimezone->getVariant(writerTimeSec).gmtOffset) * 1000;
- _stats.setMaximum(maximum);
- _upperBound = maximum;
+ stats_.setMaximum(maximum);
+ upperBound_ = maximum;
} else {
- _stats.setMaximum(0);
+ stats_.setMaximum(0);
// add 1 day 1 hour (25 hours) in milliseconds to handle unknown
// TZ and daylight savings
- _upperBound = stats.maximum() + (25 * SECONDS_PER_HOUR * 1000);
+ upperBound_ = stats.maximum() + (25 * SECONDS_PER_HOUR * 1000);
}
// Add 1 millisecond to account for microsecond precision of values
- _upperBound += 1;
+ upperBound_ += 1;
}
}
CollectionColumnStatisticsImpl::CollectionColumnStatisticsImpl(
const proto::ColumnStatistics& pb) {
- _stats.setNumberOfValues(pb.number_of_values());
- _stats.setHasNull(pb.has_null());
+ stats_.setNumberOfValues(pb.number_of_values());
+ stats_.setHasNull(pb.has_null());
if (!pb.has_collection_statistics()) {
- _stats.setMinimum(0);
- _stats.setMaximum(0);
- _stats.setSum(0);
+ stats_.setMinimum(0);
+ stats_.setMaximum(0);
+ stats_.setSum(0);
} else {
const proto::CollectionStatistics& stats = pb.collection_statistics();
- _stats.setHasMinimum(stats.has_min_children());
- _stats.setHasMaximum(stats.has_max_children());
- _stats.setHasSum(stats.has_total_children());
+ stats_.setHasMinimum(stats.has_min_children());
+ stats_.setHasMaximum(stats.has_max_children());
+ stats_.setHasSum(stats.has_total_children());
- _stats.setMinimum(stats.min_children());
- _stats.setMaximum(stats.max_children());
- _stats.setSum(stats.total_children());
+ stats_.setMinimum(stats.min_children());
+ stats_.setMaximum(stats.max_children());
+ stats_.setSum(stats.total_children());
}
}
diff --git a/c++/src/Statistics.hh b/c++/src/Statistics.hh
index e585bf971..6f212c15c 100644
--- a/c++/src/Statistics.hh
+++ b/c++/src/Statistics.hh
@@ -48,160 +48,160 @@ namespace orc {
template <typename T>
class InternalStatisticsImpl {
private:
- bool _hasNull;
- bool _hasMinimum;
- bool _hasMaximum;
- bool _hasSum;
- bool _hasTotalLength;
- uint64_t _totalLength;
- uint64_t _valueCount;
- T _minimum;
- T _maximum;
- T _sum;
+ bool hasNull_;
+ bool hasMinimum_;
+ bool hasMaximum_;
+ bool hasSum_;
+ bool hasTotalLength_;
+ uint64_t totalLength_;
+ uint64_t valueCount_;
+ T minimum_;
+ T maximum_;
+ T sum_;
public:
InternalStatisticsImpl() {
- _hasNull = false;
- _hasMinimum = false;
- _hasMaximum = false;
- _hasSum = false;
- _hasTotalLength = false;
- _totalLength = 0;
- _valueCount = 0;
+ hasNull_ = false;
+ hasMinimum_ = false;
+ hasMaximum_ = false;
+ hasSum_ = false;
+ hasTotalLength_ = false;
+ totalLength_ = 0;
+ valueCount_ = 0;
}
~InternalStatisticsImpl() {}
// GET / SET _totalLength
bool hasTotalLength() const {
- return _hasTotalLength;
+ return hasTotalLength_;
}
void setHasTotalLength(bool hasTotalLength) {
- _hasTotalLength = hasTotalLength;
+ hasTotalLength_ = hasTotalLength;
}
uint64_t getTotalLength() const {
- return _totalLength;
+ return totalLength_;
}
void setTotalLength(uint64_t totalLength) {
- _totalLength = totalLength;
+ totalLength_ = totalLength;
}
// GET / SET _sum
bool hasSum() const {
- return _hasSum;
+ return hasSum_;
}
void setHasSum(bool hasSum) {
- _hasSum = hasSum;
+ hasSum_ = hasSum;
}
T getSum() const {
- return _sum;
+ return sum_;
}
void setSum(T sum) {
- _sum = sum;
+ sum_ = sum;
}
// GET / SET _maximum
bool hasMaximum() const {
- return _hasMaximum;
+ return hasMaximum_;
}
const T& getMaximum() const {
- return _maximum;
+ return maximum_;
}
void setHasMaximum(bool hasMax) {
- _hasMaximum = hasMax;
+ hasMaximum_ = hasMax;
}
void setMaximum(T max) {
- _maximum = max;
+ maximum_ = max;
}
// GET / SET _minimum
bool hasMinimum() const {
- return _hasMinimum;
+ return hasMinimum_;
}
void setHasMinimum(bool hasMin) {
- _hasMinimum = hasMin;
+ hasMinimum_ = hasMin;
}
const T& getMinimum() const {
- return _minimum;
+ return minimum_;
}
void setMinimum(T min) {
- _minimum = min;
+ minimum_ = min;
}
// GET / SET _valueCount
uint64_t getNumberOfValues() const {
- return _valueCount;
+ return valueCount_;
}
void setNumberOfValues(uint64_t numValues) {
- _valueCount = numValues;
+ valueCount_ = numValues;
}
// GET / SET _hasNullValue
bool hasNull() const {
- return _hasNull;
+ return hasNull_;
}
void setHasNull(bool hasNull) {
- _hasNull = hasNull;
+ hasNull_ = hasNull;
}
void reset() {
- _hasNull = false;
- _hasMinimum = false;
- _hasMaximum = false;
- _hasSum = false;
- _hasTotalLength = false;
- _totalLength = 0;
- _valueCount = 0;
+ hasNull_ = false;
+ hasMinimum_ = false;
+ hasMaximum_ = false;
+ hasSum_ = false;
+ hasTotalLength_ = false;
+ totalLength_ = 0;
+ valueCount_ = 0;
}
void updateMinMax(T value) {
- if (!_hasMinimum) {
- _hasMinimum = _hasMaximum = true;
- _minimum = _maximum = value;
- } else if (compare(value, _minimum)) {
- _minimum = value;
- } else if (compare(_maximum, value)) {
- _maximum = value;
+ if (!hasMinimum_) {
+ hasMinimum_ = hasMaximum_ = true;
+ minimum_ = maximum_ = value;
+ } else if (compare(value, minimum_)) {
+ minimum_ = value;
+ } else if (compare(maximum_, value)) {
+ maximum_ = value;
}
}
// sum is not merged here as we need to check overflow
void merge(const InternalStatisticsImpl& other) {
- _hasNull = _hasNull || other._hasNull;
- _valueCount += other._valueCount;
-
- if (other._hasMinimum) {
- if (!_hasMinimum) {
- _hasMinimum = _hasMaximum = true;
- _minimum = other._minimum;
- _maximum = other._maximum;
+ hasNull_ = hasNull_ || other.hasNull_;
+ valueCount_ += other.valueCount_;
+
+ if (other.hasMinimum_) {
+ if (!hasMinimum_) {
+ hasMinimum_ = hasMaximum_ = true;
+ minimum_ = other.minimum_;
+ maximum_ = other.maximum_;
} else {
// all template types should support operator<
- if (compare(_maximum, other._maximum)) {
- _maximum = other._maximum;
+ if (compare(maximum_, other.maximum_)) {
+ maximum_ = other.maximum_;
}
- if (compare(other._minimum, _minimum)) {
- _minimum = other._minimum;
+ if (compare(other.minimum_, minimum_)) {
+ minimum_ = other.minimum_;
}
}
}
- _hasTotalLength = _hasTotalLength && other._hasTotalLength;
- _totalLength += other._totalLength;
+ hasTotalLength_ = hasTotalLength_ && other.hasTotalLength_;
+ totalLength_ += other.totalLength_;
}
};
@@ -240,7 +240,7 @@ namespace orc {
class ColumnStatisticsImpl : public ColumnStatistics, public MutableColumnStatistics {
private:
- InternalCharStatistics _stats;
+ InternalCharStatistics stats_;
public:
ColumnStatisticsImpl() {
@@ -250,36 +250,36 @@ namespace orc {
virtual ~ColumnStatisticsImpl() override;
uint64_t getNumberOfValues() const override {
- return _stats.getNumberOfValues();
+ return stats_.getNumberOfValues();
}
void setNumberOfValues(uint64_t value) override {
- _stats.setNumberOfValues(value);
+ stats_.setNumberOfValues(value);
}
void increase(uint64_t count) override {
- _stats.setNumberOfValues(_stats.getNumberOfValues() + count);
+ stats_.setNumberOfValues(stats_.getNumberOfValues() + count);
}
bool hasNull() const override {
- return _stats.hasNull();
+ return stats_.hasNull();
}
void setHasNull(bool hasNull) override {
- _stats.setHasNull(hasNull);
+ stats_.setHasNull(hasNull);
}
void merge(const MutableColumnStatistics& other) override {
- _stats.merge(dynamic_cast<const ColumnStatisticsImpl&>(other)._stats);
+ stats_.merge(dynamic_cast<const ColumnStatisticsImpl&>(other).stats_);
}
void reset() override {
- _stats.reset();
+ stats_.reset();
}
void toProtoBuf(proto::ColumnStatistics& pbStats) const override {
- pbStats.set_has_null(_stats.hasNull());
- pbStats.set_number_of_values(_stats.getNumberOfValues());
+ pbStats.set_has_null(stats_.hasNull());
+ pbStats.set_number_of_values(stats_.getNumberOfValues());
}
std::string toString() const override {
@@ -292,7 +292,7 @@ namespace orc {
class BinaryColumnStatisticsImpl : public BinaryColumnStatistics, public MutableColumnStatistics {
private:
- InternalCharStatistics _stats;
+ InternalCharStatistics stats_;
public:
BinaryColumnStatisticsImpl() {
@@ -303,63 +303,63 @@ namespace orc {
virtual ~BinaryColumnStatisticsImpl() override;
uint64_t getNumberOfValues() const override {
- return _stats.getNumberOfValues();
+ return stats_.getNumberOfValues();
}
void setNumberOfValues(uint64_t value) override {
- _stats.setNumberOfValues(value);
+ stats_.setNumberOfValues(value);
}
void increase(uint64_t count) override {
- _stats.setNumberOfValues(_stats.getNumberOfValues() + count);
+ stats_.setNumberOfValues(stats_.getNumberOfValues() + count);
}
bool hasNull() const override {
- return _stats.hasNull();
+ return stats_.hasNull();
}
void setHasNull(bool hasNull) override {
- _stats.setHasNull(hasNull);
+ stats_.setHasNull(hasNull);
}
bool hasTotalLength() const override {
- return _stats.hasTotalLength();
+ return stats_.hasTotalLength();
}
uint64_t getTotalLength() const override {
if (hasTotalLength()) {
- return _stats.getTotalLength();
+ return stats_.getTotalLength();
} else {
throw ParseError("Total length is not defined.");
}
}
void setTotalLength(uint64_t length) {
- _stats.setHasTotalLength(true);
- _stats.setTotalLength(length);
+ stats_.setHasTotalLength(true);
+ stats_.setTotalLength(length);
}
void update(size_t length) {
- _stats.setTotalLength(_stats.getTotalLength() + length);
+ stats_.setTotalLength(stats_.getTotalLength() + length);
}
void merge(const MutableColumnStatistics& other) override {
const BinaryColumnStatisticsImpl& binStats =
dynamic_cast<const BinaryColumnStatisticsImpl&>(other);
- _stats.merge(binStats._stats);
+ stats_.merge(binStats.stats_);
}
void reset() override {
- _stats.reset();
+ stats_.reset();
setTotalLength(0);
}
void toProtoBuf(proto::ColumnStatistics& pbStats) const override {
- pbStats.set_has_null(_stats.hasNull());
- pbStats.set_number_of_values(_stats.getNumberOfValues());
+ pbStats.set_has_null(stats_.hasNull());
+ pbStats.set_number_of_values(stats_.getNumberOfValues());
proto::BinaryStatistics* binStats = pbStats.mutable_binary_statistics();
- binStats->set_sum(static_cast<int64_t>(_stats.getTotalLength()));
+ binStats->set_sum(static_cast<int64_t>(stats_.getTotalLength()));
}
std::string toString() const override {
@@ -379,9 +379,9 @@ namespace orc {
class BooleanColumnStatisticsImpl : public BooleanColumnStatistics,
public MutableColumnStatistics {
private:
- InternalBooleanStatistics _stats;
- bool _hasCount;
- uint64_t _trueCount;
+ InternalBooleanStatistics stats_;
+ bool hasCount_;
+ uint64_t trueCount_;
public:
BooleanColumnStatisticsImpl() {
@@ -392,33 +392,33 @@ namespace orc {
virtual ~BooleanColumnStatisticsImpl() override;
bool hasCount() const override {
- return _hasCount;
+ return hasCount_;
}
void increase(uint64_t count) override {
- _stats.setNumberOfValues(_stats.getNumberOfValues() + count);
- _hasCount = true;
+ stats_.setNumberOfValues(stats_.getNumberOfValues() + count);
+ hasCount_ = true;
}
uint64_t getNumberOfValues() const override {
- return _stats.getNumberOfValues();
+ return stats_.getNumberOfValues();
}
void setNumberOfValues(uint64_t value) override {
- _stats.setNumberOfValues(value);
+ stats_.setNumberOfValues(value);
}
... 6220 lines suppressed ...