Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
protocol.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_PROTOCOL_H
19 #define PLASMA_PROTOCOL_H
20 
21 #include <vector>
22 
23 #include "arrow/status.h"
24 #include "plasma/plasma.h"
25 #include "plasma/plasma_generated.h"
26 
27 namespace plasma {
28 
29 using arrow::Status;
30 
31 template <class T>
32 bool verify_flatbuffer(T* object, uint8_t* data, size_t size) {
33  flatbuffers::Verifier verifier(data, size);
34  return object->Verify(verifier);
35 }
36 
37 /* Plasma receive message. */
38 
39 Status PlasmaReceive(int sock, int64_t message_type, std::vector<uint8_t>* buffer);
40 
41 /* Plasma Create message functions. */
42 
43 Status SendCreateRequest(int sock, ObjectID object_id, int64_t data_size,
44  int64_t metadata_size);
45 
46 Status ReadCreateRequest(uint8_t* data, size_t size, ObjectID* object_id,
47  int64_t* data_size, int64_t* metadata_size);
48 
49 Status SendCreateReply(int sock, ObjectID object_id, PlasmaObject* object, int error);
50 
51 Status ReadCreateReply(uint8_t* data, size_t size, ObjectID* object_id,
52  PlasmaObject* object);
53 
54 Status SendAbortRequest(int sock, ObjectID object_id);
55 
56 Status ReadAbortRequest(uint8_t* data, size_t size, ObjectID* object_id);
57 
58 Status SendAbortReply(int sock, ObjectID object_id);
59 
60 Status ReadAbortReply(uint8_t* data, size_t size, ObjectID* object_id);
61 
62 /* Plasma Seal message functions. */
63 
64 Status SendSealRequest(int sock, ObjectID object_id, unsigned char* digest);
65 
66 Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id,
67  unsigned char* digest);
68 
69 Status SendSealReply(int sock, ObjectID object_id, int error);
70 
71 Status ReadSealReply(uint8_t* data, size_t size, ObjectID* object_id);
72 
73 /* Plasma Get message functions. */
74 
75 Status SendGetRequest(int sock, const ObjectID* object_ids, int64_t num_objects,
76  int64_t timeout_ms);
77 
78 Status ReadGetRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids,
79  int64_t* timeout_ms);
80 
81 Status SendGetReply(
82  int sock, ObjectID object_ids[],
83  std::unordered_map<ObjectID, PlasmaObject, UniqueIDHasher>& plasma_objects,
84  int64_t num_objects);
85 
86 Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
87  PlasmaObject plasma_objects[], int64_t num_objects);
88 
89 /* Plasma Release message functions. */
90 
91 Status SendReleaseRequest(int sock, ObjectID object_id);
92 
93 Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id);
94 
95 Status SendReleaseReply(int sock, ObjectID object_id, int error);
96 
97 Status ReadReleaseReply(uint8_t* data, size_t size, ObjectID* object_id);
98 
99 /* Plasma Delete message functions. */
100 
101 Status SendDeleteRequest(int sock, ObjectID object_id);
102 
103 Status ReadDeleteRequest(uint8_t* data, size_t size, ObjectID* object_id);
104 
105 Status SendDeleteReply(int sock, ObjectID object_id, int error);
106 
107 Status ReadDeleteReply(uint8_t* data, size_t size, ObjectID* object_id);
108 
109 /* Satus messages. */
110 
111 Status SendStatusRequest(int sock, const ObjectID* object_ids, int64_t num_objects);
112 
113 Status ReadStatusRequest(uint8_t* data, size_t size, ObjectID object_ids[],
114  int64_t num_objects);
115 
116 Status SendStatusReply(int sock, ObjectID object_ids[], int object_status[],
117  int64_t num_objects);
118 
119 int64_t ReadStatusReply_num_objects(uint8_t* data, size_t size);
120 
121 Status ReadStatusReply(uint8_t* data, size_t size, ObjectID object_ids[],
122  int object_status[], int64_t num_objects);
123 
124 /* Plasma Constains message functions. */
125 
126 Status SendContainsRequest(int sock, ObjectID object_id);
127 
128 Status ReadContainsRequest(uint8_t* data, size_t size, ObjectID* object_id);
129 
130 Status SendContainsReply(int sock, ObjectID object_id, bool has_object);
131 
132 Status ReadContainsReply(uint8_t* data, size_t size, ObjectID* object_id,
133  bool* has_object);
134 
135 /* Plasma Connect message functions. */
136 
137 Status SendConnectRequest(int sock);
138 
139 Status ReadConnectRequest(uint8_t* data, size_t size);
140 
141 Status SendConnectReply(int sock, int64_t memory_capacity);
142 
143 Status ReadConnectReply(uint8_t* data, size_t size, int64_t* memory_capacity);
144 
145 /* Plasma Evict message functions (no reply so far). */
146 
147 Status SendEvictRequest(int sock, int64_t num_bytes);
148 
149 Status ReadEvictRequest(uint8_t* data, size_t size, int64_t* num_bytes);
150 
151 Status SendEvictReply(int sock, int64_t num_bytes);
152 
153 Status ReadEvictReply(uint8_t* data, size_t size, int64_t& num_bytes);
154 
155 /* Plasma Fetch Remote message functions. */
156 
157 Status SendFetchRequest(int sock, const ObjectID* object_ids, int64_t num_objects);
158 
159 Status ReadFetchRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids);
160 
161 /* Plasma Wait message functions. */
162 
163 Status SendWaitRequest(int sock, ObjectRequest object_requests[], int64_t num_requests,
164  int num_ready_objects, int64_t timeout_ms);
165 
166 Status ReadWaitRequest(uint8_t* data, size_t size, ObjectRequestMap& object_requests,
167  int64_t* timeout_ms, int* num_ready_objects);
168 
169 Status SendWaitReply(int sock, const ObjectRequestMap& object_requests,
170  int num_ready_objects);
171 
172 Status ReadWaitReply(uint8_t* data, size_t size, ObjectRequest object_requests[],
173  int* num_ready_objects);
174 
175 /* Plasma Subscribe message functions. */
176 
177 Status SendSubscribeRequest(int sock);
178 
179 /* Data messages. */
180 
181 Status SendDataRequest(int sock, ObjectID object_id, const char* address, int port);
182 
183 Status ReadDataRequest(uint8_t* data, size_t size, ObjectID* object_id, char** address,
184  int* port);
185 
186 Status SendDataReply(int sock, ObjectID object_id, int64_t object_size,
187  int64_t metadata_size);
188 
189 Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
190  int64_t* object_size, int64_t* metadata_size);
191 
192 } // namespace plasma
193 
194 #endif /* PLASMA_PROTOCOL */
Status ReadWaitRequest(uint8_t *data, size_t size, ObjectRequestMap &object_requests, int64_t *timeout_ms, int *num_ready_objects)
Status SendAbortRequest(int sock, ObjectID object_id)
Status SendFetchRequest(int sock, const ObjectID *object_ids, int64_t num_objects)
Status SendCreateRequest(int sock, ObjectID object_id, int64_t data_size, int64_t metadata_size)
Status SendDataRequest(int sock, ObjectID object_id, const char *address, int port)
Status ReadDeleteReply(uint8_t *data, size_t size, ObjectID *object_id)
Status SendConnectRequest(int sock)
std::unordered_map< ObjectID, ObjectRequest, UniqueIDHasher > ObjectRequestMap
Mapping from object IDs to type and status of the request.
Definition: plasma.h:62
Status ReadStatusReply(uint8_t *data, size_t size, ObjectID object_ids[], int object_status[], int64_t num_objects)
Status SendWaitReply(int sock, const ObjectRequestMap &object_requests, int num_ready_objects)
Status ReadFetchRequest(uint8_t *data, size_t size, std::vector< ObjectID > &object_ids)
Status SendStatusReply(int sock, ObjectID object_ids[], int object_status[], int64_t num_objects)
Status SendDeleteReply(int sock, ObjectID object_id, int error)
Status SendReleaseReply(int sock, ObjectID object_id, int error)
Status PlasmaReceive(int sock, int64_t message_type, std::vector< uint8_t > *buffer)
Status SendGetReply(int sock, ObjectID object_ids[], std::unordered_map< ObjectID, PlasmaObject, UniqueIDHasher > &plasma_objects, int64_t num_objects)
Status SendDeleteRequest(int sock, ObjectID object_id)
UniqueID ObjectID
Definition: common.h:63
Status ReadGetReply(uint8_t *data, size_t size, ObjectID object_ids[], PlasmaObject plasma_objects[], int64_t num_objects)
Definition: status.h:106
Status SendStatusRequest(int sock, const ObjectID *object_ids, int64_t num_objects)
Status SendSealRequest(int sock, ObjectID object_id, unsigned char *digest)
Status SendGetRequest(int sock, const ObjectID *object_ids, int64_t num_objects, int64_t timeout_ms)
Status ReadWaitReply(uint8_t *data, size_t size, ObjectRequest object_requests[], int *num_ready_objects)
Status SendEvictReply(int sock, int64_t num_bytes)
Status ReadConnectReply(uint8_t *data, size_t size, int64_t *memory_capacity)
Status ReadCreateRequest(uint8_t *data, size_t size, ObjectID *object_id, int64_t *data_size, int64_t *metadata_size)
Status SendSealReply(int sock, ObjectID object_id, int error)
Status ReadConnectRequest(uint8_t *data, size_t size)
Status ReadDeleteRequest(uint8_t *data, size_t size, ObjectID *object_id)
Status SendConnectReply(int sock, int64_t memory_capacity)
Status SendReleaseRequest(int sock, ObjectID object_id)
Definition: client.h:37
Status SendEvictRequest(int sock, int64_t num_bytes)
int64_t ReadStatusReply_num_objects(uint8_t *data, size_t size)
Status ReadGetRequest(uint8_t *data, size_t size, std::vector< ObjectID > &object_ids, int64_t *timeout_ms)
Status ReadSealRequest(uint8_t *data, size_t size, ObjectID *object_id, unsigned char *digest)
Status ReadReleaseReply(uint8_t *data, size_t size, ObjectID *object_id)
Status ReadEvictRequest(uint8_t *data, size_t size, int64_t *num_bytes)
Status ReadAbortRequest(uint8_t *data, size_t size, ObjectID *object_id)
Status ReadCreateReply(uint8_t *data, size_t size, ObjectID *object_id, PlasmaObject *object)
Status SendWaitRequest(int sock, ObjectRequest object_requests[], int64_t num_requests, int num_ready_objects, int64_t timeout_ms)
Status SendAbortReply(int sock, ObjectID object_id)
Status ReadStatusRequest(uint8_t *data, size_t size, ObjectID object_ids[], int64_t num_objects)
Status ReadEvictReply(uint8_t *data, size_t size, int64_t &num_bytes)
object_status
Definition: plasma.h:98
Status SendDataReply(int sock, ObjectID object_id, int64_t object_size, int64_t metadata_size)
Status ReadReleaseRequest(uint8_t *data, size_t size, ObjectID *object_id)
Status ReadContainsRequest(uint8_t *data, size_t size, ObjectID *object_id)
bool verify_flatbuffer(T *object, uint8_t *data, size_t size)
Definition: protocol.h:32
Status ReadDataRequest(uint8_t *data, size_t size, ObjectID *object_id, char **address, int *port)
Status SendContainsRequest(int sock, ObjectID object_id)
Status SendCreateReply(int sock, ObjectID object_id, PlasmaObject *object, int error)
Status ReadSealReply(uint8_t *data, size_t size, ObjectID *object_id)
Status SendSubscribeRequest(int sock)
Status ReadDataReply(uint8_t *data, size_t size, ObjectID *object_id, int64_t *object_size, int64_t *metadata_size)
Status ReadContainsReply(uint8_t *data, size_t size, ObjectID *object_id, bool *has_object)
Status ReadAbortReply(uint8_t *data, size_t size, ObjectID *object_id)
Status SendContainsReply(int sock, ObjectID object_id, bool has_object)