Esempio n. 1
0
bool DictionaryDatabase::stringCacheLookup(OperationContext &context,
					   DbXmlDbt &dbt, NameID &id) const
{
	nameId_t *nid = 0;
	Transaction *txn = getTxn(context);
	if (txn) {
		DictionaryStringCache *dsc =
			txn->getStringCache(const_cast<DictionaryDatabase*>(this), false);
		if (dsc) {
			nid = dsc->lookup(&dbt);
			if (nid) {
				DbXmlDbt dbt((void *)nid, sizeof(nameId_t));
				id.setThisFromDbtAsId(dbt);
				return true;
			}
		}
	}
	nid = stringCache_.lookup(&dbt);
	if (nid) {
		DbXmlDbt tdbt((void *)nid, sizeof(nameId_t));
		id.setThisFromDbtAsId(tdbt);
		return true;
	}
	return false;
}
Esempio n. 2
0
void DictionaryDatabase::display(OperationContext &context, ostream &out) const
{
	{
	Cursor myCursor(const_cast<PrimaryDatabase&>(*primary_.get()), getTxn(context), CURSOR_READ, 0);
	if(myCursor.error() != 0) throw XmlException(myCursor.error());

	int err = 0;
	NameID id;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		id.setThisFromDbtAsId(context.key());
		Buffer val(context.data().data, context.data().size, true);
		out << id << " -> " << val.asString(true) << endl;
	}
	}
	{
	Cursor myCursor(const_cast<SecondaryDatabase&>(*secondary_.get()), getTxn(context), CURSOR_READ, 0);
	if(myCursor.error() != 0) throw XmlException(myCursor.error());

	int err = 0;
	NameID id;
	while((err = myCursor.get(context.key(), context.data(), DB_NEXT)) == 0) {
		Buffer val(context.key().data, context.key().size, true);
		id.setThisFromDbt(context.data());
		out << val.asString(true) << " -> " << id << endl;
	}
	}
}
Esempio n. 3
0
int PrimaryDatabase::appendPrimary(OperationContext &context, NameID &id,
				   const DbXmlDbt &data, u_int32_t flags)
{
	int err = put(context.txn(), &context.key(), &(const_cast<DbXmlDbt&>(data)),
		      flags | DB_APPEND);
	if (err == 0)
		id.setThisFromDbtAsId(context.key());
	return err;
}