From: Casey Bodley Date: Sun, 3 Dec 2023 19:10:30 +0000 (-0500) Subject: rgw/metadata: add RGWMetadataLister abstraction X-Git-Tag: testing/wip-batrick-testing-20240411.154038~266^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6000732706890fa5d276d22972d1d83be32bb5c8;p=ceph-ci.git rgw/metadata: add RGWMetadataLister abstraction Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_metadata_lister.h b/src/rgw/driver/rados/rgw_metadata_lister.h new file mode 100644 index 00000000000..9fbb21ac3b4 --- /dev/null +++ b/src/rgw/driver/rados/rgw_metadata_lister.h @@ -0,0 +1,73 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +/* + * Ceph - scalable distributed file system + * + * Copyright contributors to the Ceph project + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include +#include +#include +#include +#include +#include "services/svc_sys_obj.h" + +class DoutPrefixProvider; + +class RGWMetadataLister { + RGWSI_SysObj::Pool pool; + RGWSI_SysObj::Pool::Op listing; + + virtual void filter_transform(std::vector& oids, + std::list& keys) { + // use all oids as keys + std::move(oids.begin(), oids.end(), std::back_inserter(keys)); + } + + public: + explicit RGWMetadataLister(RGWSI_SysObj::Pool pool) + : pool(pool), listing(this->pool) {} + virtual ~RGWMetadataLister() {} + + int init(const DoutPrefixProvider* dpp, + const std::string& marker, + const std::string& prefix) + { + return listing.init(dpp, marker, prefix); + } + + int get_next(const DoutPrefixProvider* dpp, int max, + std::list& keys, bool* truncated) + { + std::vector oids; + int r = listing.get_next(dpp, max, &oids, truncated); + if (r == -ENOENT) { + if (truncated) { + *truncated = false; + } + return 0; + } + if (r < 0) { + return r; + } + filter_transform(oids, keys); + return 0; + } + + std::string get_marker() + { + std::string marker; + listing.get_marker(&marker); + return marker; + } +};