This is an automated email from the ASF dual-hosted git repository.
dongjoon 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 6259ebbaf ORC-1377: [C++] Enforce override keyword
6259ebbaf is described below
commit 6259ebbafcef243c7812536dc2d5912accb0cda4
Author: Gang Wu <[email protected]>
AuthorDate: Mon Feb 20 23:28:23 2023 -0800
ORC-1377: [C++] Enforce override keyword
### What changes were proposed in this pull request?
Enforce adding `override` keyword to virtual functions.
### Why are the changes needed?
A lot of warnings are related to missing override keyword in the Github
Actions.
### How was this patch tested?
Make sure all tests pass.
Closes #1420 from wgtmac/ORC-1377.
Authored-by: Gang Wu <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
CMakeLists.txt | 4 +-
c++/include/orc/Exceptions.hh | 6 +-
c++/include/orc/Statistics.hh | 20 +++----
c++/include/orc/Vector.hh | 114 +++++++++++++++++++-------------------
c++/src/ByteRLE.cc | 16 +++---
c++/src/LzoDecompressor.cc | 2 +-
c++/src/Timezone.hh | 6 +-
c++/src/io/InputStream.hh | 2 +-
c++/src/wrap/orc-proto-wrapper.cc | 1 +
c++/src/wrap/orc-proto-wrapper.hh | 1 +
c++/test/TestAttributes.cc | 2 +-
c++/test/TestColumnReader.cc | 6 +-
c++/test/TestDecompression.cc | 2 +-
c++/test/TestRleEncoder.cc | 2 +-
c++/test/TestWriter.cc | 2 +-
tools/test/TestMatch.cc | 4 +-
16 files changed, 96 insertions(+), 94 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d140d428..bd67a493a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -118,10 +118,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (WARN_FLAGS "${WARN_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
set (WARN_FLAGS "${WARN_FLAGS} -Wconversion")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0")
- set (WARN_FLAGS "${WARN_FLAGS} -Wno-reserved-identifier
-Wno-suggest-destructor-override -Wno-suggest-override")
+ set (WARN_FLAGS "${WARN_FLAGS} -Wno-reserved-identifier")
endif()
if (CMAKE_HOST_APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.0")
- set (WARN_FLAGS "${WARN_FLAGS} -Wno-c++2a-compat
-Wno-unknown-warning-option -Wno-suggest-override
-Wno-suggest-destructor-override")
+ set (WARN_FLAGS "${WARN_FLAGS} -Wno-c++2a-compat
-Wno-unknown-warning-option")
elseif (CMAKE_HOST_APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER
"11.0")
set (WARN_FLAGS "${WARN_FLAGS} -Wno-c++2a-compat")
endif ()
diff --git a/c++/include/orc/Exceptions.hh b/c++/include/orc/Exceptions.hh
index 4e880f72b..7da8fbee4 100644
--- a/c++/include/orc/Exceptions.hh
+++ b/c++/include/orc/Exceptions.hh
@@ -30,7 +30,7 @@ namespace orc {
public:
explicit NotImplementedYet(const std::string& what_arg);
explicit NotImplementedYet(const char* what_arg);
- virtual ~NotImplementedYet() noexcept;
+ ~NotImplementedYet() noexcept override;
NotImplementedYet(const NotImplementedYet&);
private:
@@ -41,7 +41,7 @@ namespace orc {
public:
explicit ParseError(const std::string& what_arg);
explicit ParseError(const char* what_arg);
- virtual ~ParseError() noexcept;
+ ~ParseError() noexcept override;
ParseError(const ParseError&);
private:
@@ -52,7 +52,7 @@ namespace orc {
public:
explicit InvalidArgument(const std::string& what_arg);
explicit InvalidArgument(const char* what_arg);
- virtual ~InvalidArgument() noexcept;
+ ~InvalidArgument() noexcept override;
InvalidArgument(const InvalidArgument&);
private:
diff --git a/c++/include/orc/Statistics.hh b/c++/include/orc/Statistics.hh
index c08885b57..4ba8c35f7 100644
--- a/c++/include/orc/Statistics.hh
+++ b/c++/include/orc/Statistics.hh
@@ -58,7 +58,7 @@ namespace orc {
*/
class BinaryColumnStatistics : public ColumnStatistics {
public:
- virtual ~BinaryColumnStatistics();
+ ~BinaryColumnStatistics() override;
/**
* Check whether column has total length.
@@ -74,7 +74,7 @@ namespace orc {
*/
class BooleanColumnStatistics : public ColumnStatistics {
public:
- virtual ~BooleanColumnStatistics();
+ ~BooleanColumnStatistics() override;
/**
* Check whether column has true/false count.
@@ -91,7 +91,7 @@ namespace orc {
*/
class DateColumnStatistics : public ColumnStatistics {
public:
- virtual ~DateColumnStatistics();
+ ~DateColumnStatistics() override;
/**
* Check whether column has minimum.
@@ -123,7 +123,7 @@ namespace orc {
*/
class DecimalColumnStatistics : public ColumnStatistics {
public:
- virtual ~DecimalColumnStatistics();
+ ~DecimalColumnStatistics() override;
/**
* Check whether column has minimum.
@@ -167,7 +167,7 @@ namespace orc {
*/
class DoubleColumnStatistics : public ColumnStatistics {
public:
- virtual ~DoubleColumnStatistics();
+ ~DoubleColumnStatistics() override;
/**
* Check whether column has minimum.
@@ -214,7 +214,7 @@ namespace orc {
*/
class IntegerColumnStatistics : public ColumnStatistics {
public:
- virtual ~IntegerColumnStatistics();
+ ~IntegerColumnStatistics() override;
/**
* Check whether column has minimum.
@@ -260,7 +260,7 @@ namespace orc {
*/
class StringColumnStatistics : public ColumnStatistics {
public:
- virtual ~StringColumnStatistics();
+ ~StringColumnStatistics() override;
/**
* Check whether column has minimum.
@@ -304,7 +304,7 @@ namespace orc {
*/
class TimestampColumnStatistics : public ColumnStatistics {
public:
- virtual ~TimestampColumnStatistics();
+ ~TimestampColumnStatistics() override;
/**
* Check whether minimum timestamp exists.
@@ -390,7 +390,7 @@ namespace orc {
*/
class CollectionColumnStatistics : public ColumnStatistics {
public:
- virtual ~CollectionColumnStatistics();
+ ~CollectionColumnStatistics() override;
/**
* check whether column has minimum number of children
@@ -455,7 +455,7 @@ namespace orc {
class StripeStatistics : public Statistics {
public:
- virtual ~StripeStatistics();
+ ~StripeStatistics() override;
/**
* Get the statistics of a given RowIndex entry in a given column.
diff --git a/c++/include/orc/Vector.hh b/c++/include/orc/Vector.hh
index ac77d9be2..5e65314fb 100644
--- a/c++/include/orc/Vector.hh
+++ b/c++/include/orc/Vector.hh
@@ -95,22 +95,22 @@ namespace orc {
// PASS
}
- virtual ~IntegerVectorBatch() = default;
+ ~IntegerVectorBatch() override = default;
- inline std::string toString() const;
+ inline std::string toString() const override;
- void resize(uint64_t cap) {
+ void resize(uint64_t cap) override {
if (capacity < cap) {
ColumnVectorBatch::resize(cap);
data.resize(cap);
}
}
- void clear() {
+ void clear() override {
numElements = 0;
}
- uint64_t getMemoryUsage() {
+ uint64_t getMemoryUsage() override {
return ColumnVectorBatch::getMemoryUsage() +
static_cast<uint64_t>(data.capacity() * sizeof(ValueType));
}
@@ -158,22 +158,22 @@ namespace orc {
// PASS
}
- virtual ~FloatingVectorBatch() = default;
+ ~FloatingVectorBatch() override = default;
- inline std::string toString() const;
+ inline std::string toString() const override;
- void resize(uint64_t cap) {
+ void resize(uint64_t cap) override {
if (capacity < cap) {
ColumnVectorBatch::resize(cap);
data.resize(cap);
}
}
- void clear() {
+ void clear() override {
numElements = 0;
}
- uint64_t getMemoryUsage() {
+ uint64_t getMemoryUsage() override {
return ColumnVectorBatch::getMemoryUsage() +
static_cast<uint64_t>(data.capacity() * sizeof(FloatType));
}
@@ -200,11 +200,11 @@ namespace orc {
struct StringVectorBatch : public ColumnVectorBatch {
StringVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~StringVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
+ ~StringVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
// pointers to the start of each string
DataBuffer<char*> data;
@@ -240,9 +240,9 @@ namespace orc {
*/
struct EncodedStringVectorBatch : public StringVectorBatch {
EncodedStringVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~EncodedStringVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
+ ~EncodedStringVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
std::shared_ptr<StringDictionary> dictionary;
// index for dictionary entry
@@ -251,24 +251,24 @@ namespace orc {
struct StructVectorBatch : public ColumnVectorBatch {
StructVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~StructVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
- bool hasVariableLength();
+ ~StructVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
+ bool hasVariableLength() override;
std::vector<ColumnVectorBatch*> fields;
};
struct ListVectorBatch : public ColumnVectorBatch {
ListVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~ListVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
- bool hasVariableLength();
+ ~ListVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
+ bool hasVariableLength() override;
/**
* The offset of the first element of each list.
@@ -282,12 +282,12 @@ namespace orc {
struct MapVectorBatch : public ColumnVectorBatch {
MapVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~MapVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
- bool hasVariableLength();
+ ~MapVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
+ bool hasVariableLength() override;
/**
* The offset of the first element of each map.
@@ -303,12 +303,12 @@ namespace orc {
struct UnionVectorBatch : public ColumnVectorBatch {
UnionVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~UnionVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
- bool hasVariableLength();
+ ~UnionVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
+ bool hasVariableLength() override;
/**
* For each value, which element of children has the value.
@@ -336,11 +336,11 @@ namespace orc {
struct Decimal64VectorBatch : public ColumnVectorBatch {
Decimal64VectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~Decimal64VectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
+ ~Decimal64VectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
// total number of digits
int32_t precision;
@@ -362,11 +362,11 @@ namespace orc {
struct Decimal128VectorBatch : public ColumnVectorBatch {
Decimal128VectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~Decimal128VectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
+ ~Decimal128VectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
// total number of digits
int32_t precision;
@@ -394,11 +394,11 @@ namespace orc {
*/
struct TimestampVectorBatch : public ColumnVectorBatch {
TimestampVectorBatch(uint64_t capacity, MemoryPool& pool);
- virtual ~TimestampVectorBatch();
- std::string toString() const;
- void resize(uint64_t capacity);
- void clear();
- uint64_t getMemoryUsage();
+ ~TimestampVectorBatch() override;
+ std::string toString() const override;
+ void resize(uint64_t capacity) override;
+ void clear() override;
+ uint64_t getMemoryUsage() override;
// the number of seconds past 1 Jan 1970 00:00 UTC (aka time_t)
// Note that we always assume data is in GMT timezone; therefore it is
diff --git a/c++/src/ByteRLE.cc b/c++/src/ByteRLE.cc
index c894a158a..890dae2a3 100644
--- a/c++/src/ByteRLE.cc
+++ b/c++/src/ByteRLE.cc
@@ -305,22 +305,22 @@ namespace orc {
public:
ByteRleDecoderImpl(std::unique_ptr<SeekableInputStream> input,
ReaderMetrics* metrics);
- virtual ~ByteRleDecoderImpl();
+ ~ByteRleDecoderImpl() override;
/**
* Seek to a particular spot.
*/
- virtual void seek(PositionProvider&);
+ virtual void seek(PositionProvider&) override;
/**
* Seek over a given number of values.
*/
- virtual void skip(uint64_t numValues);
+ virtual void skip(uint64_t numValues) override;
/**
* Read a number of values into the batch.
*/
- virtual void next(char* data, uint64_t numValues, char* notNull);
+ virtual void next(char* data, uint64_t numValues, char* notNull) override;
protected:
void nextInternal(char* data, uint64_t numValues, char* notNull);
@@ -495,22 +495,22 @@ namespace orc {
public:
BooleanRleDecoderImpl(std::unique_ptr<SeekableInputStream> input,
ReaderMetrics* metrics);
- virtual ~BooleanRleDecoderImpl();
+ ~BooleanRleDecoderImpl() override;
/**
* Seek to a particular spot.
*/
- virtual void seek(PositionProvider&);
+ virtual void seek(PositionProvider&) override;
/**
* Seek over a given number of values.
*/
- virtual void skip(uint64_t numValues);
+ virtual void skip(uint64_t numValues) override;
/**
* Read a number of values into the batch.
*/
- virtual void next(char* data, uint64_t numValues, char* notNull);
+ virtual void next(char* data, uint64_t numValues, char* notNull) override;
protected:
size_t remainingBits;
diff --git a/c++/src/LzoDecompressor.cc b/c++/src/LzoDecompressor.cc
index c02c25015..cae25dcca 100644
--- a/c++/src/LzoDecompressor.cc
+++ b/c++/src/LzoDecompressor.cc
@@ -49,7 +49,7 @@ namespace orc {
MalformedInputException(const MalformedInputException& other) :
ParseError(other.what()) {}
- virtual ~MalformedInputException() noexcept;
+ ~MalformedInputException() noexcept override;
};
MalformedInputException::~MalformedInputException() noexcept {
diff --git a/c++/src/Timezone.hh b/c++/src/Timezone.hh
index 71b0281f9..bc32727f3 100644
--- a/c++/src/Timezone.hh
+++ b/c++/src/Timezone.hh
@@ -107,9 +107,9 @@ namespace orc {
class TimezoneError : public std::runtime_error {
public:
- TimezoneError(const std::string& what);
- TimezoneError(const TimezoneError&);
- virtual ~TimezoneError() noexcept;
+ explicit TimezoneError(const std::string& what);
+ explicit TimezoneError(const TimezoneError&);
+ ~TimezoneError() noexcept override;
};
/**
diff --git a/c++/src/io/InputStream.hh b/c++/src/io/InputStream.hh
index 2b9c6d293..5e1b4ba0a 100644
--- a/c++/src/io/InputStream.hh
+++ b/c++/src/io/InputStream.hh
@@ -50,7 +50,7 @@ namespace orc {
*/
class SeekableInputStream : public google::protobuf::io::ZeroCopyInputStream
{
public:
- virtual ~SeekableInputStream();
+ ~SeekableInputStream() override;
virtual void seek(PositionProvider& position) = 0;
virtual std::string getName() const = 0;
};
diff --git a/c++/src/wrap/orc-proto-wrapper.cc
b/c++/src/wrap/orc-proto-wrapper.cc
index c3d235e7e..aea0a34c8 100644
--- a/c++/src/wrap/orc-proto-wrapper.cc
+++ b/c++/src/wrap/orc-proto-wrapper.cc
@@ -32,6 +32,7 @@ DIAGNOSTIC_IGNORE("-Wmissing-variable-declarations")
DIAGNOSTIC_IGNORE("-Wnested-anon-types")
DIAGNOSTIC_IGNORE("-Wreserved-id-macro")
DIAGNOSTIC_IGNORE("-Wshorten-64-to-32")
+DIAGNOSTIC_IGNORE("-Wsuggest-destructor-override")
DIAGNOSTIC_IGNORE("-Wunknown-warning-option")
DIAGNOSTIC_IGNORE("-Wweak-vtables")
DIAGNOSTIC_IGNORE("-Wzero-as-null-pointer-constant")
diff --git a/c++/src/wrap/orc-proto-wrapper.hh
b/c++/src/wrap/orc-proto-wrapper.hh
index 118779b7b..4dcdda4c7 100644
--- a/c++/src/wrap/orc-proto-wrapper.hh
+++ b/c++/src/wrap/orc-proto-wrapper.hh
@@ -30,6 +30,7 @@ DIAGNOSTIC_IGNORE("-Wunused-parameter")
DIAGNOSTIC_IGNORE("-Wnested-anon-types")
DIAGNOSTIC_IGNORE("-Wreserved-id-macro")
DIAGNOSTIC_IGNORE("-Wshorten-64-to-32")
+DIAGNOSTIC_IGNORE("-Wsuggest-destructor-override")
DIAGNOSTIC_IGNORE("-Wunknown-warning-option")
DIAGNOSTIC_IGNORE("-Wweak-vtables")
DIAGNOSTIC_IGNORE("-Wzero-as-null-pointer-constant")
diff --git a/c++/test/TestAttributes.cc b/c++/test/TestAttributes.cc
index ad0adcfb7..50a6fc18b 100644
--- a/c++/test/TestAttributes.cc
+++ b/c++/test/TestAttributes.cc
@@ -32,7 +32,7 @@ namespace orc {
class TypeAttributes : public ::testing::Test {
public:
- ~TypeAttributes();
+ ~TypeAttributes() override;
protected:
static void SetUpTestCase() {
diff --git a/c++/test/TestColumnReader.cc b/c++/test/TestColumnReader.cc
index 7976238a2..6230c2e50 100644
--- a/c++/test/TestColumnReader.cc
+++ b/c++/test/TestColumnReader.cc
@@ -60,11 +60,11 @@ namespace orc {
MOCK_CONST_METHOD0(getForcedScaleOnHive11Decimal, int32_t());
MOCK_CONST_METHOD0(isDecimalAsLong, bool());
- MemoryPool& getMemoryPool() const {
+ MemoryPool& getMemoryPool() const override {
return *getDefaultPool();
}
- ReaderMetrics* getReaderMetrics() const {
+ ReaderMetrics* getReaderMetrics() const override {
return getDefaultReaderMetrics();
}
@@ -92,7 +92,7 @@ namespace orc {
}
class TestColumnReaderEncoded : public TestWithParam<bool> {
- virtual void SetUp();
+ void SetUp() override;
protected:
bool encoded;
diff --git a/c++/test/TestDecompression.cc b/c++/test/TestDecompression.cc
index fec3a092a..c90801d72 100644
--- a/c++/test/TestDecompression.cc
+++ b/c++/test/TestDecompression.cc
@@ -34,7 +34,7 @@ namespace orc {
class TestDecompression : public ::testing::Test {
public:
- ~TestDecompression();
+ ~TestDecompression() override;
protected:
// Per-test-case set-up.
diff --git a/c++/test/TestRleEncoder.cc b/c++/test/TestRleEncoder.cc
index 6b73972c6..1c24a6951 100644
--- a/c++/test/TestRleEncoder.cc
+++ b/c++/test/TestRleEncoder.cc
@@ -36,7 +36,7 @@ namespace orc {
const int DEFAULT_MEM_STREAM_SIZE = 1024 * 1024; // 1M
class RleTest : public TestWithParam<bool> {
- virtual void SetUp();
+ void SetUp() override;
protected:
bool alignBitpacking;
diff --git a/c++/test/TestWriter.cc b/c++/test/TestWriter.cc
index fbc13d24e..b2bee3ba1 100644
--- a/c++/test/TestWriter.cc
+++ b/c++/test/TestWriter.cc
@@ -78,7 +78,7 @@ namespace orc {
// You can implement all the usual fixture class members here.
// To access the test parameter, call GetParam() from class
// TestWithParam<T>.
- virtual void SetUp();
+ void SetUp() override;
protected:
FileVersion fileVersion;
diff --git a/tools/test/TestMatch.cc b/tools/test/TestMatch.cc
index face61d62..305f936bc 100644
--- a/tools/test/TestMatch.cc
+++ b/tools/test/TestMatch.cc
@@ -78,7 +78,7 @@ namespace orc {
class FileParam : public testing::TestWithParam<OrcFileDescription> {
public:
- virtual ~FileParam();
+ ~FileParam() override;
std::string getFilename() {
return findExample(GetParam().filename);
@@ -3260,7 +3260,7 @@ namespace orc {
class MockInputStream : public InputStream {
public:
- ~MockInputStream();
+ ~MockInputStream() override;
MOCK_CONST_METHOD0(getLength, uint64_t());
MOCK_CONST_METHOD0(getName, const std::string&());
MOCK_METHOD3(read, void(void*, uint64_t, uint64_t));