<commit_before>#ifndef NAIVEDB_BPLUSDATA_H
#define NAIVEDB_BPLUSDATA_H

#include "file.h"
#include "location.h"
#include "storage.h"

namespace naivedb {

const int TreeOrder = 4;

#pragma pack(1)

struct InternalNodeData {
    bool is_leaf;
    Location keys[TreeOrder - 1];
    int children_offset[TreeOrder];

    void init() {
        is_leaf = false;
        for (int i = 0; i < TreeOrder - 1; i++) {
            keys[i].init();
            children_offset[i] = -1;
        }
        children_offset[TreeOrder - 1] = -1;
    }
};

struct LeafNodeData {
    bool is_leaf;
    int next;
    Location keys[TreeOrder];
    Location values[TreeOrder];

    void init() {
        is_leaf = true;
        for (int i = 0; i < TreeOrder; i++) {
            keys[i].init();
            values[i].init();
        }
    }
};

#pragma pack()


}
#endif // NAIVEDB_BPLUSDATA_H<commit_msg>Uniform representation of b+ node data<commit_after>#ifndef NAIVEDB_BPLUSDATA_H
#define NAIVEDB_BPLUSDATA_H

#include "location.h"

namespace naivedb {

const int TreeOrder = 4;

#pragma pack(1)

struct BPlusNode {
    bool is_leaf;
    union {
        Location locs[TreeOrder * 2 - 1];
        struct {
            Location keys[TreeOrder - 1];
            Location children[TreeOrder];
        } Internal;

        struct {
            Location keys[TreeOrder - 1];
            Location values[TreeOrder - 1];
            Location next;
        } Leaf;
    };

    void init(bool is_leaf = false) {
        this->is_leaf = is_leaf;
        for (auto &loc:locs)
            loc.init();
    }
};

#pragma pack()


}
#endif // NAIVEDB_BPLUSDATA_H
{'fraction_non_alphanumeric': 0.11576354679802955, 'fraction_numerical': 0.009852216748768473, 'mean_word_length': 2.1431334622823983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3776614', 'n_tokens_mistral': 569, 'n_tokens_neox': 548, 'n_words': 130}