0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 14:31:11 +01:00

ircd:Ⓜ️:room: Pass db get options to the iterations.

This commit is contained in:
Jason Volk 2018-08-21 08:48:42 -07:00
parent c1e135967a
commit a4e1162ae2

View file

@ -883,9 +883,17 @@ const
if(!present()) if(!present())
return m::state::count(root_id); return m::state::count(root_id);
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
size_t ret{0}; size_t ret{0};
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(room_id)}; bool(it); ++it) for(auto it{column.begin(room_id, opts)}; bool(it); ++it)
++ret; ++ret;
return ret; return ret;
@ -904,9 +912,17 @@ const
dbs::room_state_key(keybuf, room_id, type) dbs::room_state_key(keybuf, room_id, type)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
size_t ret{0}; size_t ret{0};
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
if(std::get<0>(dbs::room_state_key(it->first)) == type) if(std::get<0>(dbs::room_state_key(it->first)) == type)
++ret; ++ret;
else else
@ -971,8 +987,16 @@ const
return closure(index(unquote(event_id), std::nothrow)); return closure(index(unquote(event_id), std::nothrow));
}); });
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(room_id)}; bool(it); ++it) for(auto it{column.begin(room_id, opts)}; bool(it); ++it)
if(closure(byte_view<event::idx>(it->second))) if(closure(byte_view<event::idx>(it->second)))
return true; return true;
@ -1044,8 +1068,16 @@ const
dbs::room_state_key(keybuf, room_id, type) dbs::room_state_key(keybuf, room_id, type)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
if(std::get<0>(dbs::room_state_key(it->first)) == type) if(std::get<0>(dbs::room_state_key(it->first)) == type)
{ {
if(closure(byte_view<event::idx>(it->second))) if(closure(byte_view<event::idx>(it->second)))
@ -1075,8 +1107,16 @@ const
dbs::room_state_key(keybuf, room_id, type) dbs::room_state_key(keybuf, room_id, type)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
{ {
const auto part const auto part
{ {
@ -1162,8 +1202,16 @@ const
dbs::room_state_key(keybuf, room_id, type, state_key_lb) dbs::room_state_key(keybuf, room_id, type, state_key_lb)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
if(std::get<0>(dbs::room_state_key(it->first)) == type) if(std::get<0>(dbs::room_state_key(it->first)) == type)
{ {
if(closure(byte_view<event::idx>(it->second))) if(closure(byte_view<event::idx>(it->second)))
@ -1231,8 +1279,16 @@ const
closure(index(unquote(event_id), std::nothrow)); closure(index(unquote(event_id), std::nothrow));
}); });
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(room_id)}; bool(it); ++it) for(auto it{column.begin(room_id, opts)}; bool(it); ++it)
closure(byte_view<event::idx>(it->second)); closure(byte_view<event::idx>(it->second));
} }
@ -1291,8 +1347,16 @@ const
dbs::room_state_key(keybuf, room_id, type) dbs::room_state_key(keybuf, room_id, type)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
if(std::get<0>(dbs::room_state_key(it->first)) == type) if(std::get<0>(dbs::room_state_key(it->first)) == type)
closure(byte_view<event::idx>(it->second)); closure(byte_view<event::idx>(it->second));
else else
@ -1318,8 +1382,16 @@ const
dbs::room_state_key(keybuf, room_id, type) dbs::room_state_key(keybuf, room_id, type)
}; };
db::gopts opts
{
this->fopts? this->fopts->gopts : db::gopts{}
};
if(!opts.readahead)
opts.readahead = 0_KiB;
auto &column{dbs::room_state}; auto &column{dbs::room_state};
for(auto it{column.begin(key)}; bool(it); ++it) for(auto it{column.begin(key, opts)}; bool(it); ++it)
{ {
const auto part const auto part
{ {