예제 #1
0
파일: RdbIdx.cpp 프로젝트: nightstyles/focp
uint32 CRdbPrefixIndex::DetachRecord(CRecord* pRecord)
{
	CField* pField;
	uint32 nFieldNo = m_pIdxDef->m_pFields[0];

	char* sStr = NULL;
	uint32 nStrLen = 0;

	pField = pRecord->GetField(nFieldNo);
	sStr = pField->GetString(&nStrLen);

	uint64 nRowId = pRecord->m_nRowId;

	if(m_oTree.RemoveNode((const uint8*)sStr, nStrLen, FOCP_NAME::IsEqualRowId, &nRowId))
	{
		uint64 nTreeThis = m_oTree.GetThis();
		if(!nTreeThis)
		{
			uint64 pAddr[2] = {nTreeThis, m_oAllocator.GetThis()};
			vcommit(m_nThis, (char*)pAddr, 16);
		}
		return RDB_SUCCESS;
	}
	return RDB_RECORD_NOT_EXIST;
}
예제 #2
0
파일: RdbIdx.cpp 프로젝트: nightstyles/focp
uint32 CRdbPrefixIndex::AttachRecord(CRecord* pRecord)
{
	CField* pField;
	uint32 nFieldNo = m_pIdxDef->m_pFields[0];
	char* sStr = NULL;
	uint32 nStrLen = 0;
	pField = pRecord->GetField(nFieldNo);
	sStr = pField->GetString(&nStrLen);

	bool bConflict;
	int32 bMemory = 1;
	if(m_pTabDef->m_pBaseAttr->nStorage == RDB_FILE_TABLE)
		bMemory = 0;

	uint64 nNode;
	uint64 nRowId = pRecord->m_nRowId;
	uint64 nTreeThis = m_oTree.GetThis();
	TNTreeNode* pNode = m_oTree.InsertNode((const uint8*)sStr, nStrLen, nRowId, bMemory, nNode, bConflict);
	if(!pNode)
	{
		if(bConflict)
			return RDB_UNIQUE_INDEX_CONFLICT;
		return RDB_LACK_STORAGE;
	}
	m_oTree.ReleaseNode(nNode, pNode);
	uint64 nTreeThis2 = m_oTree.GetThis();
	if(nTreeThis != nTreeThis2)
	{
		uint64 pAddr[2] = {nTreeThis2, m_oAllocator.GetThis()};
		vcommit(m_nThis, (char*)pAddr, 16);
	}
	return RDB_SUCCESS;
}