Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
plasma.h
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #ifndef PLASMA_PLASMA_H
19 #define PLASMA_PLASMA_H
20 
21 #include <errno.h>
22 #include <inttypes.h>
23 #include <stdbool.h>
24 #include <stddef.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h> // pid_t
29 
30 #include <string>
31 #include <unordered_map>
32 #include <unordered_set>
33 
34 #include "plasma/compat.h"
35 
36 #include "arrow/status.h"
37 #include "arrow/util/logging.h"
38 #include "plasma/common.h"
39 #include "plasma/common_generated.h"
40 
41 namespace plasma {
42 
43 #define HANDLE_SIGPIPE(s, fd_) \
44  do { \
45  Status _s = (s); \
46  if (!_s.ok()) { \
47  if (errno == EPIPE || errno == EBADF || errno == ECONNRESET) { \
48  ARROW_LOG(WARNING) \
49  << "Received SIGPIPE, BAD FILE DESCRIPTOR, or ECONNRESET when " \
50  "sending a message to client on fd " \
51  << fd_ << ". " \
52  "The client on the other end may have hung up."; \
53  } else { \
54  return _s; \
55  } \
56  } \
57  } while (0);
58 
60 #define BLOCK_SIZE 64
61 
62 struct Client;
63 
65 typedef std::unordered_map<ObjectID, ObjectRequest, UniqueIDHasher> ObjectRequestMap;
66 
68 struct object_handle {
72  int store_fd;
74  int64_t mmap_size;
75 };
76 
77 // TODO(pcm): Replace this by the flatbuffers message PlasmaObjectSpec.
78 struct PlasmaObject {
82  ptrdiff_t data_offset;
84  ptrdiff_t metadata_offset;
86  int64_t data_size;
88  int64_t metadata_size;
89 };
90 
96 };
97 
103 };
104 
111  ObjectInfoT info;
113  int fd;
115  int64_t map_size;
117  ptrdiff_t offset;
119  uint8_t* pointer;
121  std::unordered_set<Client*> clients;
125  unsigned char digest[kDigestSize];
126 };
127 
131  std::unordered_map<ObjectID, std::unique_ptr<ObjectTableEntry>, UniqueIDHasher> objects;
141  std::string directory;
142 };
143 
152  const ObjectID& object_id);
153 
168 int warn_if_sigpipe(int status, int client_sock);
169 
170 uint8_t* create_object_info_buffer(ObjectInfoT* object_info);
171 
172 } // namespace plasma
173 
174 #endif // PLASMA_PLASMA_H
int64_t data_size
The size in bytes of the data.
Definition: plasma.h:86
uint8_t * create_object_info_buffer(ObjectInfoT *object_info)
The plasma store information that is exposed to the eviction policy.
Definition: plasma.h:129
std::unordered_map< ObjectID, ObjectRequest, UniqueIDHasher > ObjectRequestMap
Mapping from object IDs to type and status of the request.
Definition: plasma.h:62
object_state state
The state of the object, e.g., whether it is open or sealed.
Definition: plasma.h:123
Object was created but not sealed in the local Plasma Store.
Definition: plasma.h:93
int warn_if_sigpipe(int status, int client_sock)
Print a warning if the status is less than zero.
int64_t memory_capacity
The amount of memory (in bytes) that we allow to be allocated in the store.
Definition: plasma.h:134
object_handle handle
Handle for memory mapped file the object is stored in.
Definition: plasma.h:80
The object was found.
Definition: plasma.h:102
uint8_t * pointer
Pointer to the object data. Needed to free the object.
Definition: plasma.h:119
object_state
Definition: plasma.h:91
Definition: common.h:38
Object is sealed and stored in the local Plasma Store.
Definition: plasma.h:95
ptrdiff_t metadata_offset
The offset in bytes in the memory mapped file of the metadata.
Definition: plasma.h:84
int64_t metadata_size
The size in bytes of the metadata.
Definition: plasma.h:88
ObjectInfoT info
Object info like size, creation time and owner.
Definition: plasma.h:111
int store_fd
The file descriptor of the memory mapped file in the store.
Definition: plasma.h:72
constexpr int64_t kDigestSize
Size of object hash digests.
Definition: common.h:68
std::unordered_set< Client * > clients
Set of clients currently using this object.
Definition: plasma.h:121
Definition: plasma.h:78
Contains all information that is associated with a Plasma store client.
Definition: store.h:42
int fd
Memory mapped file containing the object.
Definition: plasma.h:113
The object was not found.
Definition: plasma.h:100
int64_t map_size
Size of the underlying map.
Definition: plasma.h:115
Definition: client.h:35
Definition: common.h:54
ObjectID object_id
Object id of this object.
Definition: plasma.h:109
std::unordered_map< ObjectID, std::unique_ptr< ObjectTableEntry >, UniqueIDHasher > objects
Objects that are in the Plasma store.
Definition: plasma.h:131
std::string directory
A (platform-dependent) directory where to create the memory-backed file.
Definition: plasma.h:141
Handle to access memory mapped file and map it into client address space.
Definition: plasma.h:68
ObjectTableEntry * get_object_table_entry(PlasmaStoreInfo *store_info, const ObjectID &object_id)
Get an entry from the object table and return NULL if the object_id is not present.
ptrdiff_t data_offset
The offset in bytes in the memory mapped file of the data.
Definition: plasma.h:82
object_status
Definition: plasma.h:98
int64_t mmap_size
The size in bytes of the memory mapped file.
Definition: plasma.h:74
ptrdiff_t offset
Offset from the base of the mmap.
Definition: plasma.h:117
bool hugepages_enabled
Boolean flag indicating whether to start the object store with hugepages support enabled.
Definition: plasma.h:139
This type is used by the Plasma store.
Definition: plasma.h:107