]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/cyanstore/cyan_object.h
624f9513a930e8afd43f9b71cc3b41d99bbd2cdf
[ceph.git] / ceph / src / crimson / os / cyanstore / cyan_object.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #pragma once
4
5 #include <cstddef>
6 #include <map>
7 #include <string>
8 #include <boost/intrusive_ptr.hpp>
9 #include <boost/smart_ptr/intrusive_ref_counter.hpp>
10
11 #include "include/buffer.h"
12
13 namespace crimson::os {
14
15 struct Object : public boost::intrusive_ref_counter<
16 Object,
17 boost::thread_unsafe_counter>
18 {
19 using bufferlist = ceph::bufferlist;
20
21 bufferlist data;
22 // use transparent comparator for better performance, see
23 // https://en.cppreference.com/w/cpp/utility/functional/less_void
24 std::map<std::string,bufferlist,std::less<>> xattr;
25 bufferlist omap_header;
26 std::map<std::string,bufferlist> omap;
27
28 typedef boost::intrusive_ptr<Object> Ref;
29
30 Object() = default;
31
32 // interface for object data
33 size_t get_size() const;
34 ceph::bufferlist read(uint64_t offset, uint64_t len);
35 int write(uint64_t offset, const bufferlist &bl);
36 int clone(Object *src, uint64_t srcoff, uint64_t len,
37 uint64_t dstoff);
38 int truncate(uint64_t offset);
39
40 void encode(bufferlist& bl) const;
41 void decode(bufferlist::const_iterator& p);
42 };
43 using ObjectRef = boost::intrusive_ptr<Object>;
44
45 }