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

Method GetPaddedStringView

cpp/src/arrow/json/chunker.cc:99–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97 std::shared_ptr<ResizableBuffer> buffer_;
98
99 Result<simdjson::padded_string_view> GetPaddedStringView(std::string_view partial,
100 std::string_view block) {
101 const auto data_size = partial.size() + block.size();
102 const auto required_size = data_size + simdjson::SIMDJSON_PADDING;
103 if (!buffer_) {
104 ARROW_ASSIGN_OR_RAISE(buffer_, AllocateResizableBuffer(
105 /*size=*/0, pool_));
106 }
107 // Ensure the buffer has enough space for this data + padding
108 if (buffer_->capacity() < static_cast<int64_t>(required_size)) {
109 RETURN_NOT_OK(buffer_->Reserve(static_cast<int64_t>(required_size * 3 / 2)));
110 }
111 auto data = buffer_->mutable_data();
112 std::memcpy(data, partial.data(), partial.size());
113 std::memcpy(data + partial.size(), block.data(), block.size());
114 auto view = simdjson::padded_string_view(data, /*len=*/data_size,
115 /*capacity=*/buffer_->capacity());
116 DCHECK(view.has_sufficient_padding());
117 return view;
118 }
119
120 // Find the first or last JSON object (depending on `find_last`)
121 // and return the consumed JSON byte length, or 0 if no complete document

Callers

nothing calls this directly

Calls 7

AllocateResizableBufferFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.50
sizeMethod · 0.45
capacityMethod · 0.45
ReserveMethod · 0.45
mutable_dataMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected