2 * index.h: Manage indexes for agedu.
8 * Given the size of an existing data file and the number of
9 * entries required in the index, return the file size required to
10 * store the fixed initial fragment of the index before the
11 * indexbuild functions are invoked.
13 off_t
index_initial_size(off_t currentsize
, int nodecount
);
16 * Build an index, given the address of a memory-mapped data file
17 * and the starting offset within it.
19 * trie_file structures passed to tf must of course be within the
20 * bounds of the memory-mapped file.
22 * The "delta" parameter to indexbuild_new is filled in with the
23 * maximum size by which the index can ever grow in a single
24 * indexbuild_add call. This can be used, together with
25 * indexbuild_realsize, to detect when the index is about to get
26 * too big for its file and the file needs resizing.
28 * indexbuild_add adds a trie_file structure to the index.
29 * indexbuild_tag, called after that, causes the current state of
30 * the index to be preserved so that it can be queried later. It's
31 * idempotent, and will safely do nothing if called before
34 * indexbuild_realsize returns the total amount of data _actually_
35 * written into the file, to allow it to be truncated afterwards,
36 * and to allow the caller of the indexbuild functions to know
37 * when the file is about to need to grow bigger during index
40 * indexbuild_rebase is used when the file has been
41 * re-memory-mapped at a different address (because it needs to
44 typedef struct indexbuild indexbuild
;
45 indexbuild
*indexbuild_new(void *t
, off_t startoff
, int nodecount
,
47 void indexbuild_add(indexbuild
*ib
, const struct trie_file
*tf
);
48 void indexbuild_tag(indexbuild
*ib
);
49 void indexbuild_rebase(indexbuild
*ib
, void *t
);
50 off_t
indexbuild_realsize(indexbuild
*ib
);
51 void indexbuild_free(indexbuild
*ib
);
54 * Check to see if a name index has an index tree root available
55 * (i.e. represents a directory rather than a file).
57 int index_has_root(const void *t
, int n
);
60 * Query an index to find the total size of records with name
61 * index strictly less than n, with atime less than at.
63 unsigned long long index_query(const void *t
, int n
, unsigned long long at
);
66 * Retrieve an order statistic from the index: given a fraction f,
67 * return an atime such that (at most) the requested fraction of
68 * the total data is older than it.
70 unsigned long long index_order_stat(const void *t
, double f
);