From 5dae84354b42b42a3d5b3fcc3a41cb1b469b23e3 Mon Sep 17 00:00:00 2001 From: Thejas-bhat Date: Wed, 8 Jan 2025 22:11:19 +0530 Subject: [PATCH] BP - Cardinality API impl for TermDictionary --- dict.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dict.go b/dict.go index e30bf242..9b7cd1ee 100644 --- a/dict.go +++ b/dict.go @@ -46,6 +46,13 @@ func (d *Dictionary) PostingsList(term []byte, except *roaring.Bitmap, return d.postingsList(term, except, preallocPL) } +func (d *Dictionary) Cardinality() int { + if d.fst != nil { + return d.fst.Len() + } + return 0 +} + func (d *Dictionary) postingsList(term []byte, except *roaring.Bitmap, rv *PostingsList) (*PostingsList, error) { if d.fstReader == nil { if rv == nil || rv == emptyPostingsList {