{"id":44400363,"url":"https://github.com/jerolba/bikey","last_synced_at":"2026-02-12T06:14:58.364Z","repository":{"id":51301568,"uuid":"182254896","full_name":"jerolba/bikey","owner":"jerolba","description":"Low memory footprint Map and Set implementation on objects with composited keys","archived":false,"fork":false,"pushed_at":"2021-05-17T04:25:27.000Z","size":150,"stargazers_count":14,"open_issues_count":5,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T19:09:40.387Z","etag":null,"topics":["bikey","collections","java","map","set","table"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jerolba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-19T11:32:23.000Z","updated_at":"2023-11-27T10:06:15.000Z","dependencies_parsed_at":"2022-09-02T11:01:33.338Z","dependency_job_id":null,"html_url":"https://github.com/jerolba/bikey","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jerolba/bikey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerolba%2Fbikey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerolba%2Fbikey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerolba%2Fbikey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerolba%2Fbikey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jerolba","download_url":"https://codeload.github.com/jerolba/bikey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jerolba%2Fbikey/sbom","scorecard":{"id":515883,"data":{"date":"2025-08-11","repo":{"name":"github.com/jerolba/bikey","commit":"2fe78dc28add5a2272afd34b548a9e8224556029"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T01:48:59.079Z","repository_id":51301568,"created_at":"2025-08-20T01:48:59.079Z","updated_at":"2025-08-20T01:48:59.079Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29360522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bikey","collections","java","map","set","table"],"created_at":"2026-02-12T06:14:58.305Z","updated_at":"2026-02-12T06:14:58.358Z","avatar_url":"https://github.com/jerolba.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/com.jerolba/bikey.svg)](https://maven-badges.herokuapp.com/maven-central/com.jerolba/bikey)\n[![Build Status](https://circleci.com/gh/jerolba/bikey.svg?style=shield)](https://circleci.com/gh/jerolba/bikey) \n[![Download](https://api.bintray.com/packages/jerolba/maven/bikey/images/download.svg)](https://bintray.com/jerolba/maven/bikey/_latestVersion)\n[![Codecov](https://codecov.io/gh/jerolba/bikey/branch/master/graph/badge.svg)](https://codecov.io/gh/jerolba/bikey/)\n[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)\n[![Javadocs](https://javadoc.io/badge/com.jerolba/bikey.svg)](https://javadoc.io/doc/com.jerolba/bikey)\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cbr\u003e\n\t\u003cimg src=\"./config/bikey-logo.svg\" width=\"140\"/\u003e\t\n    \u003cspan style=\"font-size: 25px\"\u003e\u003ch1\u003eBikey\u003c/h1\u003e\u003c/span\u003e\n\u003c/div\u003e\n\nBikey implements Map and Set data structures with two keys minimizing memory consumption.\n\n## Why Bikey collections?\n\nCurrent collections libraries ([Guava](https://github.com/google/guava), [Commons Collection](https://commons.apache.org/proper/commons-collections/), [Eclipse Collections](https://github.com/eclipse/eclipse-collections)) have poor or not support to Maps and Sets with two keys.\n\nImplementing it manually with a `Map\u003cR, Map\u003cC, V\u003e\u003e`, `Map\u003cTuple\u003cR, C\u003e, V\u003e` or a `Set\u003cTuple\u003cR, C\u003e\u003e` consumes a lot of memory, and [choosing an incorrect hashCode function](https://medium.com/@jerolba/hashing-and-maps-87950eed673f) for Tuple (or equivalent) class can [penalize memory and CPU consumption](https://medium.com/@jerolba/composite-key-hashmaps-1422e2e6cdbc).\n\n**Bikey Map collection can reduce to a 15%-30% of consumed memory** by a traditional double map (depending on the map _fill rate_) and **Bikey Set collection can reduce to a 1% of consumed memory by a Set\\\u003cTuple\\\u003e**, with none or low penalization in access time.\n\n## Some Quick Examples\n\n`BikeyMap` API is defined like the [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html) interface but everywhere a key is needed, you must provide both key values.\n\nTo simplify the example `String`s has been used as keys, but any object that implements `equals` and `hashCode` can be used as row or column key. You can also use any kind of object as value. I've used Integer to simplify the following code:\n\n```java\nBikeyMap\u003cString, String, Integer\u003e stock = new TableBikeyMap\u003c\u003e();\nstock.put(\"shirt-ref-123\", \"store-76\", 10);\nstock.put(\"pants-ref-456\", \"store-12\", 24);\n...\nstock.put(\"tie-ref-789\", \"store-23\", 2);\n\nInteger available = stock.get(\"shirt-ref-1234\", \"store-45\");\n\n//Total stock in store-123\nstock.entrySet().stream()\n     .filter(entry -\u003e entry.getColumn().equals(\"store-123\"))\n     .mapToInt(entry -\u003e entry.getValue())\n     .sum();\n\n//Total stock in pants-ref-457\nstock.entrySet().stream()\n     .filter(entry -\u003e entry.getRow().equals(\"pants-ref-457\"))\n     .mapToInt(entry -\u003e entry.getValue())\n     .sum();\n\n//All products included\nSet\u003cString\u003e products = stock.rowKeySet();\n\n//All stores included\nSet\u003cString\u003e stores = stock.columnKeySet();\n\n//Contains a product and store?\nif (stock.containsKey(\"tie-ref-789\", \"store-23\")) {\n    ....\n}\n\n//Get all product/stores presents in the map\nBikeySet\u003cString, String\u003e productStores = map.bikeySet();\n\n//BikeySet\u003cR, C\u003e also implements Set\u003cBikey\u003cR, C\u003e\u003e\nSet\u003cBikey\u003cString, String\u003e\u003e productStoresSet = map.bikeySet();\n\n//Get products and stores with stock\nBikeySet\u003cString, String\u003e withStock = stock.entrySet().stream()\n    .filter(entry -\u003e entry.getValue() \u003e 0)\n    .map(BikeyEntry::getKey)\n    .collect(BikeyCollectors.toSet());\n\n//Do something with each element in the map\nstock.forEach((product, store, units) -\u003e {\n    System.out.println(\"Product \" + product + \" has \" + units + \" in store \" + store);\n});\n```\n\n\n`BikeySet` API is defined like the [Set](https://docs.oracle.com/javase/8/docs/api/java/util/Set.html) interface but everywhere an element is used, changes to two values:\n\n```java\nBikeySet\u003cString, String\u003e avengerFilms = new TableBikeySet\u003c\u003e();\navengerFilms.add(\"Hulk\", \"The Avengers\");\navengerFilms.add(\"Iron Man\", \"The Avengers\");\navengerFilms.add(\"Thor\", \"Avengers: Age of Ultron\");\navengerFilms.add(\"Thor\", \"Thor: Ragnarok\");\navengerFilms.add(\"Captain America\", \"Avengers: Infinity War\");\n....\n\nif (avengerFilms.contains(\"Iron Man\", \"Black Panther\")) {\n    ....\n}\n\n//Films in the Set\nSet\u003cString\u003e filmsInSet = avengerFilms.columnKeySet();\n\n//Avengers in the Set\nSet\u003cString\u003e avengersInSet = avengerFilms.rowKeySet();\n\n//Films with Iron Man\nList\u003cString\u003e ironManFilms = avengerFilms.stream()\n    .filter(entry -\u003e entry.getRow().equals(\"Iron Man\"))\n    .map(Bikey::getColumn)\n    .collect(toList());\n\n//Call to a BiFunction for each element in the Set\nbikeySet.forEach(this::doSomething);\n\npublic void doSomething(String avenger, String film) {\n  ....\n}\n```\n\n## Implementations\n\n`BikeyMap\u003cR, C ,V\u003e` has two implementations:\n\n- `TableBikeyMap\u003cR, C ,V\u003e`: optimized for memory consumption, and with performance similar to a double map or tuple map version.\n- `MatrixBikeyMap\u003cR, C V`: optimizes performance, but with the disadvantage of consuming a little more memory with low fill rates.\n\ndepending on your business logic, you can use one or the other. \n\n`MatrixBikeyMap` behaves like a matrix and grows quickly in memory consumption, but then it remains stable. It's recommended only if the fill rate is greater than 60% or access time to their elements is important. By default we recommend to use `TableBikey` implementation. \n\n\n## Dependency\n\nBikey is uploaded to Maven Central Repository and to use it, you need to add the following Maven dependency:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.jerolba\u003c/groupId\u003e\n  \u003cartifactId\u003ebikey\u003c/artifactId\u003e\n  \u003cversion\u003e0.9.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nin Gradle:\n\n`implementation 'com.jerolba:bikey:0.9.0'`\n\nor download the single [jar](http://central.maven.org/maven2/com/jerolba/bikey/0.9.0/bikey-0.9.0.jar) from Maven Central Repository.\n\n## Benchmarks\n\nExecute your own benchmarks before deciding to use this library, but as a reference you can start with these numbers:\n\n### Memory\n\nCompared to `Map\u003cR, Map\u003cC, V\u003e\u003e` and `Map\u003cTuple\u003cR, C\u003e, V\u003e`, the memory consumed filling a map with 10.000 x 1.000 elements is:\n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vSQ28bJxu3RYU0WwBWKmm1_d6sLM0I3aPvr5bctzsblGgHRvfvOSkczdoT-JXpAmXrD74DShTlzo1Um/pubchart?oid=2140734164\u0026format=image\"/\u003e\n\nCompared to `HashMap\u003cR, HashSet\u003cC\u003e\u003e` and `HashSet\u003cTuple\u003cR, C\u003e\u003e` implementations, the memory consumed filling a Set with 10.000 x 1.000 elements is: \n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vSQ28bJxu3RYU0WwBWKmm1_d6sLM0I3aPvr5bctzsblGgHRvfvOSkczdoT-JXpAmXrD74DShTlzo1Um/pubchart?oid=635532048\u0026format=image\"/\u003e\n\n### Performance\n\nTo create and fill randomly different maps in each implementation, the time spent is:\n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vRiwv5Uo_b2c7jklJn59b__EaUnNfnhakDaZUgjMue7tE9OL0IQPbwFmY7QR42VGCEH4jJJkHLIPpk2/pubchart?oid=1182671191\u0026format=image\"/\u003e\n\nTo find randomly different maps in each implementation, the time spent is:\n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vRiwv5Uo_b2c7jklJn59b__EaUnNfnhakDaZUgjMue7tE9OL0IQPbwFmY7QR42VGCEH4jJJkHLIPpk2/pubchart?oid=1247212528\u0026format=image\"/\u003e\n\nTo create and fill randomly a Set with 10.000 x 1.000 elements, the time spent is:\n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vSQ28bJxu3RYU0WwBWKmm1_d6sLM0I3aPvr5bctzsblGgHRvfvOSkczdoT-JXpAmXrD74DShTlzo1Um/pubchart?oid=817188927\u0026format=image\"/\u003e\n\nTo check randomly the existence of each element in a Set with 10.000 x 1.000 elements, the time spent is:\n\n\u003cimg src=\"https://docs.google.com/spreadsheets/d/e/2PACX-1vSQ28bJxu3RYU0WwBWKmm1_d6sLM0I3aPvr5bctzsblGgHRvfvOSkczdoT-JXpAmXrD74DShTlzo1Um/pubchart?oid=1242227435\u0026format=image\"/\u003e\n \n\n## Contribute\nFeel free to dive in! [Open an issue](https://github.com/jerolba/bikey/issues/new) or submit PRs.\n\nAny contributor and maintainer of this project follows the [Contributor Covenant Code of Conduct](https://github.com/jerolba/bikey/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n[Apache 2](https://github.com/jerolba/bikey/blob/master/LICENSE.txt) © Jerónimo López\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerolba%2Fbikey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjerolba%2Fbikey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjerolba%2Fbikey/lists"}