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

Method initialize

programs/keeper-bench/Generator.cpp:191–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void PathGetter::initialize(const ListChildrenFn & list_children, const TaggedPaths * tagged_paths)
192{
193 if (!parent_paths.empty() && !list_children)
194 throw DB::Exception(
195 DB::ErrorCodes::BAD_ARGUMENTS,
196 "`children_of` paths requested but no list callback provided to PathGetter");
197
198 for (const auto & parent_path : parent_paths)
199 {
200 for (const auto & child : list_children(parent_path))
201 paths.push_back(std::filesystem::path(parent_path) / child);
202 }
203
204 for (const auto & tag_name : tag_names)
205 {
206 if (!tagged_paths)
207 throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Tag '{}' referenced but no tagged paths available (is setup missing?)", tag_name);
208
209 auto it = tagged_paths->find(tag_name);
210 if (it == tagged_paths->end())
211 throw DB::Exception(
212 DB::ErrorCodes::BAD_ARGUMENTS,
213 "Tag '{}' not found in setup. Available tags: {}",
214 tag_name,
215 tagged_paths->empty() ? "(none)" : fmt::to_string(fmt::join(*tagged_paths | std::views::keys, ", ")));
216
217 for (const auto & path : it->second)
218 paths.push_back(path);
219 }
220
221 if (paths.empty())
222 throw DB::Exception(
223 DB::ErrorCodes::BAD_ARGUMENTS,
224 "PathGetter has no paths after initialization. "
225 "Check that children_of targets have children, tagged nodes exist, or add explicit path entries");
226
227 path_picker = std::uniform_int_distribution<size_t>(0, paths.size() - 1);
228 initialized = true;
229}
230
231std::string PathGetter::getPath() const
232{

Callers 1

startupImplMethod · 0.45

Calls 7

ExceptionClass · 0.50
to_stringFunction · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected