One can use omap_iterate instead.
The primary goal of this change is to cleanup ObjectStore API
Signed-off-by: Garry Drankovich <garry.drankovich@clyso.com>
case FN_OBJECT_OMAP:
{
set<string> keys;
- fs->store->omap_get_keys(ch, oid, &keys);
+ fs->store->omap_iterate(
+ ch, oid,
+ ObjectStore::omap_iter_seek_t::min_lower_bound(),
+ [&keys]
+ (std::string_view key, std::string_view) mutable {
+ keys.emplace(key);
+ return ObjectStore::omap_iter_ret_t::NEXT;
+ });
unsigned skip = offset;
for (auto k : keys) {
if (skip) {
bool allow_eio = false ///< [in] don't assert on eio
) = 0;
- /// Get keys defined on oid
- virtual int omap_get_keys(
- CollectionHandle &c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- ) = 0;
-
/// Get key values
virtual int omap_get_values(
CollectionHandle &c, ///< [in] Collection containing oid
return r;
}
-int BlueStore::omap_get_keys(
- CollectionHandle &c_, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- set<string> *keys ///< [out] Keys defined on oid
- )
-{
- Collection *c = static_cast<Collection *>(c_.get());
- dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
- if (!c->exists)
- return -ENOENT;
- auto start1 = mono_clock::now();
- std::shared_lock l(c->lock);
- int r = 0;
- OnodeRef o = c->get_onode(oid, false);
- if (!o || !o->exists) {
- r = -ENOENT;
- goto out;
- }
- if (!o->onode.has_omap())
- goto out;
- o->flush();
- {
- const string& prefix = o->get_omap_prefix();
- string head, tail;
- o->get_omap_key(string(), &head);
- o->get_omap_tail(&tail);
- KeyValueDB::Iterator it = db->get_iterator(prefix, 0, KeyValueDB::IteratorBounds{head, tail});
- it->lower_bound(head);
- while (it->valid()) {
- if (it->key() >= tail) {
- dout(30) << __func__ << " reached tail" << dendl;
- break;
- }
- string user_key;
- o->decode_omap_key(it->key(), &user_key);
- dout(20) << __func__ << " got " << pretty_binary_string(it->key())
- << " -> " << user_key << dendl;
- keys->insert(user_key);
- it->next();
- }
- }
- out:
- c->store->log_latency(
- __func__,
- l_bluestore_omap_get_keys_lat,
- mono_clock::now() - start1,
- c->store->cct->_conf->bluestore_log_omap_iterator_age);
-
- dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
- << dendl;
- return r;
-}
-
int BlueStore::omap_get_values(
CollectionHandle &c_, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
bool allow_eio = false ///< [in] don't assert on eio
) override;
- /// Get keys defined on oid
- int omap_get_keys(
- CollectionHandle &c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- ) override;
-
/// Get key values
int omap_get_values(
CollectionHandle &c, ///< [in] Collection containing oid
return r;
}
-int KStore::omap_get_keys(
- CollectionHandle& ch, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- set<string> *keys ///< [out] Keys defined on oid
- )
-{
- dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
- Collection *c = static_cast<Collection*>(ch.get());
- std::shared_lock l{c->lock};
- int r = 0;
- OnodeRef o = c->get_onode(oid, false);
- if (!o || !o->exists) {
- r = -ENOENT;
- goto out;
- }
- if (!o->onode.omap_head)
- goto out;
- o->flush();
- {
- KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
- string head, tail;
- get_omap_key(o->onode.omap_head, string(), &head);
- get_omap_tail(o->onode.omap_head, &tail);
- it->lower_bound(head);
- while (it->valid()) {
- if (it->key() >= tail) {
- dout(30) << __func__ << " reached tail" << dendl;
- break;
- }
- string user_key;
- decode_omap_key(it->key(), &user_key);
- dout(30) << __func__ << " got " << pretty_binary_string(it->key())
- << " -> " << user_key << dendl;
- ceph_assert(it->key() < tail);
- keys->insert(user_key);
- it->next();
- }
- }
- out:
- dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
- return r;
-}
-
int KStore::omap_get_values(
CollectionHandle& ch, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
bool allow_eio = false ///< [in] don't assert on eio
) override;
- using ObjectStore::omap_get_keys;
- /// Get keys defined on oid
- int omap_get_keys(
- CollectionHandle& c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- ) override;
-
using ObjectStore::omap_get_values;
/// Get key values
int omap_get_values(
return 0;
}
-int MemStore::omap_get_keys(
- CollectionHandle& ch, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- )
-{
- dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
- Collection *c = static_cast<Collection*>(ch.get());
- ObjectRef o = c->get_object(oid);
- if (!o)
- return -ENOENT;
- std::lock_guard lock{o->omap_mutex};
- for (auto p = o->omap.begin(); p != o->omap.end(); ++p)
- keys->insert(p->first);
- return 0;
-}
-
int MemStore::omap_get_values(
CollectionHandle& ch, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
bool allow_eio = false ///< [in] don't assert on eio
) override;
- using ObjectStore::omap_get_keys;
- /// Get keys defined on oid
- int omap_get_keys(
- CollectionHandle& c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- ) override;
-
using ObjectStore::omap_get_values;
/// Get key values
int omap_get_values(
) override {
return 0;
}
- int omap_get_keys(CollectionHandle &c, ///< [in] Collection containing oid
- const ghobject_t &oid, ///< [in] Object containing omap
- std::set<std::string> *keys ///< [out] Keys defined on oid
- ) override {
- return 0;
- }
int omap_get_values(CollectionHandle &c, ///< [in] Collection containing oid
const ghobject_t &oid, ///< [in] Object containing omap
const std::set<std::string> &keys, ///< [in] Keys to get
ASSERT_EQ(cur_attrs.size(), size_t(1));
ASSERT_TRUE(bl_eq(bl1, bl3));
- set<string> keys;
- r = store->omap_get_keys(ch, hoid, &keys);
- ASSERT_EQ(r, 0);
- ASSERT_EQ(keys.size(), size_t(1));
}
// test omap_clear, omap_rmkey_range