]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_compression_types.h
import 15.2.0 Octopus source
[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 string compression_type;
46 uint64_t orig_size;
47 vector<compression_block> blocks;
48
49 RGWCompressionInfo() : compression_type("none"), orig_size(0) {}
50 RGWCompressionInfo(const RGWCompressionInfo& cs_info) : compression_type(cs_info.compression_type),
51 orig_size(cs_info.orig_size),
52 blocks(cs_info.blocks) {}
53
54 void encode(bufferlist& bl) const {
55 ENCODE_START(1, 1, bl);
56 encode(compression_type, bl);
57 encode(orig_size, bl);
58 encode(blocks, bl);
59 ENCODE_FINISH(bl);
60 }
61
62 void decode(bufferlist::const_iterator& bl) {
63 DECODE_START(1, bl);
64 decode(compression_type, bl);
65 decode(orig_size, bl);
66 decode(blocks, bl);
67 DECODE_FINISH(bl);
68 }
69 void dump(Formatter *f) const;
70 };
71 WRITE_CLASS_ENCODER(RGWCompressionInfo)
72