269
row objects after the persistent operation completes successfully. write_row() is an
important method because, in addition to the allocation of persistent pool storage to
the rows, it is used to populate the indexing containers. pmemobj_tx_alloc() is used for
inserts. write_row() transactionally allocates a new object of a given size and type_num.
Listing 13-7. ha_pmdk.cc – Closing a database table
417 int ha_pmdk::write_row(uchar *buf)
418 {
...
421
int err = 0;
422
423
if (isPrimaryKey() == true)
424
DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY);
425
426
persistent_ptr row;
427
TX_BEGIN(objtab) {
428
row = pmemobj_tx_alloc(sizeof (row) + table->s->reclength, 0);
429
memcpy(row->buf, buf, table->s->reclength);
430
row->next = proot->rows;
431
proot->rows = row;
432
} TX_ONABORT {
433
DBUG_PRINT("info", ("write_row_abort errno :%d ",errno));
434
err = errno;
435
} TX_END
436
stats.records++;
437
438
for (Field **field = table->field; *field; field++) {
439
if ((*field)->key_start.to_ulonglong() >= 1) {
440
std::string convertedKey = IdentifyTypeAndConvertToString((*fie
ld)->ptr, (*field)->type(),(*field)->key_length(),1);
441
insertRowIntoIndexTable(*field, convertedKey, row);
442
}
443
}
444
DBUG_RETURN(err);
445 }
Chapter 13 enabling persistenCe Using a real-World appliCation
row objects after the persistent operation completes successfully. write_row() is an
important method because, in addition to the allocation of persistent pool storage to
the rows, it is used to populate the indexing containers. pmemobj_tx_alloc() is used for
inserts. write_row() transactionally allocates a new object of a given size and type_num.
Listing 13-7. ha_pmdk.cc – Closing a database table
417 int ha_pmdk::write_row(uchar *buf)
418 {
...
421
int err = 0;
422
423
if (isPrimaryKey() == true)
424
DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY);
425
426
persistent_ptr
427
TX_BEGIN(objtab) {
428
row = pmemobj_tx_alloc(sizeof (row) + table->s->reclength, 0);
429
memcpy(row->buf, buf, table->s->reclength);
430
row->next = proot->rows;
431
proot->rows = row;
432
} TX_ONABORT {
433
DBUG_PRINT("info", ("write_row_abort errno :%d ",errno));
434
err = errno;
435
} TX_END
436
stats.records++;
437
438
for (Field **field = table->field; *field; field++) {
439
if ((*field)->key_start.to_ulonglong() >= 1) {
440
std::string convertedKey = IdentifyTypeAndConvertToString((*fie
ld)->ptr, (*field)->type(),(*field)->key_length(),1);
441
insertRowIntoIndexTable(*field, convertedKey, row);
442
}
443
}
444
DBUG_RETURN(err);
445 }
Chapter 13 enabling persistenCe Using a real-World appliCation
