}
}
+template <typename T>
+int collection_list(T &store, ObjectStore::CollectionHandle &c,
+ const ghobject_t& start, const ghobject_t& end, int max,
+ vector<ghobject_t> *ls, ghobject_t *pnext,
+ bool disable_legacy = false) {
+ if (disable_legacy || rand() % 2) {
+ return store->collection_list(c, start, end, max, ls, pnext);
+ } else {
+ return store->collection_list_legacy(c, start, end, max, ls, pnext);
+ }
+}
bool sorted(const vector<ghobject_t> &in) {
ghobject_t start;
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
- int r = store->collection_list(ch, current, ghobject_t::get_max(),
- 50,
- &objects, &next);
+ int r = collection_list(store, ch, current, ghobject_t::get_max(), 50,
+ &objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
cout << " got " << objects.size() << " next " << next << std::endl;
end.hobj.pool = 1;
vector<ghobject_t> objects;
ghobject_t next;
- int r = store->collection_list(ch, ghobject_t(), end, 500,
- &objects, &next);
+ int r = collection_list(store, ch, ghobject_t(), end, 500, &objects, &next);
ASSERT_EQ(r, 0);
for (auto &p : objects) {
ASSERT_NE(p, end);
vector<ghobject_t> objects;
ghobject_t next, current;
while (!next.is_max()) {
- int r = store->collection_list(ch, current, ghobject_t::get_max(), 50,
- &objects, &next);
+ int r = collection_list(store, ch, current, ghobject_t::get_max(), 50,
+ &objects, &next);
ASSERT_EQ(r, 0);
cout << " got " << objects.size() << " next " << next << std::endl;
for (vector<ghobject_t>::iterator p = objects.begin(); p != objects.end();
set<ghobject_t> listed, listed2;
vector<ghobject_t> objects;
- r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+ r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &objects, 0);
ASSERT_EQ(r, 0);
cerr << "objects.size() is " << objects.size() << std::endl;
ghobject_t start, next;
objects.clear();
- r = store->collection_list(
+ r = collection_list(
+ store,
ch,
ghobject_t::get_max(),
ghobject_t::get_max(),
listed.clear();
ghobject_t start2, next2;
while (1) {
- r = store->collection_list(ch, start, ghobject_t::get_max(),
- 50,
- &objects,
- &next);
+ r = collection_list(store, ch, start, ghobject_t::get_max(), 50, &objects,
+ &next);
ASSERT_TRUE(sorted(objects));
ASSERT_EQ(r, 0);
listed.insert(objects.begin(), objects.end());
void shutdown() {
while (1) {
vector<ghobject_t> objects;
- int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
- 10, &objects, 0);
+ int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(),
+ 10, &objects, 0);
assert(r >= 0);
if (objects.empty())
break;
ghobject_t next, current;
while (1) {
//cerr << "scanning..." << std::endl;
- int r = store->collection_list(ch, current, ghobject_t::get_max(), 100,
- &objects, &next);
+ int r = collection_list(store, ch, current, ghobject_t::get_max(), 100,
+ &objects, &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
objects_set.insert(objects.begin(), objects.end());
ASSERT_GT(available_objects.count(*i), (unsigned)0);
}
- int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(),
+ INT_MAX, &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(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+ r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &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;
listed.clear();
ghobject_t current, next;
while (1) {
- r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
- &objects, &next);
+ r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects,
+ &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
for (vector<ghobject_t>::iterator i = objects.begin();
}
TEST_P(StoreTest, HashCollisionSorting) {
+ bool disable_legacy = (string(GetParam()) == "bluestore");
+
char buf121664318_1[] = {18, -119, -121, -111, 0};
char buf121664318_2[] = {19, 127, -121, 32, 0};
char buf121664318_3[] = {19, -118, 15, 19, 0};
}
vector<ghobject_t> objects;
- int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ int r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(),
+ INT_MAX, &objects, 0, disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created.size(), objects.size());
auto it = objects.begin();
std::set<ghobject_t> created_sub(i, j);
objects.clear();
ghobject_t next;
- r = store->collection_list(ch, *i, ghobject_t::get_max(),
- created_sub.size(),
- &objects, &next);
+ r = collection_list(store, ch, *i, ghobject_t::get_max(),
+ created_sub.size(), &objects, &next, disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created_sub.size(), objects.size());
it = objects.begin();
std::set<ghobject_t> created_sub(i, j);
objects.clear();
ghobject_t next;
- r = store->collection_list(ch, *i, *j, INT_MAX, &objects, &next);
+ r = collection_list(store, ch, *i, *j, INT_MAX, &objects, &next,
+ disable_legacy);
ASSERT_EQ(r, 0);
ASSERT_EQ(created_sub.size(), objects.size());
it = objects.begin();
}
vector<ghobject_t> objects;
- r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &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;
listed.clear();
ghobject_t current, next;
while (1) {
- r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
- &objects, &next);
+ r = collection_list(store, ch, current, ghobject_t::get_max(), 60, &objects,
+ &next);
ASSERT_EQ(r, 0);
ASSERT_TRUE(sorted(objects));
for (vector<ghobject_t>::iterator i = objects.begin();
ObjectStore::Transaction t;
vector<ghobject_t> objects;
- r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), num_objects);
unsigned size = 0;
t = ObjectStore::Transaction();
objects.clear();
- r = store->collection_list(tch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ r = collection_list(store, tch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &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(ch, ghobject_t(), ghobject_t::get_max(),
- INT_MAX, &objects, 0);
+ r = collection_list(store, ch, ghobject_t(), ghobject_t::get_max(), INT_MAX,
+ &objects, 0);
ASSERT_EQ(r, 0);
ASSERT_EQ(objects.size(), 1u);
ASSERT_EQ(objects[0], oid2);