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

Method DecodeArrowDense

cpp/src/parquet/decoder.cc:2145–2185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2143 }
2144
2145 Status DecodeArrowDense(int num_values, int null_count, const uint8_t* valid_bits,
2146 int64_t valid_bits_offset,
2147 typename EncodingTraits<DType>::Accumulator* out,
2148 int* out_num_values) {
2149 ARROW_ASSIGN_OR_RAISE(
2150 auto values_buffer,
2151 ::arrow::AllocateBuffer(sizeof(ByteArray) * (num_values - null_count), pool_));
2152 auto values_data = values_buffer->template mutable_data_as<ByteArray>();
2153
2154 const int num_valid_values = GetInternal(values_data, num_values - null_count);
2155 if (ARROW_PREDICT_FALSE(num_values - null_count != num_valid_values)) {
2156 throw ParquetException("Expected to decode ", num_values - null_count,
2157 " values, but decoded ", num_valid_values, " values.");
2158 }
2159
2160 auto visit_binary_helper = [&](auto* helper) {
2161 auto values_ptr = reinterpret_cast<const ByteArray*>(values_data);
2162 int value_idx = 0;
2163
2164 PARQUET_THROW_NOT_OK(
2165 VisitBitRuns(valid_bits, valid_bits_offset, num_values,
2166 [&](int64_t position, int64_t run_length, bool is_valid) {
2167 if (is_valid) {
2168 for (int64_t i = 0; i < run_length; ++i) {
2169 const auto& val = values_ptr[value_idx];
2170 RETURN_NOT_OK(helper->AppendValue(
2171 val.ptr, static_cast<int32_t>(val.len)));
2172 ++value_idx;
2173 }
2174 return Status::OK();
2175 } else {
2176 return helper->AppendNulls(run_length);
2177 }
2178 }));
2179
2180 *out_num_values = num_valid_values;
2181 return Status::OK();
2182 };
2183 return DispatchArrowBinaryHelper<DType>(out, num_values, /*estimated_data_length=*/{},
2184 visit_binary_helper);
2185 }
2186
2187 MemoryPool* pool_;
2188

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