]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_compression_types.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_compression_types.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2019 Red Hat, Inc.
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 *
14 */
15
16 #pragma once
17
18 #include "rgw_common.h"
19
20 struct compression_block {
21 uint64_t old_ofs;
22 uint64_t new_ofs;
23 uint64_t len;
24
25 void encode(bufferlist& bl) const {
26 ENCODE_START(1, 1, bl);
27 encode(old_ofs, bl);
28 encode(new_ofs, bl);
29 encode(len, bl);
30 ENCODE_FINISH(bl);
31 }
32
33 void decode(bufferlist::const_iterator& bl) {
34 DECODE_START(1, bl);
35 decode(old_ofs, bl);
36 decode(new_ofs, bl);
37 decode(len, bl);
38 DECODE_FINISH(bl);
39 }
40 void dump(Formatter *f) const;
41 };
42 WRITE_CLASS_ENCODER(compression_block)
43
44 struct RGWCompressionInfo {
45 std::string compression_type;
46 uint64_t orig_size;
47 boost::optional<int32_t> compressor_message;
48 std::vector<compression_block> blocks;
49
50 RGWCompressionInfo() : compression_type("none"), orig_size(0) {}
51 RGWCompressionInfo(const RGWCompressionInfo& cs_info) : compression_type(cs_info.compression_type),
52 orig_size(cs_info.orig_size),
53 compressor_message(cs_info.compressor_message),
54 blocks(cs_info.blocks) {}
55
56 void encode(bufferlist& bl) const {
57 ENCODE_START(2, 1, bl);
58 encode(compression_type, bl);
59 encode(orig_size, bl);
60 encode(compressor_message, bl);
61 encode(blocks, bl);
62 ENCODE_FINISH(bl);
63 }
64
65 void decode(bufferlist::const_iterator& bl) {
66 DECODE_START(2, bl);
67 decode(compression_type, bl);
68 decode(orig_size, bl);
69 if (struct_v >= 2) {
70 decode(compressor_message, bl);
71 }
72 decode(blocks, bl);
73 DECODE_FINISH(bl);
74 }
75 void dump(Formatter *f) const;
76 };
77 WRITE_CLASS_ENCODER(RGWCompressionInfo)
78