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

Method PutBinaryArray

cpp/src/parquet/encoder.cc:1532–1573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1530
1531 template <typename ArrayType>
1532 void PutBinaryArray(const ArrayType& array) {
1533 auto previous_len = static_cast<uint32_t>(last_value_.length());
1534 std::string_view last_value_view = last_value_;
1535
1536 PARQUET_THROW_NOT_OK(::arrow::VisitArraySpanInline<typename ArrayType::TypeClass>(
1537 *array.data(),
1538 [&](::std::string_view view) {
1539 if (ARROW_PREDICT_FALSE(view.size() >= kMaxByteArraySize)) {
1540 return Status::Invalid(
1541 "Parquet cannot store strings with size 2GB or more, got: ", view.size());
1542 }
1543 const ByteArray src{view};
1544
1545 uint32_t common_prefix_length = 0;
1546 const uint32_t len = src.len;
1547 const uint32_t maximum_common_prefix_length = std::min(previous_len, len);
1548 while (common_prefix_length < maximum_common_prefix_length) {
1549 if (last_value_view[common_prefix_length] != view[common_prefix_length]) {
1550 break;
1551 }
1552 common_prefix_length++;
1553 }
1554 previous_len = len;
1555 prefix_length_encoder_.Put({static_cast<int32_t>(common_prefix_length)}, 1);
1556
1557 last_value_view = view;
1558 const auto suffix_length = static_cast<uint32_t>(len - common_prefix_length);
1559 if (suffix_length == 0) {
1560 suffix_encoder_.Put(&empty_, 1);
1561 return Status::OK();
1562 }
1563 const uint8_t* suffix_ptr = src.ptr + common_prefix_length;
1564 // Convert to ByteArray, so it can be passed to the suffix_encoder_.
1565 const ByteArray suffix(suffix_length, suffix_ptr);
1566 suffix_encoder_.Put(&suffix, 1);
1567
1568 unencoded_byte_array_data_bytes_ += len;
1569 return Status::OK();
1570 },
1571 []() { return Status::OK(); }));
1572 last_value_ = last_value_view;
1573 }
1574
1575 ::arrow::BufferBuilder sink_;
1576 DeltaBitPackEncoder<Int32Type> prefix_length_encoder_;

Callers

nothing calls this directly

Calls 6

InvalidFunction · 0.50
OKFunction · 0.50
lengthMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected