// enum of possible values for LEAFENTRY->type field
// LE_CLEAN means that there is a single committed value in a format that saves disk space
// LE_MVCC means that there may be multiple committed values or there are provisional values
//
enum{LE_CLEAN=0,LE_MVCC=1};
// This is an on-disk format. static_asserts verify everything is packed and aligned correctly.
structleafentry{
structleafentry_clean{
uint32_tvallen;
uint8_tval[0];//actual val
};// For the case where LEAFENTRY->type is LE_CLEAN
static_assert(4==sizeof(leafentry::leafentry_clean),"leafentry_clean size is wrong");
static_assert(4==__builtin_offsetof(leafentry::leafentry_clean,val),"val is in the wrong place");
struct__attribute__((__packed__))leafentry_mvcc{
uint32_tnum_cxrs;// number of committed transaction records
uint8_tnum_pxrs;// number of provisional transaction records
uint8_txrs[0];//then TXNIDs of XRs relevant for reads:
// if provisional XRs exist, store OUTERMOST TXNID
// store committed TXNIDs, from most recently committed to least recently committed (newest first)
//then lengths of XRs relevant for reads (length is at most 1<<31, MSB is 1 for insert, 0 for delete):
// if provisional XRs exist (num_pxrs>0), store length and insert/delete flag associated with INNERMOST TXNID
// store length and insert/delete flag associated with each committed TXNID, in same order as above (newest first)
//then data of XRs relevant for reads
// if provisional XRs exist (num_pxrs>0), store data associated with INNERMOST provisional TXNID
// store data associated with committed TXNIDs (all committed data, newest committed values first)
//if provisional XRs still exist (that is, num_puxrs > 1, so INNERMOST provisional TXNID != OUTERMOST provisional TXNID):
// for OUTERMOST provisional XR:
// 1 byte: store type (insert/delete/placeholder)
// 4 bytes: length (if type is INSERT, no length stored if placeholder or delete)
// data
// for rest of provisional stack (if num_pxrs > 2), from second-outermost to second-innermost (outermost is stored above, innermost is stored separately):
// 8 bytes: TXNID
// 1 byte: store type (insert/delete/placeholder)
// 4 bytes: length (if type is INSERT)
// data
// for INNERMOST provisional XR:
// 8 bytes: TXNID
// (innermost data and length with insert/delete flag are stored above, cannot be a placeholder)
};// For the case where LEAFENTRY->type is LE_MVCC
static_assert(5==sizeof(leafentry::leafentry_mvcc),"leafentry_mvcc size is wrong");
static_assert(5==__builtin_offsetof(leafentry::leafentry_mvcc,xrs),"xrs is in the wrong place");
uint8_ttype;// type is LE_CLEAN or LE_MVCC
//uint32_t keylen;
union__attribute__((__packed__)){
structleafentry_cleanclean;
structleafentry_mvccmvcc;
}u;
};
static_assert(6==sizeof(leafentry),"leafentry size is wrong");
static_assert(1==__builtin_offsetof(leafentry,u),"union is in the wrong place");
intprint_klpair(FILE*outf,constvoid*key,uint32_tkeylen,LEAFENTRYv);// Print a leafentry out in human-readable form.
intle_latest_is_del(LEAFENTRYle);// Return true if it is a provisional delete.
intle_val_is_del(LEAFENTRYle,enumcursor_read_typeread_type,TOKUTXNtxn);// Returns true if the value that is to be read is empty
boolle_is_clean(LEAFENTRYle);//Return how many xids exist (0 does not count)
boolle_has_xids(LEAFENTRYle,XIDSxids);// Return true transaction represented by xids is still provisional in this leafentry (le's xid stack is a superset or equal to xids)
void*le_latest_val(LEAFENTRYle);// Return the latest val (return NULL for provisional deletes)
uint32_tle_latest_vallen(LEAFENTRYle);// Return the latest vallen. Returns 0 for provisional deletes.