Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on totalSize function #114

Open
acondolu opened this issue Apr 1, 2020 · 1 comment
Open

Question on totalSize function #114

acondolu opened this issue Apr 1, 2020 · 1 comment

Comments

@acondolu
Copy link
Contributor

acondolu commented Apr 1, 2020

While adding documentation I stumbled upon the function totalSize in Admin.hs:

totalSize :: MonadIO m => Collection -> Action m Int
totalSize coll = do
    x <- storageSize coll
    xs <- mapM isize =<< getIndexes coll
    return (foldl (+) x xs)
 where
    isize idx = at "storageSize" `liftM` collectionStats (coll `T.append` ".$" `T.append` at "name" idx)

The function sums the storage size of a collection with the (separately computed) sizes of its indices. What is strange to me is that collectionStats is called on things that are not collections, but indices.

Why not just using the totalIndexSize function (defined just above totalSize) i.e. something like:

totalSize coll = liftM2 (+) (storageSize coll) (totalIndexSize coll)
@VictorDenisov
Copy link
Member

It definitely looks suspicious. However since this is part of public API I would refrain from modifying this method's behavior even though it seems broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants