Пример #1
0
MojErr MojDbLevelDatabase::get(MojDbLevelItem& key, MojDbStorageTxn* txn, bool forUpdate,
                               MojDbLevelItem& valOut, bool& foundOut)
{
    LOG_TRACE("Entering function %s", __FUNCTION__);
    MojAssert(m_db);
    MojAssert( !txn || dynamic_cast<MojDbLevelAbstractTxn *> (txn) );

    foundOut = false;
    std::string str;

    MojDbLevelAbstractTxn * leveldb_txn = static_cast<MojDbLevelAbstractTxn *> (txn);

    leveldb::Status s;
    if (leveldb_txn)
        s = leveldb_txn->tableTxn(impl()).Get(*key.impl(), str);
    else
        s = m_db->Get(MojDbLevelEngine::getReadOptions(), *key.impl(), &str);

    //MojLdbErrCheck(s, _T("db->get"));

    if(s.IsNotFound() == false)
    {
        foundOut = true;
        valOut.fromBytes(reinterpret_cast<const MojByte*>(str.data()), str.size());
    }

    return MojErrNone;
}