Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / compressor / compressor_example.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph distributed storage system
5  *
6  * Copyright (C) 2015 Mirantis, Inc.
7  *
8  * Author: Alyona Kiseleva <akiselyova@mirantis.com>
9  *
10  *
11  *  This library is free software; you can redistribute it and/or
12  *  modify it under the terms of the GNU Lesser General Public
13  *  License as published by the Free Software Foundation; either
14  *  version 2.1 of the License, or (at your option) any later version.
15  * 
16  */
17
18 #ifndef CEPH_COMPRESSOR_EXAMPLE_H
19 #define CEPH_COMPRESSOR_EXAMPLE_H
20
21 #include <unistd.h>
22 #include <errno.h>
23 #include <algorithm>
24 #include <sstream>
25
26 #include "crush/CrushWrapper.h"
27 #include "osd/osd_types.h"
28 #include "compressor/Compressor.h"
29
30 class CompressorExample : public Compressor {
31 public:
32   CompressorExample() : Compressor(COMP_ALG_NONE, "example") {}
33   ~CompressorExample() override {}
34
35   int compress(const bufferlist &in, bufferlist &out) override
36   {
37     out = in;
38     return 0;
39   }
40
41   int decompress(const bufferlist &in, bufferlist &out) override
42   {
43     out = in;
44     return 0;
45   }
46   int decompress(bufferlist::iterator &p, size_t compressed_len, bufferlist &out) override
47   {
48     p.copy(MIN(p.get_remaining(), compressed_len), out);
49     return 0;
50   }
51 };
52
53 #endif