MCPcopy Create free account
hub / github.com/apache/arrow / operator()

Method operator()

cpp/src/arrow/io/memory_test.cc:488–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486 explicit BaseShrinkingTransform(int64_t keep_every) : keep_every_(keep_every) {}
487
488 Result<std::shared_ptr<Buffer>> operator()(const std::shared_ptr<Buffer>& buf) {
489 int64_t dest_size = (buf->size() - skip_bytes_ + keep_every_ - 1) / keep_every_;
490 ARROW_ASSIGN_OR_RAISE(auto dest, AllocateBuffer(dest_size));
491 const uint8_t* data = buf->data() + skip_bytes_;
492 uint8_t* out_data = dest->mutable_data();
493 for (int64_t i = 0; i < dest_size; ++i) {
494 out_data[i] = data[i * keep_every_];
495 }
496 if (dest_size > 0) {
497 skip_bytes_ = skip_bytes_ + dest_size * keep_every_ - buf->size();
498 } else {
499 skip_bytes_ = skip_bytes_ - buf->size();
500 }
501 DCHECK_GE(skip_bytes_, 0);
502 DCHECK_LT(skip_bytes_, keep_every_);
503 return std::shared_ptr<Buffer>(std::move(dest));
504 }
505
506 protected:
507 int64_t skip_bytes_ = 0;

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.45
dataMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected