| 94 | } |
| 95 | |
| 96 | Status RunCompressorBuilder::AppendScalar(const Scalar& scalar, int64_t n_repeats) { |
| 97 | if (ARROW_PREDICT_FALSE(n_repeats == 0)) { |
| 98 | return Status::OK(); |
| 99 | } |
| 100 | if (ARROW_PREDICT_FALSE(current_run_length_ == 0)) { |
| 101 | // Open a new run |
| 102 | current_value_ = scalar.is_valid ? scalar.shared_from_this() : NULLPTR; |
| 103 | current_run_length_ = n_repeats; |
| 104 | } else if ((current_value_ == NULLPTR && !scalar.is_valid) || |
| 105 | (current_value_ != NULLPTR && current_value_->Equals(scalar))) { |
| 106 | // Extend the currently open run |
| 107 | current_run_length_ += n_repeats; |
| 108 | } else { |
| 109 | // Close the current run |
| 110 | ARROW_RETURN_NOT_OK(WillCloseRun(current_value_, current_run_length_)); |
| 111 | ARROW_RETURN_NOT_OK(current_value_ ? inner_builder_->AppendScalar(*current_value_) |
| 112 | : inner_builder_->AppendNull()); |
| 113 | UpdateDimensions(); |
| 114 | // Open a new run |
| 115 | current_value_ = scalar.is_valid ? scalar.shared_from_this() : NULLPTR; |
| 116 | current_run_length_ = n_repeats; |
| 117 | } |
| 118 | return Status::OK(); |
| 119 | } |
| 120 | |
| 121 | Status RunCompressorBuilder::AppendScalars(const ScalarVector& scalars) { |
| 122 | if (scalars.empty()) { |
no test coverage detected