Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
io.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_IO_H
19 #define PLASMA_IO_H
20 
21 #include <inttypes.h>
22 #include <sys/socket.h>
23 #include <sys/un.h>
24 #include <unistd.h>
25 
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
30 #include "arrow/status.h"
31 #include "plasma/compat.h"
32 
33 namespace plasma {
34 
35 namespace flatbuf {
36 
37 // Forward declaration outside the namespace, which is defined in plasma_generated.h.
38 enum class MessageType : int64_t;
39 
40 } // namespace flatbuf
41 
42 // TODO(pcm): Replace our own custom message header (message type,
43 // message length, plasma protocol verion) with one that is serialized
44 // using flatbuffers.
45 constexpr int64_t kPlasmaProtocolVersion = 0x0000000000000000;
46 
47 using arrow::Status;
48 
49 Status WriteBytes(int fd, uint8_t* cursor, size_t length);
50 
51 Status WriteMessage(int fd, flatbuf::MessageType type, int64_t length, uint8_t* bytes);
52 
53 Status ReadBytes(int fd, uint8_t* cursor, size_t length);
54 
55 Status ReadMessage(int fd, flatbuf::MessageType* type, std::vector<uint8_t>* buffer);
56 
57 int BindIpcSock(const std::string& pathname, bool shall_listen);
58 
59 int ConnectIpcSock(const std::string& pathname);
60 
61 Status ConnectIpcSocketRetry(const std::string& pathname, int num_retries,
62  int64_t timeout, int* fd);
63 
64 int AcceptClient(int socket_fd);
65 
66 std::unique_ptr<uint8_t[]> ReadMessageAsync(int sock);
67 
68 } // namespace plasma
69 
70 #endif // PLASMA_IO_H
int BindIpcSock(const std::string &pathname, bool shall_listen)
Status ConnectIpcSocketRetry(const std::string &pathname, int num_retries, int64_t timeout, int *fd)
Status WriteBytes(int fd, uint8_t *cursor, size_t length)
Definition: status.h:95
int AcceptClient(int socket_fd)
int ConnectIpcSock(const std::string &pathname)
Definition: client.h:35
Status ReadMessage(int fd, flatbuf::MessageType *type, std::vector< uint8_t > *buffer)
constexpr int64_t kPlasmaProtocolVersion
Definition: io.h:45
Status WriteMessage(int fd, flatbuf::MessageType type, int64_t length, uint8_t *bytes)
std::unique_ptr< uint8_t[]> ReadMessageAsync(int sock)
Status ReadBytes(int fd, uint8_t *cursor, size_t length)