added remove().
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@2547 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
5291a25dce
commit
129342b42c
3 changed files with 28 additions and 17 deletions
11
logstore.cpp
11
logstore.cpp
|
@ -437,6 +437,11 @@ datatuple * logtable<TUPLE>::findTuple(int xid, const datatuple::key_t key, size
|
|||
|
||||
rwlc_unlock(header_mut);
|
||||
datatuple::freetuple(search_tuple);
|
||||
if (ret_tuple != NULL && ret_tuple->isDelete()) {
|
||||
// this is a tombstone. don't return it
|
||||
datatuple::freetuple(ret_tuple);
|
||||
return NULL;
|
||||
}
|
||||
return ret_tuple;
|
||||
|
||||
}
|
||||
|
@ -530,6 +535,12 @@ datatuple * logtable<TUPLE>::findTuple_first(int xid, datatuple::key_t key, size
|
|||
|
||||
datatuple::freetuple(search_tuple);
|
||||
|
||||
if (ret_tuple != NULL && ret_tuple->isDelete()) {
|
||||
// this is a tombstone. don't return it
|
||||
datatuple::freetuple(ret_tuple);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret_tuple;
|
||||
|
||||
}
|
||||
|
|
|
@ -246,7 +246,8 @@ get(datatuple* tuple)
|
|||
{
|
||||
// -1 is invalid txn id
|
||||
//return ltable_->findTuple_first(-1, tuple->strippedkey(), tuple->strippedkeylen());
|
||||
return ltable_->findTuple_first(-1, tuple->rawkey(), tuple->rawkeylen());
|
||||
datatuple* tup = ltable_->findTuple_first(-1, tuple->rawkey(), tuple->rawkeylen());
|
||||
return tup;
|
||||
}
|
||||
|
||||
void LSMServerHandler::
|
||||
|
@ -349,7 +350,6 @@ update(const std::string& databaseName,
|
|||
const std::string& recordBody)
|
||||
{
|
||||
uint32_t id = getDatabaseId(databaseName);
|
||||
std::cout << "michim: enter update" << std::endl;
|
||||
if (id == 0) {
|
||||
return sherpa::ResponseCode::DatabaseNotFound;
|
||||
}
|
||||
|
@ -357,7 +357,6 @@ update(const std::string& databaseName,
|
|||
if (oldRecordBody == NULL) {
|
||||
return sherpa::ResponseCode::RecordNotFound;
|
||||
}
|
||||
std::cout << "michim: updating record" << std::endl;
|
||||
datatuple::freetuple(oldRecordBody);
|
||||
datatuple* tup = buildTuple(id, recordName, recordBody);
|
||||
return insert(tup);
|
||||
|
@ -366,22 +365,17 @@ update(const std::string& databaseName,
|
|||
ResponseCode::type LSMServerHandler::
|
||||
remove(const std::string& databaseName, const std::string& recordName)
|
||||
{
|
||||
/*
|
||||
uint32_t id;
|
||||
ResponseCode::type rc = getDatabaseId(databaseName, id);
|
||||
if (rc != sherpa::ResponseCode::Ok) {
|
||||
return rc;
|
||||
uint32_t id = getDatabaseId(databaseName);
|
||||
if (id == 0) {
|
||||
return sherpa::ResponseCode::DatabaseNotFound;
|
||||
}
|
||||
insertDatabaseId(const_cast<std::string&>(recordName), id);
|
||||
Bdb::ResponseCode dbrc = db_[id % numPartitions_]->remove(recordName);
|
||||
if (dbrc == Bdb::Ok) {
|
||||
return sherpa::ResponseCode::Ok;
|
||||
} else if (dbrc == Bdb::KeyNotFound) {
|
||||
datatuple* oldRecordBody = get(id, recordName);
|
||||
if (oldRecordBody == NULL) {
|
||||
return sherpa::ResponseCode::RecordNotFound;
|
||||
} else {
|
||||
}
|
||||
*/
|
||||
return sherpa::ResponseCode::Error;
|
||||
datatuple::freetuple(oldRecordBody);
|
||||
datatuple* tup = buildTuple(id, recordName);
|
||||
return insert(tup);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -103,6 +103,12 @@ int main(int argc, char **argv) {
|
|||
client.get(getResponse, db, "new key");
|
||||
cout << getResponse.responseCode << endl;
|
||||
cout << getResponse.value << endl;
|
||||
|
||||
cout << client.remove(db1, "new key") << endl;
|
||||
client.get(getResponse, db1, "new key");
|
||||
cout << getResponse.responseCode << endl;
|
||||
cout << client.remove(db1, "new key") << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue