leveldb-ruby 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +17 -0
- data/ext/leveldb/extconf.rb +10 -0
- data/ext/leveldb/leveldb.cc +181 -0
- data/leveldb/Makefile +172 -0
- data/leveldb/db/builder.cc +90 -0
- data/leveldb/db/builder.h +36 -0
- data/leveldb/db/corruption_test.cc +354 -0
- data/leveldb/db/db_bench.cc +677 -0
- data/leveldb/db/db_impl.cc +1236 -0
- data/leveldb/db/db_impl.h +180 -0
- data/leveldb/db/db_iter.cc +298 -0
- data/leveldb/db/db_iter.h +26 -0
- data/leveldb/db/db_test.cc +1192 -0
- data/leveldb/db/dbformat.cc +87 -0
- data/leveldb/db/dbformat.h +165 -0
- data/leveldb/db/dbformat_test.cc +112 -0
- data/leveldb/db/filename.cc +135 -0
- data/leveldb/db/filename.h +80 -0
- data/leveldb/db/filename_test.cc +122 -0
- data/leveldb/db/log_format.h +35 -0
- data/leveldb/db/log_reader.cc +254 -0
- data/leveldb/db/log_reader.h +108 -0
- data/leveldb/db/log_test.cc +500 -0
- data/leveldb/db/log_writer.cc +103 -0
- data/leveldb/db/log_writer.h +48 -0
- data/leveldb/db/memtable.cc +108 -0
- data/leveldb/db/memtable.h +85 -0
- data/leveldb/db/repair.cc +384 -0
- data/leveldb/db/skiplist.h +378 -0
- data/leveldb/db/skiplist_test.cc +378 -0
- data/leveldb/db/snapshot.h +66 -0
- data/leveldb/db/table_cache.cc +95 -0
- data/leveldb/db/table_cache.h +50 -0
- data/leveldb/db/version_edit.cc +268 -0
- data/leveldb/db/version_edit.h +106 -0
- data/leveldb/db/version_edit_test.cc +46 -0
- data/leveldb/db/version_set.cc +1060 -0
- data/leveldb/db/version_set.h +306 -0
- data/leveldb/db/write_batch.cc +138 -0
- data/leveldb/db/write_batch_internal.h +45 -0
- data/leveldb/db/write_batch_test.cc +89 -0
- data/leveldb/include/leveldb/cache.h +99 -0
- data/leveldb/include/leveldb/comparator.h +63 -0
- data/leveldb/include/leveldb/db.h +148 -0
- data/leveldb/include/leveldb/env.h +302 -0
- data/leveldb/include/leveldb/iterator.h +100 -0
- data/leveldb/include/leveldb/options.h +198 -0
- data/leveldb/include/leveldb/slice.h +109 -0
- data/leveldb/include/leveldb/status.h +100 -0
- data/leveldb/include/leveldb/table.h +70 -0
- data/leveldb/include/leveldb/table_builder.h +91 -0
- data/leveldb/include/leveldb/write_batch.h +64 -0
- data/leveldb/port/port.h +23 -0
- data/leveldb/port/port_android.cc +64 -0
- data/leveldb/port/port_android.h +150 -0
- data/leveldb/port/port_chromium.cc +80 -0
- data/leveldb/port/port_chromium.h +97 -0
- data/leveldb/port/port_example.h +115 -0
- data/leveldb/port/port_osx.cc +50 -0
- data/leveldb/port/port_osx.h +125 -0
- data/leveldb/port/port_posix.cc +50 -0
- data/leveldb/port/port_posix.h +94 -0
- data/leveldb/port/sha1_portable.cc +298 -0
- data/leveldb/port/sha1_portable.h +25 -0
- data/leveldb/port/sha1_test.cc +39 -0
- data/leveldb/port/win/stdint.h +24 -0
- data/leveldb/table/block.cc +263 -0
- data/leveldb/table/block.h +43 -0
- data/leveldb/table/block_builder.cc +109 -0
- data/leveldb/table/block_builder.h +57 -0
- data/leveldb/table/format.cc +131 -0
- data/leveldb/table/format.h +103 -0
- data/leveldb/table/iterator.cc +67 -0
- data/leveldb/table/iterator_wrapper.h +63 -0
- data/leveldb/table/merger.cc +197 -0
- data/leveldb/table/merger.h +26 -0
- data/leveldb/table/table.cc +175 -0
- data/leveldb/table/table_builder.cc +227 -0
- data/leveldb/table/table_test.cc +845 -0
- data/leveldb/table/two_level_iterator.cc +182 -0
- data/leveldb/table/two_level_iterator.h +34 -0
- data/leveldb/util/arena.cc +68 -0
- data/leveldb/util/arena.h +68 -0
- data/leveldb/util/arena_test.cc +68 -0
- data/leveldb/util/cache.cc +255 -0
- data/leveldb/util/cache_test.cc +169 -0
- data/leveldb/util/coding.cc +194 -0
- data/leveldb/util/coding.h +104 -0
- data/leveldb/util/coding_test.cc +173 -0
- data/leveldb/util/comparator.cc +72 -0
- data/leveldb/util/crc32c.cc +332 -0
- data/leveldb/util/crc32c.h +45 -0
- data/leveldb/util/crc32c_test.cc +72 -0
- data/leveldb/util/env.cc +77 -0
- data/leveldb/util/env_chromium.cc +612 -0
- data/leveldb/util/env_posix.cc +606 -0
- data/leveldb/util/env_test.cc +102 -0
- data/leveldb/util/hash.cc +45 -0
- data/leveldb/util/hash.h +19 -0
- data/leveldb/util/histogram.cc +128 -0
- data/leveldb/util/histogram.h +41 -0
- data/leveldb/util/logging.cc +81 -0
- data/leveldb/util/logging.h +47 -0
- data/leveldb/util/mutexlock.h +39 -0
- data/leveldb/util/options.cc +28 -0
- data/leveldb/util/random.h +59 -0
- data/leveldb/util/status.cc +75 -0
- data/leveldb/util/testharness.cc +65 -0
- data/leveldb/util/testharness.h +129 -0
- data/leveldb/util/testutil.cc +51 -0
- data/leveldb/util/testutil.h +53 -0
- data/lib/leveldb.rb +36 -0
- metadata +183 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
4
|
+
|
5
|
+
#ifndef STORAGE_LEVELDB_UTIL_TESTUTIL_H_
|
6
|
+
#define STORAGE_LEVELDB_UTIL_TESTUTIL_H_
|
7
|
+
|
8
|
+
#include "leveldb/env.h"
|
9
|
+
#include "leveldb/slice.h"
|
10
|
+
#include "util/random.h"
|
11
|
+
|
12
|
+
namespace leveldb {
|
13
|
+
namespace test {
|
14
|
+
|
15
|
+
// Store in *dst a random string of length "len" and return a Slice that
|
16
|
+
// references the generated data.
|
17
|
+
extern Slice RandomString(Random* rnd, int len, std::string* dst);
|
18
|
+
|
19
|
+
// Return a random key with the specified length that may contain interesting
|
20
|
+
// characters (e.g. \x00, \xff, etc.).
|
21
|
+
extern std::string RandomKey(Random* rnd, int len);
|
22
|
+
|
23
|
+
// Store in *dst a string of length "len" that will compress to
|
24
|
+
// "N*compressed_fraction" bytes and return a Slice that references
|
25
|
+
// the generated data.
|
26
|
+
extern Slice CompressibleString(Random* rnd, double compressed_fraction,
|
27
|
+
int len, std::string* dst);
|
28
|
+
|
29
|
+
// A wrapper that allows injection of errors.
|
30
|
+
class ErrorEnv : public EnvWrapper {
|
31
|
+
public:
|
32
|
+
bool writable_file_error_;
|
33
|
+
int num_writable_file_errors_;
|
34
|
+
|
35
|
+
ErrorEnv() : EnvWrapper(Env::Default()),
|
36
|
+
writable_file_error_(false),
|
37
|
+
num_writable_file_errors_(0) { }
|
38
|
+
|
39
|
+
virtual Status NewWritableFile(const std::string& fname,
|
40
|
+
WritableFile** result) {
|
41
|
+
if (writable_file_error_) {
|
42
|
+
++num_writable_file_errors_;
|
43
|
+
*result = NULL;
|
44
|
+
return Status::IOError(fname, "fake error");
|
45
|
+
}
|
46
|
+
return target()->NewWritableFile(fname, result);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
#endif // STORAGE_LEVELDB_UTIL_TESTUTIL_H_
|
data/lib/leveldb.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'leveldb/leveldb' # the c extension
|
2
|
+
|
3
|
+
module LevelDB
|
4
|
+
class DB
|
5
|
+
include Enumerable
|
6
|
+
class << self
|
7
|
+
|
8
|
+
## Loads or creates a LevelDB database as necessary, stored on disk at
|
9
|
+
## +pathname+.
|
10
|
+
def new pathname
|
11
|
+
make pathname, true, false
|
12
|
+
end
|
13
|
+
|
14
|
+
## Creates a new LevelDB database stored on disk at +pathname+. Throws an
|
15
|
+
## exception if the database already exists.
|
16
|
+
def create pathname
|
17
|
+
make pathname, true, true
|
18
|
+
end
|
19
|
+
|
20
|
+
## Loads a LevelDB database stored on disk at +pathname+. Throws an
|
21
|
+
## exception unless the database already exists.
|
22
|
+
def load pathname
|
23
|
+
make pathname, false, false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
alias :includes? :exists?
|
28
|
+
alias :contains? :exists?
|
29
|
+
alias :member? :exists?
|
30
|
+
alias :[] :get
|
31
|
+
alias :[]= :put
|
32
|
+
|
33
|
+
def keys; map { |k, v| k } end
|
34
|
+
def values; map { |k, v| v } end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leveldb-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- William Morgan
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-16 22:35:18 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: LevelDB-Ruby is a Ruby binding to LevelDB.
|
22
|
+
email: wmorgan-leveldb-ruby-gemspec@masanjin.net
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions:
|
26
|
+
- ext/leveldb/extconf.rb
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
- ext/leveldb/leveldb.cc
|
30
|
+
files:
|
31
|
+
- README
|
32
|
+
- ext/leveldb/extconf.rb
|
33
|
+
- lib/leveldb.rb
|
34
|
+
- ext/leveldb/leveldb.cc
|
35
|
+
- leveldb/Makefile
|
36
|
+
- leveldb/port/win/stdint.h
|
37
|
+
- leveldb/port/port_osx.h
|
38
|
+
- leveldb/port/port_android.h
|
39
|
+
- leveldb/port/sha1_test.cc
|
40
|
+
- leveldb/port/port_chromium.h
|
41
|
+
- leveldb/port/port_chromium.cc
|
42
|
+
- leveldb/port/port_posix.h
|
43
|
+
- leveldb/port/sha1_portable.cc
|
44
|
+
- leveldb/port/port_example.h
|
45
|
+
- leveldb/port/port_posix.cc
|
46
|
+
- leveldb/port/port.h
|
47
|
+
- leveldb/port/sha1_portable.h
|
48
|
+
- leveldb/port/port_android.cc
|
49
|
+
- leveldb/port/port_osx.cc
|
50
|
+
- leveldb/db/dbformat.cc
|
51
|
+
- leveldb/db/db_test.cc
|
52
|
+
- leveldb/db/write_batch_internal.h
|
53
|
+
- leveldb/db/db_impl.h
|
54
|
+
- leveldb/db/log_writer.cc
|
55
|
+
- leveldb/db/write_batch.cc
|
56
|
+
- leveldb/db/corruption_test.cc
|
57
|
+
- leveldb/db/db_impl.cc
|
58
|
+
- leveldb/db/filename.h
|
59
|
+
- leveldb/db/skiplist.h
|
60
|
+
- leveldb/db/table_cache.cc
|
61
|
+
- leveldb/db/log_test.cc
|
62
|
+
- leveldb/db/log_reader.h
|
63
|
+
- leveldb/db/db_bench.cc
|
64
|
+
- leveldb/db/repair.cc
|
65
|
+
- leveldb/db/db_iter.cc
|
66
|
+
- leveldb/db/write_batch_test.cc
|
67
|
+
- leveldb/db/version_set.h
|
68
|
+
- leveldb/db/memtable.cc
|
69
|
+
- leveldb/db/version_set.cc
|
70
|
+
- leveldb/db/filename_test.cc
|
71
|
+
- leveldb/db/snapshot.h
|
72
|
+
- leveldb/db/log_reader.cc
|
73
|
+
- leveldb/db/log_format.h
|
74
|
+
- leveldb/db/version_edit.cc
|
75
|
+
- leveldb/db/table_cache.h
|
76
|
+
- leveldb/db/builder.h
|
77
|
+
- leveldb/db/dbformat.h
|
78
|
+
- leveldb/db/db_iter.h
|
79
|
+
- leveldb/db/memtable.h
|
80
|
+
- leveldb/db/version_edit_test.cc
|
81
|
+
- leveldb/db/dbformat_test.cc
|
82
|
+
- leveldb/db/builder.cc
|
83
|
+
- leveldb/db/skiplist_test.cc
|
84
|
+
- leveldb/db/log_writer.h
|
85
|
+
- leveldb/db/version_edit.h
|
86
|
+
- leveldb/db/filename.cc
|
87
|
+
- leveldb/include/leveldb/comparator.h
|
88
|
+
- leveldb/include/leveldb/table.h
|
89
|
+
- leveldb/include/leveldb/slice.h
|
90
|
+
- leveldb/include/leveldb/iterator.h
|
91
|
+
- leveldb/include/leveldb/table_builder.h
|
92
|
+
- leveldb/include/leveldb/env.h
|
93
|
+
- leveldb/include/leveldb/db.h
|
94
|
+
- leveldb/include/leveldb/cache.h
|
95
|
+
- leveldb/include/leveldb/write_batch.h
|
96
|
+
- leveldb/include/leveldb/status.h
|
97
|
+
- leveldb/include/leveldb/options.h
|
98
|
+
- leveldb/table/block.h
|
99
|
+
- leveldb/table/format.cc
|
100
|
+
- leveldb/table/table_test.cc
|
101
|
+
- leveldb/table/iterator_wrapper.h
|
102
|
+
- leveldb/table/merger.h
|
103
|
+
- leveldb/table/iterator.cc
|
104
|
+
- leveldb/table/two_level_iterator.h
|
105
|
+
- leveldb/table/two_level_iterator.cc
|
106
|
+
- leveldb/table/format.h
|
107
|
+
- leveldb/table/table.cc
|
108
|
+
- leveldb/table/merger.cc
|
109
|
+
- leveldb/table/block_builder.h
|
110
|
+
- leveldb/table/block.cc
|
111
|
+
- leveldb/table/block_builder.cc
|
112
|
+
- leveldb/table/table_builder.cc
|
113
|
+
- leveldb/util/comparator.cc
|
114
|
+
- leveldb/util/histogram.cc
|
115
|
+
- leveldb/util/hash.h
|
116
|
+
- leveldb/util/crc32c.cc
|
117
|
+
- leveldb/util/histogram.h
|
118
|
+
- leveldb/util/testutil.h
|
119
|
+
- leveldb/util/arena.h
|
120
|
+
- leveldb/util/cache_test.cc
|
121
|
+
- leveldb/util/arena_test.cc
|
122
|
+
- leveldb/util/crc32c_test.cc
|
123
|
+
- leveldb/util/env.cc
|
124
|
+
- leveldb/util/coding_test.cc
|
125
|
+
- leveldb/util/testharness.cc
|
126
|
+
- leveldb/util/coding.h
|
127
|
+
- leveldb/util/mutexlock.h
|
128
|
+
- leveldb/util/logging.cc
|
129
|
+
- leveldb/util/testutil.cc
|
130
|
+
- leveldb/util/hash.cc
|
131
|
+
- leveldb/util/crc32c.h
|
132
|
+
- leveldb/util/testharness.h
|
133
|
+
- leveldb/util/env_test.cc
|
134
|
+
- leveldb/util/env_posix.cc
|
135
|
+
- leveldb/util/arena.cc
|
136
|
+
- leveldb/util/options.cc
|
137
|
+
- leveldb/util/random.h
|
138
|
+
- leveldb/util/logging.h
|
139
|
+
- leveldb/util/coding.cc
|
140
|
+
- leveldb/util/status.cc
|
141
|
+
- leveldb/util/cache.cc
|
142
|
+
- leveldb/util/env_chromium.cc
|
143
|
+
has_rdoc: true
|
144
|
+
homepage: http://github.com/wmorgan/leveldb-ruby
|
145
|
+
licenses: []
|
146
|
+
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options:
|
149
|
+
- -c
|
150
|
+
- utf8
|
151
|
+
- --main
|
152
|
+
- README
|
153
|
+
- --title
|
154
|
+
- LevelDB
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
hash: 3
|
163
|
+
segments:
|
164
|
+
- 0
|
165
|
+
version: "0"
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
hash: 3
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
version: "0"
|
175
|
+
requirements: []
|
176
|
+
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 1.6.0
|
179
|
+
signing_key:
|
180
|
+
specification_version: 3
|
181
|
+
summary: a Ruby binding to LevelDB
|
182
|
+
test_files: []
|
183
|
+
|