266
216
pmdk_hton->flags= HTON_CAN_RECREATE;
217
pmdk_hton->tablefile_extensions= ha_pmdk_exts;
218
219
pmdk_hton->commit= pmdk_commit;
220
pmdk_hton->rollback= pmdk_rollback;
...
223 }
The abstract methods defined in the handler class are implemented to work with
persistent memory. An internal representation of the objects in persistent memory is
created using a single linked list (SLL). This internal representation is very helpful to
iterate through the records to improve performance.
To perform a variety of operations and gain faster and easier access to data, we used
the simple row structure shown in Listing 13-3 to hold the pointer to persistent memory
and the associated field value in the buffer.
Listing 13-3. ha_pmdk.h – A simple data structure to store data in a single
linked list
71 struct row {
72
persistent_ptr next;
73
uchar buf[];
74 };
Creating a Database Table
The create() method is used to create the table. This method creates all necessary
files in persistent memory using libpmemobj. As shown in Listing 13-4, we create a new
pmemobj type pool for each table using the pmemobj_create() method; this method
creates a transactional object store with the given total poolsize. The table is created in
the form of an .obj extension.
Listing 13-4. Creating a table method
1247 int ha_pmdk::create(const char *name, TABLE *table_arg,
1248
HA_CREATE_INFO *create_info)
1249 {
1250
Chapter 13 enabling persistenCe Using a real-World appliCation
Précédent

- 290/457

Suivant