本文整理汇总了C++中StreamType::version方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamType::version方法的具体用法?C++ StreamType::version怎么用?C++ StreamType::version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamType
的用法示例。
在下文中一共展示了StreamType::version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
void DBController::initialize(std::string dataDir) {
if (_logger->isInfo()) _logger->info("DBController initializing. Data dir: %s", dataDir.c_str());
_dataDir = dataDir;
if (_logger->isDebug()) _logger->debug(0, "data dir = %s", _dataDir.c_str());
if (!existDir(_dataDir.c_str())) {
makeDir(_dataDir.c_str());
}
if (!checkFileCreation(_dataDir.c_str())) {
_logger->error("An error ocurred using the data folder: %s. Please check that the user has permissions for writing over that directory. Error: %s", _dataDir.c_str(), lastErrorDescription());
exit(1);
}
StreamManager::getStreamManager()->setDataDir(_dataDir);
StreamManager::getStreamManager()->setInitializing(true);
std::auto_ptr<FileInputStream> fis(new FileInputStream((_dataDir + "djondb.dat").c_str(), "rb"));
while (!fis->eof()) {
std::string* db = fis->readString();
std::string* ns = fis->readString();
int streams = fis->readInt();
for (int x = 0; x < streams; x++) {
FILE_TYPE type = static_cast<FILE_TYPE>(fis->readInt());
StreamType* stream = StreamManager::getStreamManager()->open(db->c_str(), ns->c_str(), type);
if (type == INDEX_FTYPE) {
StreamType* dbstream = StreamManager::getStreamManager()->open(db->c_str(), ns->c_str(), DATA_FTYPE);
std::set<std::string> skeys;
skeys.insert("_id");
IndexAlgorithm* impl = IndexFactory::indexFactory.index(db->c_str(), ns->c_str(), skeys);
// If the database is version lesser than 0.3 then the indexes should
// be migrated to the new format
Version vindex("0.300000000");
if (*dbstream->version() < vindex) {
migrateIndex0_3(db->c_str(), ns->c_str(), stream, impl);
removeFile(stream->fileName().c_str());
((DBFileStream*)dbstream)->updateVersion(&vindex);
}
/*
long currentPos = stream->currentPos();
stream->seek(0);
int records = 0;
while (!stream->eof()) {
BSONObj* obj = readBSON(stream);
if (!impl) {
std::set<std::string> skeys;
for (BSONObj::const_iterator i = obj->begin(); i != obj->end(); i++) {
std::string key = i->first;
skeys.insert(key);
}
}
long indexPos = stream->readLong();
long posData = stream->readLong();
if (obj->has("_id")) {
impl->add(*obj, obj->getDJString("_id"), posData, indexPos);
records++;
}
delete obj;
}
stream->seek(currentPos);
if (_logger->isInfo()) _logger->info("db: %s, ns: %s, Index initialized. Records: %d", db->c_str(), ns->c_str(), records);
*/
}
}
}
fis->close();
StreamManager::getStreamManager()->setInitializing(false);
}