MCPcopy Create free account
hub / github.com/apache/arrow / Finalize

Method Finalize

cpp/src/arrow/compute/kernels/aggregate_tdigest.cc:102–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 }
101
102 Status Finalize(KernelContext* ctx, Datum* out) override {
103 const int64_t out_length = options.q.size();
104 auto out_data = ArrayData::Make(float64(), out_length, 0);
105 out_data->buffers.resize(2, nullptr);
106 ARROW_ASSIGN_OR_RAISE(out_data->buffers[1],
107 ctx->Allocate(out_length * sizeof(double)));
108 double* out_buffer = out_data->template GetMutableValues<double>(1);
109
110 if (this->tdigest.is_empty() || !this->all_valid || this->count < options.min_count) {
111 ARROW_ASSIGN_OR_RAISE(out_data->buffers[0], ctx->AllocateBitmap(out_length));
112 std::memset(out_data->buffers[0]->mutable_data(), 0x00,
113 out_data->buffers[0]->size());
114 std::fill(out_buffer, out_buffer + out_length, 0.0);
115 out_data->null_count = out_length;
116 } else {
117 for (int64_t i = 0; i < out_length; ++i) {
118 out_buffer[i] = this->tdigest.Quantile(this->options.q[i]);
119 }
120 }
121 *out = Datum(std::move(out_data));
122 return Status::OK();
123 }
124
125 const TDigestOptions options;
126 TDigest tdigest;

Callers 1

Calls 11

resizeMethod · 0.80
AllocateBitmapMethod · 0.80
MakeFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
DatumClass · 0.50
OKFunction · 0.50
sizeMethod · 0.45
AllocateMethod · 0.45
is_emptyMethod · 0.45
mutable_dataMethod · 0.45
QuantileMethod · 0.45

Tested by

no test coverage detected