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

Method executeImpl

programs/disks/CommandRead.cpp:24–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24 void executeImpl(const CommandLineOptions & options, DisksClient & client) override
25 {
26 const auto & disk = client.getCurrentDiskWithPath();
27 String path_from = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path-from"));
28 std::optional<String> path_to = getValueFromCommandLineOptionsWithOptional<String>(options, "path-to");
29
30 auto in = disk.getDisk()->readFile(path_from, getReadSettings());
31 std::unique_ptr<WriteBufferFromFileBase> out = {};
32 if (path_to.has_value())
33 {
34 String relative_path_to = disk.getRelativeFromRoot(path_to.value());
35 out = disk.getDisk()->writeFile(relative_path_to);
36 LOG_INFO(log, "Writing file from '{}' to '{}' at disk '{}'", path_from, path_to.value(), disk.getDisk()->getName());
37 copyData(*in, *out);
38 }
39 else
40 {
41 out = std::make_unique<WriteBufferFromFileDescriptor>(STDOUT_FILENO);
42 LOG_INFO(log, "Writing file from '{}' to 'stdout' at disk '{}'", path_from, disk.getDisk()->getName());
43 copyData(*in, *out);
44 out->write('\n');
45 }
46 out->finalize();
47 }
48};
49
50CommandPtr makeCommandRead()

Callers

nothing calls this directly

Calls 10

getReadSettingsFunction · 0.85
copyDataFunction · 0.85
getRelativeFromRootMethod · 0.80
readFileMethod · 0.45
getDiskMethod · 0.45
valueMethod · 0.45
writeFileMethod · 0.45
getNameMethod · 0.45
writeMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected