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

Method Resize

cpp/src/arrow/memory_pool.cc:935–956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

933 }
934
935 Status Resize(const int64_t new_size, bool shrink_to_fit = true) override {
936 if (ARROW_PREDICT_FALSE(new_size < 0)) {
937 return Status::Invalid("Negative buffer resize: ", new_size);
938 }
939 uint8_t* ptr = mutable_data();
940 if (ptr && shrink_to_fit && new_size <= size_) {
941 // Buffer is non-null and is not growing, so shrink to the requested size without
942 // excess space.
943 ARROW_ASSIGN_OR_RAISE(int64_t new_capacity, RoundCapacity(new_size));
944 if (capacity_ != new_capacity) {
945 // Buffer hasn't got yet the requested size.
946 RETURN_NOT_OK(pool_->Reallocate(capacity_, new_capacity, alignment_, &ptr));
947 data_ = ptr;
948 capacity_ = new_capacity;
949 }
950 } else {
951 RETURN_NOT_OK(Reserve(new_size));
952 }
953 size_ = new_size;
954
955 return Status::OK();
956 }
957
958 static std::shared_ptr<PoolBuffer> MakeShared(MemoryPool* pool, int64_t alignment) {
959 std::shared_ptr<MemoryManager> mm;

Callers 1

ResizePoolBufferFunction · 0.45

Calls 5

InvalidFunction · 0.70
mutable_dataFunction · 0.70
ReserveFunction · 0.70
OKFunction · 0.70
ReallocateMethod · 0.45

Tested by

no test coverage detected