MCPcopy Create free account
hub / github.com/Kitware/VTK / checkConsistency

Method checkConsistency

ThirdParty/libproj/vtklibproj/src/networkfilemanager.cpp:388–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386#define INVALIDATED_SQL_LITERAL "'invalidated'"
387
388bool DiskChunkCache::checkConsistency() {
389
390 auto stmt = prepare("SELECT * FROM chunk_data WHERE id NOT IN (SELECT "
391 "data_id FROM chunks)");
392 if (!stmt) {
393 return false;
394 }
395 if (stmt->execute() != SQLITE_DONE) {
396 fprintf(stderr, "Rows in chunk_data not referenced by chunks.\n");
397 return false;
398 }
399
400 stmt = prepare("SELECT * FROM chunks WHERE id NOT IN (SELECT chunk_id FROM "
401 "linked_chunks)");
402 if (!stmt) {
403 return false;
404 }
405 if (stmt->execute() != SQLITE_DONE) {
406 fprintf(stderr, "Rows in chunks not referenced by linked_chunks.\n");
407 return false;
408 }
409
410 stmt = prepare("SELECT * FROM chunks WHERE url <> " INVALIDATED_SQL_LITERAL
411 " AND url "
412 "NOT IN (SELECT url FROM properties)");
413 if (!stmt) {
414 return false;
415 }
416 if (stmt->execute() != SQLITE_DONE) {
417 fprintf(stderr, "url values in chunks not referenced by properties.\n");
418 return false;
419 }
420
421 stmt = prepare("SELECT head, tail FROM linked_chunks_head_tail");
422 if (!stmt) {
423 return false;
424 }
425 if (stmt->execute() != SQLITE_ROW) {
426 fprintf(stderr, "linked_chunks_head_tail empty.\n");
427 return false;
428 }
429 const auto head = stmt->getInt64();
430 const auto tail = stmt->getInt64();
431 if (stmt->execute() != SQLITE_DONE) {
432 fprintf(stderr, "linked_chunks_head_tail has more than one row.\n");
433 return false;
434 }
435
436 stmt = prepare("SELECT COUNT(*) FROM linked_chunks");
437 if (!stmt) {
438 return false;
439 }
440 if (stmt->execute() != SQLITE_ROW) {
441 fprintf(stderr, "linked_chunks_head_tail empty.\n");
442 return false;
443 }
444 const auto count_linked_chunks = stmt->getInt64();
445

Callers

nothing calls this directly

Calls 9

fprintfFunction · 0.85
getInt64Method · 0.80
bindInt64Method · 0.80
executeMethod · 0.45
insertMethod · 0.45
resetMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected