Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
client.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_CLIENT_H
19 #define PLASMA_CLIENT_H
20 
21 #include <functional>
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "arrow/buffer.h"
27 #include "arrow/status.h"
28 #include "arrow/util/macros.h"
29 #include "arrow/util/visibility.h"
30 #include "plasma/common.h"
31 
32 using arrow::Buffer;
33 using arrow::Status;
34 
35 namespace plasma {
36 
37 ARROW_DEPRECATED("PLASMA_DEFAULT_RELEASE_DELAY is deprecated")
38 constexpr int64_t kDeprecatedPlasmaDefaultReleaseDelay = 64;
39 #define PLASMA_DEFAULT_RELEASE_DELAY kDeprecatedPlasmaDefaultReleaseDelay;
40 
44 constexpr int64_t kPlasmaDefaultReleaseDelay = 64;
45 
47 struct ObjectBuffer {
49  std::shared_ptr<Buffer> data;
51  std::shared_ptr<Buffer> metadata;
54 };
55 
56 class ARROW_EXPORT PlasmaClient {
57  public:
58  PlasmaClient();
59  ~PlasmaClient();
60 
73  Status Connect(const std::string& store_socket_name,
74  const std::string& manager_socket_name,
75  int release_delay = kPlasmaDefaultReleaseDelay, int num_retries = -1);
76 
99  Status Create(const ObjectID& object_id, int64_t data_size, const uint8_t* metadata,
100  int64_t metadata_size, std::shared_ptr<Buffer>* data, int device_num = 0);
101 
116  Status Get(const std::vector<ObjectID>& object_ids, int64_t timeout_ms,
117  std::vector<ObjectBuffer>* object_buffers);
118 
131  Status Get(const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
132  ObjectBuffer* object_buffers);
133 
140  Status Release(const ObjectID& object_id);
141 
152  Status Contains(const ObjectID& object_id, bool* has_object);
153 
161  Status Abort(const ObjectID& object_id);
162 
169  Status Seal(const ObjectID& object_id);
170 
180  Status Delete(const ObjectID& object_id);
181 
189  Status Evict(int64_t num_bytes, int64_t& num_bytes_evicted);
190 
197  Status Hash(const ObjectID& object_id, uint8_t* digest);
198 
207  Status Subscribe(int* fd);
208 
216  Status GetNotification(int fd, ObjectID* object_id, int64_t* data_size,
217  int64_t* metadata_size);
218 
223  Status Disconnect();
224 
250  Status Fetch(int num_object_ids, const ObjectID* object_ids);
251 
283  Status Wait(int64_t num_object_requests, ObjectRequest* object_requests,
284  int num_ready_objects, int64_t timeout_ms, int* num_objects_ready);
285 
292  Status Transfer(const char* addr, int port, const ObjectID& object_id);
293 
310  Status Info(const ObjectID& object_id, int* object_status);
311 
316  int get_manager_fd() const;
317 
318  private:
319  friend class PlasmaBuffer;
320  FRIEND_TEST(TestPlasmaStore, GetTest);
321  FRIEND_TEST(TestPlasmaStore, LegacyGetTest);
322  FRIEND_TEST(TestPlasmaStore, AbortTest);
323 
326  Status FlushReleaseHistory();
327 
328  bool IsInUse(const ObjectID& object_id);
329 
330  class ARROW_NO_EXPORT Impl;
331  std::shared_ptr<Impl> impl_;
332 };
333 
334 } // namespace plasma
335 
336 #endif // PLASMA_CLIENT_H
Object buffer data structure.
Definition: client.h:47
#define ARROW_NO_EXPORT
Definition: visibility.h:42
constexpr int64_t kDeprecatedPlasmaDefaultReleaseDelay
Definition: client.h:38
Object request data structure. Used for Wait.
Definition: common.h:71
Definition: common.h:38
Definition: status.h:93
int device_num
The device number.
Definition: client.h:53
std::shared_ptr< Buffer > data
The data buffer.
Definition: client.h:49
#define FRIEND_TEST(test_case_name, test_name)
Definition: macros.h:136
std::shared_ptr< Buffer > metadata
The metadata buffer.
Definition: client.h:51
constexpr int64_t kPlasmaDefaultReleaseDelay
We keep a queue of unreleased objects cached in the client until we start sending release requests to...
Definition: client.h:44
Definition: client.h:35
#define ARROW_DEPRECATED(...)
Definition: macros.h:85
object_status
Definition: plasma.h:105
Object containing a pointer to a piece of contiguous memory with a particular size.
Definition: buffer.h:48
Definition: client.h:56