static void verify_or_upgrade_db_descriptor(DB *db, const Descriptor &descriptor, const bool hot_index) { const DBT *desc = &db->cmp_descriptor->dbt; verify(desc->data != NULL && desc->size >= 4); if (desc->size == 4) { // existing descriptor is from before descriptors were even versioned. // it's only an ordering. make sure it matches, then upgrade. const Ordering &ordering(*reinterpret_cast<const Ordering *>(desc->data)); const Ordering &expected(descriptor.ordering()); verify(memcmp(&ordering, &expected, 4) == 0); set_db_descriptor(db, descriptor, hot_index); } else { const Descriptor existing(reinterpret_cast<const char *>(desc->data), desc->size); if (existing.version() < descriptor.version()) { // existing descriptor is out-dated. upgrade to the current version. set_db_descriptor(db, descriptor, hot_index); } else if (existing.version() > descriptor.version()) { problem() << "Detected a \"dictionary descriptor\" version that is too new: " << existing.version() << ". The highest known version is " << descriptor.version() << "This data may have already been upgraded by a newer version of " << "TokuMX and is now no longer usable by this version." << endl << endl << "The assertion failure you are about to see is intentional." << endl; verify(false); } else { // same version, ensure the contents of the descriptor are correct verify(existing == descriptor); } } }