Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
store.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_STORE_H
19 #define PLASMA_STORE_H
20 
21 #include <deque>
22 #include <memory>
23 #include <string>
24 #include <unordered_map>
25 #include <unordered_set>
26 #include <vector>
27 
28 #include "plasma/common.h"
29 #include "plasma/events.h"
30 #include "plasma/eviction_policy.h"
31 #include "plasma/plasma.h"
32 #include "plasma/protocol.h"
33 
34 namespace plasma {
35 
36 struct GetRequest;
37 
41  std::deque<std::unique_ptr<uint8_t[]>> object_notifications;
42 };
43 
45 struct Client {
46  explicit Client(int fd);
47 
49  int fd;
50 
52  std::unordered_set<ObjectID, UniqueIDHasher> object_ids;
53 };
54 
55 class PlasmaStore {
56  public:
57  // TODO: PascalCase PlasmaStore methods.
58  PlasmaStore(EventLoop* loop, int64_t system_memory, std::string directory,
59  bool hugetlbfs_enabled);
60 
61  ~PlasmaStore();
62 
65 
87  int create_object(const ObjectID& object_id, int64_t data_size, int64_t metadata_size,
88  int device_num, Client* client, PlasmaObject* result);
89 
97  int abort_object(const ObjectID& object_id, Client* client);
98 
106  int delete_object(ObjectID& object_id);
107 
112  void delete_objects(const std::vector<ObjectID>& object_ids);
113 
125  void process_get_request(Client* client, const std::vector<ObjectID>& object_ids,
126  int64_t timeout_ms);
127 
134  void seal_object(const ObjectID& object_id, unsigned char digest[]);
135 
141  int contains_object(const ObjectID& object_id);
142 
147  void release_object(const ObjectID& object_id, Client* client);
148 
152  void subscribe_to_updates(Client* client);
153 
157  void connect_client(int listener_sock);
158 
162  void disconnect_client(int client_fd);
163 
164  void send_notifications(int client_fd);
165 
166  Status process_message(Client* client);
167 
168  private:
169  void push_notification(ObjectInfoT* object_notification);
170 
171  void add_to_client_object_ids(ObjectTableEntry* entry, Client* client);
172 
173  void return_from_get(GetRequest* get_req);
174 
175  void update_object_get_requests(const ObjectID& object_id);
176 
177  int remove_from_client_object_ids(ObjectTableEntry* entry, Client* client);
178 
180  EventLoop* loop_;
183  PlasmaStoreInfo store_info_;
185  EvictionPolicy eviction_policy_;
188  std::vector<uint8_t> input_buffer_;
191  std::unordered_map<ObjectID, std::vector<GetRequest*>, UniqueIDHasher>
192  object_get_requests_;
198  std::unordered_map<int, NotificationQueue> pending_notifications_;
199 
200  std::unordered_map<int, std::unique_ptr<Client>> connected_clients_;
201 #ifdef PLASMA_GPU
203 #endif
204 };
205 
206 } // namespace plasma
207 
208 #endif // PLASMA_STORE_H
Status process_message(Client *client)
void disconnect_client(int client_fd)
Disconnect a client from the PlasmaStore.
The plasma store information that is exposed to the eviction policy.
Definition: plasma.h:147
void subscribe_to_updates(Client *client)
Subscribe a file descriptor to updates about new sealed objects.
void send_notifications(int client_fd)
void seal_object(const ObjectID &object_id, unsigned char digest[])
Seal an object.
int delete_object(ObjectID &object_id)
Delete an specific object by object_id that have been created in the hash table.
Definition: common.h:38
PlasmaStore(EventLoop *loop, int64_t system_memory, std::string directory, bool hugetlbfs_enabled)
Definition: status.h:93
int abort_object(const ObjectID &object_id, Client *client)
Abort a created but unsealed object.
int contains_object(const ObjectID &object_id)
Check if the plasma store contains an object:
Definition: cuda_context.h:35
Definition: plasma.h:77
int fd
The file descriptor used to communicate with the client.
Definition: store.h:49
Definition: store.h:55
Definition: store.h:38
Contains all information that is associated with a Plasma store client.
Definition: store.h:45
std::deque< std::unique_ptr< uint8_t[]> > object_notifications
The object notifications for clients.
Definition: store.h:41
Definition: events.h:42
void connect_client(int listener_sock)
Connect a new client to the PlasmaStore.
void process_get_request(Client *client, const std::vector< ObjectID > &object_ids, int64_t timeout_ms)
Process a get request from a client.
Definition: client.h:35
Definition: common.h:54
int create_object(const ObjectID &object_id, int64_t data_size, int64_t metadata_size, int device_num, Client *client, PlasmaObject *result)
Create a new object.
std::unordered_set< ObjectID, UniqueIDHasher > object_ids
Object ids that are used by this client.
Definition: store.h:52
void release_object(const ObjectID &object_id, Client *client)
Record the fact that a particular client is no longer using an object.
const PlasmaStoreInfo * get_plasma_store_info()
Get a const pointer to the internal PlasmaStoreInfo object.
The eviction policy.
Definition: eviction_policy.h:59
void delete_objects(const std::vector< ObjectID > &object_ids)
Delete objects that have been created in the hash table.
This type is used by the Plasma store.
Definition: plasma.h:114