diff options
Diffstat (limited to 'src/domain/search.c')
| -rw-r--r-- | src/domain/search.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/domain/search.c b/src/domain/search.c index faf16ff..e34cc72 100644 --- a/src/domain/search.c +++ b/src/domain/search.c @@ -356,6 +356,24 @@ tiny_search_index_create(void) return calloc(1, sizeof(tiny_search_index_t)); } +uint64_t +tiny_search_index_memory_estimate(const tiny_search_index_t *index) +{ + uint64_t total; + size_t position; + if (!index) + { + return 0; + } + total = sizeof(*index) + index->bucket_capacity * sizeof(*index->buckets) + + index->slot_capacity * sizeof(*index->slots); + for (position = 0; position < index->bucket_count; ++position) + { + total += index->buckets[position].capacity * sizeof(*index->buckets[position].messages); + } + return total; +} + void tiny_search_index_free(tiny_search_index_t *index) { @@ -710,4 +728,4 @@ tiny_search_score(const char *query, const tiny_message_t *message) return 0.0; } return breakdown.total; -}
\ No newline at end of file +} |
