From c27a7c69e5028e4a74ffc6deba869b04646b2a33 Mon Sep 17 00:00:00 2001 From: Thejas-bhat Date: Fri, 6 Dec 2024 12:34:59 +0530 Subject: [PATCH] exposing the cardinality API of the fst --- dict.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dict.go b/dict.go index 7c52ae9..e0f29bc 100644 --- a/dict.go +++ b/dict.go @@ -38,6 +38,13 @@ type Dictionary struct { // represents an immutable, empty dictionary var emptyDictionary = &Dictionary{} +func (d *Dictionary) Cardinality() int { + if d.fst != nil { + return d.fst.Len() + } + return 0 +} + // PostingsList returns the postings list for the specified term func (d *Dictionary) PostingsList(term []byte, except *roaring.Bitmap, prealloc segment.PostingsList) (segment.PostingsList, error) {