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 <memory>
31 #include <string>
32 #include <unordered_map>
33 #include <unordered_set>
34 
35 #include "plasma/compat.h"
36 
37 #include "arrow/status.h"
38 #include "arrow/util/logging.h"
39 #include "arrow/util/macros.h"
40 #include "plasma/common.h"
41 #include "plasma/common_generated.h"
42 
43 #ifdef PLASMA_GPU
45 #endif
46 
47 namespace plasma {
48 
49 #define HANDLE_SIGPIPE(s, fd_) \
50  do { \
51  Status _s = (s); \
52  if (!_s.ok()) { \
53  if (errno == EPIPE || errno == EBADF || errno == ECONNRESET) { \
54  ARROW_LOG(WARNING) \
55  << "Received SIGPIPE, BAD FILE DESCRIPTOR, or ECONNRESET when " \
56  "sending a message to client on fd " \
57  << fd_ \
58  << ". " \
59  "The client on the other end may have hung up."; \
60  } else { \
61  return _s; \
62  } \
63  } \
64  } while (0);
65 
67 constexpr int64_t kBlockSize = 64;
68 
69 struct Client;
70 
72 typedef std::unordered_map<ObjectID, ObjectRequest> ObjectRequestMap;
73 
74 // TODO(pcm): Replace this by the flatbuffers message PlasmaObjectSpec.
75 struct PlasmaObject {
76 #ifdef PLASMA_GPU
77  // IPC handle for Cuda.
78  std::shared_ptr<CudaIpcMemHandle> ipc_handle;
79 #endif
80  int store_fd;
85  ptrdiff_t data_offset;
87  ptrdiff_t metadata_offset;
89  int64_t data_size;
91  int64_t metadata_size;
94 };
95 
96 enum class ObjectStatus : int {
98  OBJECT_NOT_FOUND = 0,
100  OBJECT_FOUND = 1
101 };
102 
116  std::string directory;
117 };
118 
127  const ObjectID& object_id);
128 
143 int WarnIfSigpipe(int status, int client_sock);
144 
145 std::unique_ptr<uint8_t[]> CreateObjectInfoBuffer(flatbuf::ObjectInfoT* object_info);
146 
147 } // namespace plasma
148 
149 #endif // PLASMA_PLASMA_H
int64_t data_size
The size in bytes of the data.
Definition: plasma.h:89
int store_fd
The file descriptor of the memory mapped file in the store.
Definition: plasma.h:83
The plasma store information that is exposed to the eviction policy.
Definition: plasma.h:104
int64_t memory_capacity
The amount of memory (in bytes) that we allow to be allocated in the store.
Definition: plasma.h:109
The object was not found.
ObjectTable objects
Objects that are in the Plasma store.
Definition: plasma.h:106
Definition: common.h:47
ptrdiff_t metadata_offset
The offset in bytes in the memory mapped file of the metadata.
Definition: plasma.h:87
int64_t metadata_size
The size in bytes of the metadata.
Definition: plasma.h:91
ObjectStatus
Definition: plasma.h:96
ObjectTableEntry * GetObjectTableEntry(PlasmaStoreInfo *store_info, const ObjectID &object_id)
Get an entry from the object table and return NULL if the object_id is not present.
Definition: plasma.h:75
Definition: cuda_memory.h:98
int WarnIfSigpipe(int status, int client_sock)
Print a warning if the status is less than zero.
Contains all information that is associated with a Plasma store client.
Definition: store.h:48
std::unordered_map< ObjectID, ObjectRequest > ObjectRequestMap
Mapping from object IDs to type and status of the request.
Definition: plasma.h:69
Definition: client.h:35
std::string directory
A (platform-dependent) directory where to create the memory-backed file.
Definition: plasma.h:116
ptrdiff_t data_offset
The offset in bytes in the memory mapped file of the data.
Definition: plasma.h:85
std::unordered_map< ObjectID, std::unique_ptr< ObjectTableEntry > > ObjectTable
Mapping from ObjectIDs to information about the object.
Definition: common.h:139
bool hugepages_enabled
Boolean flag indicating whether to start the object store with hugepages support enabled.
Definition: plasma.h:114
std::unique_ptr< uint8_t[]> CreateObjectInfoBuffer(flatbuf::ObjectInfoT *object_info)
int device_num
Device number object is on.
Definition: plasma.h:93
constexpr int64_t kBlockSize
Allocation granularity used in plasma for object allocation.
Definition: plasma.h:67
This type is used by the Plasma store.
Definition: common.h:102