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 <stdbool.h>
22 #include <time.h>
23 
24 #include <deque>
25 #include <memory>
26 #include <string>
27 #include <unordered_map>
28 
29 #include "arrow/status.h"
30 #include "arrow/util/visibility.h"
31 #include "plasma/common.h"
32 
33 using arrow::Status;
34 
35 namespace plasma {
36 
37 #define PLASMA_DEFAULT_RELEASE_DELAY 64
38 
39 // Use 100MB as an overestimate of the L3 cache size.
40 constexpr int64_t kL3CacheSizeBytes = 100000000;
41 
43 struct ObjectBuffer {
45  int64_t data_size;
47  uint8_t* data;
49  int64_t metadata_size;
51  uint8_t* metadata;
52 };
53 
59  size_t release_delay;
60 };
61 
64  uint8_t* pointer;
66  size_t length;
69  int count;
70 };
71 
72 struct ObjectInUseEntry;
73 struct ObjectRequest;
74 struct PlasmaObject;
75 
76 class ARROW_EXPORT PlasmaClient {
77  public:
78  PlasmaClient();
79 
80  ~PlasmaClient();
81 
94  Status Connect(const std::string& store_socket_name,
95  const std::string& manager_socket_name, int release_delay,
96  int num_retries = -1);
97 
112  Status Create(const ObjectID& object_id, int64_t data_size, uint8_t* metadata,
113  int64_t metadata_size, uint8_t** data);
114 
130  Status Get(const ObjectID* object_ids, int64_t num_objects, int64_t timeout_ms,
131  ObjectBuffer* object_buffers);
132 
141  Status Release(const ObjectID& object_id);
142 
153  Status Contains(const ObjectID& object_id, bool* has_object);
154 
161  Status Seal(const ObjectID& object_id);
162 
171  Status Delete(const ObjectID& object_id);
172 
180  Status Evict(int64_t num_bytes, int64_t& num_bytes_evicted);
181 
188  Status Hash(const ObjectID& object_id, uint8_t* digest);
189 
198  Status Subscribe(int* fd);
199 
207  Status GetNotification(int fd, ObjectID* object_id, int64_t* data_size,
208  int64_t* metadata_size);
209 
214  Status Disconnect();
215 
241  Status Fetch(int num_object_ids, const ObjectID* object_ids);
242 
274  Status Wait(int64_t num_object_requests, ObjectRequest* object_requests,
275  int num_ready_objects, int64_t timeout_ms, int* num_objects_ready);
276 
283  Status Transfer(const char* addr, int port, const ObjectID& object_id);
284 
301  Status Info(const ObjectID& object_id, int* object_status);
302 
307  int get_manager_fd();
308 
309  private:
310  Status PerformRelease(const ObjectID& object_id);
311 
312  uint8_t* lookup_or_mmap(int fd, int store_fd_val, int64_t map_size);
313 
314  uint8_t* lookup_mmapped_file(int store_fd_val);
315 
316  void increment_object_count(const ObjectID& object_id, PlasmaObject* object,
317  bool is_sealed);
318 
320  int store_conn_;
322  int manager_conn_;
326  std::unordered_map<int, ClientMmapTableEntry> mmap_table_;
329  std::unordered_map<ObjectID, std::unique_ptr<ObjectInUseEntry>, UniqueIDHasher>
330  objects_in_use_;
336  std::deque<ObjectID> release_history_;
340  int64_t in_use_object_bytes_;
342  PlasmaClientConfig config_;
346  int64_t store_capacity_;
347 };
348 
349 } // namespace plasma
350 
351 #endif // PLASMA_CLIENT_H
uint8_t * data
The address of the data object.
Definition: client.h:47
Object buffer data structure.
Definition: client.h:43
Definition: client.h:62
Object request data structure. Used for Wait.
Definition: common.h:71
uint8_t * metadata
The address of the metadata.
Definition: client.h:51
Definition: common.h:38
Definition: status.h:106
int64_t metadata_size
The metadata size in bytes.
Definition: client.h:49
Definition: plasma.h:78
Configuration options for the plasma client.
Definition: client.h:55
uint8_t * pointer
The result of mmap for this file descriptor.
Definition: client.h:64
size_t length
The length of the memory-mapped file.
Definition: client.h:66
Definition: client.h:35
Definition: common.h:54
int64_t data_size
The size in bytes of the data object.
Definition: client.h:45
object_status
Definition: plasma.h:98
Definition: client.h:76
int count
The number of objects in this memory-mapped file that are currently being used by the client...
Definition: client.h:69
size_t release_delay
Number of release calls we wait until the object is actually released.
Definition: client.h:59
constexpr int64_t kL3CacheSizeBytes
Definition: client.h:40