t->set(GHOBJECT_TO_SEQ_PREFIX, to_set);
}
-int GenericObjectMap::list_objects(const coll_t &cid, ghobject_t start, int max,
+int GenericObjectMap::list_objects(const coll_t &cid, ghobject_t start, ghobject_t end, int max,
vector<ghobject_t> *out, ghobject_t *next)
{
// FIXME
break;
}
+ if (header.oid >= end) {
+ if (next)
+ *next = ghobject_t::get_max();
+ break;
+ }
+
assert(start <= header.oid);
+ assert(header.oid < end);
size++;
}
}
- r = backend->list_objects(c, ghobject_t(), modified_object+1, &oids,
+ r = backend->list_objects(c, ghobject_t(), ghobject_t::get_max(), modified_object+1, &oids,
0);
// No other object
if (oids.size() != modified_object && oids.size() != 0) {
dout(10) << __func__ << " " << dendl;
vector<ghobject_t> oids;
- backend->list_objects(c, ghobject_t(), 1, &oids, 0);
+ backend->list_objects(c, ghobject_t(), ghobject_t::get_max(), 1, &oids, 0);
return oids.empty();
}
-int KeyValueStore::collection_list_range(coll_t c, ghobject_t start,
- ghobject_t end, snapid_t seq,
- vector<ghobject_t> *ls)
+int KeyValueStore::collection_list_impl(coll_t c, ghobject_t start,
+ ghobject_t end, int max, snapid_t seq,
+ vector<ghobject_t> *ls, ghobject_t *next)
{
- bool done = false;
- ghobject_t next = start;
-
- while (!done) {
- vector<ghobject_t> next_objects;
- int r = collection_list_partial(c, next, get_ideal_list_min(),
- get_ideal_list_max(), seq,
- &next_objects, &next);
- if (r < 0)
- return r;
-
- ls->insert(ls->end(), next_objects.begin(), next_objects.end());
+ if ( max < 0)
+ return -EINVAL;
- // special case for empty collection
- if (ls->empty()) {
- break;
- }
+ if (start.is_max())
+ return 0;
- while (!ls->empty() && ls->back() >= end) {
- ls->pop_back();
- done = true;
- }
+ int r = backend->list_objects(c, start, end, max, ls, next);
- if (next >= end) {
- done = true;
- }
- }
+ return r;
+}
- return 0;
+int KeyValueStore::collection_list_range(coll_t c, ghobject_t start,
+ ghobject_t end, snapid_t seq,
+ vector<ghobject_t> *ls)
+{
+ ghobject_t next;
+ int r = collection_list_impl(c, start, end, -1, seq, ls, &next);
+ return r;
}
int KeyValueStore::collection_list_partial(coll_t c, ghobject_t start,
dout(10) << __func__ << " " << c << " start:" << start << " is_max:"
<< start.is_max() << dendl;
- if (min < 0 || max < 0)
- return -EINVAL;
-
- if (start.is_max())
- return 0;
-
- return backend->list_objects(c, start, max, ls, next);
+ int r = collection_list_impl(c, start, ghobject_t::get_max(), max, seq, ls, next);
+ return r;
}
int KeyValueStore::collection_list(coll_t c, vector<ghobject_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);
int collection_list_partial(coll_t c, ghobject_t start,
int min, int max, snapid_t snap,
vector<ghobject_t> *ls, ghobject_t *next);