{"id":19032495,"url":"https://github.com/creadone/counter_tree","last_synced_at":"2025-02-21T20:28:00.823Z","repository":{"id":185025124,"uuid":"662675134","full_name":"creadone/counter_tree","owner":"creadone","description":"A sectioned hash table for storing counters","archived":false,"fork":false,"pushed_at":"2023-07-05T18:35:42.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T04:27:29.112Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creadone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-05T16:30:50.000Z","updated_at":"2023-07-05T16:33:30.000Z","dependencies_parsed_at":"2023-07-31T12:10:38.147Z","dependency_job_id":"f115ff31-d155-4f79-9bc4-513b7a566958","html_url":"https://github.com/creadone/counter_tree","commit_stats":null,"previous_names":["creadone/counter_tree"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fcounter_tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fcounter_tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fcounter_tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fcounter_tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creadone","download_url":"https://codeload.github.com/creadone/counter_tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240082641,"owners_count":19745257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T21:28:58.103Z","updated_at":"2025-02-21T20:28:00.804Z","avatar_url":"https://github.com/creadone.png","language":"Crystal","readme":"# CounterTree\n\nA sectioned hash table for storing counters that allow you to store values on a specific date and fetch as a sum or slice between two dates. This is part of the [Karma](https://github.com/creadone/karma)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     counter_tree:\n       github: creadone/counter_tree\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"counter_tree\"\n\n# Init with 9 sections\ntree = CounterTree::Tree.new(9)\n\n# Increment value for key\ntree.increment(1234_u64)\n\n# Decrement value for key\ntree.decrement(1234_u64)\n\n# Fetch sum of values for key\ntree.sum(1234_u64)\n\n# Fetch sum between timestamps for key\ntree.sum(1234_u64, 1684767251993, 1684767253996)\n\n# Fetch hash between timestamps for key\ntree.find(1234_u64, 1684767251993, 1684767253996)\n\n# Fetch hash between timestamps for all counters\ntree.find(1684767251993, 1684767253996)\n\n# Delete values between timestamps for key\ntree.delete(1234_u64, 1684767251993, 1684767253996)\n\n# Delete values between timestamps over all counters\ntree.delete(1684767251993, 1684767253996)\n\n# Reset counter for key\ntree.reset(1234_u64)\n\n# Reset all counters\ntree.reset\n\n# Store tree to msgpack\nCounterTree.dump(tree)\n\n# Load tree from msgpack\nCounterTree.load(tree_bytes)\n```\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/your-github-user/counter_tree/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [creadone](https://github.com/creadone) - creator and maintainer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fcounter_tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreadone%2Fcounter_tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fcounter_tree/lists"}