MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / deserializeSets

Method deserializeSets

src/Processors/QueryPlan/SetsSerialization.cpp:136–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136QueryPlanAndSets QueryPlan::deserializeSets(
137 QueryPlan plan,
138 DeserializedSetsRegistry & registry,
139 ReadBuffer & in,
140 const SerializationFlags & flags,
141 const ContextPtr & context)
142{
143 UInt64 num_sets = 0;
144 readVarUInt(num_sets, in);
145
146 QueryPlanAndSets res;
147 res.plan = std::move(plan);
148
149 for (size_t i = 0; i < num_sets; ++i)
150 {
151 PreparedSets::Hash hash;
152 readBinary(hash, in);
153
154 auto it = registry.sets.find(hash);
155 if (it == registry.sets.end())
156 throw Exception(ErrorCodes::INCORRECT_DATA, "Serialized set {}_{} is not registered", hash.low64, hash.high64);
157
158 auto & columns = it->second;
159 if (columns.empty())
160 throw Exception(ErrorCodes::INCORRECT_DATA, "Serialized set {}_{} is serialized twice", hash.low64, hash.high64);
161
162 UInt8 kind = 0;
163 readVarUInt(kind, in);
164 if (kind == UInt8(SetSerializationKind::StorageSet))
165 {
166 String storage_name;
167 readStringBinary(storage_name, in);
168 res.sets_from_storage.emplace_back(QueryPlanAndSets::SetFromStorage{{hash, std::move(columns)}, std::move(storage_name)});
169 }
170 else if (kind == UInt8(SetSerializationKind::TupleValues))
171 {
172 UInt64 num_columns = 0;
173 UInt64 num_rows = 0;
174 readVarUInt(num_columns, in);
175 readVarUInt(num_rows, in);
176
177 ColumnsWithTypeAndName set_columns;
178 set_columns.reserve(num_columns);
179
180 for (size_t col = 0; col < num_columns; ++col)
181 {
182 auto type = decodeDataType(in);
183 auto serialization = type->getDefaultSerialization();
184 ColumnPtr column = type->createColumn();
185 NativeReader::readData(*serialization, column, in, {}, num_rows, nullptr, nullptr);
186
187 set_columns.emplace_back(std::move(column), std::move(type), String{});
188 }
189
190 res.sets_from_tuple.emplace_back(QueryPlanAndSets::SetFromTuple{{hash, std::move(columns)}, std::move(set_columns)});
191 }
192 else if (kind == UInt8(SetSerializationKind::SubqueryPlan))
193 {

Callers

nothing calls this directly

Calls 12

readStringBinaryFunction · 0.85
decodeDataTypeFunction · 0.85
readDataFunction · 0.85
readBinaryFunction · 0.50
ExceptionClass · 0.50
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
reserveMethod · 0.45
createColumnMethod · 0.45

Tested by

no test coverage detected