@@ -118,17 +118,7 @@ PlasmaStore::PlasmaStore(EventLoop* loop, int64_t system_memory, std::string dir
118
118
}
119
119
120
120
// TODO(pcm): Get rid of this destructor by using RAII to clean up data.
121
- PlasmaStore::~PlasmaStore () {
122
- for (const auto & element : pending_notifications_) {
123
- auto object_notifications = element.second .object_notifications ;
124
- for (size_t i = 0 ; i < object_notifications.size (); ++i) {
125
- uint8_t * notification = reinterpret_cast <uint8_t *>(object_notifications.at (i));
126
- uint8_t * data = notification;
127
- // TODO(pcm): Get rid of this delete.
128
- delete[] data;
129
- }
130
- }
131
- }
121
+ PlasmaStore::~PlasmaStore () {}
132
122
133
123
const PlasmaStoreInfo* PlasmaStore::get_plasma_store_info () { return &store_info_; }
134
124
@@ -322,11 +312,11 @@ void PlasmaStore::return_from_get(GetRequest* get_req) {
322
312
}
323
313
324
314
void PlasmaStore::update_object_get_requests (const ObjectID& object_id) {
325
- std::vector<GetRequest*> & get_requests = object_get_requests_[object_id];
315
+ auto & get_requests = object_get_requests_[object_id];
326
316
size_t index = 0 ;
327
317
size_t num_requests = get_requests.size ();
328
318
for (size_t i = 0 ; i < num_requests; ++i) {
329
- GetRequest* get_req = get_requests[index ];
319
+ auto get_req = get_requests[index ];
330
320
auto entry = get_object_table_entry (&store_info_, object_id);
331
321
ARROW_CHECK (entry != NULL );
332
322
@@ -356,7 +346,7 @@ void PlasmaStore::process_get_request(Client* client,
356
346
const std::vector<ObjectID>& object_ids,
357
347
int64_t timeout_ms) {
358
348
// Create a get request for this object.
359
- GetRequest* get_req = new GetRequest (client, object_ids);
349
+ auto get_req = new GetRequest (client, object_ids);
360
350
361
351
for (auto object_id : object_ids) {
362
352
// Check if this object is already present locally. If so, record that the
@@ -582,13 +572,12 @@ void PlasmaStore::send_notifications(int client_fd) {
582
572
// Loop over the array of pending notifications and send as many of them as
583
573
// possible.
584
574
for (size_t i = 0 ; i < it->second .object_notifications .size (); ++i) {
585
- uint8_t * notification =
586
- reinterpret_cast <uint8_t *>(it->second .object_notifications .at (i));
575
+ auto & notification = it->second .object_notifications .at (i);
587
576
// Decode the length, which is the first bytes of the message.
588
- int64_t size = *(reinterpret_cast <int64_t *>(notification));
577
+ int64_t size = *(reinterpret_cast <int64_t *>(notification. get () ));
589
578
590
579
// Attempt to send a notification about this object ID.
591
- ssize_t nbytes = send (client_fd, notification, sizeof (int64_t ) + size, 0 );
580
+ ssize_t nbytes = send (client_fd, notification. get () , sizeof (int64_t ) + size, 0 );
592
581
if (nbytes >= 0 ) {
593
582
ARROW_CHECK (nbytes == static_cast <ssize_t >(sizeof (int64_t )) + size);
594
583
} else if (nbytes == -1 &&
@@ -613,9 +602,6 @@ void PlasmaStore::send_notifications(int client_fd) {
613
602
}
614
603
}
615
604
num_processed += 1 ;
616
- // The corresponding malloc happened in create_object_info_buffer
617
- // within push_notification.
618
- delete[] notification;
619
605
}
620
606
// Remove the sent notifications from the array.
621
607
it->second .object_notifications .erase (
@@ -636,8 +622,8 @@ void PlasmaStore::send_notifications(int client_fd) {
636
622
637
623
void PlasmaStore::push_notification (ObjectInfoT* object_info) {
638
624
for (auto & element : pending_notifications_) {
639
- uint8_t * notification = create_object_info_buffer (object_info);
640
- element.second .object_notifications .push_back ( notification);
625
+ auto notification = create_object_info_buffer (object_info);
626
+ element.second .object_notifications .emplace_back ( std::move ( notification) );
641
627
send_notifications (element.first );
642
628
// The notification gets freed in send_notifications when the notification
643
629
// is sent over the socket.
0 commit comments