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

Function DecodeDict

cpp/src/parquet/encoding_benchmark.cc:1083–1124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081
1082template <typename Type>
1083static void DecodeDict(const std::vector<typename Type::c_type>& values,
1084 benchmark::State& state) {
1085 typedef typename Type::c_type T;
1086 int num_values = static_cast<int>(values.size());
1087
1088 MemoryPool* allocator = default_memory_pool();
1089 std::shared_ptr<ColumnDescriptor> descr = Int64Schema(Repetition::REQUIRED);
1090
1091 auto base_encoder =
1092 MakeEncoder(Type::type_num, Encoding::PLAIN, true, descr.get(), allocator);
1093 auto encoder =
1094 dynamic_cast<typename EncodingTraits<Type>::Encoder*>(base_encoder.get());
1095 auto dict_traits = dynamic_cast<DictEncoder<Type>*>(base_encoder.get());
1096 encoder->Put(values.data(), num_values);
1097
1098 std::shared_ptr<ResizableBuffer> dict_buffer =
1099 AllocateBuffer(allocator, dict_traits->dict_encoded_size());
1100
1101 std::shared_ptr<ResizableBuffer> indices =
1102 AllocateBuffer(allocator, encoder->EstimatedDataEncodedSize());
1103
1104 dict_traits->WriteDict(dict_buffer->mutable_data());
1105 int actual_bytes = dict_traits->WriteIndices(indices->mutable_data(),
1106 static_cast<int>(indices->size()));
1107
1108 PARQUET_THROW_NOT_OK(indices->Resize(actual_bytes));
1109
1110 std::vector<T> decoded_values(num_values);
1111 for (auto _ : state) {
1112 auto dict_decoder = MakeTypedDecoder<Type>(Encoding::PLAIN, descr.get());
1113 dict_decoder->SetData(dict_traits->num_entries(), dict_buffer->data(),
1114 static_cast<int>(dict_buffer->size()));
1115
1116 auto decoder = MakeDictDecoder<Type>(descr.get());
1117 decoder->SetDict(dict_decoder.get());
1118 decoder->SetData(num_values, indices->data(), static_cast<int>(indices->size()));
1119 decoder->Decode(decoded_values.data(), num_values);
1120 }
1121
1122 state.SetBytesProcessed(state.iterations() * num_values * sizeof(T));
1123 state.SetItemsProcessed(state.iterations() * num_values);
1124}
1125
1126static void BM_DictDecodingInt64_repeats(benchmark::State& state) {
1127 typedef Int64Type Type;

Callers 1

SetDictMethod · 0.85

Calls 15

default_memory_poolFunction · 0.85
dict_encoded_sizeMethod · 0.80
num_entriesMethod · 0.80
SetDictMethod · 0.80
Int64SchemaFunction · 0.70
MakeEncoderFunction · 0.70
AllocateBufferFunction · 0.70
sizeMethod · 0.45
getMethod · 0.45
PutMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected