Пример #1
0
bool DatabaseAdapter_DocMetaData::load( const Index& blockno, MetaDataBlock& blk)
{
	std::string blkstr;
	DatabaseKey dbkey( KeyPrefix, blockno);
	if (!m_database->readValue( dbkey.ptr(), dbkey.size(), blkstr, DatabaseOptions())) return false;
	blk.init( m_descr, blockno, blkstr.c_str(), blkstr.size());
	return true;
}
Пример #2
0
bool DatabaseAdapter_DocMetaData::getBlock( const DatabaseCursorInterface::Slice& key, MetaDataBlock& blk)
{
	if (!key.defined()) return false;
	char const* ki = key.ptr()+1;
	char const* ke = ki + key.size()-1;
	Index blockno = unpackIndex( ki, ke);
	DatabaseCursorInterface::Slice blkslice = m_cursor->value();
	blk.init( m_descr, blockno, blkslice.ptr(), blkslice.size());
	return true;
}
Пример #3
0
void MetaDataMap::getWriteBatch( DatabaseTransactionInterface* transaction, std::vector<Index>& cacheRefreshList)
{
	Map::const_iterator mi = m_map.begin(), me = m_map.end();
	Index blockno = 0;
	MetaDataBlock blk;
	DatabaseAdapter_DocMetaData dbadapter( m_database, m_descr);
	for (; mi != me; ++mi)
	{
		Index docno = mi->first.first;
		Index elemhandle = mi->first.second;

		Index bn = MetaDataBlock::blockno( docno);
		if (bn != blockno)
		{
			if (!blk.empty())
			{
				dbadapter.store( transaction, blk);
			}
			if (dbadapter.load( bn, blk))
			{
				cacheRefreshList.push_back( bn);
			}
			else
			{
				blk.init( m_descr, bn);
			}
			blockno = bn;
		}
		const MetaDataElement* elem = m_descr->get( elemhandle);
		MetaDataRecord record = blk[ MetaDataBlock::index( docno)];
		record.setValue( elem, mi->second);
	}
	if (!blk.empty())
	{
		dbadapter.store( transaction, blk);
	}
}