mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::db: Simplify internal _read() interface to single Get().
This commit is contained in:
parent
187701bd27
commit
597052e5c0
2 changed files with 7 additions and 40 deletions
44
ircd/db.cc
44
ircd/db.cc
|
@ -7984,7 +7984,7 @@ namespace ircd::db
|
|||
static rocksdb::Status _seek(database::column &, rocksdb::PinnableSlice &, const string_view &, const rocksdb::ReadOptions &);
|
||||
}
|
||||
|
||||
size_t
|
||||
rocksdb::Status
|
||||
ircd::db::_read(column &column,
|
||||
const string_view &key,
|
||||
const rocksdb::ReadOptions &opts,
|
||||
|
@ -7997,11 +7997,14 @@ ircd::db::_read(column &column,
|
|||
};
|
||||
|
||||
database::column &c(column);
|
||||
throw_on_error
|
||||
const rocksdb::Status ret
|
||||
{
|
||||
_seek(c, ps, key, opts)
|
||||
};
|
||||
|
||||
if(!valid(ret))
|
||||
return ret;
|
||||
|
||||
const string_view value
|
||||
{
|
||||
slice(ps)
|
||||
|
@ -8012,42 +8015,7 @@ ircd::db::_read(column &column,
|
|||
|
||||
// triggered when the result was not zero-copy
|
||||
//assert(buf.empty());
|
||||
return size(value);
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::db::_read(std::nothrow_t,
|
||||
column &column,
|
||||
const string_view &key,
|
||||
const rocksdb::ReadOptions &opts,
|
||||
const column::view_closure &closure)
|
||||
{
|
||||
std::string buf;
|
||||
rocksdb::PinnableSlice ps
|
||||
{
|
||||
&buf
|
||||
};
|
||||
|
||||
database::column &c(column);
|
||||
const auto status
|
||||
{
|
||||
_seek(c, ps, key, opts)
|
||||
};
|
||||
|
||||
if(!valid(status))
|
||||
return 0;
|
||||
|
||||
const string_view value
|
||||
{
|
||||
slice(ps)
|
||||
};
|
||||
|
||||
if(likely(closure))
|
||||
closure(value);
|
||||
|
||||
// triggered when the result was not zero-copy
|
||||
//assert(buf.empty());
|
||||
return size(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
rocksdb::Status
|
||||
|
|
|
@ -126,8 +126,7 @@ namespace ircd::db
|
|||
using _read_op = std::tuple<column, string_view>;
|
||||
using _read_closure = std::function<bool (column &, const column::delta &, const rocksdb::Status &)>;
|
||||
bool _read(const vector_view<_read_op> &, const rocksdb::ReadOptions &, const _read_closure & = {});
|
||||
size_t _read(std::nothrow_t, column &, const string_view &key, const rocksdb::ReadOptions &, const column::view_closure & = {});
|
||||
size_t _read(column &, const string_view &key, const rocksdb::ReadOptions &, const column::view_closure & = {});
|
||||
rocksdb::Status _read(column &, const string_view &key, const rocksdb::ReadOptions &, const column::view_closure & = {});
|
||||
|
||||
// [SET] writebatch suite
|
||||
std::string debug(const rocksdb::WriteBatch &);
|
||||
|
|
Loading…
Add table
Reference in a new issue