Skip to content

Commit 35c17c9

Browse files
committed
refactor(orc): inline validity bitmap appends
1 parent 7941343 commit 35c17c9

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

src/paimon/format/orc/orc_adapter.cpp

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ class OrcBackedArrowBuffer : public arrow::ResizableBuffer {
101101
::orc::DataBuffer<T> orc_buffer_;
102102
};
103103

104-
template <typename AppendToBitmap>
105-
arrow::Status AppendValidBytesToBitmap(arrow::ArrayBuilder* builder, int64_t length,
106-
AppendToBitmap append_to_bitmap) {
107-
ARROW_RETURN_NOT_OK(builder->Reserve(length));
108-
append_to_bitmap();
109-
return arrow::Status::OK();
110-
}
111-
112104
class EmptyBuilder : public arrow::ArrayBuilder {
113105
public:
114106
using arrow::ArrayBuilder::SetNotNull;
@@ -152,9 +144,9 @@ class UnPooledBooleanBuilder : public EmptyBuilder {
152144
}
153145

154146
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
155-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
156-
this->UnsafeAppendToBitmap(valid_bytes, length);
157-
});
147+
ARROW_RETURN_NOT_OK(this->Reserve(length));
148+
this->UnsafeAppendToBitmap(valid_bytes, length);
149+
return arrow::Status::OK();
158150
}
159151

160152
arrow::Status SetData(const uint8_t* data, int64_t length) {
@@ -199,9 +191,9 @@ class UnPooledPrimitiveBuilder : public arrow::NumericBuilder<Type> {
199191
}
200192

201193
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
202-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
203-
this->UnsafeAppendToBitmap(valid_bytes, length);
204-
});
194+
ARROW_RETURN_NOT_OK(this->Reserve(length));
195+
this->UnsafeAppendToBitmap(valid_bytes, length);
196+
return arrow::Status::OK();
205197
}
206198

207199
arrow::Status FinishInternal(std::shared_ptr<arrow::ArrayData>* out) override {
@@ -242,9 +234,9 @@ class UnPooledLargeBinaryBuilder : public arrow::LargeBinaryBuilder {
242234
length_ += length;
243235
}
244236
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
245-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
246-
this->UnsafeAppendToBitmap(valid_bytes, length);
247-
});
237+
ARROW_RETURN_NOT_OK(this->Reserve(length));
238+
this->UnsafeAppendToBitmap(valid_bytes, length);
239+
return arrow::Status::OK();
248240
}
249241
arrow::Status FinishInternal(std::shared_ptr<arrow::ArrayData>* out) override {
250242
std::shared_ptr<arrow::Buffer> null_bitmap;
@@ -289,9 +281,9 @@ class UnPooledBinaryBuilder : public arrow::BinaryBuilder {
289281
}
290282

291283
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
292-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
293-
this->UnsafeAppendToBitmap(valid_bytes, length);
294-
});
284+
ARROW_RETURN_NOT_OK(this->Reserve(length));
285+
this->UnsafeAppendToBitmap(valid_bytes, length);
286+
return arrow::Status::OK();
295287
}
296288

297289
arrow::Status FinishInternal(std::shared_ptr<arrow::ArrayData>* out) override {
@@ -331,9 +323,9 @@ class UnPooledListBuilder : public EmptyBuilder {
331323
}
332324

333325
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
334-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
335-
this->UnsafeAppendToBitmap(valid_bytes, length);
336-
});
326+
ARROW_RETURN_NOT_OK(this->Reserve(length));
327+
this->UnsafeAppendToBitmap(valid_bytes, length);
328+
return arrow::Status::OK();
337329
}
338330

339331
void SetOffsets(const std::shared_ptr<arrow::Buffer>& offsets) {
@@ -381,9 +373,9 @@ class UnPooledStructBuilder : public EmptyBuilder {
381373
}
382374

383375
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
384-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
385-
this->UnsafeAppendToBitmap(valid_bytes, length);
386-
});
376+
ARROW_RETURN_NOT_OK(this->Reserve(length));
377+
this->UnsafeAppendToBitmap(valid_bytes, length);
378+
return arrow::Status::OK();
387379
}
388380

389381
arrow::Status FinishInternal(std::shared_ptr<arrow::ArrayData>* out) override {
@@ -509,9 +501,9 @@ class UnPooledStringDictionaryBuilder : public EmptyBuilder {
509501
indices_ = indices;
510502
}
511503
arrow::Status SetNulls(const uint8_t* valid_bytes, int64_t length) {
512-
return AppendValidBytesToBitmap(this, length, [this, valid_bytes, length] {
513-
this->UnsafeAppendToBitmap(valid_bytes, length);
514-
});
504+
ARROW_RETURN_NOT_OK(this->Reserve(length));
505+
this->UnsafeAppendToBitmap(valid_bytes, length);
506+
return arrow::Status::OK();
515507
}
516508
arrow::Status FinishInternal(std::shared_ptr<arrow::ArrayData>* out) override {
517509
std::shared_ptr<arrow::Buffer> null_bitmap;

0 commit comments

Comments
 (0)