{"id":16333113,"url":"https://github.com/fzakaria/space-saving","last_synced_at":"2025-07-12T01:35:00.615Z","repository":{"id":37734327,"uuid":"66505765","full_name":"fzakaria/space-saving","owner":"fzakaria","description":"Space Saving algorithm implementation (StreamSummary) in Java, used to solve heavy hitters / topk items.","archived":false,"fork":false,"pushed_at":"2016-08-24T23:05:51.000Z","size":16,"stargazers_count":32,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T15:43:22.490Z","etag":null,"topics":["algorithm","java","topk"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/fzakaria.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}},"created_at":"2016-08-24T23:00:33.000Z","updated_at":"2024-12-20T03:44:01.000Z","dependencies_parsed_at":"2022-09-16T06:13:21.689Z","dependency_job_id":null,"html_url":"https://github.com/fzakaria/space-saving","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fspace-saving","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fspace-saving/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fspace-saving/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fspace-saving/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fzakaria","download_url":"https://codeload.github.com/fzakaria/space-saving/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245036111,"owners_count":20550661,"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":["algorithm","java","topk"],"created_at":"2024-10-10T23:34:21.618Z","updated_at":"2025-03-22T23:32:00.043Z","avatar_url":"https://github.com/fzakaria.png","language":"Java","readme":"# SpaceSaving\n\nSpace Saving algorithm implementation in Java, also know as \"HeavyHitter\"\n\nThe purpose of the algorithm is to find the most frequently used items from an infinite stream.\nIn other words, even if you have millions of different values, the algorithm will try to find the most frequently used\nwithin some acceptable error bound.\n\nThe datastructure used is described by the paper [Efficient Computation of Frequent and Top-k Elements in Data Streams](http://www.cse.ust.hk/~raywong/comp5331/References/EfficientComputationOfFrequentAndTop-kElementsInDataStreams.pdf)\nby *Ahmed Metwally, Divyakant Agrawal, and Amr El Abbadi*\n\nIt is a a ϴ(1) \"constant time\" insert and  ϴ(k) lookup for the *topk* entries.\n\n```\n/**\n An epsilon of 0.001 will create 1000 counters and dictates the accuracy of the elements in the\n resulting topk based on the size of the stream.\n If your stream is 1,000,000 items an item is truly guarenteed to be in the top K elements if\n the frequency reported - error reported \u003e 1000 [0.001 * 1,000,000 = 1000]\n Since top k only cares with skewed data, we generally care for elements in the stream that probably\n have way more than 1000 entries in the stream.\n**/\nfinal double epsilon = 0.001;\nStreamSummary\u003cString\u003e streamSummary = new StreamSummary\u003c\u003e(0.01);\nstreamSummary.offer(item);\n```\n\n## Aside\nThis repository is created because although other implementations existed, I was frustrated that\nthey did not include any unit tests or thorough documentation explaining some of the error bounds.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzakaria%2Fspace-saving","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffzakaria%2Fspace-saving","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzakaria%2Fspace-saving/lists"}