Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Written some non-update API calls and "add" based update API calls #37

Merged
merged 16 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions hhds/testing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>

class MyClass {
private:
void privateFunction() {
std::cout << "Private function called" << std::endl;
// Calling a public member function from a private member function
publicFunction();
}
public:
void publicFunction() {
std::cout << "Public function called" << std::endl;
}

void callPrivateFunction() {
privateFunction();
}

};

int main() {
MyClass obj;
obj.callPrivateFunction(); // This will call the private function indirectly
return 0;
}
116 changes: 116 additions & 0 deletions hhds/tree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include <sys/types.h>
#include <sys/stat.h>

#include <stdexcept>
#include <cassert>

#include <cstdint>
#include <functional>
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <vector>
using namespace std;

using Tree_pos = uint64_t;

static constexpr Tree_pos INVALID = 0; // ROOT ID
static constexpr Tree_pos ROOT = 0; // ROOT ID
static constexpr short CHUNK_BITS = 43; // Number of chunks in a tree node
static constexpr short SHORT_DELTA = 21; // Amount of short delta allowed
static constexpr short MAX_OFFSET = 3; // The number of bits in a chunk offset
static constexpr short CHUNK_SIZE = 1 << MAX_OFFSET; // Size of a chunk in bits
static constexpr short CHUNK_MASK = CHUNK_SIZE - 1; // Mask for chunk offset
static constexpr uint64_t MAX_TREE_SIZE = 1LL << CHUNK_BITS; // Maximum number of nodes in the tree

struct __attribute__((packed)) Tree_pointers {
// We only store the exact ID of parent
Tree_pos parent : CHUNK_BITS + MAX_OFFSET;
Tree_pos next_sibling : CHUNK_BITS;
Tree_pos prev_sibling : CHUNK_BITS;

// Long child pointers
Tree_pos first_child_l : CHUNK_BITS;
Tree_pos last_child_l : CHUNK_BITS;

// Short (delta) child pointers
struct __attribute__((packed)) short_child {
Tree_pos delta : SHORT_DELTA;
} first_child_s[CHUNK_SIZE - 1], last_child_s[CHUNK_SIZE - 1];

// Gives 70 bits
// struct __attribute__((packed)) short_child {
// Tree_pos delta : SHORT_DELTA;
// } first_child_s[CHUNK_SIZE - 1], last_child_s[CHUNK_SIZE - 1];

// Short deltas
// These give 64 bit alignment
// Tree_pos first_child_s_0 : SHORT_DELTA;
// Tree_pos first_child_s_1 : SHORT_DELTA;
// Tree_pos first_child_s_2 : SHORT_DELTA;
// Tree_pos first_child_s_3 : SHORT_DELTA;
// Tree_pos first_child_s_4 : SHORT_DELTA;
// Tree_pos first_child_s_5 : SHORT_DELTA;
// Tree_pos first_child_s_6 : SHORT_DELTA;

// Tree_pos last_child_s_0 : SHORT_DELTA;
// Tree_pos last_child_s_1 : SHORT_DELTA;
// Tree_pos last_child_s_2 : SHORT_DELTA;
// Tree_pos last_child_s_3 : SHORT_DELTA;
// Tree_pos last_child_s_4 : SHORT_DELTA;
// Tree_pos last_child_s_5 : SHORT_DELTA;
// Tree_pos last_child_s_6 : SHORT_DELTA;

// Gives 70 bytes, 3 for each arr
// std::array<short_child, CHUNK_MASK> first_child_s;
// std::array<short_child, CHUNK_MASK> last_child_s;

// Gives
// uint_32t first_child_s[CHUNK_MASK] : SHORT_DELTA;
// uint_32t last_child_s[CHUNK_MASK] : SHORT_DELTA;

Tree_pointers()
: parent(MAX_TREE_SIZE), next_sibling(0), prev_sibling(0),
first_child_l(0), last_child_l(0) {

// Fill first_child_s and last_child_s
// for (int i = 0; i < CHUNK_SIZE - 1; i++) {
// first_child_s[i].delta = 0;
// last_child_s[i].delta = 0;
// }

// std::fill(first_child_s.begin(), first_child_s.end(), short_child{0});
// std::fill(last_child_s.begin(), last_child_s.end(), short_child{0});

// first_child_s_0 = 0;
// first_child_s_1 = 0;
// first_child_s_2 = 0;
// first_child_s_3 = 0;
// first_child_s_4 = 0;
// first_child_s_5 = 0;
// first_child_s_6 = 0;

// last_child_s_0 = 0;
// last_child_s_1 = 0;
// last_child_s_2 = 0;
// last_child_s_3 = 0;
// last_child_s_4 = 0;
// last_child_s_5 = 0;
// last_child_s_6 = 0;

// for (int i = 0; i < CHUNK_MASK; i++) {
// first_child_s[i] = 0;
// last_child_s[i] = 0;
// }
}
renau marked this conversation as resolved.
Show resolved Hide resolved
};

int main() {

Tree_pointers test;
cout << sizeof(test) << endl;
// cout << sizeof(test.first_child_s[0]) << endl;

return 0;
}
Loading