At Tom Womack's request, a trivial option to use mtimes instead of
[sgt/agedu] / index.h
1 /*
2 * index.h: Manage indexes for agedu.
3 */
4
5 #include <sys/types.h>
6
7 /*
8 * Given the size of an existing data file and the number of
9 * entries required in the index, calculate and return an upper
10 * bound on the required size of the index file after an index has
11 * been written on to the end of it.
12 */
13 off_t index_compute_size(off_t currentsize, int nodecount);
14
15 /*
16 * Build an index, given the address of a memory-mapped data file
17 * and the starting offset within it.
18 *
19 * trie_file structures passed to tf must of course be within the
20 * bounds of the memory-mapped file.
21 *
22 * indexbuild_realsize returns the total amount of data _actually_
23 * written into the file, to allow it to be truncated afterwards.
24 */
25 typedef struct indexbuild indexbuild;
26 indexbuild *indexbuild_new(void *t, off_t startoff, int nodecount);
27 void indexbuild_add(indexbuild *ib, const struct trie_file *tf);
28 off_t indexbuild_realsize(indexbuild *ib);
29 void indexbuild_free(indexbuild *ib);
30
31 /*
32 * Query an index to find the total size of records with name
33 * index strictly less than n, with atime less than at.
34 */
35 unsigned long long index_query(const void *t, int n, unsigned long long at);
36
37 /*
38 * Retrieve an order statistic from the index: given a fraction f,
39 * return an atime such that (at most) the requested fraction of
40 * the total data is older than it.
41 */
42 unsigned long long index_order_stat(const void *t, double f);