Skip to content

Commit

Permalink
compressor: put Compressor into TOPNSPC namespace
Browse files Browse the repository at this point in the history
we want to add the support for on-the-wire compression to msgr v2, and
this feature will be shared by classic osd and crimson. but
Compressor.cc is also used by bluestore which is linked against by
crimson also. Compressor depends on CephContext which has two different
implementation in two namespaces for classic osd and crison.

so to avoid violating ODR, we should also put Compressor into two
different namespaces so it can be shared by alienstore and crimson in
the same executable.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Dec 6, 2020
1 parent 72f27fc commit 1684f60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/compressor/CompressionPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@
#include <iostream>

#include "common/PluginRegistry.h"
#include "include/common_fwd.h"
#include "Compressor.h"

namespace ceph {

class CompressionPlugin : public Plugin {
public:
CompressorRef compressor;
TOPNSPC::CompressorRef compressor;

explicit CompressionPlugin(CephContext *cct) : Plugin(cct),
compressor(0)
explicit CompressionPlugin(CephContext *cct)
: Plugin(cct)
{}

~CompressionPlugin() override {}

virtual int factory(CompressorRef *cs,
std::ostream *ss) = 0;
virtual int factory(TOPNSPC::CompressorRef *cs,
std::ostream *ss) = 0;

virtual const char* name() {return "CompressionPlugin";}
};
Expand Down
4 changes: 4 additions & 0 deletions src/compressor/Compressor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "common/debug.h"
#include "common/dout.h"

namespace TOPNSPC {

const char* Compressor::get_comp_alg_name(int a) {

auto p = std::find_if(std::cbegin(compression_algorithms), std::cend(compression_algorithms),
Expand Down Expand Up @@ -100,3 +102,5 @@ CompressorRef Compressor::create(CephContext *cct, int alg)
std::string type_name = get_comp_alg_name(alg);
return create(cct, type_name);
}

} // namespace TOPNSPC
3 changes: 3 additions & 0 deletions src/compressor/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "QatAccel.h"
#endif

namespace TOPNSPC {

class Compressor;
typedef std::shared_ptr<Compressor> CompressorRef;

Expand Down Expand Up @@ -103,4 +105,5 @@ class Compressor {

};

} // namespace TOPNSPC
#endif

0 comments on commit 1684f60

Please sign in to comment.