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

Method DecodeArrowDense

cpp/src/parquet/decoder.cc:2194–2234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2192 }
2193
2194 Status DecodeArrowDense(int num_values, int null_count, const uint8_t* valid_bits,
2195 int64_t valid_bits_offset,
2196 typename EncodingTraits<DType>::Accumulator* out,
2197 int* out_num_values) {
2198 ARROW_ASSIGN_OR_RAISE(
2199 auto values_buffer,
2200 ::arrow::AllocateBuffer(sizeof(ByteArray) * (num_values - null_count), pool_));
2201 auto values_data = values_buffer->template mutable_data_as<ByteArray>();
2202
2203 const int num_valid_values = GetInternal(values_data, num_values - null_count);
2204 if (ARROW_PREDICT_FALSE(num_values - null_count != num_valid_values)) {
2205 throw ParquetException("Expected to decode ", num_values - null_count,
2206 " values, but decoded ", num_valid_values, " values.");
2207 }
2208
2209 auto visit_binary_helper = [&](auto* helper) {
2210 auto values_ptr = reinterpret_cast<const ByteArray*>(values_data);
2211 int value_idx = 0;
2212
2213 PARQUET_THROW_NOT_OK(
2214 VisitBitRuns(valid_bits, valid_bits_offset, num_values,
2215 [&](int64_t position, int64_t run_length, bool is_valid) {
2216 if (is_valid) {
2217 for (int64_t i = 0; i < run_length; ++i) {
2218 const auto& val = values_ptr[value_idx];
2219 RETURN_NOT_OK(helper->AppendValue(
2220 val.ptr, static_cast<int32_t>(val.len)));
2221 ++value_idx;
2222 }
2223 return Status::OK();
2224 } else {
2225 return helper->AppendNulls(run_length);
2226 }
2227 }));
2228
2229 *out_num_values = num_valid_values;
2230 return Status::OK();
2231 };
2232 return DispatchArrowBinaryHelper<DType>(out, num_values, /*estimated_data_length=*/{},
2233 visit_binary_helper);
2234 }
2235
2236 MemoryPool* pool_;
2237

Callers

nothing calls this directly

Calls 5

ParquetExceptionFunction · 0.85
VisitBitRunsFunction · 0.85
OKFunction · 0.50
AppendValueMethod · 0.45
AppendNullsMethod · 0.45

Tested by

no test coverage detected