{"id":22059912,"url":"https://github.com/criccomini/ezdb","last_synced_at":"2025-07-24T01:31:45.071Z","repository":{"id":6483067,"uuid":"7723306","full_name":"criccomini/ezdb","owner":"criccomini","description":"EZDB provides a nice Java wrapper around LevelDB, RocksDB, and LMDB.","archived":false,"fork":false,"pushed_at":"2023-11-02T10:03:59.000Z","size":836,"stargazers_count":66,"open_issues_count":1,"forks_count":11,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-17T13:02:51.620Z","etag":null,"topics":["java","jni","leveldb","lmdb","lsmtree","rocksdb"],"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/criccomini.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-01-20T23:16:44.000Z","updated_at":"2024-06-28T15:05:57.000Z","dependencies_parsed_at":"2022-09-11T10:40:29.673Z","dependency_job_id":null,"html_url":"https://github.com/criccomini/ezdb","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criccomini%2Fezdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criccomini%2Fezdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criccomini%2Fezdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criccomini%2Fezdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/criccomini","download_url":"https://codeload.github.com/criccomini/ezdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227384652,"owners_count":17772411,"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":["java","jni","leveldb","lmdb","lsmtree","rocksdb"],"created_at":"2024-11-30T17:34:30.148Z","updated_at":"2024-11-30T17:34:30.813Z","avatar_url":"https://github.com/criccomini.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EZDB\n\nEZDB provides a nice Java wrapper around LevelDB that provides:\n\n* Key/value lookup\n* Hash/range lookup (like Amazon's DynamoDB)\n* Pluggable serializers\n* Pluggable range key sorting\n* Basic versioning for values\n* Choice between native (JNI) and pure-Java LevelDB implementations\n\n### Using EZDB\n\nTo use EZDB, you need to create a database:\n\n    Db ezdb = new EzLevelDb(new File(\"/tmp\"));\n\nThe database is the place where all of your tables will be stored. Each \"table\" is actually just a LevelDB database. The file that's passed into EzLevelDB specifies a root folder where LevelDB databases will be stored.\n\n##### Key/Value\n\nOnce you have a database, you can create a table:\n\n    Table\u003cInteger, Integer\u003e table = ezdb.getTable(\"simple\", IntegerSerde.get, IntegerSerde.get);\n\nIn this example, we're just creating a simple key/value table. If \"simple\" already exists on disk, it will be re-used. If not, it will be created. A \"serde\" (serializer/deserializer) is supplied to translate your Java objects to and from byte[] arrays that LevelDB can handle.\n\nNow you can store data in your table:\n\n    table.put(1, 2);\n\nAnd read data back out:\n\n    System.out.println(table.get(1));\n\nThis would print the number 2.\n\n##### Hash/Range\n\nEZDB also supports hash/range tables. These tables provide range query functionality, so you can scan rows, instead of just doing a simple lookup. First, you need to get a hash/range table:\n\n    RangeTable\u003cInteger, String, Integer\u003e table = ezdb.getTable(\"hash-range\", IntegerSerde.get, StringSerde.get, IntegerSerde.get);\n\nWith hash/range tables, you supply three serdes when getting the table; one for the hash key, range key, and value, respectively.\n\nNow you can store data in the table:\n\n    table.put(1213, \"20120101-bang\", 1357);\n    table.put(1213, \"20120102-foo\", 1234);\n    table.put(1213, \"20120102-bar\", 5678);\n    table.put(2324, \"20120102-baz\", 2468);\n    table.put(1213, \"20120103-baz\", 3579);\n    table.put(1213, 12345678);\n\nNotice that you can use a hash/range table flexibly as both a key/value store and a hash/range store. In the last line, we've stored a simple key/value. \n\n    System.out.println(table.get(1213));\n\nThis would print 12345678. If you don't supply a range key, EZDB just defaults to null.\n\nYou can always do simple lookups by hash/range:\n\n    System.out.println(table.get(1213, \"20120103-baz\"));\n\nThis would print 2468.\n\nYou can also do a range query within a hash bucket.\n\n    TableIterator\u003cInteger, String, Integer\u003e it = table.range(1213, \"20120102\", \"20120103\");\n    \n    while(it.hasNext()) {\n      System.out.println(it.next().getValue());\n    }\n\nThis would print 5678 then 1234 (\"20120102-bar\" is lexicographically less than \"20120102-foo\"), but not 1357, 2468, 3579, or 12345678. This functionality is very similar to DynamoDB's hash key/range key behavior. Using the hash key, you can group rows together, and then perform range queries within these buckets! Pretty cool, huh?\n\n##### Pluggable Range Key Comparators\n\nEZDB also lets you customize the way that your range keys are sorted for a table. Here's an example of how to plug in a comparator that sorts your range keys in reverse order:\n\n    Table\u003cInteger, Integer, Integer\u003e table = ezdb.getTable(\"range-keys-comparators\", IntegerSerde.get, IntegerSerde.get, IntegerSerde.get, new Comparator\u003cbyte[]\u003e() {\n      @Override\n      public int compare(byte[] o1, byte[] o2) {\n        // Let's do things in reverse lexicographical order.\n        return -1 * ByteBuffer.wrap(o1).compareTo(ByteBuffer.wrap(o2));\n      }\n    });\n\n##### Versioned Values\n\nEZDB also provides some utility classes to let you version your data. EZDB only persists the \"latest\" version of your data, but it can be useful to tag your data with some version number for future lookups. To use versioning, just wrap your value's serde in a VersionSerde.\n\n    RangeTable\u003cInteger, String, Versioned\u003cInteger\u003e\u003e table = ezdb.getTable(\"test-versioned-values\", IntegerSerde.get, StringSerde.get, new VersionedSerde\u003cInteger\u003e(IntegerSerde.get));\n\nThen, when you put data, put your values in a Versioned wrapper.\n\n    table.put(1213, \"foo\", new Versioned\u003cInteger\u003e(2, 0));\n    table.put(1213, \"foo\", new Versioned\u003cInteger\u003e(3, 1));\n    table.put(1213, new Versioned\u003cInteger\u003e(12345678, 0));\n\nYou do your lookups as normal.\n\n    System.out.println(table.get(1213, \"foo\"))\n\nThis would print obj=3, version=1. The get() method returns a Versioned wrapper with your data and version number inside of it.\n\n### Using JNI\n\nBy default, EZDB uses a pure-Java port of LevelDB. If you wish to use the JNI-based implementation, you need an extra parameter in the constructor:\n\n    Db ezdb = new EzLevelDb(new File(\"/tmp\"), new EzLevelDbJniFactory());\n\nThis class is available in the ezdb-leveldb-jni artifact.\n\n### Building EZDB\n\nEZDB is built with Maven:\n\n    mvn clean package\n\n### Using EZDB\n\nYou can get current releases from this maven repository:\n```\nhttps://invesdwin.de/repo/invesdwin-oss-remote/\n```\n\nDependency declaration:\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.criccomini\u003c/groupId\u003e\n\t\u003cartifactId\u003eezdb-leveldb\u003c/artifactId\u003e\n\t\u003cversion\u003e0.1.16\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Java Documentation\n\nYou can get the javadocs for EZDB here:\n\nhttp://criccomini.github.com/ezdb/javadocs\n\n### License\n\nCopyright (c) 2013 Chris Riccomini\n\nPublished under Apache Software License 2.0, see LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcriccomini%2Fezdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcriccomini%2Fezdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcriccomini%2Fezdb/lists"}