leveldb-ruby 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README +1 -1
  2. data/leveldb/Makefile +70 -29
  3. data/leveldb/build_detect_platform +74 -0
  4. data/leveldb/db/builder.cc +2 -4
  5. data/leveldb/db/builder.h +4 -6
  6. data/leveldb/db/c.cc +471 -0
  7. data/leveldb/db/corruption_test.cc +21 -16
  8. data/leveldb/db/db_bench.cc +400 -200
  9. data/leveldb/db/db_impl.cc +276 -131
  10. data/leveldb/db/db_impl.h +22 -10
  11. data/leveldb/db/db_iter.cc +2 -1
  12. data/leveldb/db/db_test.cc +391 -43
  13. data/leveldb/db/dbformat.cc +31 -0
  14. data/leveldb/db/dbformat.h +51 -1
  15. data/leveldb/db/filename.h +1 -1
  16. data/leveldb/db/log_format.h +1 -1
  17. data/leveldb/db/log_reader.cc +16 -11
  18. data/leveldb/db/memtable.cc +37 -0
  19. data/leveldb/db/memtable.h +6 -0
  20. data/leveldb/db/repair.cc +17 -14
  21. data/leveldb/db/skiplist_test.cc +2 -2
  22. data/leveldb/db/version_edit.cc +7 -9
  23. data/leveldb/db/version_edit.h +2 -1
  24. data/leveldb/db/version_set.cc +416 -104
  25. data/leveldb/db/version_set.h +78 -14
  26. data/leveldb/db/version_set_test.cc +179 -0
  27. data/leveldb/db/write_batch_internal.h +2 -0
  28. data/leveldb/include/leveldb/c.h +246 -0
  29. data/leveldb/include/leveldb/db.h +14 -2
  30. data/leveldb/include/leveldb/env.h +31 -10
  31. data/leveldb/include/leveldb/options.h +7 -18
  32. data/leveldb/include/leveldb/slice.h +2 -2
  33. data/leveldb/include/leveldb/status.h +1 -1
  34. data/leveldb/port/atomic_pointer.h +144 -0
  35. data/leveldb/port/port.h +0 -2
  36. data/leveldb/port/port_android.h +7 -1
  37. data/leveldb/port/port_example.h +11 -1
  38. data/leveldb/port/port_posix.h +56 -38
  39. data/leveldb/table/format.cc +12 -8
  40. data/leveldb/table/table_test.cc +16 -7
  41. data/leveldb/util/cache.cc +173 -100
  42. data/leveldb/util/cache_test.cc +28 -11
  43. data/leveldb/util/coding.h +4 -4
  44. data/leveldb/util/comparator.cc +1 -0
  45. data/leveldb/util/env.cc +10 -5
  46. data/leveldb/util/env_posix.cc +48 -87
  47. data/leveldb/util/histogram.cc +11 -0
  48. data/leveldb/util/histogram.h +1 -0
  49. data/leveldb/util/posix_logger.h +98 -0
  50. data/leveldb/util/testharness.cc +12 -0
  51. data/leveldb/util/testharness.h +10 -1
  52. data/lib/leveldb.rb +11 -3
  53. metadata +41 -22
@@ -4,6 +4,8 @@
4
4
 
5
5
  #include "util/testharness.h"
6
6
 
7
+ #include <string>
8
+ #include <stdlib.h>
7
9
  #include <sys/stat.h>
8
10
  #include <sys/types.h>
9
11
 
@@ -32,10 +34,20 @@ bool RegisterTest(const char* base, const char* name, void (*func)()) {
32
34
  }
33
35
 
34
36
  int RunAllTests() {
37
+ const char* matcher = getenv("LEVELDB_TESTS");
38
+
35
39
  int num = 0;
36
40
  if (tests != NULL) {
37
41
  for (int i = 0; i < tests->size(); i++) {
38
42
  const Test& t = (*tests)[i];
43
+ if (matcher != NULL) {
44
+ std::string name = t.base;
45
+ name.push_back('.');
46
+ name.append(t.name);
47
+ if (strstr(name.c_str(), matcher) == NULL) {
48
+ continue;
49
+ }
50
+ }
39
51
  fprintf(stderr, "==== Test %s.%s\n", t.base, t.name);
40
52
  (*t.func)();
41
53
  ++num;
@@ -15,7 +15,16 @@
15
15
  namespace leveldb {
16
16
  namespace test {
17
17
 
18
- // Run all tests registered by the TEST() macro.
18
+ // Run some of the tests registered by the TEST() macro. If the
19
+ // environment variable "LEVELDB_TESTS" is not set, runs all tests.
20
+ // Otherwise, runs only the tests whose name contains the value of
21
+ // "LEVELDB_TESTS" as a substring. E.g., suppose the tests are:
22
+ // TEST(Foo, Hello) { ... }
23
+ // TEST(Foo, World) { ... }
24
+ // LEVELDB_TESTS=Hello will run the first test
25
+ // LEVELDB_TESTS=o will run both tests
26
+ // LEVELDB_TESTS=Junk will run no tests
27
+ //
19
28
  // Returns 0 if all tests pass.
20
29
  // Dies or returns a non-zero value if some test fails.
21
30
  extern int RunAllTests();
data/lib/leveldb.rb CHANGED
@@ -8,20 +8,28 @@ class DB
8
8
  ## Loads or creates a LevelDB database as necessary, stored on disk at
9
9
  ## +pathname+.
10
10
  def new pathname
11
- make pathname, true, false
11
+ make path_string(pathname), true, false
12
12
  end
13
13
 
14
14
  ## Creates a new LevelDB database stored on disk at +pathname+. Throws an
15
15
  ## exception if the database already exists.
16
16
  def create pathname
17
- make pathname, true, true
17
+ make path_string(pathname), true, true
18
18
  end
19
19
 
20
20
  ## Loads a LevelDB database stored on disk at +pathname+. Throws an
21
21
  ## exception unless the database already exists.
22
22
  def load pathname
23
- make pathname, false, false
23
+ make path_string(pathname), false, false
24
24
  end
25
+
26
+ private
27
+
28
+ ## Coerces the argument into a String for use as a filename/-path
29
+ def path_string pathname
30
+ File.respond_to?(:path) ? File.path(pathname) : pathname.to_str
31
+ end
32
+
25
33
  end
26
34
 
27
35
  alias :includes? :exists?
metadata CHANGED
@@ -1,33 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: leveldb-ruby
3
- version: !ruby/object:Gem::Version
4
- version: '0.7'
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 8
8
+ version: "0.8"
6
9
  platform: ruby
7
- authors:
10
+ authors:
8
11
  - William Morgan
9
12
  autorequire:
10
13
  bindir: bin
11
14
  cert_chain: []
12
- date: 2011-07-16 13:48:52.000000000 -07:00
15
+
16
+ date: 2011-10-25 19:39:38 +00:00
13
17
  default_executable:
14
18
  dependencies: []
19
+
15
20
  description: LevelDB-Ruby is a Ruby binding to LevelDB.
16
21
  email: wmorgan-leveldb-ruby-gemspec@masanjin.net
17
22
  executables: []
18
- extensions:
23
+
24
+ extensions:
19
25
  - ext/leveldb/extconf.rb
20
- extra_rdoc_files:
26
+ extra_rdoc_files:
21
27
  - README
22
28
  - ext/leveldb/leveldb.cc
23
- files:
29
+ files:
24
30
  - README
25
31
  - ext/leveldb/extconf.rb
26
32
  - lib/leveldb.rb
27
33
  - ext/leveldb/leveldb.cc
28
34
  - leveldb/Makefile
35
+ - leveldb/build_detect_platform
29
36
  - leveldb/db/builder.cc
30
37
  - leveldb/db/builder.h
38
+ - leveldb/db/c.cc
31
39
  - leveldb/db/corruption_test.cc
32
40
  - leveldb/db/db_bench.cc
33
41
  - leveldb/db/db_impl.cc
@@ -60,9 +68,11 @@ files:
60
68
  - leveldb/db/version_edit_test.cc
61
69
  - leveldb/db/version_set.cc
62
70
  - leveldb/db/version_set.h
71
+ - leveldb/db/version_set_test.cc
63
72
  - leveldb/db/write_batch.cc
64
73
  - leveldb/db/write_batch_internal.h
65
74
  - leveldb/db/write_batch_test.cc
75
+ - leveldb/include/leveldb/c.h
66
76
  - leveldb/include/leveldb/cache.h
67
77
  - leveldb/include/leveldb/comparator.h
68
78
  - leveldb/include/leveldb/db.h
@@ -74,6 +84,7 @@ files:
74
84
  - leveldb/include/leveldb/table.h
75
85
  - leveldb/include/leveldb/table_builder.h
76
86
  - leveldb/include/leveldb/write_batch.h
87
+ - leveldb/port/atomic_pointer.h
77
88
  - leveldb/port/port.h
78
89
  - leveldb/port/port_android.cc
79
90
  - leveldb/port/port_android.h
@@ -127,6 +138,7 @@ files:
127
138
  - leveldb/util/logging.h
128
139
  - leveldb/util/mutexlock.h
129
140
  - leveldb/util/options.cc
141
+ - leveldb/util/posix_logger.h
130
142
  - leveldb/util/random.h
131
143
  - leveldb/util/status.cc
132
144
  - leveldb/util/testharness.cc
@@ -136,32 +148,39 @@ files:
136
148
  has_rdoc: true
137
149
  homepage: http://github.com/wmorgan/leveldb-ruby
138
150
  licenses: []
151
+
139
152
  post_install_message:
140
- rdoc_options:
153
+ rdoc_options:
141
154
  - -c
142
155
  - utf8
143
156
  - --main
144
157
  - README
145
158
  - --title
146
159
  - LevelDB
147
- require_paths:
160
+ require_paths:
148
161
  - lib
149
- required_ruby_version: !ruby/object:Gem::Requirement
162
+ required_ruby_version: !ruby/object:Gem::Requirement
150
163
  none: false
151
- requirements:
152
- - - ! '>='
153
- - !ruby/object:Gem::Version
154
- version: '0'
155
- required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ segments:
168
+ - 0
169
+ version: "0"
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
171
  none: false
157
- requirements:
158
- - - ! '>='
159
- - !ruby/object:Gem::Version
160
- version: '0'
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ segments:
176
+ - 0
177
+ version: "0"
161
178
  requirements: []
179
+
162
180
  rubyforge_project:
163
- rubygems_version: 1.6.0
181
+ rubygems_version: 1.3.7
164
182
  signing_key:
165
183
  specification_version: 3
166
184
  summary: a Ruby binding to LevelDB
167
185
  test_files: []
186
+