Example #1
0
/*
 *
 * Adds an entry to the table by ref, then rev
 *
 */
int addPDFObjEntry (ObjTableEntry *entry) {

    uint32_t index;
	ObjTableEntry *temp;

	index = hashObj(entry);

	if (table[index] == NULL) {
		table[index] = entry;
	}
	else {
        temp = table[index];
	
	    if (temp->refnum == entry->refnum && temp->revnum == entry->revnum) {
		    foxLog(NONFATAL, "%s: Entry already exists with that ref/rev.\n", __func__);
		    return 0;
	    }

		while (temp->next != NULL) {
            temp = temp->next;

            if (temp->refnum == entry->refnum && temp->revnum == entry->revnum) {
                foxLog(NONFATAL, "%s: Entry already exists with that ref/rev.\n", __func__);
                return 0;
            }   
		}
 
        temp->next = entry;
	}

    return 1;

}
const int BlockRequestProcessor::getBlock(const BRM::LBID_t& lbid, const BRM::QueryContext &ver, BRM::VER_t txn,
		int compType, void* bufferPtr, bool vbFlg, bool &wasCached, bool *versioned, bool insertIntoCache,
		bool readFromCache)
{
	if (readFromCache) {
		HashObject_t hashObj(lbid, ver.currentScn, 0);
		wasCached = fbMgr.find(hashObj, bufferPtr);
		if (wasCached)
			return 1;
	}

	wasCached = false;
	fileRequest rqstBlk(lbid, ver, vbFlg, txn, compType, (uint8_t *) bufferPtr, insertIntoCache);
	check(rqstBlk);
	if (rqstBlk.RequestStatus() == fileRequest::BRM_LOOKUP_ERROR)
	{
		ostringstream os;
		os << "BRP::getBlock(): got a BRM lookup error.  LBID=" << lbid << " ver=" << ver << " txn="
		<< txn << " vbFlg=" << (int) vbFlg;
		primitiveprocessor::Logger logger;
		logger.logMessage(os.str(), false);
		throw logging::IDBExcept(logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_BRM_LOOKUP), logging::ERR_BRM_LOOKUP);
	}
	else if (rqstBlk.RequestStatus() == fileRequest::FS_EINVAL)
	{
		throw logging::IDBExcept(logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_O_DIRECT),
								 logging::ERR_O_DIRECT);
	}
	else if (rqstBlk.RequestStatus() == fileRequest::FS_ENOENT)
	{
		throw logging::IDBExcept(
			logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_ENOENT),
			logging::ERR_ENOENT);
	}
	else if (rqstBlk.RequestStatus() != fileRequest::SUCCESSFUL) {
		throw runtime_error(rqstBlk.RequestStatusStr());
	}
	if (versioned)
		*versioned = rqstBlk.versioned();
	return 1;
}