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


C++ MojDbReq类代码示例

本文整理汇总了C++中MojDbReq的典型用法代码示例。如果您正苦于以下问题:C++ MojDbReq类的具体用法?C++ MojDbReq怎么用?C++ MojDbReq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MojDbReq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST_F

TEST_F(ReqSuite, deleteUpdateRollback)
{
    buildSample();
    mark1();

    {
        MojDbReq req;
        // start transaction
        req.begin(&db, false);

        checkMarkWithUpdate(50ul, -1, req);
        checkMarkWithUpdate(0ul, -3, req);

        deleteMark(50ul, -1, req);

        checkMarkWithUpdate(0ul, -1, req);
        checkMarkWithUpdate(0ul, -3, req);

        mark3(req);

        checkMarkWithUpdate(0ul, -1, req);
        checkMarkWithUpdate(33ul, -3, req);

    }
    checkMarkWithUpdate(50ul, -1);
    checkMarkWithUpdate(0ul, -3);
}
开发者ID:KyleMaas,项目名称:db8,代码行数:27,代码来源:ReqTest.cpp

示例2: MojAssert

MojErr MojDb::updateLocale(const MojChar* locale, MojDbReqRef req)
{
	MojAssert(locale);
	MojLogTrace(s_log);

	MojErr err = beginReq(req, true);
	MojErrCheck(err);
	MojString oldLocale;
	err = getLocale(oldLocale, req);
	MojErrCheck(err);
	MojString newLocale;
	err = newLocale.assign(locale);
	MojErrCheck(err);
	MojErr updateErr = err = updateLocaleImpl(oldLocale, newLocale, req);
	MojErrCatchAll(err) {
		err = req->abort();
		MojErrCheck(err);
		err = m_kindEngine.close();
		MojErrCheck(err);
		MojDbReq openReq;
		err = beginReq(openReq, true);
		MojErrCheck(err);
		err = m_kindEngine.open(this, openReq);
		MojErrCheck(err);
		err = openReq.end();
		MojErrCheck(err);
		MojErrThrow(updateErr);
	}
	return MojErrNone;
}
开发者ID:feniksa,项目名称:indb8,代码行数:30,代码来源:MojDbAdmin.cpp

示例3: delObj

MojErr MojDb::delObj(const MojObject& id, const MojObject& obj, MojDbStorageItem* item, MojObject& foundObjOut, MojDbReq& req, MojUInt32 flags)
{
	MojAssert(item);
	MojLogTrace(s_log);

	if (MojFlagGet(flags, FlagPurge)) {
		// update indexes
		MojTokenSet tokenSet;
		// we want purge to force delete
		req.fixmode(true);
		MojErr err = m_kindEngine.update(NULL, &obj, req, OpDelete, tokenSet);
		MojErrCheck(err);
		// gross layering violation
		err = req.txn()->offsetQuota(-(MojInt64) item->size());
		MojErrCheck(err);
		// permanently delete
		bool found = false;
		err = m_objDb->del(id, req.txn(), found);
		MojErrCheck(err);
		if (!found)
			MojErrThrow(MojErrDbCorruptDatabase);
		err = foundObjOut.put(IdKey, id);
		MojErrCheck(err);
	} else {
		// set deleted flag and put if we are not purging
		MojObject newObj = obj;
		MojErr err = newObj.putBool(DelKey, true);
		MojErrCheck(err);
		err = putObj(id, newObj, &obj, item, req, OpDelete);
		MojErrCheck(err);
		foundObjOut = newObj;
	}
	return MojErrNone;
}
开发者ID:KyleMaas,项目名称:db8,代码行数:34,代码来源:MojDb.cpp

示例4: find

MojErr MojDbIndex::find(MojDbCursor& cursor, MojDbWatcher* watcher, MojDbReq& req)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(isOpen());

	MojAutoPtr<MojDbQueryPlan> plan(new MojDbQueryPlan(*m_kindEngine));
	MojAllocCheck(plan.get());
	MojErr err = plan->init(cursor.query(), *this);
	MojErrCheck(err);
	if (watcher) {
		// we have to add the watch before beginning the txn or we may miss events
		MojAssert(cursor.txn() == NULL);
		err = addWatch(*plan, cursor, watcher, req);
		MojErrCheck(err);
	}
	if (!cursor.txn()) {
		MojDbStorageTxn* txn = req.txn();
		bool cursorOwnsTxn = !(req.batch() || txn);
		if (txn) {
			cursor.txn(txn, cursorOwnsTxn);
		} else {
			MojRefCountedPtr<MojDbStorageTxn> localTxn;
			err = m_collection->beginTxn(localTxn);
			MojErrCheck(err);
			cursor.txn(localTxn.get(), cursorOwnsTxn);
			req.txn(localTxn.get());
		}
	}
	cursor.m_dbIndex = this;	// for debugging
	err = m_collection->find(plan, cursor.txn(), cursor.m_storageQuery);
	MojErrCheck(err);
	cursor.m_watcher = watcher;
	
	return MojErrNone;
}
开发者ID:sailesharya,项目名称:db8,代码行数:35,代码来源:MojDbIndex.cpp

示例5: addWatch

MojErr MojDbIndex::addWatch(const MojDbQueryPlan& plan, MojDbCursor& cursor, MojDbWatcher* watcher, MojDbReq& req)
{
	MojAssert(watcher);
	MojLogTrace(s_log);

	// TODO: use interval tree instead of vector for watches
	MojThreadWriteGuard guard(m_lock);
	MojErr err = m_watcherVec.push(watcher);
	MojErrCheck(err);
	// update count map
	watcher->domain(req.domain());
	WatcherMap::Iterator iter;
	err = m_watcherMap.find(req.domain(), iter);
	MojErrCheck(err);
	if (iter == m_watcherMap.end()) {
		err = m_watcherMap.put(req.domain(), 1);
		MojErrCheck(err);
	} else {
		iter.value() += 1;
		if (iter.value() > WatchWarningThreshold) {
			MojLogWarning(s_log, _T("db:'%s' has %zd watches open on index '%s - %s'"),
					req.domain().data(), iter.value(), m_kind->id().data(), m_name.data());
		}
	}
	MojLogInfo(s_log, _T("DbIndex_addWatch - '%s' on index '%s - %s'"),
					req.domain().data(),  m_kind->id().data(), m_name.data());
	// drop lock before acquiring watcher mutex in init
	guard.unlock();
	watcher->init(this, plan.ranges(), plan.desc(), false);

	return MojErrNone;
}
开发者ID:KyleMaas,项目名称:db8,代码行数:32,代码来源:MojDbIndex.cpp

示例6: updateLocale

MojErr MojDbIndex::updateLocale(const MojChar* locale, MojDbReq& req)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(isOpen());
	MojAssert(locale);

	bool haveCollate = false;
	for (PropVec::ConstIterator i = m_props.begin(); i != m_props.end(); ++i) {
       if ((*i)->collation() != MojDbCollationInvalid) {
			haveCollate = true;
			MojErr err = (*i)->updateLocale(locale);
			MojErrCheck(err);
       }
	}
	if (haveCollate) {
		// drop and reindex
		MojErr err = drop(req);
		MojErrCheck(err);
		err = build(req.txn());
		MojErrCheck(err);
	}
    m_locale.assign(locale);
    
	return MojErrNone;
}
开发者ID:sailesharya,项目名称:db8,代码行数:25,代码来源:MojDbIndex.cpp

示例7: writeIds

MojErr MojDbKindState::writeIds(const MojChar* key, const MojObject& obj, MojDbReq& req, MojRefCountedPtr<MojDbStorageItem>& oldItem)
{
	MojErr err = writeObj(key, obj, m_kindEngine->indexIdDb(), req.txn(), oldItem);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:feniksa,项目名称:indb8,代码行数:7,代码来源:MojDbKindState.cpp

示例8: stats

MojErr MojDbIndex::stats(MojObject& objOut, MojSize& usageOut, MojDbReq& req)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(isOpen());
	
	MojSize count = 0;
	MojSize size = 0;
	MojErr err = m_index->stats(req.txn(), count, size);

    LOG_DEBUG("[db_mojodb] IndexStats: Kind: %s;Index: %s; Id: %zX; count= %zu; size= %zu; delMisses = %d, err= %d \n",
        m_kind->name().data(), m_name.data(), idIndex(), count, size, m_delMisses, err);

	MojErrCheck(err);
	usageOut += size;

	err = objOut.put(SizeKey, (MojInt64) size);
	MojErrCheck(err);
	err = objOut.put(CountKey, (MojInt64) count);
	MojErrCheck(err);
	err = objOut.put(DelMissesKey, (MojInt64) m_delMisses); // cumulative since start
	MojErrCheck(err);

	MojThreadReadGuard guard(m_lock);
	if (!m_watcherMap.empty()) {
		MojObject watcherInfo;
		for (WatcherMap::ConstIterator i = m_watcherMap.begin(); i != m_watcherMap.end(); ++i) {
			err = watcherInfo.put(i.key(), (MojInt64) i.value());
			MojErrCheck(err);
		}
		err = objOut.put(WatchesKey, watcherInfo);
		MojErrCheck(err);
	}
	return MojErrNone;
}
开发者ID:sailesharya,项目名称:db8,代码行数:34,代码来源:MojDbIndex.cpp

示例9: open

MojErr MojDbIndex::open(MojDbStorageIndex* index, const MojObject& id, MojDbReq& req, bool created)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
	MojAssert(!isOpen() && !m_props.empty());
	MojAssert(index);

	// we don't want to take built-in props into account when sorting indexes,
	m_sortKey = m_propNames;
	m_id = id;

	MojDbKey idKey;
	MojErr err = idKey.assign(id);
	MojErrCheck(err);
	err = m_idSet.put(idKey);
	MojErrCheck(err);
	err = addBuiltinProps();
	MojErrCheck(err);

	if (created && !isIdIndex()) {
		// if this index was just created, we need to re-index before committing the transaction
		MojDbStorageTxn* txn = req.txn();
		txn->notifyPreCommit(m_preCommitSlot);
		txn->notifyPostCommit(m_postCommitSlot);
	} else {
		// otherwise it's ready
		m_ready = true;
	}
	// and we're open
	m_index.reset(index);
	m_collection = m_index.get();

	return MojErrNone;
}
开发者ID:sailesharya,项目名称:db8,代码行数:33,代码来源:MojDbIndex.cpp

示例10: readIds

MojErr MojDbKindState::readIds(const MojChar* key, MojDbReq& req, MojObject& objOut, MojRefCountedPtr<MojDbStorageItem>& itemOut)
{
	MojErr err = readObj(key, objOut, m_kindEngine->indexIdDb(), req.txn(), itemOut);
	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:feniksa,项目名称:indb8,代码行数:7,代码来源:MojDbKindState.cpp

示例11: updateOwnIndexes

MojErr MojDbKind::updateOwnIndexes(const MojObject* newObj, const MojObject* oldObj, const MojDbReq& req, MojInt32& idxcount)
{
	
	MojInt32 count = 0;

	for (IndexVec::ConstIterator i = m_indexes.begin();
		 i != m_indexes.end(); ++i) {
		count++;
		MojErr err = (*i)->update(newObj, oldObj, req.txn(), req.fixmode());
		MojErrCheck(err);
	}
	MojLogInfo(s_log, _T("Kind_UpdateOwnIndexes: %s; count: %d \n"), this->id().data(), count);
	
	idxcount += count;
	return MojErrNone;
}
开发者ID:webOS101,项目名称:db8,代码行数:16,代码来源:MojDbKind.cpp

示例12: update

MojErr MojDbKind::update(MojObject* newObj, const MojObject* oldObj, MojDbOp op, MojDbReq& req, bool checkSchema)
{
	MojLogTrace(s_log);

	MojErr err = checkPermission(op, req);
	MojErrCheck(err);
	err = req.curKind(this);
	MojErrCheck(err);

#if defined(TESTDBKIND)
	MojString s;
	MojErr e2;
	
	if (oldObj) {
		e2 = oldObj->toJson(s);
		MojLogInfo(s_log, _T("Kind_Update_OldObj: %s ;\n"), s.data());
	}
	if (newObj) {
		e2 = newObj->toJson(s);
		MojLogInfo(s_log, _T("Kind_Update_NewObj: %s ;\n"), s.data());
	}
#endif
	if (newObj) {
		// add the _backup property if not set
		if (m_backup && !newObj->contains(MojDb::SyncKey)) {
			err = newObj->putBool(MojDb::SyncKey, true);
			MojErrCheck(err);
		}

		// TEMPORARY!!! This should be done in pre-update to also check parent kinds
        	// warning message comes from preUpdate
		if(checkSchema)
		{
		   
		   MojSchema::Result res;
		   err = m_schema.validate(*newObj, res);
		   MojErrCheck(err);
		   if (!res.valid())
		   {
		      MojErrThrowMsg(MojErrSchemaValidation, _T("schema validation failed for kind '%s': %s"),
		                     m_id.data(), res.msg().data());
		   }
		}
        
	}

	// update revSets and validate schema
	err = preUpdate(newObj, oldObj, req);
	MojErrCheck(err);
	// update indexes
	MojVector<MojDbKind*> kindVec;
	MojInt32 idxcount = 0;
	err = updateIndexes(newObj, oldObj, req, op, kindVec, idxcount);
	MojLogInfo(s_log, _T("Kind_UpdateIndexes_End: %s; supers = %zu; indexcount = %zu; updated = %d \n"), this->id().data(), 
				m_supers.size(), m_indexes.size(), idxcount);

	MojErrCheck(err);

	return MojErrNone;
}
开发者ID:webOS101,项目名称:db8,代码行数:60,代码来源:MojDbKind.cpp

示例13: initUsage

MojErr MojDbQuotaEngine::initUsage(MojDbKind* kind, MojDbReq& req)
{
	MojAssert(kind);

	MojRefCountedPtr<MojDbStorageItem> item;
	MojErr err = m_usageDb->get(kind->id(), req.txn(), false, item);
	MojErrCheck(err);
	if (!item.get()) {
		MojObject stats;
		MojSize usage = 0;
		err = kind->stats(stats, usage, req, false);
		MojErrCheck(err);
		err = insertUsage(kind->id(), (MojInt64) usage, req.txn());
		MojErrCheck(err);
	}
	return MojErrNone;
}
开发者ID:anttiharju-owo,项目名称:db8,代码行数:17,代码来源:MojDbQuotaEngine.cpp

示例14: deny

MojErr MojDbKind::deny(MojDbReq& req)
{
	MojLogWarning(s_log, _T("db: permission denied for caller '%s' on kind '%s'"), req.domain().data(), m_id.data());
	if (m_kindEngine->permissionEngine()->enabled()) {
		// don't leak any information in an error message
		MojErrThrow(MojErrDbPermissionDenied);
	}
	return MojErrNone;
}
开发者ID:webOS101,项目名称:db8,代码行数:9,代码来源:MojDbKind.cpp

示例15: objectPermission

MojDbPermissionEngine::Value MojDbKind::objectPermission(const MojChar* op, MojDbReq& req)
{
	MojDbPermissionEngine::Value val = m_kindEngine->permissionEngine()->
			check(PermissionType, m_id, req.domain(), op);
	if (val == MojDbPermissionEngine::ValueUndefined && !m_supers.empty()) {
		val = m_supers[0]->objectPermission(op, req);
	}
	return val;
}
开发者ID:webOS101,项目名称:db8,代码行数:9,代码来源:MojDbKind.cpp


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