<commit_before>#ifndef LEAFENTRY_H
#define LEAFENTRY_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 Tokutek Inc.  All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."


/*
 * Header file for Leafentries
 */

#include <toku_portability.h>
#include "rbuf.h"
#include "x1764.h"

#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
#endif

#if 0
    Memory format of packed nodup leaf entry
    CONSTANTS:
        num_uxrs
        keylen
    Run-time-constants
        voffset of val/vallen??? (for le_any_val) This must be small if it is interpreted as voffset = realoffset_of_val - keylen
            GOOD performance optimization.
            ALSO good for simplicity (no having to scan packed version)
        key[]
    variable length
        
        
    Memory format of packed dup leaf entry
    CONSTANTS:
        num_uxrs
        keylen
        vallen
    Run-time-constants
        key[]
        val[]
#endif
#if TOKU_WINDOWS
#pragma pack(push, 1)
#endif

//
// enum of possible values for LEAFENTRY->type field
//
enum { LE_CLEAN = 0, LE_MVCC = 1 };

struct __attribute__ ((__packed__)) leafentry {
    uint8_t  type;
    uint32_t keylen;
    union {
        struct __attribute__ ((__packed__)) leafentry_clean {
            uint32_t vallen;
            uint8_t  key_val[0];     //Actual key, then actual val
        } clean; // For the case where LEAFENTRY->type is LE_CLEAN
        struct __attribute__ ((__packed__)) leafentry_mvcc {
            uint32_t num_cxrs; // number of committed uxrs
            uint8_t  num_pxrs; // number of provisional uxrs
            u_int8_t key_xrs[0]; //Actual key,
                                 //then interesting TXNIDs
                                 //then interesting lengths (type bit is MSB of length)
                                 //then interesting data
                                 //then other transaction records
        } mvcc; // For the case where LEAFENTRY->type is LE_MVCC
    } u;<commit_msg>[t:3008], add comments to leafentry struct describing format<commit_after>#ifndef LEAFENTRY_H
#define LEAFENTRY_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 Tokutek Inc.  All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."


/*
 * Header file for Leafentries
 */

#include <toku_portability.h>
#include "rbuf.h"
#include "x1764.h"

#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
#endif

#if 0
    Memory format of packed nodup leaf entry
    CONSTANTS:
        num_uxrs
        keylen
    Run-time-constants
        voffset of val/vallen??? (for le_any_val) This must be small if it is interpreted as voffset = realoffset_of_val - keylen
            GOOD performance optimization.
            ALSO good for simplicity (no having to scan packed version)
        key[]
    variable length
        
        
    Memory format of packed dup leaf entry
    CONSTANTS:
        num_uxrs
        keylen
        vallen
    Run-time-constants
        key[]
        val[]
#endif
#if TOKU_WINDOWS
#pragma pack(push, 1)
#endif

//
// enum of possible values for LEAFENTRY->type field
//
enum { LE_CLEAN = 0, LE_MVCC = 1 };

struct __attribute__ ((__packed__)) leafentry {
    uint8_t  type;
    uint32_t keylen;
    union {
        struct __attribute__ ((__packed__)) leafentry_clean {
            uint32_t vallen;
            uint8_t  key_val[0];     //Actual key, then actual val
        } clean; // For the case where LEAFENTRY->type is LE_CLEAN
        struct __attribute__ ((__packed__)) leafentry_mvcc {
            uint32_t num_cxrs; // number of committed uxrs
            uint8_t  num_pxrs; // number of provisional uxrs
            u_int8_t key_xrs[0]; //Actual key,
                                 //then "interesting" TXNIDs:
                                 //  if provisional uxrs exist, store OUTERMOST TXNID
                                 //  then store committed TXNIDs, from most recently committed to least recently committed
                                 //then "interesting" lengths (length is at most 1<<31, MSB is used to store the type bit):
                                 //  if provisional uxrs exist, store length and type of INNERMOST TXNID
                                 //  then store length and type of committed TXNIDs, in same order as above
                                 //then "interesting" data
                                 //  if provisional uxrs exist, store data for INNERMOST TXNID
                                 //  then store data for committed TXNIDs
                                 //if provisional uxrs still exist (that is, num_puxrs > 1, so INNERMOST provisional != OUTERMOST provisional):
                                 //  for OUTERMOST provisional TXNID:
                                 //    1 byte: store type
                                 //    4 bytes: length (if type is INSERT)
                                 //    data
                                 //  for rest of provisional stack, from outermost to innermost, but NOT including innermost:
                                 //   8 bytes: TXNID
                                 //   1 byte: store type
                                 //   4 bytes: length (if type is INSERT)
                                 //   data
                                 //  for INNERMOST provisional TXNID:
                                 //   8 bytes: TXNID
        } mvcc; // For the case where LEAFENTRY->type is LE_MVCC
    } u;
{'fraction_non_alphanumeric': 0.06638935108153078, 'fraction_numerical': 0.014309484193011647, 'mean_word_length': 1.7447488584474886, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1157045', 'n_tokens_mistral': 1701, 'n_tokens_neox': 1612, 'n_words': 604}