MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / recognize_data_file

Function recognize_data_file

tools/comdb2ar/file_info.cpp:271–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269
270
271bool recognize_data_file(const std::string& filename,
272 bool& is_data_file, bool& is_queue_file, bool& is_queuedb_file,
273 std::string& out_table_name)
274// Determine if the given filename looks like a table or queue file. If it does
275// then return true and set the is_ flags appropriately, and put the name of the
276// object in out_table_name.
277{
278 size_t dot_pos = filename.find_first_of('.');
279 if(dot_pos == std::string::npos) {
280 return false;
281 }
282 const std::string ext(filename.substr(dot_pos + 1));
283
284 // queues are the same whether we are llmeta or not
285 if(ext == "queue") {
286 is_queue_file = true;
287 out_table_name = filename.substr(0, dot_pos);
288 return true;
289 }
290 if (ext == "queuedb") {
291 is_queuedb_file = true;
292 out_table_name = filename.substr(0, dot_pos);
293 return true;
294 }
295
296 // comdb2 seems to use metalite.dta even in llmeta mode..
297 // copy it to stop it trying to create them on startup.
298 // Same seems to apply to things like freerec; conversion to llmeta
299 // mode doesn't kill off all these exotic file types so occasionally
300 // you come across a db that requires them.
301 if(ext == "metalite.dta" ||
302 ext == "freerec" ||
303 ext == "freerecq" ||
304 ext == "meta.dta" ||
305 ext == "meta.ix0" ||
306 ext == "meta.freerec")
307 {
308 out_table_name = filename.substr(0, dot_pos);
309 is_data_file = true;
310 return true;
311 }
312
313 // Look for *.data*, *.index and *.blob*
314 // Also strip out the 16 digit hex suffix that comes after the table
315 // name.
316 if(dot_pos > 17 && filename[dot_pos-17] == '_' &&
317 (ext == "index" ||
318 ext.compare(0, 4, "data") == 0 ||
319 ext.compare(0, 4, "blob") == 0)) {
320 out_table_name = filename.substr(0, dot_pos - 17);
321 is_data_file = true;
322 return true;
323 }
324 return false;
325}

Callers 4

serialise_databaseFunction · 0.85
create_partialsFunction · 0.85
deserialise_databaseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected