Skip to content

Commit

Permalink
Add MultiGet back.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangtzh committed Jan 27, 2021
1 parent fb35b5c commit 0ad976a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions ermia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,54 @@ void ConcurrentMasstreeIndex::GetRecord(transaction *t, rc_t &rc, const varstr &
}
}

void ConcurrentMasstreeIndex::GetRecordMulti(transaction *t, rc_t &rc, const varstr &key,
std::vector<varstr> &result_vec, std::vector<OID> *out_oid) {
rc = {RC_INVALID};
OID dir_oid = INVALID_OID;
std::vector<OID> oids;
ermia::varstr tmpval;
if (!t) {
auto e = MM::epoch_enter();
rc._val = masstree_.search(key, dir_oid, e, nullptr) ? RC_TRUE : RC_FALSE;
MM::epoch_exit(0, e);
} else {
t->ensure_active();
bool found = masstree_.search(key, dir_oid, t->xc->begin_epoch, nullptr);
dbtuple *tuple = nullptr;
if (found) {
LOG_IF(FATAL, config::is_backup_srv()) << "GetRecordMulti is not supportted for backup server";
bool ok = oidmgr->oid_get_dir(table_descriptor->GetTupleArray(), dir_oid, oids);
ALWAYS_ASSERT(ok);
for (auto &o : oids) {
tuple = oidmgr->oid_get_version(table_descriptor->GetTupleArray(), o, t->xc);
if (!tuple) {
DLOG(WARNING) << "(SKIPPED) Some tuple is empty: OID = " << std::hex << o;
found = false;
}

if (found) {
bool ret = t->DoTupleRead(tuple, &tmpval)._val;
if (!ret) {
DLOG(WARNING) << "(SKIPPED) Cannot do tuple read for OID = " << std::hex << o;
continue;
}
result_vec.push_back(tmpval);
} else if (config::phantom_prot) {
// volatile_write(rc._val, DoNodeRead(t, sinfo.first, sinfo.second)._val);
} else {
continue;
}
}
volatile_write(rc._val, RC_TRUE);
return;
} else {
volatile_write(rc._val, RC_FALSE);
return;
}
}
}


void ConcurrentMasstreeIndex::PurgeTreeWalker::on_node_begin(
const typename ConcurrentMasstree::node_opaque_t *n) {
ASSERT(spec_values.empty());
Expand Down
2 changes: 2 additions & 0 deletions ermia.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class ConcurrentMasstreeIndex : public OrderedIndex {

virtual void GetRecord(transaction *t, rc_t &rc, const varstr &key, varstr &value,
OID *out_oid = nullptr) override;
virtual void GetRecordMulti(transaction *t, rc_t &rc, const varstr &key, std::vector<varstr> &value,
std::vector<OID> *oids = nullptr);

rc_t UpdateRecord(transaction *t, const varstr &key, varstr &value) override;
rc_t InsertRecord(transaction *t, const varstr &key, varstr &value, OID *out_oid = nullptr) override;
Expand Down

0 comments on commit 0ad976a

Please sign in to comment.