# Reference count storage

class `larch.refcountstore.``RefcountStore`(node_store)

  Store node reference counts.

  Each node has a reference count, which gets stored on disk. Reference counts are grouped into blocks of `self.per_group` counts, and each group is stored in its own file. This balances the per-file overhead with the overhead of keeping a lot of unneeded reference counts in memory.

  Only those blocks that are used get loaded into memory. Blocks that are full of zeroes are not stored in files, to save disk space.

  `get_refcount`(node_id)

    Return reference count for a given node.

  `per_group` = 32768
  `refcountdir` = 'refcounts'
  `save_refcounts`()

    Save all modified refcounts.

  `set_refcount`(node_id, refcount)

    Set the reference count for a given node.

`larch.refcountstore.``decode_refcounts`(encoded)

`larch.refcountstore.``encode_refcounts`(refcounts, start_id, how_many, keys)