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

Method BuildBufferInternal

cpp/src/parquet/decoder.cc:2086–2120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2084 protected:
2085 template <bool is_first_run>
2086 static void BuildBufferInternal(const int32_t* prefix_len_ptr, int i, ByteArray* buffer,
2087 std::string_view* prefix, uint8_t** data_ptr) {
2088 if (ARROW_PREDICT_FALSE(static_cast<size_t>(prefix_len_ptr[i]) > prefix->length())) {
2089 throw ParquetException("prefix length too large in DELTA_BYTE_ARRAY");
2090 }
2091 // For now, `buffer` points to string suffixes, and the suffix decoder
2092 // ensures that the suffix data has sufficient lifetime.
2093 if (prefix_len_ptr[i] == 0) {
2094 // prefix is empty: buffer[i] already points to the suffix.
2095 *prefix = std::string_view{buffer[i]};
2096 return;
2097 }
2098 DCHECK_EQ(is_first_run, i == 0);
2099 if constexpr (!is_first_run) {
2100 if (buffer[i].len == 0) {
2101 // suffix is empty: buffer[i] can simply point to the prefix.
2102 // This is not possible for the first run since the prefix
2103 // would point to the mutable `last_value_`.
2104 *prefix = prefix->substr(0, prefix_len_ptr[i]);
2105 buffer[i] = ByteArray(*prefix);
2106 return;
2107 }
2108 }
2109 // Both prefix and suffix are non-empty, so we need to decode the string
2110 // into `data_ptr`.
2111 // 1. Copy the prefix
2112 memcpy(*data_ptr, prefix->data(), prefix_len_ptr[i]);
2113 // 2. Copy the suffix.
2114 memcpy(*data_ptr + prefix_len_ptr[i], buffer[i].ptr, buffer[i].len);
2115 // 3. Point buffer[i] to the decoded string.
2116 buffer[i].ptr = *data_ptr;
2117 buffer[i].len += prefix_len_ptr[i];
2118 *data_ptr += buffer[i].len;
2119 *prefix = std::string_view{buffer[i]};
2120 }
2121
2122 int GetInternal(ByteArray* buffer, int max_values) {
2123 // Decode up to `max_values` strings into an internal buffer

Callers

nothing calls this directly

Calls 5

ParquetExceptionFunction · 0.85
ByteArrayClass · 0.85
substrMethod · 0.80
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected