Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ffacs committed Mar 18, 2024
1 parent b3f2625 commit b5ae81d
Show file tree
Hide file tree
Showing 73 changed files with 3,923 additions and 3,580 deletions.
16 changes: 16 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dependency-reduced-pom.xml
.java-version
java/bench/data
*.swp
.cache/*
12 changes: 6 additions & 6 deletions c++/include/orc/Common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions c++/include/orc/Exceptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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&);

Expand All @@ -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&);

Expand All @@ -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&);

Expand All @@ -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;
Expand Down
134 changes: 67 additions & 67 deletions c++/include/orc/Int128.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ namespace orc {
class Int128 {
public:
Int128() {
highbits = 0;
lowbits = 0;
highbits_ = 0;
lowbits_ = 0;
}

/**
* Convert a signed 64 bit value into an Int128.
*/
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);
}
}

/**
* Create from the twos complement representation.
*/
Int128(int64_t high, uint64_t low) {
highbits = high;
lowbits = low;
highbits_ = high;
lowbits_ = low;
}

/**
Expand All @@ -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;
Expand All @@ -100,8 +100,8 @@ namespace orc {
}

Int128& invert() {
lowbits = ~lowbits;
highbits = ~highbits;
lowbits_ = ~lowbits_;
highbits_ = ~highbits_;
return *this;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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");
}
Expand Down Expand Up @@ -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_;
}

/**
Expand All @@ -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_;
};

/**
Expand Down
Loading

0 comments on commit b5ae81d

Please sign in to comment.