use collection_list_impl as well.
Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
if (start.is_max())
return 0;
+ ghobject_t temp_next;
+ if (!next)
+ next = &temp_next;
// figure out the pool id. we need this in order to generate a
// meaningful 'next' value.
int64_t pool = -1;
return 0;
}
-int FileStore::collection_list(coll_t c, vector<ghobject_t>& ls)
-{
- tracepoint(objectstore, collection_list_enter, c.c_str());
-
- if (!c.is_temp() && !c.is_meta()) {
- coll_t temp = c.get_temp();
- int r = collection_list(temp, ls);
- if (r < 0)
- return r;
- }
-
- Index index;
- int r = get_index(c, &index);
- if (r < 0)
- return r;
-
- assert(NULL != index.index);
- RWLock::RLocker l((index.index)->access_lock);
-
- r = index->collection_list(&ls);
- assert(!m_filestore_fail_eio || r != -EIO);
- tracepoint(objectstore, collection_list_exit, r);
- return r;
-}
-
int FileStore::omap_get(coll_t c, const ghobject_t &hoid,
bufferlist *header,
map<string, bufferlist> *out)
int collection_stat(coll_t c, struct stat *st);
bool collection_exists(coll_t c);
bool collection_empty(coll_t c);
- int collection_list(coll_t c, vector<ghobject_t>& oid);
// omap (see ObjectStore.h for documentation)
int omap_get(coll_t c, const ghobject_t &oid, bufferlist *header,
return r;
}
-int KeyValueStore::collection_list(coll_t c, vector<ghobject_t>& ls)
-{
- return collection_list_impl(c, ghobject_t(), ghobject_t::get_max(), 0, 0, &ls, 0);
-}
-
int KeyValueStore::collection_version_current(coll_t c, uint32_t *version)
{
*version = COLLECTION_VERSION;
int list_collections(vector<coll_t>& ls);
bool collection_exists(coll_t c);
bool collection_empty(coll_t c);
- int collection_list(coll_t c, vector<ghobject_t>& oid);
int collection_list_impl(coll_t c, ghobject_t start, ghobject_t end,
int max, snapid_t snap,
vector<ghobject_t> *ls, ghobject_t *next);
return c->object_map.empty();
}
-int MemStore::collection_list(coll_t cid, vector<ghobject_t>& o)
-{
- dout(10) << __func__ << " " << cid << dendl;
- CollectionRef c = get_collection(cid);
- if (!c)
- return -ENOENT;
- RWLock::RLocker l(c->lock);
-
- for (map<ghobject_t,ObjectRef>::iterator p = c->object_map.begin();
- p != c->object_map.end();
- ++p)
- o.push_back(p->first);
- return 0;
-}
-
int MemStore::collection_list_impl(coll_t cid, ghobject_t start, ghobject_t end,
int max, snapid_t snap,
vector<ghobject_t> *ls, ghobject_t *next)
map<ghobject_t,ObjectRef>::iterator p = c->object_map.lower_bound(start);
while (p != c->object_map.end() &&
- (max == -1 || ls->size() < (unsigned)max) &&
+ ls->size() < (unsigned)max &&
p->first < end) {
ls->push_back(p->first);
++p;
int list_collections(vector<coll_t>& ls);
bool collection_exists(coll_t c);
bool collection_empty(coll_t c);
- int collection_list(coll_t cid, vector<ghobject_t>& o);
int collection_list_impl(coll_t cid, ghobject_t start, ghobject_t end,
int max, snapid_t snap,
vector<ghobject_t> *ls, ghobject_t *next);
*/
virtual bool collection_empty(coll_t c) = 0;
- /**
- * collection_list - get all objects of a collection in sorted order
- *
- * @param c collection name
- * @param o [out] list of objects
- * @returns 0 on success, negative error code on failure
- */
- virtual int collection_list(coll_t c, vector<ghobject_t>& o) = 0;
-
/**
* list contents of a collection that fall in the range [start, end) and no more than a specified many result
*
ghobject_t next;
while (1) {
vector<ghobject_t> objects;
- store->collection_list_partial(*p, next,
- store->get_ideal_list_min(),
- store->get_ideal_list_max(),
- 0, &objects, &next);
+ store->collection_list_impl(*p, next, ghobject_t::get_max(),
+ store->get_ideal_list_max(),
+ 0, &objects, &next);
if (objects.empty())
break;
vector<ghobject_t>::iterator q;
SnapMapper mapper(&driver, 0, 0, 0, pgid.shard);
vector<ghobject_t> objects;
- store->collection_list(tmp, objects);
+ store->collection_list_impl(tmp, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
// delete them.
unsigned removed = 0;
int err;
std::vector<ghobject_t> b_objects, a_objects;
- err = b_store->collection_list(coll, b_objects);
+ err = b_store->collection_list_impl(coll, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &b_objects, NULL);
if (err < 0) {
dout(0) << "diff_objects list on verify coll " << coll.to_str()
<< " returns " << err << dendl;
return true;
}
- err = a_store->collection_list(coll, a_objects);
+ err = a_store->collection_list_impl(coll, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &a_objects, NULL);
if (err < 0) {
dout(0) << "diff_objects list on store coll " << coll.to_str()
<< " returns " << err << dendl;
set<ghobject_t> listed;
vector<ghobject_t> objects;
- r = store->collection_list(cid, objects);
+ r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
cerr << "objects.size() is " << objects.size() << std::endl;
ASSERT_GT(available_objects.count(*i), (unsigned)0);
}
- int r = store->collection_list(cid, objects);
+ int r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
objects_set2.insert(objects.begin(), objects.end());
ASSERT_EQ(objects_set2.size(), available_objects.size());
}
}
vector<ghobject_t> objects;
- r = store->collection_list(cid, objects);
+ r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
}
vector<ghobject_t> objects;
- r = store->collection_list(cid, objects);
+ r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
ObjectStore::Transaction t;
vector<ghobject_t> objects;
- r = store->collection_list(cid, objects);
+ r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
for (vector<ghobject_t>::iterator i = objects.begin();
}
objects.clear();
- r = store->collection_list(tid, objects);
+ r = store->collection_list_impl(tid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
for (vector<ghobject_t>::iterator i = objects.begin();
{
vector<ghobject_t> objects;
- r = store->collection_list(cid, objects);
+ r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), 1u);
ASSERT_EQ(objects[0], oid2);
const std::string object_name(10, 'A');
ghobject_t hoid(hobject_t(object_t(object_name), key, CEPH_NOSNAP, hash, pool, ""));
vector<ghobject_t> ls;
- ASSERT_THROW(index.collection_list_partial(hoid, 0, 0, 0, &ls, &hoid), FailedAssertion);
+ ASSERT_THROW(index.collection_list_partial(hoid, ghobject_t::get_max(), 0, 0, &ls, &hoid), FailedAssertion);
}
TEST(FlatIndex, created_unlink) {
virtual int _collection_list_partial(
const ghobject_t &start,
const ghobject_t &end,
- int min_count,
int max_count,
vector<ghobject_t> *ls,
ghobject_t *next