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 <string>
23 #include <vector>
24 
25 #include "plasma/common.h"
26 #include "plasma/events.h"
27 #include "plasma/eviction_policy.h"
28 #include "plasma/plasma.h"
29 #include "plasma/protocol.h"
30 
31 namespace plasma {
32 
33 struct GetRequest;
34 
38  std::deque<uint8_t*> object_notifications;
39 };
40 
42 struct Client {
43  explicit Client(int fd);
44 
46  int fd;
47 };
48 
49 class PlasmaStore {
50  public:
51  PlasmaStore(EventLoop* loop, int64_t system_memory, std::string directory,
52  bool hugetlbfs_enabled);
53 
54  ~PlasmaStore();
55 
57  const PlasmaStoreInfo* get_plasma_store_info();
58 
73  int create_object(const ObjectID& object_id, int64_t data_size, int64_t metadata_size,
74  Client* client, PlasmaObject* result);
75 
80  void delete_objects(const std::vector<ObjectID>& object_ids);
81 
93  void process_get_request(Client* client, const std::vector<ObjectID>& object_ids,
94  int64_t timeout_ms);
95 
102  void seal_object(const ObjectID& object_id, unsigned char digest[]);
103 
109  int contains_object(const ObjectID& object_id);
110 
115  void release_object(const ObjectID& object_id, Client* client);
116 
120  void subscribe_to_updates(Client* client);
121 
125  void connect_client(int listener_sock);
126 
130  void disconnect_client(int client_fd);
131 
132  void send_notifications(int client_fd);
133 
134  Status process_message(Client* client);
135 
136  private:
137  void push_notification(ObjectInfoT* object_notification);
138 
139  void add_client_to_object_clients(ObjectTableEntry* entry, Client* client);
140 
141  void return_from_get(GetRequest* get_req);
142 
143  void update_object_get_requests(const ObjectID& object_id);
144 
145  int remove_client_from_object_clients(ObjectTableEntry* entry, Client* client);
146 
148  EventLoop* loop_;
151  PlasmaStoreInfo store_info_;
153  EvictionPolicy eviction_policy_;
156  std::vector<uint8_t> input_buffer_;
159  std::unordered_map<ObjectID, std::vector<GetRequest*>, UniqueIDHasher>
160  object_get_requests_;
166  std::unordered_map<int, NotificationQueue> pending_notifications_;
167 
168  std::unordered_map<int, std::unique_ptr<Client>> connected_clients_;
169 };
170 
171 } // namespace plasma
172 
173 #endif // PLASMA_STORE_H
The plasma store information that is exposed to the eviction policy.
Definition: plasma.h:129
Definition: common.h:38
std::deque< uint8_t * > object_notifications
The object notifications for clients.
Definition: store.h:38
Definition: status.h:106
Definition: plasma.h:78
int fd
The file descriptor used to communicate with the client.
Definition: store.h:46
Definition: store.h:49
Definition: store.h:35
Contains all information that is associated with a Plasma store client.
Definition: store.h:42
Definition: events.h:42
Definition: client.h:35
Definition: common.h:54
The eviction policy.
Definition: eviction_policy.h:59
This type is used by the Plasma store.
Definition: plasma.h:107