Skip to content

Commit

Permalink
no_memset_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
XinyuZeng committed Jan 10, 2024
1 parent 0f52b34 commit 6d584b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
7 changes: 6 additions & 1 deletion c++/include/orc/MemoryPool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace orc {
};
MemoryPool* getDefaultPool();

struct no_memset_tag_t {
explicit no_memset_tag_t() = default;
};
inline constexpr no_memset_tag_t no_memset_tag{};

template <class T>
class DataBuffer {
private:
Expand All @@ -51,7 +56,7 @@ namespace orc {

public:
DataBuffer(MemoryPool& pool, uint64_t _size = 0);
DataBuffer(MemoryPool& pool, uint64_t _size, bool noMemSet);
DataBuffer(MemoryPool& pool, uint64_t _size, no_memset_tag_t no_memset_tag);

DataBuffer(DataBuffer<T>&& buffer) noexcept;

Expand Down
4 changes: 2 additions & 2 deletions c++/include/orc/Vector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace orc {
template <typename ValueType>
struct IntegerVectorBatch : public ColumnVectorBatch {
IntegerVectorBatch(uint64_t cap, MemoryPool& pool)
: ColumnVectorBatch(cap, pool), data(pool, cap, /*noMemSet=*/true) {
: ColumnVectorBatch(cap, pool), data(pool, cap, no_memset_tag) {
// PASS
}

Expand Down Expand Up @@ -159,7 +159,7 @@ namespace orc {
template <typename FloatType>
struct FloatingVectorBatch : public ColumnVectorBatch {
FloatingVectorBatch(uint64_t cap, MemoryPool& pool)
: ColumnVectorBatch(cap, pool), data(pool, cap, /*noMemSet=*/true) {
: ColumnVectorBatch(cap, pool), data(pool, cap, no_memset_tag) {
// PASS
}

Expand Down
4 changes: 2 additions & 2 deletions c++/src/Compression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace orc {
uint64_t capacity, uint64_t blockSize,
MemoryPool& pool, WriterMetrics* metrics)
: BufferedOutputStream(pool, outStream, capacity, blockSize, metrics),
rawInputBuffer(pool, blockSize, /*noMemSet*/ true),
rawInputBuffer(pool, blockSize, no_memset_tag),
level(compressionLevel),
outputBuffer(nullptr),
bufferSize(0),
Expand Down Expand Up @@ -403,7 +403,7 @@ namespace orc {
ReaderMetrics* _metrics)
: pool(_pool),
input(std::move(inStream)),
outputDataBuffer(pool, bufferSize, /*noMemSet*/ true),
outputDataBuffer(pool, bufferSize, no_memset_tag),
state(DECOMPRESS_HEADER),
outputBufferStart(nullptr),
outputBuffer(nullptr),
Expand Down
4 changes: 2 additions & 2 deletions c++/src/MemoryPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ namespace orc {
}

// This constructor is used to create a DataBuffer that does not need to be memset to 0.
// bool noMemSet is not used in the code, but is kept here to avoid run-time branching.
// memset_tag is not used in the code, but is kept here to avoid run-time branching.
template <class T>
DataBuffer<T>::DataBuffer(MemoryPool& pool, uint64_t newSize, [[maybe_unused]] bool noMemSet)
DataBuffer<T>::DataBuffer(MemoryPool& pool, uint64_t newSize, no_memset_tag_t no_memset_tag)
: memoryPool(pool), buf(nullptr), currentSize(0), currentCapacity(0) {
reserve(newSize);
currentSize = newSize;
Expand Down
23 changes: 11 additions & 12 deletions c++/src/Vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "Adaptor.hh"
#include "orc/Exceptions.hh"
#include "orc/MemoryPool.hh"

#include <cstdlib>
#include <iostream>
Expand All @@ -30,7 +31,7 @@ namespace orc {
ColumnVectorBatch::ColumnVectorBatch(uint64_t cap, MemoryPool& pool)
: capacity(cap),
numElements(0),
notNull(pool, cap, /*noMemSet=*/true),
notNull(pool, cap, no_memset_tag),
hasNulls(false),
isEncoded(false),
memoryPool(pool) {
Expand Down Expand Up @@ -66,9 +67,7 @@ namespace orc {
}

EncodedStringVectorBatch::EncodedStringVectorBatch(uint64_t _capacity, MemoryPool& pool)
: StringVectorBatch(_capacity, pool),
dictionary(),
index(pool, _capacity, /*noMemSet=*/true) {
: StringVectorBatch(_capacity, pool), dictionary(), index(pool, _capacity, no_memset_tag) {
// PASS
}

Expand All @@ -91,8 +90,8 @@ namespace orc {

StringVectorBatch::StringVectorBatch(uint64_t _capacity, MemoryPool& pool)
: ColumnVectorBatch(_capacity, pool),
data(pool, _capacity, /*noMemSet=*/true),
length(pool, _capacity, /*noMemSet=*/true),
data(pool, _capacity, no_memset_tag),
length(pool, _capacity, no_memset_tag),
blob(pool) {
// PASS
}
Expand Down Expand Up @@ -314,8 +313,8 @@ namespace orc {
: ColumnVectorBatch(cap, pool),
precision(0),
scale(0),
values(pool, cap, /*noMemSet=*/true),
readScales(pool, cap, /*noMemSet=*/true) {
values(pool, cap, no_memset_tag),
readScales(pool, cap, no_memset_tag) {
// PASS
}

Expand Down Expand Up @@ -350,8 +349,8 @@ namespace orc {
: ColumnVectorBatch(cap, pool),
precision(0),
scale(0),
values(pool, cap, /*noMemSet=*/true),
readScales(pool, cap, /*noMemSet=*/true) {
values(pool, cap, no_memset_tag),
readScales(pool, cap, no_memset_tag) {
// PASS
}

Expand Down Expand Up @@ -410,8 +409,8 @@ namespace orc {

TimestampVectorBatch::TimestampVectorBatch(uint64_t _capacity, MemoryPool& pool)
: ColumnVectorBatch(_capacity, pool),
data(pool, _capacity, /*noMemSet=*/true),
nanoseconds(pool, _capacity, /*noMemSet=*/true) {
data(pool, _capacity, no_memset_tag),
nanoseconds(pool, _capacity, no_memset_tag) {
// PASS
}

Expand Down

0 comments on commit 6d584b6

Please sign in to comment.