rocksdb-jruby 1.0.0.pre0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf5dad2e75b48e8cbebb0946397110fb2455a746
4
+ data.tar.gz: df2ba841ba5f181dc75fe160bc830e62d4c8330e
5
+ SHA512:
6
+ metadata.gz: 6688b22d9228e0ec4db377da7737ffca2964ce3afddda0cdae03f9ab0521a2d9d5665d0a7a09e713fc23b3dfcb2616097adf2913c42d6ca06bf48c82fbea0f43
7
+ data.tar.gz: b6f2ac8064108acbf9780b85253c879ae1a7f03f8c3b87f33a0300d5a2e9840b7f66ad8ea42096251c58805ee0618dadb4c097338722bbf3213aebb6a83b235b
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --markup markdown
3
+ lib/**/*.rb
4
+ -- README.md
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # RocksDB bindings for JRuby
2
+
3
+ [![Build Status](https://travis-ci.org/burtcorp/rocksdb-jruby.png?branch=master)](https://travis-ci.org/burtcorp/rocksdb-jruby)
4
+
5
+ _If you're reading this on GitHub, please note that this is the readme for the development version and that some features described here might not yet have been released. You can find the readme for a specific version via the release tags ([here is an example](https://github.com/burtcorp/rocksdb-jruby/releases/tag/v0.1.0))._
6
+
7
+ ## Installation
8
+
9
+ rocksdb-jruby is available from RubyGems. Either install it manually:
10
+
11
+ ```
12
+ $ gem install rocksdb-jruby
13
+ ```
14
+
15
+ or add this to your `Gemfile`:
16
+
17
+ ```ruby
18
+ gem 'rocksdb-jruby', require: 'rocks_db'
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'rocks_db'
25
+
26
+ db = RocksDb.open('path/to/database')
27
+
28
+ # basic key operations
29
+ db.put('foo', 'bar')
30
+ puts db.get('foo') # => 'bar'
31
+ db.delete('foo')
32
+
33
+ # iterating over a range of keys
34
+ 10.times { |i| db.put("foo#{i.to_s.rjust(2, '0')}", i.to_s) }
35
+ db.each(from: 'foo', to: 'foo08') do |key, value|
36
+ puts "#{key} => #{value}"
37
+ end
38
+
39
+ # batch mutations
40
+ db.batch do |batch|
41
+ batch.put('foo', 'bar')
42
+ batch.delete('bar')
43
+ end
44
+
45
+ # read from a snapshot
46
+ db.put('foo', 'bar')
47
+ snapshot = db.snapshot
48
+ db.put('foo', 'baz')
49
+ puts snapshot.get('foo') # => 'bar'
50
+ puts db.get('foo') # => 'baz'
51
+ ```
52
+
53
+ ## How to build and run the tests
54
+
55
+ The best place to see how to build and run the tests is to look at the `.travis.yml` file, but if you just want to get going run:
56
+
57
+ ```
58
+ $ bundle install
59
+ $ bundle exec rake
60
+ ```
61
+
62
+ # Copyright
63
+
64
+ © 2016 Burt AB, see LICENSE.txt (BSD 3-Clause).
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ class Batch
5
+ # @!method put(key, value)
6
+ # Puts a value into the database
7
+ #
8
+ # @return [nil]
9
+
10
+ # @!method delete(key)
11
+ # Deletes a value from the database
12
+ #
13
+ # @return [nil]
14
+ end
15
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ #
5
+ class Db
6
+ # @!method close
7
+ # Closes the database handle.
8
+ #
9
+ # This should be done when you are done using the database.
10
+ #
11
+ # @return [nil]
12
+
13
+ # @!method put(key, value)
14
+ # Puts a value into the database
15
+ #
16
+ # @return [nil]
17
+
18
+ # @!method get(key)
19
+ # Retrieves a value from the database
20
+ #
21
+ # @return [String] the value
22
+
23
+ # @!method delete(key)
24
+ # Deletes a value from the database
25
+ #
26
+ # @return [nil]
27
+
28
+ # @!method batch(&block)
29
+ # Yields a batch object that can be used to do multiple mutations as one
30
+ # atomic operation
31
+ #
32
+ # Batching can be used both to perform multiple operations that must be
33
+ # performed atomically, or to speed up bulk loads.
34
+ #
35
+ # @see RocksDb::Batch
36
+ # @yieldparam [RocksDb::Batch] batch the batch
37
+ # @return [nil]
38
+
39
+ # @!method snapshot
40
+ # Returns a view of the database as it looks at this point in time
41
+ #
42
+ # Mutations that happen after the snapshot has been created are not
43
+ # visible when using the snapshot (e.g. {RocksDb::Snapshot#get} will not
44
+ # return values that are written after the snaphot was created).
45
+ #
46
+ # The snapshot must be closed using {RocksDb::Snapshot#close} when you
47
+ # are done with it.
48
+ #
49
+ # When a block is given the snapshot is automatically closed when the
50
+ # block returns.
51
+ #
52
+ # @see RocksDb::Snapshot
53
+ # @return [nil, RocksDb::Snapshot] a snapshot or nil if a block is given
54
+
55
+ # @!method each(options={}, &block)
56
+ # Iterate over all or a subset of all keys and values.
57
+ #
58
+ # Without any options this will yield every key and value in the database
59
+ # in order. Most of the time you want to specify the `:from` and/or `:to`
60
+ # and/or `:limit` to control which portion of the database that will be
61
+ # iterated over.
62
+ #
63
+ # You can also iterate in reverse order by setting the `:reverse` option
64
+ # to `true`. Note that when you iterate in reverse order, the key specifed
65
+ # in `:from` will still be the first key yielded, and that the `:to` key
66
+ # should be a key _before_ the `:from` key in regular order.
67
+ #
68
+ # @param [Hash] options
69
+ # @option options [String] :from (nil) the key to start the iteration from
70
+ # @option options [String] :to (nil) the key to end the iteration at
71
+ # @option options [Integer] :limit (nil) the maximum number of keys to
72
+ # iterate over. Negative values are ignored.
73
+ # @option options [true, false] :reverse (false) whether or not to iterate
74
+ # in reverse order
75
+ # @yieldparam [String] key a key
76
+ # @yieldparam [String] value a value
77
+ # @return [Enumerable] an enumerable of the same keys and values as the
78
+ # call would have yielded if a block was given
79
+ end
80
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ #
5
+ class Error < StandardError
6
+ end
7
+ end
Binary file
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ # @private
5
+ module LazyEnumerable
6
+ include Enumerable
7
+
8
+ def map(&transform)
9
+ LazyMap.new(self, &transform)
10
+ end
11
+
12
+ def select(&filter)
13
+ LazySelect.new(self, &filter)
14
+ end
15
+ end
16
+
17
+ # @private
18
+ class LazyMap
19
+ include LazyEnumerable
20
+
21
+ def initialize(enum, &transform)
22
+ @enum = enum
23
+ @transform = transform
24
+ end
25
+
26
+ def each(&block)
27
+ if block
28
+ @enum.each do |element|
29
+ block.call(@transform.call(element))
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+
36
+ # @private
37
+ class LazySelect
38
+ include LazyEnumerable
39
+
40
+ def initialize(enum, &filter)
41
+ @enum = enum
42
+ @filter = filter
43
+ end
44
+
45
+ def each(&block)
46
+ if block
47
+ @enum.each do |element|
48
+ block.call(element) if @filter.call(element)
49
+ end
50
+ end
51
+ self
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ class Snapshot
5
+ # @!method close
6
+ # Tells the database that it doesn't have to track this snapshot anymore
7
+ #
8
+ # This should be done when you are done using the snapshot. Do not attempt
9
+ # to use the snapshot after having called this method.
10
+ #
11
+ # @return [nil]
12
+
13
+ # @!method get(key)
14
+ # Retrieves a value from the database
15
+ #
16
+ # @return [String] the value
17
+
18
+ # @!method each(options={}, &block)
19
+ # Iterate over all or a subset of all keys and values.
20
+ #
21
+ # Please refer to {RocksDb::Db#each} for the full documentation.
22
+ #
23
+ # @see RocksDb::Db#each
24
+ # @return [Enumerable] an enumerable of the same values as the
25
+ # call would have yielded to the block
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module RocksDb
4
+ VERSION = '1.0.0.pre0'
5
+ end
data/lib/rocks_db.rb ADDED
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rocks_db/ext/rocks_db.jar'
4
+
5
+ Java::IoBurtRocksdb::RocksDbLibrary.new.load(JRuby.runtime, false)
6
+
7
+ require 'rocks_db/version'
8
+ require 'rocks_db/lazy_enumerable'
9
+
10
+ module RocksDb
11
+ # @private
12
+ class Iterator
13
+ include LazyEnumerable
14
+ end
15
+
16
+ # @!method open(path, options={}, &block)
17
+ # Open and/or create a database
18
+ #
19
+ # A database is a directory of files on disk, specified by a path to the
20
+ # directory. A database may only be opened by one process at a time, but
21
+ # within a process the database can safely be used concurrently by multiple
22
+ # threads.
23
+ #
24
+ # When a block is given the database is yielded to the block and closed when
25
+ # the block returns.
26
+ #
27
+ # @param [String] path the path to the database
28
+ # @yieldparam [RocksDb::Db] db a database object
29
+ # @param [Hash] options
30
+ # @option options [true, false] :create_if_missing (true) Whether or not to
31
+ # create the database if it does not already exist.
32
+ # @option options [true, false] :error_if_exists (false) Whether or not to
33
+ # throw an error when the database already exists.
34
+ # @raise [RocksDb::Error] raised when an internal error occurs, and when
35
+ # the `:error_if_exists` options is true and the database already exists.
36
+ # @return [nil, RocksDb::Db] a database object or nil when a block is given
37
+ end
data/lib/rocksrb.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rocks_db'
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rocksdb-jruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre0
5
+ platform: java
6
+ authors:
7
+ - Theo Hultberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: RocksDB bindings for JRuby
14
+ email: theo@burtcorp.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".yardopts"
20
+ - README.md
21
+ - lib/rocks_db.rb
22
+ - lib/rocks_db/batch.rb
23
+ - lib/rocks_db/db.rb
24
+ - lib/rocks_db/error.rb
25
+ - lib/rocks_db/ext/rocks_db.jar
26
+ - lib/rocks_db/lazy_enumerable.rb
27
+ - lib/rocks_db/snapshot.rb
28
+ - lib/rocks_db/version.rb
29
+ - lib/rocksrb.rb
30
+ homepage:
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.1
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.6.6
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: RocksDB for JRuby
53
+ test_files: []