268
302
objtab = pmemobj_open(path, name);
303
if (objtab == NULL)
304
DBUG_RETURN(errCodeMap[errno]);
305
306
proot = pmemobj_root(objtab, sizeof (root));
307
// update the MAP when start occured
308
loadIndexTableFromPersistentMemory();
...
310 }
Once the storage engine is up and running, we can begin to insert data into it. But we
first must implement the INSERT, UPDATE, DELETE, and SELECT operations.
Closing a Database Table
When the server is finished working with a table, it calls the closeTable() method to
close the file using pmemobj_close() and release any other resources (see Listing 13-6).
The pmemobj_close() function closes the memory pool indicated by objtab and deletes
the memory pool handle.
Listing 13-6. ha_pmdk.cc – Closing a database table
376 int ha_pmdk::close(void)
377 {
378
DBUG_ENTER("ha_pmdk::close");
379
DBUG_PRINT("info", ("close"));
380
381
pmemobj_close(objtab);
382
objtab = NULL;
383
384
DBUG_RETURN(0);
385 }
INSERT Operation
The INSERT operation is implemented in the write_row() method, shown in Listing 13- 7.
During an INSERT, the row objects are maintained in a singly linked list. If the table
is indexed, the index table container in volatile memory is updated with the new
Chapter 13 enabling persistenCe Using a real-World appliCation
302
objtab = pmemobj_open(path, name);
303
if (objtab == NULL)
304
DBUG_RETURN(errCodeMap[errno]);
305
306
proot = pmemobj_root(objtab, sizeof (root));
307
// update the MAP when start occured
308
loadIndexTableFromPersistentMemory();
...
310 }
Once the storage engine is up and running, we can begin to insert data into it. But we
first must implement the INSERT, UPDATE, DELETE, and SELECT operations.
Closing a Database Table
When the server is finished working with a table, it calls the closeTable() method to
close the file using pmemobj_close() and release any other resources (see Listing 13-6).
The pmemobj_close() function closes the memory pool indicated by objtab and deletes
the memory pool handle.
Listing 13-6. ha_pmdk.cc – Closing a database table
376 int ha_pmdk::close(void)
377 {
378
DBUG_ENTER("ha_pmdk::close");
379
DBUG_PRINT("info", ("close"));
380
381
pmemobj_close(objtab);
382
objtab = NULL;
383
384
DBUG_RETURN(0);
385 }
INSERT Operation
The INSERT operation is implemented in the write_row() method, shown in Listing 13- 7.
During an INSERT, the row objects are maintained in a singly linked list. If the table
is indexed, the index table container in volatile memory is updated with the new
Chapter 13 enabling persistenCe Using a real-World appliCation
