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

Method executeImpl

programs/disks/CommandReadBitmap.cpp:34–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 }
33
34 void executeImpl(const CommandLineOptions & options, DisksClient & client) override
35 {
36 const auto & disk = client.getCurrentDiskWithPath();
37 String path_from = disk.getRelativeFromRoot(getValueFromCommandLineOptionsThrow<String>(options, "path-from"));
38
39 if (!disk.getDisk()->existsFile(path_from))
40 throw Exception(ErrorCodes::FILE_DOESNT_EXIST,
41 "delete-bitmap file {} does not exist on disk {}", path_from, disk.getDisk()->getName());
42
43 const bool dump_values = options.contains("values");
44
45 const UInt64 file_size = disk.getDisk()->getFileSize(path_from);
46 auto in = disk.getDisk()->readFile(path_from, getReadSettings());
47
48 auto info = inspectDeleteBitmap(*in, dump_values);
49
50 auto & out = std::cout;
51 out << "file: " << path_from << " (" << file_size << " bytes)\n";
52
53 if (!info.header_read)
54 {
55 out.flush();
56 throw Exception(ErrorCodes::CORRUPTED_DATA,
57 "not a delete-bitmap (.rbm) file (truncated: {} bytes, need at least a {}-byte header)",
58 file_size, DeleteBitmap::HEADER_SIZE + DeleteBitmap::CRC_SIZE);
59 }
60
61 if (!info.magic_ok)
62 {
63 out << "magic: BAD\n";
64 out.flush();
65 throw Exception(ErrorCodes::CORRUPTED_DATA, "not a delete-bitmap (.rbm) file (bad magic)");
66 }
67 out << "magic: OK\n";
68
69 out << "version: " << info.version;
70 if (info.version == DeleteBitmap::VERSION_R32)
71 out << " (Roaring32)\n";
72 else if (info.version == DeleteBitmap::VERSION_R64)
73 out << " (Roaring64; body is host-endian, not cross-arch portable)\n";
74 else
75 {
76 /// Unsupported version: the inspector stops before reading the body
77 /// (mirrors deserialize), so there are no stats to print.
78 out << " (UNSUPPORTED)\nbody_size: " << info.body_size << " bytes\n";
79 out.flush();
80 throw Exception(ErrorCodes::UNKNOWN_FORMAT_VERSION,
81 "unsupported delete-bitmap version {} (supported: {} or {})",
82 info.version, DeleteBitmap::VERSION_R32, DeleteBitmap::VERSION_R64);
83 }
84
85 out << "body_size: " << info.body_size << " bytes";
86 if (!info.body_read)
87 out << " (TRUNCATED — fewer bytes on disk than declared)";
88 out << "\n";
89
90 out << "crc: stored=" << fmt::format("{:#010x}", info.crc_stored)
91 << " computed=" << fmt::format("{:#010x}", info.crc_computed) << " -> "

Callers

nothing calls this directly

Calls 13

getReadSettingsFunction · 0.85
inspectDeleteBitmapFunction · 0.85
getRelativeFromRootMethod · 0.80
ExceptionClass · 0.50
formatFunction · 0.50
existsFileMethod · 0.45
getDiskMethod · 0.45
getNameMethod · 0.45
containsMethod · 0.45
getFileSizeMethod · 0.45
readFileMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected