]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_compression.h
e58d959e294a4e9f64efaa9d76b0089b908efba5
[ceph.git] / ceph / src / rgw / rgw_compression.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_RGW_COMPRESSION_H
5 #define CEPH_RGW_COMPRESSION_H
6
7 #include <vector>
8
9 #include "compressor/Compressor.h"
10 #include "rgw_op.h"
11
12 class RGWGetObj_Decompress : public RGWGetObj_Filter
13 {
14 CephContext* cct;
15 CompressorRef compressor;
16 RGWCompressionInfo* cs_info;
17 bool partial_content;
18 vector<compression_block>::iterator first_block, last_block;
19 off_t q_ofs, q_len;
20 bool first_data;
21 uint64_t cur_ofs;
22 bufferlist waiting;
23 public:
24 RGWGetObj_Decompress(CephContext* cct_,
25 RGWCompressionInfo* cs_info_,
26 bool partial_content_,
27 RGWGetDataCB* next);
28 ~RGWGetObj_Decompress() override {}
29
30 int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) override;
31 int fixup_range(off_t& ofs, off_t& end) override;
32
33 };
34
35 class RGWPutObj_Compress : public RGWPutObj_Filter
36 {
37 CephContext* cct;
38 bool compressed{false};
39 CompressorRef compressor;
40 std::vector<compression_block> blocks;
41 public:
42 RGWPutObj_Compress(CephContext* cct_, CompressorRef compressor,
43 RGWPutObjDataProcessor* next)
44 : RGWPutObj_Filter(next), cct(cct_), compressor(compressor) {}
45 ~RGWPutObj_Compress() override{}
46 int handle_data(bufferlist& bl, off_t ofs, void **phandle, rgw_raw_obj *pobj, bool *again) override;
47
48 bool is_compressed() { return compressed; }
49 vector<compression_block>& get_compression_blocks() { return blocks; }
50
51 }; /* RGWPutObj_Compress */
52
53 #endif /* CEPH_RGW_COMPRESSION_H */