| 134 | } |
| 135 | |
| 136 | QueryPlanAndSets 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 | { |
nothing calls this directly
no test coverage detected