本文整理汇总了C++中StreamType::seek方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamType::seek方法的具体用法?C++ StreamType::seek怎么用?C++ StreamType::seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamType
的用法示例。
在下文中一共展示了StreamType::seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
void DBController::remove(const char* db, const char* ns, const char* documentId, const char* revision, const BSONObj* options) {
if (_logger->isDebug()) _logger->debug(2, "DBController::update db: %s, ns: %s, documentId: %s, revision: %s", db, ns, documentId, revision);
StreamType* streamData = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);
IndexAlgorithm* impl = IndexFactory::indexFactory.index(db, ns, "_id");
BSONObj indexBSON;
indexBSON.add("_id", documentId);
Index* index = impl->find(&indexBSON);
if (index != NULL) {
// TODO check the revision id
StreamType* out = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);
out->flush();
long currentPos = out->currentPos();
out->seek(index->posData);
BSONObj* obj = readBSON(out);
obj->add("_status", 2); // DELETED
// Get back to the record start
out->seek(index->posData);
writeBSON(out, obj);
// restores the last position
out->seek(currentPos);
//std::string id = obj->getDJString("_id");
//CacheManager::objectCache()->remove(id);
delete obj;
}
}
示例2: update
void DBController::update(const char* db, const char* ns, BSONObj* obj, const BSONObj* options) {
if (_logger->isDebug()) _logger->debug(2, "DBController::update ns: %s, bson: %s", ns, obj->toChar());
StreamType* streamData = StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);
Index* index = findIndex(db, ns, obj);
long currentPos = streamData->currentPos();
// Moves to the record to update
streamData->seek(index->posData);
BSONObj* previous = readBSON(streamData);
previous->add("_status", 3); // Updated
streamData->seek(index->posData);
writeBSON(streamData, previous);
// Back to the end of the stream
streamData->seek(currentPos);
updateIndex(db, ns, obj, streamData->currentPos());
obj->add("_status", 1); // Active
writeBSON(streamData, obj);
//std::string id = obj->getDJString("_id");
//CacheManager::objectCache()->add(id, new BSONObj(*obj));
}