start implementing cluster table using b_tree

This commit is contained in:
2025-02-01 22:13:00 +00:00
parent fea949f1f4
commit 8ca50e4888
2 changed files with 68 additions and 0 deletions

41
src/cluster.c Normal file
View File

@@ -0,0 +1,41 @@
#include <string.h>
#include "bin.h"
#include "cluster.h"
static const struct b_tree_ops cluster_table_ops = {
.tree_get_node = NULL,
.tree_put_node = NULL,
.tree_alloc_node = NULL,
.node_get_nr_entries = NULL,
.node_set_nr_entries = NULL,
.node_get_entries = NULL,
.node_get_children = NULL,
.entry_compare = NULL,
};
void cluster_table_init(struct cluster_table *table, FILE *storage)
{
memset(table, 0x0, sizeof *table);
table->t_storage = storage;
b_tree_init(&table->t_base, &cluster_table_ops, sizeof(struct ec3_cluster_group), sizeof(struct ec3_cluster), EC3_CLUSTERS_PER_GROUP + 1);
}
void cluster_table_finish(struct cluster_table *table)
{
}
int cluster_table_get(struct cluster_table *table, unsigned long id, struct cluster *out)
{
return -1;
}
int cluster_table_put(struct cluster_table *table, const struct cluster *in)
{
return -1;
}

27
src/cluster.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef CLUSTER_H_
#define CLUSTER_H_
#include <stdio.h>
#include "b-tree.h"
struct cluster_table {
struct b_tree t_base;
FILE *t_storage;
};
struct cluster {
unsigned long c_id;
size_t c_base;
size_t c_len;
unsigned long c_checksum;
unsigned int c_flags;
};
extern void cluster_table_init(struct cluster_table *table, FILE *storage);
extern void cluster_table_finish(struct cluster_table *table);
extern int cluster_table_get(struct cluster_table *table, unsigned long id, struct cluster *out);
extern int cluster_table_put(struct cluster_table *table, const struct cluster *in);
#endif