Skip to content

Commit 0ad976a

Browse files
committed
Add MultiGet back.
1 parent fb35b5c commit 0ad976a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

ermia.cc

+48
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,54 @@ void ConcurrentMasstreeIndex::GetRecord(transaction *t, rc_t &rc, const varstr &
199199
}
200200
}
201201

202+
void ConcurrentMasstreeIndex::GetRecordMulti(transaction *t, rc_t &rc, const varstr &key,
203+
std::vector<varstr> &result_vec, std::vector<OID> *out_oid) {
204+
rc = {RC_INVALID};
205+
OID dir_oid = INVALID_OID;
206+
std::vector<OID> oids;
207+
ermia::varstr tmpval;
208+
if (!t) {
209+
auto e = MM::epoch_enter();
210+
rc._val = masstree_.search(key, dir_oid, e, nullptr) ? RC_TRUE : RC_FALSE;
211+
MM::epoch_exit(0, e);
212+
} else {
213+
t->ensure_active();
214+
bool found = masstree_.search(key, dir_oid, t->xc->begin_epoch, nullptr);
215+
dbtuple *tuple = nullptr;
216+
if (found) {
217+
LOG_IF(FATAL, config::is_backup_srv()) << "GetRecordMulti is not supportted for backup server";
218+
bool ok = oidmgr->oid_get_dir(table_descriptor->GetTupleArray(), dir_oid, oids);
219+
ALWAYS_ASSERT(ok);
220+
for (auto &o : oids) {
221+
tuple = oidmgr->oid_get_version(table_descriptor->GetTupleArray(), o, t->xc);
222+
if (!tuple) {
223+
DLOG(WARNING) << "(SKIPPED) Some tuple is empty: OID = " << std::hex << o;
224+
found = false;
225+
}
226+
227+
if (found) {
228+
bool ret = t->DoTupleRead(tuple, &tmpval)._val;
229+
if (!ret) {
230+
DLOG(WARNING) << "(SKIPPED) Cannot do tuple read for OID = " << std::hex << o;
231+
continue;
232+
}
233+
result_vec.push_back(tmpval);
234+
} else if (config::phantom_prot) {
235+
// volatile_write(rc._val, DoNodeRead(t, sinfo.first, sinfo.second)._val);
236+
} else {
237+
continue;
238+
}
239+
}
240+
volatile_write(rc._val, RC_TRUE);
241+
return;
242+
} else {
243+
volatile_write(rc._val, RC_FALSE);
244+
return;
245+
}
246+
}
247+
}
248+
249+
202250
void ConcurrentMasstreeIndex::PurgeTreeWalker::on_node_begin(
203251
const typename ConcurrentMasstree::node_opaque_t *n) {
204252
ASSERT(spec_values.empty());

ermia.h

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class ConcurrentMasstreeIndex : public OrderedIndex {
146146

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

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

0 commit comments

Comments
 (0)