track the number of cluster groups written by a cluster_table

This commit is contained in:
2025-02-04 12:54:26 +00:00
parent 02258f6403
commit eabdc8777b
2 changed files with 14 additions and 5 deletions

View File

@@ -60,6 +60,7 @@ static long tree_alloc_node(struct b_tree *p)
fseek(table->t_storage, pos, SEEK_SET); fseek(table->t_storage, pos, SEEK_SET);
len /= sizeof *n; len /= sizeof *n;
table->t_nr_groups++;
return (long)len; return (long)len;
} }
@@ -165,6 +166,8 @@ void cluster_table_init(struct cluster_table *table, FILE *storage)
&table->t_base); &table->t_base);
node_init(root); node_init(root);
tree_put_node(&table->t_base, 0, (b_tree_node *)root); tree_put_node(&table->t_base, 0, (b_tree_node *)root);
table->t_nr_groups++;
b_tree_cache_release_node(&table->t_base, (b_tree_node *)root); b_tree_cache_release_node(&table->t_base, (b_tree_node *)root);
} }

View File

@@ -1,12 +1,13 @@
#ifndef CLUSTER_H_ #ifndef CLUSTER_H_
#define CLUSTER_H_ #define CLUSTER_H_
#include <stdio.h>
#include "b-tree.h" #include "b-tree.h"
#include <stdio.h>
struct cluster_table { struct cluster_table {
struct b_tree t_base; struct b_tree t_base;
size_t t_nr_groups;
FILE *t_storage; FILE *t_storage;
}; };
@@ -21,7 +22,12 @@ struct cluster {
extern void cluster_table_init(struct cluster_table *table, FILE *storage); extern void cluster_table_init(struct cluster_table *table, FILE *storage);
extern void cluster_table_finish(struct cluster_table *table); 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_get(
extern int cluster_table_put(struct cluster_table *table, const struct cluster *in); struct cluster_table *table,
unsigned long id,
struct cluster *out);
extern int cluster_table_put(
struct cluster_table *table,
const struct cluster *in);
#endif #endif