filiptepper-leveldb-ruby 0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/LICENSE +24 -0
  2. data/README +72 -0
  3. data/ext/leveldb/extconf.rb +14 -0
  4. data/ext/leveldb/leveldb.cc +530 -0
  5. data/ext/leveldb/platform.rb +83 -0
  6. data/leveldb/Makefile +191 -0
  7. data/leveldb/build_detect_platform +160 -0
  8. data/leveldb/db/builder.cc +88 -0
  9. data/leveldb/db/builder.h +34 -0
  10. data/leveldb/db/c.cc +581 -0
  11. data/leveldb/db/corruption_test.cc +359 -0
  12. data/leveldb/db/db_bench.cc +970 -0
  13. data/leveldb/db/db_impl.cc +1448 -0
  14. data/leveldb/db/db_impl.h +194 -0
  15. data/leveldb/db/db_iter.cc +299 -0
  16. data/leveldb/db/db_iter.h +26 -0
  17. data/leveldb/db/db_test.cc +1901 -0
  18. data/leveldb/db/dbformat.cc +140 -0
  19. data/leveldb/db/dbformat.h +227 -0
  20. data/leveldb/db/dbformat_test.cc +112 -0
  21. data/leveldb/db/filename.cc +139 -0
  22. data/leveldb/db/filename.h +80 -0
  23. data/leveldb/db/filename_test.cc +122 -0
  24. data/leveldb/db/log_format.h +35 -0
  25. data/leveldb/db/log_reader.cc +259 -0
  26. data/leveldb/db/log_reader.h +108 -0
  27. data/leveldb/db/log_test.cc +500 -0
  28. data/leveldb/db/log_writer.cc +103 -0
  29. data/leveldb/db/log_writer.h +48 -0
  30. data/leveldb/db/memtable.cc +145 -0
  31. data/leveldb/db/memtable.h +91 -0
  32. data/leveldb/db/repair.cc +389 -0
  33. data/leveldb/db/skiplist.h +379 -0
  34. data/leveldb/db/skiplist_test.cc +378 -0
  35. data/leveldb/db/snapshot.h +66 -0
  36. data/leveldb/db/table_cache.cc +121 -0
  37. data/leveldb/db/table_cache.h +61 -0
  38. data/leveldb/db/version_edit.cc +266 -0
  39. data/leveldb/db/version_edit.h +107 -0
  40. data/leveldb/db/version_edit_test.cc +46 -0
  41. data/leveldb/db/version_set.cc +1402 -0
  42. data/leveldb/db/version_set.h +370 -0
  43. data/leveldb/db/version_set_test.cc +179 -0
  44. data/leveldb/db/write_batch.cc +147 -0
  45. data/leveldb/db/write_batch_internal.h +49 -0
  46. data/leveldb/db/write_batch_test.cc +120 -0
  47. data/leveldb/helpers/memenv/memenv.cc +374 -0
  48. data/leveldb/helpers/memenv/memenv.h +20 -0
  49. data/leveldb/helpers/memenv/memenv_test.cc +232 -0
  50. data/leveldb/include/leveldb/c.h +275 -0
  51. data/leveldb/include/leveldb/cache.h +99 -0
  52. data/leveldb/include/leveldb/comparator.h +63 -0
  53. data/leveldb/include/leveldb/db.h +161 -0
  54. data/leveldb/include/leveldb/env.h +323 -0
  55. data/leveldb/include/leveldb/filter_policy.h +70 -0
  56. data/leveldb/include/leveldb/iterator.h +100 -0
  57. data/leveldb/include/leveldb/options.h +195 -0
  58. data/leveldb/include/leveldb/slice.h +109 -0
  59. data/leveldb/include/leveldb/status.h +106 -0
  60. data/leveldb/include/leveldb/table.h +85 -0
  61. data/leveldb/include/leveldb/table_builder.h +92 -0
  62. data/leveldb/include/leveldb/write_batch.h +64 -0
  63. data/leveldb/port/atomic_pointer.h +144 -0
  64. data/leveldb/port/port.h +21 -0
  65. data/leveldb/port/port_android.cc +64 -0
  66. data/leveldb/port/port_android.h +159 -0
  67. data/leveldb/port/port_example.h +125 -0
  68. data/leveldb/port/port_posix.cc +50 -0
  69. data/leveldb/port/port_posix.h +129 -0
  70. data/leveldb/port/win/stdint.h +24 -0
  71. data/leveldb/table/block.cc +267 -0
  72. data/leveldb/table/block.h +44 -0
  73. data/leveldb/table/block_builder.cc +109 -0
  74. data/leveldb/table/block_builder.h +57 -0
  75. data/leveldb/table/filter_block.cc +111 -0
  76. data/leveldb/table/filter_block.h +68 -0
  77. data/leveldb/table/filter_block_test.cc +128 -0
  78. data/leveldb/table/format.cc +145 -0
  79. data/leveldb/table/format.h +108 -0
  80. data/leveldb/table/iterator.cc +67 -0
  81. data/leveldb/table/iterator_wrapper.h +63 -0
  82. data/leveldb/table/merger.cc +197 -0
  83. data/leveldb/table/merger.h +26 -0
  84. data/leveldb/table/table.cc +276 -0
  85. data/leveldb/table/table_builder.cc +270 -0
  86. data/leveldb/table/table_test.cc +838 -0
  87. data/leveldb/table/two_level_iterator.cc +182 -0
  88. data/leveldb/table/two_level_iterator.h +34 -0
  89. data/leveldb/util/arena.cc +68 -0
  90. data/leveldb/util/arena.h +68 -0
  91. data/leveldb/util/arena_test.cc +68 -0
  92. data/leveldb/util/bloom.cc +95 -0
  93. data/leveldb/util/bloom_test.cc +159 -0
  94. data/leveldb/util/cache.cc +328 -0
  95. data/leveldb/util/cache_test.cc +186 -0
  96. data/leveldb/util/coding.cc +194 -0
  97. data/leveldb/util/coding.h +104 -0
  98. data/leveldb/util/coding_test.cc +173 -0
  99. data/leveldb/util/comparator.cc +76 -0
  100. data/leveldb/util/crc32c.cc +332 -0
  101. data/leveldb/util/crc32c.h +45 -0
  102. data/leveldb/util/crc32c_test.cc +72 -0
  103. data/leveldb/util/env.cc +96 -0
  104. data/leveldb/util/env_posix.cc +609 -0
  105. data/leveldb/util/env_test.cc +104 -0
  106. data/leveldb/util/filter_policy.cc +11 -0
  107. data/leveldb/util/hash.cc +45 -0
  108. data/leveldb/util/hash.h +19 -0
  109. data/leveldb/util/histogram.cc +139 -0
  110. data/leveldb/util/histogram.h +42 -0
  111. data/leveldb/util/logging.cc +81 -0
  112. data/leveldb/util/logging.h +47 -0
  113. data/leveldb/util/mutexlock.h +39 -0
  114. data/leveldb/util/options.cc +29 -0
  115. data/leveldb/util/posix_logger.h +98 -0
  116. data/leveldb/util/random.h +59 -0
  117. data/leveldb/util/status.cc +75 -0
  118. data/leveldb/util/testharness.cc +77 -0
  119. data/leveldb/util/testharness.h +138 -0
  120. data/leveldb/util/testutil.cc +51 -0
  121. data/leveldb/util/testutil.h +53 -0
  122. data/lib/leveldb.rb +76 -0
  123. metadata +175 -0
@@ -0,0 +1,51 @@
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
+ #include "util/testutil.h"
6
+
7
+ #include "util/random.h"
8
+
9
+ namespace leveldb {
10
+ namespace test {
11
+
12
+ Slice RandomString(Random* rnd, int len, std::string* dst) {
13
+ dst->resize(len);
14
+ for (int i = 0; i < len; i++) {
15
+ (*dst)[i] = static_cast<char>(' ' + rnd->Uniform(95)); // ' ' .. '~'
16
+ }
17
+ return Slice(*dst);
18
+ }
19
+
20
+ std::string RandomKey(Random* rnd, int len) {
21
+ // Make sure to generate a wide variety of characters so we
22
+ // test the boundary conditions for short-key optimizations.
23
+ static const char kTestChars[] = {
24
+ '\0', '\1', 'a', 'b', 'c', 'd', 'e', '\xfd', '\xfe', '\xff'
25
+ };
26
+ std::string result;
27
+ for (int i = 0; i < len; i++) {
28
+ result += kTestChars[rnd->Uniform(sizeof(kTestChars))];
29
+ }
30
+ return result;
31
+ }
32
+
33
+
34
+ extern Slice CompressibleString(Random* rnd, double compressed_fraction,
35
+ int len, std::string* dst) {
36
+ int raw = static_cast<int>(len * compressed_fraction);
37
+ if (raw < 1) raw = 1;
38
+ std::string raw_data;
39
+ RandomString(rnd, raw, &raw_data);
40
+
41
+ // Duplicate the random data until we have filled "len" bytes
42
+ dst->clear();
43
+ while (dst->size() < len) {
44
+ dst->append(raw_data);
45
+ }
46
+ dst->resize(len);
47
+ return Slice(*dst);
48
+ }
49
+
50
+ } // namespace test
51
+ } // namespace leveldb
@@ -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
+ } // namespace test
51
+ } // namespace leveldb
52
+
53
+ #endif // STORAGE_LEVELDB_UTIL_TESTUTIL_H_
@@ -0,0 +1,76 @@
1
+ require 'leveldb/leveldb' # the c extension
2
+
3
+ module LevelDB
4
+ class DB
5
+ include Enumerable
6
+ class << self
7
+ ## Loads or creates a LevelDB database as necessary, stored on disk at
8
+ ## +pathname+.
9
+ def new pathname
10
+ make path_string(pathname), true, false
11
+ end
12
+
13
+ ## Creates a new LevelDB database stored on disk at +pathname+. Throws an
14
+ ## exception if the database already exists.
15
+ def create pathname
16
+ make path_string(pathname), true, true
17
+ end
18
+
19
+ ## Loads a LevelDB database stored on disk at +pathname+. Throws an
20
+ ## exception unless the database already exists.
21
+ def load pathname
22
+ make path_string(pathname), false, false
23
+ end
24
+
25
+ private
26
+
27
+ ## Coerces the argument into a String for use as a filename/-path
28
+ def path_string pathname
29
+ File.respond_to?(:path) ? File.path(pathname) : pathname.to_str
30
+ end
31
+ end
32
+
33
+ attr_reader :pathname
34
+
35
+ alias :includes? :exists?
36
+ alias :contains? :exists?
37
+ alias :member? :exists?
38
+ alias :[] :get
39
+ alias :[]= :put
40
+
41
+ def each(*args, &block)
42
+ i = iterator(*args)
43
+ i.each(&block) if block
44
+ i
45
+ end
46
+
47
+ def iterator(*args); Iterator.new self, *args end
48
+ def keys; map { |k, v| k } end
49
+ def values; map { |k, v| v } end
50
+
51
+ def inspect
52
+ %(<#{self.class} #{@pathname.inspect}>)
53
+ end
54
+ end
55
+
56
+ class Iterator
57
+ include Enumerable
58
+
59
+ attr_reader :db, :from, :to
60
+
61
+ def self.new(db, opts={})
62
+ make db, opts
63
+ end
64
+
65
+ def reversed?; @reversed end
66
+ def inspect
67
+ %(<#{self.class} #{@db.inspect} @from=#{@from.inspect} @to=#{@to.inspect}#{' (reversed)' if @reversed}>)
68
+ end
69
+ end
70
+
71
+ class WriteBatch
72
+ class << self
73
+ private :new
74
+ end
75
+ end
76
+ end # module LevelDB
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filiptepper-leveldb-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.14'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - William Morgan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: LevelDB-Ruby is a Ruby binding to LevelDB.
15
+ email: wmorgan-leveldb-ruby-gemspec@masanjin.net
16
+ executables: []
17
+ extensions:
18
+ - ext/leveldb/extconf.rb
19
+ extra_rdoc_files:
20
+ - README
21
+ - ext/leveldb/leveldb.cc
22
+ files:
23
+ - README
24
+ - LICENSE
25
+ - ext/leveldb/extconf.rb
26
+ - ext/leveldb/platform.rb
27
+ - lib/leveldb.rb
28
+ - ext/leveldb/leveldb.cc
29
+ - leveldb/Makefile
30
+ - leveldb/build_detect_platform
31
+ - leveldb/db/builder.cc
32
+ - leveldb/db/builder.h
33
+ - leveldb/db/c.cc
34
+ - leveldb/db/corruption_test.cc
35
+ - leveldb/db/db_bench.cc
36
+ - leveldb/db/db_impl.cc
37
+ - leveldb/db/db_impl.h
38
+ - leveldb/db/db_iter.cc
39
+ - leveldb/db/db_iter.h
40
+ - leveldb/db/db_test.cc
41
+ - leveldb/db/dbformat.cc
42
+ - leveldb/db/dbformat.h
43
+ - leveldb/db/dbformat_test.cc
44
+ - leveldb/db/filename.cc
45
+ - leveldb/db/filename.h
46
+ - leveldb/db/filename_test.cc
47
+ - leveldb/db/log_format.h
48
+ - leveldb/db/log_reader.cc
49
+ - leveldb/db/log_reader.h
50
+ - leveldb/db/log_test.cc
51
+ - leveldb/db/log_writer.cc
52
+ - leveldb/db/log_writer.h
53
+ - leveldb/db/memtable.cc
54
+ - leveldb/db/memtable.h
55
+ - leveldb/db/repair.cc
56
+ - leveldb/db/skiplist.h
57
+ - leveldb/db/skiplist_test.cc
58
+ - leveldb/db/snapshot.h
59
+ - leveldb/db/table_cache.cc
60
+ - leveldb/db/table_cache.h
61
+ - leveldb/db/version_edit.cc
62
+ - leveldb/db/version_edit.h
63
+ - leveldb/db/version_edit_test.cc
64
+ - leveldb/db/version_set.cc
65
+ - leveldb/db/version_set.h
66
+ - leveldb/db/version_set_test.cc
67
+ - leveldb/db/write_batch.cc
68
+ - leveldb/db/write_batch_internal.h
69
+ - leveldb/db/write_batch_test.cc
70
+ - leveldb/helpers/memenv/memenv.cc
71
+ - leveldb/helpers/memenv/memenv.h
72
+ - leveldb/helpers/memenv/memenv_test.cc
73
+ - leveldb/include/leveldb/c.h
74
+ - leveldb/include/leveldb/cache.h
75
+ - leveldb/include/leveldb/comparator.h
76
+ - leveldb/include/leveldb/db.h
77
+ - leveldb/include/leveldb/env.h
78
+ - leveldb/include/leveldb/filter_policy.h
79
+ - leveldb/include/leveldb/iterator.h
80
+ - leveldb/include/leveldb/options.h
81
+ - leveldb/include/leveldb/slice.h
82
+ - leveldb/include/leveldb/status.h
83
+ - leveldb/include/leveldb/table.h
84
+ - leveldb/include/leveldb/table_builder.h
85
+ - leveldb/include/leveldb/write_batch.h
86
+ - leveldb/port/atomic_pointer.h
87
+ - leveldb/port/port.h
88
+ - leveldb/port/port_android.cc
89
+ - leveldb/port/port_android.h
90
+ - leveldb/port/port_example.h
91
+ - leveldb/port/port_posix.cc
92
+ - leveldb/port/port_posix.h
93
+ - leveldb/port/win/stdint.h
94
+ - leveldb/table/block.cc
95
+ - leveldb/table/block.h
96
+ - leveldb/table/block_builder.cc
97
+ - leveldb/table/block_builder.h
98
+ - leveldb/table/filter_block.cc
99
+ - leveldb/table/filter_block.h
100
+ - leveldb/table/filter_block_test.cc
101
+ - leveldb/table/format.cc
102
+ - leveldb/table/format.h
103
+ - leveldb/table/iterator.cc
104
+ - leveldb/table/iterator_wrapper.h
105
+ - leveldb/table/merger.cc
106
+ - leveldb/table/merger.h
107
+ - leveldb/table/table.cc
108
+ - leveldb/table/table_builder.cc
109
+ - leveldb/table/table_test.cc
110
+ - leveldb/table/two_level_iterator.cc
111
+ - leveldb/table/two_level_iterator.h
112
+ - leveldb/util/arena.cc
113
+ - leveldb/util/arena.h
114
+ - leveldb/util/arena_test.cc
115
+ - leveldb/util/bloom.cc
116
+ - leveldb/util/bloom_test.cc
117
+ - leveldb/util/cache.cc
118
+ - leveldb/util/cache_test.cc
119
+ - leveldb/util/coding.cc
120
+ - leveldb/util/coding.h
121
+ - leveldb/util/coding_test.cc
122
+ - leveldb/util/comparator.cc
123
+ - leveldb/util/crc32c.cc
124
+ - leveldb/util/crc32c.h
125
+ - leveldb/util/crc32c_test.cc
126
+ - leveldb/util/env.cc
127
+ - leveldb/util/env_posix.cc
128
+ - leveldb/util/env_test.cc
129
+ - leveldb/util/filter_policy.cc
130
+ - leveldb/util/hash.cc
131
+ - leveldb/util/hash.h
132
+ - leveldb/util/histogram.cc
133
+ - leveldb/util/histogram.h
134
+ - leveldb/util/logging.cc
135
+ - leveldb/util/logging.h
136
+ - leveldb/util/mutexlock.h
137
+ - leveldb/util/options.cc
138
+ - leveldb/util/posix_logger.h
139
+ - leveldb/util/random.h
140
+ - leveldb/util/status.cc
141
+ - leveldb/util/testharness.cc
142
+ - leveldb/util/testharness.h
143
+ - leveldb/util/testutil.cc
144
+ - leveldb/util/testutil.h
145
+ homepage: http://github.com/wmorgan/leveldb-ruby
146
+ licenses: []
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
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 1.8.24
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: a Ruby binding to LevelDB
175
+ test_files: []