r = _remove_collection(cid);
}
break;
+ case Transaction::OP_MERGE_COLLECTION:
+ {
+ coll_t cid = i.get_cid(op->cid);
+ coll_t dest_cid = i.get_cid(op->dest_cid);
+ r = _merge_collection(cid, dest_cid, op->split_bits);
+ }
+ break;
case Transaction::OP_SETALLOCHINT:
{
r = 0;
return 0;
}
+int CyanStore::Shard::_merge_collection(
+ const coll_t& cid,
+ const coll_t& dest_cid,
+ int bits)
+{
+ logger().debug("{} cid={} dest_cid={} bits={}", __func__, cid, dest_cid, bits);
+ auto src = _get_collection(cid);
+ if (!src) {
+ return -ENOENT;
+ }
+ auto dest = _get_collection(dest_cid);
+ if (!dest) {
+ return -ENOENT;
+ }
+ for (auto& [oid, obj] : src->object_map) {
+ dest->object_map.emplace(oid, obj);
+ dest->object_hash.emplace(oid, obj);
+ }
+ dest->bits = bits;
+ coll_map.erase(cid);
+ return 0;
+}
+
int CyanStore::Shard::_remove_collection(const coll_t& cid)
{
logger().debug("{} cid={}", __func__, cid);
std::string_view name);
int _rm_attrs(const coll_t& cid, const ghobject_t& oid);
int _create_collection(const coll_t& cid, int bits);
+ int _merge_collection(const coll_t& cid, const coll_t& dest_cid, int bits);
int _remove_collection(const coll_t& cid);
boost::intrusive_ptr<Collection> _get_collection(const coll_t& cid);