예제 #1
0
MojErr MojDbKindState::id(const MojChar* name, const MojChar* objKey, MojDbReq& req, MojObject& idOut, bool& createdOut)
{
	MojAssert(name && objKey);
	MojAssertMutexLocked(m_lock);

	createdOut = false;

	// reload object each time because last update may have been rolled back
	MojObject obj;
	MojRefCountedPtr<MojDbStorageItem> item;
	MojErr err = readIds(objKey, req, obj, item);
	MojErrCheck(err);

	if (!obj.get(name, idOut)) {
		// get next id from seq
		MojDbStorageSeq* seq = m_kindEngine->indexSeq();
		MojAssert(seq);
		MojInt64 id = 0;
		MojErr err = seq->get(id);
		MojErrCheck(err);
		// update copy of id map and write it out
		err = obj.put(name, id);
		MojErrCheck(err);
		err = writeIds(objKey, obj, req, item);
		MojErrCheck(err);
		// update retval
		idOut = id;
		createdOut = true;
	}
	return MojErrNone;
}
예제 #2
0
void DimBuilder::writeOutput(std::ostream& out)
{
    writeHeader(out);
    out << "\n";
    writeIds(out);
    out << "\n";
    writeDescriptions(out);
    out << "\n";
    writeNameToId(out);
    out << "\n";
    writeIdToName(out);
    out << "\n";
    writeTypes(out);
    out << "\n";
    writeFooter(out);
}
예제 #3
0
MojErr MojDbKindState::delIndex(const MojChar* indexName, MojDbReq& req)
{
	MojAssert(indexName);
	MojThreadGuard guard(m_lock);

	MojObject obj;
	MojRefCountedPtr<MojDbStorageItem> item;
	MojErr err = readIds(IndexIdsKey, req, obj, item);
	MojErrCheck(err);
	bool found = false;
	err = obj.del(indexName, found);
    MojErrCheck(err);
	MojAssert(found);
	err = writeIds(IndexIdsKey, obj, req, item);
	MojErrCheck(err);

	return MojErrNone;
}