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

Method Encode

cpp/src/arrow/compute/row/row_encoder_internal.h:170–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 }
169
170 Status Encode(const ExecValue& data, int64_t batch_length,
171 uint8_t** encoded_bytes) override {
172 auto handle_next_valid_value = [&encoded_bytes](std::string_view bytes) {
173 auto& encoded_ptr = *encoded_bytes++;
174 *encoded_ptr++ = kValidByte;
175 util::SafeStore(encoded_ptr, static_cast<Offset>(bytes.size()));
176 encoded_ptr += sizeof(Offset);
177 memcpy(encoded_ptr, bytes.data(), bytes.size());
178 encoded_ptr += bytes.size();
179 };
180 auto handle_next_null_value = [&encoded_bytes]() {
181 auto& encoded_ptr = *encoded_bytes++;
182 *encoded_ptr++ = kNullByte;
183 util::SafeStore(encoded_ptr, static_cast<Offset>(0));
184 encoded_ptr += sizeof(Offset);
185 };
186 if (data.is_array()) {
187 ARROW_DCHECK_EQ(data.length(), batch_length);
188 VisitArraySpanInline<T>(data.array, handle_next_valid_value,
189 handle_next_null_value);
190 } else {
191 const auto& scalar = data.scalar_as<BaseBinaryScalar>();
192 if (scalar.is_valid) {
193 const auto bytes = std::string_view{*scalar.value};
194 for (int64_t i = 0; i < batch_length; i++) {
195 handle_next_valid_value(bytes);
196 }
197 } else {
198 for (int64_t i = 0; i < batch_length; i++) {
199 handle_next_null_value();
200 }
201 }
202 }
203 return Status::OK();
204 }
205
206 void EncodeNull(uint8_t** encoded_bytes) override {
207 auto& encoded_ptr = *encoded_bytes;

Callers

nothing calls this directly

Calls 6

SafeStoreFunction · 0.85
is_arrayMethod · 0.80
OKFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected