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

Method Consume

cpp/src/arrow/compute/kernels/aggregate_basic.cc:327–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 nulls_observed(false) {}
326
327 Status Consume(KernelContext*, const ExecSpan& batch) override {
328 if (batch[0].is_array()) {
329 const ArraySpan& data = batch[0].array;
330 this->count += data.length - data.GetNullCount();
331 this->nulls_observed = this->nulls_observed || data.GetNullCount();
332
333 if (!options.skip_nulls && this->nulls_observed) {
334 // Short-circuit
335 return Status::OK();
336 }
337
338 internal::VisitArrayValuesInline<ArrowType>(
339 data,
340 [&](typename TypeTraits<ArrowType>::CType value) {
341 this->product = MultiplyTraits<AccType>::Multiply(
342 *out_type, this->product, static_cast<ProductType>(value));
343 },
344 [] {});
345 } else {
346 const Scalar& data = *batch[0].scalar;
347 this->count += data.is_valid * batch.length;
348 this->nulls_observed = this->nulls_observed || !data.is_valid;
349 if (data.is_valid) {
350 for (int64_t i = 0; i < batch.length; i++) {
351 auto value = internal::UnboxScalar<ArrowType>::Unbox(data);
352 this->product = MultiplyTraits<AccType>::Multiply(
353 *out_type, this->product, static_cast<ProductType>(value));
354 }
355 }
356 }
357 return Status::OK();
358 }
359
360 Status MergeFrom(KernelContext*, KernelState&& src) override {
361 const auto& other = checked_cast<const ThisType&>(src);

Callers

nothing calls this directly

Calls 4

is_arrayMethod · 0.80
GetNullCountMethod · 0.80
MultiplyClass · 0.70
OKFunction · 0.50

Tested by

no test coverage detected