当前位置: 首页>>代码示例>>C++>>正文


C++ StreamType::version方法代码示例

本文整理汇总了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);
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:75,代码来源:dbcontroller.cpp


注:本文中的StreamType::version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。