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 /* Plasma Seal message functions. */
55 
56 Status SendSealRequest(int sock, ObjectID object_id, unsigned char* digest);
57 
58 Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id,
59  unsigned char* digest);
60 
61 Status SendSealReply(int sock, ObjectID object_id, int error);
62 
63 Status ReadSealReply(uint8_t* data, size_t size, ObjectID* object_id);
64 
65 /* Plasma Get message functions. */
66 
67 Status SendGetRequest(int sock, const ObjectID* object_ids, int64_t num_objects,
68  int64_t timeout_ms);
69 
70 Status ReadGetRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids,
71  int64_t* timeout_ms);
72 
74  int sock, ObjectID object_ids[],
75  std::unordered_map<ObjectID, PlasmaObject, UniqueIDHasher>& plasma_objects,
76  int64_t num_objects);
77 
78 Status ReadGetReply(uint8_t* data, size_t size, ObjectID object_ids[],
79  PlasmaObject plasma_objects[], int64_t num_objects);
80 
81 /* Plasma Release message functions. */
82 
83 Status SendReleaseRequest(int sock, ObjectID object_id);
84 
85 Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id);
86 
87 Status SendReleaseReply(int sock, ObjectID object_id, int error);
88 
89 Status ReadReleaseReply(uint8_t* data, size_t size, ObjectID* object_id);
90 
91 /* Plasma Delete message functions. */
92 
93 Status SendDeleteRequest(int sock, ObjectID object_id);
94 
95 Status ReadDeleteRequest(uint8_t* data, size_t size, ObjectID* object_id);
96 
97 Status SendDeleteReply(int sock, ObjectID object_id, int error);
98 
99 Status ReadDeleteReply(uint8_t* data, size_t size, ObjectID* object_id);
100 
101 /* Satus messages. */
102 
103 Status SendStatusRequest(int sock, const ObjectID* object_ids, int64_t num_objects);
104 
105 Status ReadStatusRequest(uint8_t* data, size_t size, ObjectID object_ids[],
106  int64_t num_objects);
107 
108 Status SendStatusReply(int sock, ObjectID object_ids[], int object_status[],
109  int64_t num_objects);
110 
111 int64_t ReadStatusReply_num_objects(uint8_t* data, size_t size);
112 
113 Status ReadStatusReply(uint8_t* data, size_t size, ObjectID object_ids[],
114  int object_status[], int64_t num_objects);
115 
116 /* Plasma Constains message functions. */
117 
118 Status SendContainsRequest(int sock, ObjectID object_id);
119 
120 Status ReadContainsRequest(uint8_t* data, size_t size, ObjectID* object_id);
121 
122 Status SendContainsReply(int sock, ObjectID object_id, bool has_object);
123 
124 Status ReadContainsReply(uint8_t* data, size_t size, ObjectID* object_id,
125  bool* has_object);
126 
127 /* Plasma Connect message functions. */
128 
129 Status SendConnectRequest(int sock);
130 
131 Status ReadConnectRequest(uint8_t* data, size_t size);
132 
133 Status SendConnectReply(int sock, int64_t memory_capacity);
134 
135 Status ReadConnectReply(uint8_t* data, size_t size, int64_t* memory_capacity);
136 
137 /* Plasma Evict message functions (no reply so far). */
138 
139 Status SendEvictRequest(int sock, int64_t num_bytes);
140 
141 Status ReadEvictRequest(uint8_t* data, size_t size, int64_t* num_bytes);
142 
143 Status SendEvictReply(int sock, int64_t num_bytes);
144 
145 Status ReadEvictReply(uint8_t* data, size_t size, int64_t& num_bytes);
146 
147 /* Plasma Fetch Remote message functions. */
148 
149 Status SendFetchRequest(int sock, const ObjectID* object_ids, int64_t num_objects);
150 
151 Status ReadFetchRequest(uint8_t* data, size_t size, std::vector<ObjectID>& object_ids);
152 
153 /* Plasma Wait message functions. */
154 
155 Status SendWaitRequest(int sock, ObjectRequest object_requests[], int64_t num_requests,
156  int num_ready_objects, int64_t timeout_ms);
157 
158 Status ReadWaitRequest(uint8_t* data, size_t size, ObjectRequestMap& object_requests,
159  int64_t* timeout_ms, int* num_ready_objects);
160 
161 Status SendWaitReply(int sock, const ObjectRequestMap& object_requests,
162  int num_ready_objects);
163 
164 Status ReadWaitReply(uint8_t* data, size_t size, ObjectRequest object_requests[],
165  int* num_ready_objects);
166 
167 /* Plasma Subscribe message functions. */
168 
169 Status SendSubscribeRequest(int sock);
170 
171 /* Data messages. */
172 
173 Status SendDataRequest(int sock, ObjectID object_id, const char* address, int port);
174 
175 Status ReadDataRequest(uint8_t* data, size_t size, ObjectID* object_id, char** address,
176  int* port);
177 
178 Status SendDataReply(int sock, ObjectID object_id, int64_t object_size,
179  int64_t metadata_size);
180 
181 Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
182  int64_t* object_size, int64_t* metadata_size);
183 
184 } // namespace plasma
185 
186 #endif /* PLASMA_PROTOCOL */
Status ReadWaitRequest(uint8_t *data, size_t size, ObjectRequestMap &object_requests, int64_t *timeout_ms, int *num_ready_objects)
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)
Object request data structure. Used for Wait.
Definition: common.h:71
Status ReadGetReply(uint8_t *data, size_t size, ObjectID object_ids[], PlasmaObject plasma_objects[], int64_t num_objects)
Definition: common.h:38
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)
Definition: plasma.h:78
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:35
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 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 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 SendContainsReply(int sock, ObjectID object_id, bool has_object)