diff --git a/index/rolodex.go b/index/rolodex.go index 8e1f8c5..2df7607 100644 --- a/index/rolodex.go +++ b/index/rolodex.go @@ -626,3 +626,23 @@ func (r *Rolodex) RolodexFileSize() int64 { } return size } + +// GetFullLineCount returns the total number of lines from all files in the Rolodex +func (r *Rolodex) GetFullLineCount() int64 { + var lineCount int64 + for _, v := range r.localFS { + if lfs, ok := v.(RolodexFS); ok { + for _, f := range lfs.GetFiles() { + lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1 + } + } + } + for _, v := range r.remoteFS { + if lfs, ok := v.(RolodexFS); ok { + for _, f := range lfs.GetFiles() { + lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1 + } + } + } + return lineCount +} diff --git a/index/rolodex_test.go b/index/rolodex_test.go index c24e0c7..3064689 100644 --- a/index/rolodex_test.go +++ b/index/rolodex_test.go @@ -1529,6 +1529,9 @@ func TestRolodex_SimpleTest_OneDoc(t *testing.T) { assert.Nil(t, rolo.GetRootIndex()) assert.Len(t, rolo.GetIndexes(), 10) + lineCount := rolo.GetFullLineCount() + assert.Equal(t, int64(158), lineCount, "total line count in the rolodex is wrong") + assert.NoError(t, err) assert.Len(t, rolo.indexes, 10)