leveldb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +95 -0
  4. data/ext/Rakefile +11 -0
  5. data/ext/leveldb/LICENSE +27 -0
  6. data/ext/leveldb/Makefile +206 -0
  7. data/ext/leveldb/build_config.mk +13 -0
  8. data/ext/leveldb/db/builder.cc +88 -0
  9. data/ext/leveldb/db/builder.h +34 -0
  10. data/ext/leveldb/db/c.cc +595 -0
  11. data/ext/leveldb/db/c_test.c +390 -0
  12. data/ext/leveldb/db/corruption_test.cc +359 -0
  13. data/ext/leveldb/db/db_bench.cc +979 -0
  14. data/ext/leveldb/db/db_impl.cc +1485 -0
  15. data/ext/leveldb/db/db_impl.h +203 -0
  16. data/ext/leveldb/db/db_iter.cc +299 -0
  17. data/ext/leveldb/db/db_iter.h +26 -0
  18. data/ext/leveldb/db/db_test.cc +2092 -0
  19. data/ext/leveldb/db/dbformat.cc +140 -0
  20. data/ext/leveldb/db/dbformat.h +227 -0
  21. data/ext/leveldb/db/dbformat_test.cc +112 -0
  22. data/ext/leveldb/db/filename.cc +139 -0
  23. data/ext/leveldb/db/filename.h +80 -0
  24. data/ext/leveldb/db/filename_test.cc +122 -0
  25. data/ext/leveldb/db/leveldb_main.cc +238 -0
  26. data/ext/leveldb/db/log_format.h +35 -0
  27. data/ext/leveldb/db/log_reader.cc +259 -0
  28. data/ext/leveldb/db/log_reader.h +108 -0
  29. data/ext/leveldb/db/log_test.cc +500 -0
  30. data/ext/leveldb/db/log_writer.cc +103 -0
  31. data/ext/leveldb/db/log_writer.h +48 -0
  32. data/ext/leveldb/db/memtable.cc +145 -0
  33. data/ext/leveldb/db/memtable.h +91 -0
  34. data/ext/leveldb/db/repair.cc +389 -0
  35. data/ext/leveldb/db/skiplist.h +379 -0
  36. data/ext/leveldb/db/skiplist_test.cc +378 -0
  37. data/ext/leveldb/db/snapshot.h +66 -0
  38. data/ext/leveldb/db/table_cache.cc +121 -0
  39. data/ext/leveldb/db/table_cache.h +61 -0
  40. data/ext/leveldb/db/version_edit.cc +266 -0
  41. data/ext/leveldb/db/version_edit.h +107 -0
  42. data/ext/leveldb/db/version_edit_test.cc +46 -0
  43. data/ext/leveldb/db/version_set.cc +1443 -0
  44. data/ext/leveldb/db/version_set.h +383 -0
  45. data/ext/leveldb/db/version_set_test.cc +179 -0
  46. data/ext/leveldb/db/write_batch.cc +147 -0
  47. data/ext/leveldb/db/write_batch_internal.h +49 -0
  48. data/ext/leveldb/db/write_batch_test.cc +120 -0
  49. data/ext/leveldb/doc/bench/db_bench_sqlite3.cc +718 -0
  50. data/ext/leveldb/doc/bench/db_bench_tree_db.cc +528 -0
  51. data/ext/leveldb/helpers/memenv/memenv.cc +384 -0
  52. data/ext/leveldb/helpers/memenv/memenv.h +20 -0
  53. data/ext/leveldb/helpers/memenv/memenv_test.cc +232 -0
  54. data/ext/leveldb/include/leveldb/c.h +291 -0
  55. data/ext/leveldb/include/leveldb/cache.h +99 -0
  56. data/ext/leveldb/include/leveldb/comparator.h +63 -0
  57. data/ext/leveldb/include/leveldb/db.h +161 -0
  58. data/ext/leveldb/include/leveldb/env.h +333 -0
  59. data/ext/leveldb/include/leveldb/filter_policy.h +70 -0
  60. data/ext/leveldb/include/leveldb/iterator.h +100 -0
  61. data/ext/leveldb/include/leveldb/options.h +195 -0
  62. data/ext/leveldb/include/leveldb/slice.h +109 -0
  63. data/ext/leveldb/include/leveldb/status.h +106 -0
  64. data/ext/leveldb/include/leveldb/table.h +85 -0
  65. data/ext/leveldb/include/leveldb/table_builder.h +92 -0
  66. data/ext/leveldb/include/leveldb/write_batch.h +64 -0
  67. data/ext/leveldb/issues/issue178_test.cc +92 -0
  68. data/ext/leveldb/port/atomic_pointer.h +224 -0
  69. data/ext/leveldb/port/port.h +19 -0
  70. data/ext/leveldb/port/port_example.h +135 -0
  71. data/ext/leveldb/port/port_posix.cc +54 -0
  72. data/ext/leveldb/port/port_posix.h +157 -0
  73. data/ext/leveldb/port/thread_annotations.h +59 -0
  74. data/ext/leveldb/port/win/stdint.h +24 -0
  75. data/ext/leveldb/table/block.cc +268 -0
  76. data/ext/leveldb/table/block.h +44 -0
  77. data/ext/leveldb/table/block_builder.cc +109 -0
  78. data/ext/leveldb/table/block_builder.h +57 -0
  79. data/ext/leveldb/table/filter_block.cc +111 -0
  80. data/ext/leveldb/table/filter_block.h +68 -0
  81. data/ext/leveldb/table/filter_block_test.cc +128 -0
  82. data/ext/leveldb/table/format.cc +145 -0
  83. data/ext/leveldb/table/format.h +108 -0
  84. data/ext/leveldb/table/iterator.cc +67 -0
  85. data/ext/leveldb/table/iterator_wrapper.h +63 -0
  86. data/ext/leveldb/table/merger.cc +197 -0
  87. data/ext/leveldb/table/merger.h +26 -0
  88. data/ext/leveldb/table/table.cc +275 -0
  89. data/ext/leveldb/table/table_builder.cc +270 -0
  90. data/ext/leveldb/table/table_test.cc +868 -0
  91. data/ext/leveldb/table/two_level_iterator.cc +182 -0
  92. data/ext/leveldb/table/two_level_iterator.h +34 -0
  93. data/ext/leveldb/util/arena.cc +68 -0
  94. data/ext/leveldb/util/arena.h +68 -0
  95. data/ext/leveldb/util/arena_test.cc +68 -0
  96. data/ext/leveldb/util/bloom.cc +95 -0
  97. data/ext/leveldb/util/bloom_test.cc +160 -0
  98. data/ext/leveldb/util/cache.cc +325 -0
  99. data/ext/leveldb/util/cache_test.cc +186 -0
  100. data/ext/leveldb/util/coding.cc +194 -0
  101. data/ext/leveldb/util/coding.h +104 -0
  102. data/ext/leveldb/util/coding_test.cc +196 -0
  103. data/ext/leveldb/util/comparator.cc +81 -0
  104. data/ext/leveldb/util/crc32c.cc +332 -0
  105. data/ext/leveldb/util/crc32c.h +45 -0
  106. data/ext/leveldb/util/crc32c_test.cc +72 -0
  107. data/ext/leveldb/util/env.cc +96 -0
  108. data/ext/leveldb/util/env_posix.cc +698 -0
  109. data/ext/leveldb/util/env_test.cc +104 -0
  110. data/ext/leveldb/util/filter_policy.cc +11 -0
  111. data/ext/leveldb/util/hash.cc +52 -0
  112. data/ext/leveldb/util/hash.h +19 -0
  113. data/ext/leveldb/util/histogram.cc +139 -0
  114. data/ext/leveldb/util/histogram.h +42 -0
  115. data/ext/leveldb/util/logging.cc +81 -0
  116. data/ext/leveldb/util/logging.h +47 -0
  117. data/ext/leveldb/util/mutexlock.h +41 -0
  118. data/ext/leveldb/util/options.cc +29 -0
  119. data/ext/leveldb/util/posix_logger.h +98 -0
  120. data/ext/leveldb/util/random.h +59 -0
  121. data/ext/leveldb/util/status.cc +75 -0
  122. data/ext/leveldb/util/testharness.cc +77 -0
  123. data/ext/leveldb/util/testharness.h +138 -0
  124. data/ext/leveldb/util/testutil.cc +51 -0
  125. data/ext/leveldb/util/testutil.h +53 -0
  126. data/lib/leveldb/version.rb +3 -0
  127. data/lib/leveldb.rb +1006 -0
  128. metadata +228 -0
data/lib/leveldb.rb ADDED
@@ -0,0 +1,1006 @@
1
+ require 'ffi'
2
+
3
+ module Leveldb
4
+ extend FFI::Library
5
+ ffi_lib File.expand_path("../../ext/leveldb/libleveldb.#{FFI::Platform::LIBSUFFIX}", __FILE__)
6
+
7
+ class FFI::Struct
8
+ def self.release(pointer)
9
+ Leveldb.free(pointer) unless pointer.null?
10
+ end
11
+ end
12
+
13
+ class Err
14
+ def initialize
15
+ @_err = FFI::MemoryPointer.new(:pointer, 1)
16
+ end
17
+
18
+ def ptr
19
+ @_err.read_pointer
20
+ end
21
+
22
+ def to_ptr
23
+ @_err
24
+ end
25
+
26
+ def null?
27
+ ptr.null?
28
+ end
29
+
30
+ def message
31
+ ptr.read_string
32
+ end
33
+ end
34
+
35
+ def err_create
36
+ Err.new
37
+ end
38
+
39
+ def read_len
40
+ FFI::MemoryPointer.new(:size_t)
41
+ end
42
+
43
+ ##
44
+ # Writing FFI::Gen::Enum
45
+ #
46
+ ##
47
+ # Writing FFI::Gen::StructOrUnion
48
+ #
49
+ # (Not documented)
50
+ class DB < FFI::Struct
51
+ layout :dummy, :char
52
+
53
+ def close
54
+ Leveldb.close(self)
55
+ end
56
+
57
+ def self.release
58
+ # free by #close
59
+ end
60
+ end
61
+
62
+ # (Not documented)
63
+ module ComparatorWrappers
64
+ # @return [nil]
65
+ def destroy()
66
+ Leveldb.comparator_destroy(self)
67
+ end
68
+ end
69
+
70
+ class Comparator < FFI::Struct
71
+ include ComparatorWrappers
72
+ layout :dummy, :char
73
+ end
74
+
75
+ # (Not documented)
76
+ class Filelock < FFI::Struct
77
+ layout :dummy, :char
78
+ end
79
+
80
+ # (Not documented)
81
+ class Iterator < FFI::Struct
82
+ layout :dummy, :char
83
+ end
84
+
85
+ # (Not documented)
86
+ module OptionsWrappers
87
+ # @param [Comparator] comparator
88
+ # @return [nil]
89
+ def set_comparator(comparator)
90
+ Leveldb.options_set_comparator(self, comparator)
91
+ end
92
+
93
+ # @param [Integer] u_char
94
+ # @return [nil]
95
+ def set_create_if_missing(u_char)
96
+ Leveldb.options_set_create_if_missing(self, u_char)
97
+ end
98
+
99
+ # @param [Integer] u_char
100
+ # @return [nil]
101
+ def set_paranoid_checks(u_char)
102
+ Leveldb.options_set_paranoid_checks(self, u_char)
103
+ end
104
+
105
+ # @param [FFI::Pointer(*Logger)] logger
106
+ # @return [nil]
107
+ def set_info_log(logger)
108
+ Leveldb.options_set_info_log(self, logger)
109
+ end
110
+
111
+ # @param [Integer] int
112
+ # @return [nil]
113
+ def set_max_open_files(int)
114
+ Leveldb.options_set_max_open_files(self, int)
115
+ end
116
+
117
+ # @param [Integer] u_long
118
+ # @return [nil]
119
+ def set_block_size(u_long)
120
+ Leveldb.options_set_block_size(self, u_long)
121
+ end
122
+
123
+ # @param [Integer] int
124
+ # @return [nil]
125
+ def set_compression(int)
126
+ Leveldb.options_set_compression(self, int)
127
+ end
128
+
129
+ # @param [FFI::Pointer(*Filterpolicy)] filterpolicy
130
+ # @return [nil]
131
+ def set_filter_policy(filterpolicy)
132
+ Leveldb.options_set_filter_policy(self, filterpolicy)
133
+ end
134
+
135
+ # @param [FFI::Pointer(*Env)] env
136
+ # @return [nil]
137
+ def set_env(env)
138
+ Leveldb.options_set_env(self, env)
139
+ end
140
+
141
+ # @param [FFI::Pointer(*Cache)] cache
142
+ # @return [nil]
143
+ def set_cache(cache)
144
+ Leveldb.options_set_cache(self, cache)
145
+ end
146
+
147
+ # @param [Integer] u_char
148
+ # @return [nil]
149
+ def set_error_if_exists(u_char)
150
+ Leveldb.options_set_error_if_exists(self, u_char)
151
+ end
152
+
153
+ # @param [Integer] int
154
+ # @return [nil]
155
+ def set_block_restart_interval(int)
156
+ Leveldb.options_set_block_restart_interval(self, int)
157
+ end
158
+
159
+ # @param [Integer] u_long
160
+ # @return [nil]
161
+ def set_write_buffer_size(u_long)
162
+ Leveldb.options_set_write_buffer_size(self, u_long)
163
+ end
164
+
165
+ # @return [nil]
166
+ def destroy()
167
+ Leveldb.options_destroy(self)
168
+ end
169
+ end
170
+
171
+ class Options < FFI::Struct
172
+ include OptionsWrappers
173
+ layout :dummy, :char
174
+ end
175
+
176
+ # (Not documented)
177
+ module ReadoptionsWrappers
178
+ # @param [Integer] u_char
179
+ # @return [nil]
180
+ def set_verify_checksums(u_char)
181
+ Leveldb.readoptions_set_verify_checksums(self, u_char)
182
+ end
183
+
184
+ # @param [FFI::Pointer(*Snapshot)] snapshot
185
+ # @return [nil]
186
+ def set_snapshot(snapshot)
187
+ Leveldb.readoptions_set_snapshot(self, snapshot)
188
+ end
189
+
190
+ # @param [Integer] u_char
191
+ # @return [nil]
192
+ def set_fill_cache(u_char)
193
+ Leveldb.readoptions_set_fill_cache(self, u_char)
194
+ end
195
+
196
+ # @return [nil]
197
+ def destroy()
198
+ Leveldb.readoptions_destroy(self)
199
+ end
200
+ end
201
+
202
+ class Readoptions < FFI::Struct
203
+ include ReadoptionsWrappers
204
+ layout :dummy, :char
205
+ end
206
+
207
+ # (Not documented)
208
+ class Snapshot < FFI::Struct
209
+ layout :dummy, :char
210
+ end
211
+
212
+ # (Not documented)
213
+ module WritebatchWrappers
214
+ # @return [nil]
215
+ def clear()
216
+ Leveldb.writebatch_clear(self)
217
+ end
218
+
219
+ # @param [String] key
220
+ # @param [Integer] klen
221
+ # @return [nil]
222
+ def delete(key, klen)
223
+ Leveldb.writebatch_delete(self, key, klen)
224
+ end
225
+
226
+ # @return [nil]
227
+ def destroy()
228
+ Leveldb.writebatch_destroy(self)
229
+ end
230
+
231
+ # @param [FFI::Pointer(*Void)] state
232
+ # @param [FFI::Pointer(*)] put
233
+ # @param [FFI::Pointer(*)] deleted
234
+ # @return [nil]
235
+ def iterate(state, put, deleted)
236
+ Leveldb.writebatch_iterate(self, state, put, deleted)
237
+ end
238
+
239
+ # @param [String] key
240
+ # @param [Integer] klen
241
+ # @param [String] val
242
+ # @param [Integer] vlen
243
+ # @return [nil]
244
+ def put(key, klen, val, vlen)
245
+ Leveldb.writebatch_put(self, key, klen, val, vlen)
246
+ end
247
+ end
248
+
249
+ class Writebatch < FFI::Struct
250
+ include WritebatchWrappers
251
+ layout :dummy, :char
252
+ end
253
+
254
+ # (Not documented)
255
+ module CacheWrappers
256
+ # @return [nil]
257
+ def destroy()
258
+ Leveldb.cache_destroy(self)
259
+ end
260
+ end
261
+
262
+ class Cache < FFI::Struct
263
+ include CacheWrappers
264
+ layout :dummy, :char
265
+ end
266
+
267
+ # (Not documented)
268
+ module FilterpolicyWrappers
269
+ # @return [nil]
270
+ def destroy()
271
+ Leveldb.filterpolicy_destroy(self)
272
+ end
273
+ end
274
+
275
+ class Filterpolicy < FFI::Struct
276
+ include FilterpolicyWrappers
277
+ layout :dummy, :char
278
+ end
279
+
280
+ # (Not documented)
281
+ class Randomfile < FFI::Struct
282
+ layout :dummy, :char
283
+ end
284
+
285
+ # (Not documented)
286
+ class Writablefile < FFI::Struct
287
+ layout :dummy, :char
288
+ end
289
+
290
+ # (Not documented)
291
+ module EnvWrappers
292
+ # @return [nil]
293
+ def destroy()
294
+ Leveldb.env_destroy(self)
295
+ end
296
+ end
297
+
298
+ class Env < FFI::Struct
299
+ include EnvWrappers
300
+ layout :dummy, :char
301
+ end
302
+
303
+ # (Not documented)
304
+ class Seqfile < FFI::Struct
305
+ layout :dummy, :char
306
+ end
307
+
308
+ # (Not documented)
309
+ class Logger < FFI::Struct
310
+ layout :dummy, :char
311
+ end
312
+
313
+ # (Not documented)
314
+ module WriteoptionsWrappers
315
+ # @return [nil]
316
+ def destroy()
317
+ Leveldb.writeoptions_destroy(self)
318
+ end
319
+
320
+ # @param [Integer] u_char
321
+ # @return [nil]
322
+ def set_sync(u_char)
323
+ Leveldb.writeoptions_set_sync(self, u_char)
324
+ end
325
+ end
326
+
327
+ class Writeoptions < FFI::Struct
328
+ include WriteoptionsWrappers
329
+ layout :dummy, :char
330
+ end
331
+
332
+ ##
333
+ # Writing Callbacks
334
+ #
335
+ ##
336
+ # Writing Functions
337
+ #
338
+ # DB operations
339
+ #
340
+ # @method open(options, name, errptr)
341
+ # @param [Options] options
342
+ # @param [String] name
343
+ # @param [FFI::Pointer(**CharS)] errptr
344
+ # @return [DB]
345
+ # @scope class
346
+ #
347
+ attach_function :open, :leveldb_open, [Options, :string, :pointer], DB.auto_ptr
348
+
349
+ # (Not documented)
350
+ #
351
+ # @method put(db, options, key, keylen, val, vallen, errptr)
352
+ # @param [DB] db
353
+ # @param [Writeoptions] options
354
+ # @param [String] key
355
+ # @param [Integer] keylen
356
+ # @param [String] val
357
+ # @param [Integer] vallen
358
+ # @param [FFI::Pointer(**CharS)] errptr
359
+ # @return [nil]
360
+ # @scope class
361
+ #
362
+ attach_function :put, :leveldb_put, [DB, Writeoptions, :string, :ulong, :string, :ulong, :pointer], :void
363
+
364
+ alias __put put
365
+ def self.put(db, wo, key, value, err)
366
+ __put(db, wo, key, key.size, value, value.size, err)
367
+ end
368
+ def put(*args); Leveldb.put(*args); end
369
+
370
+ # (Not documented)
371
+ #
372
+ # @method write(db, options, batch, errptr)
373
+ # @param [DB] db
374
+ # @param [Writeoptions] options
375
+ # @param [Writebatch] batch
376
+ # @param [FFI::Pointer(**CharS)] errptr
377
+ # @return [nil]
378
+ # @scope class
379
+ #
380
+ attach_function :write, :leveldb_write, [DB, Writeoptions, Writebatch, :pointer], :void
381
+
382
+ # Returns NULL if not found. A malloc()ed array otherwise.
383
+ # Stores the length of the array in *vallen.
384
+ #
385
+ # @method create_iterator(db, options)
386
+ # @param [DB] db
387
+ # @param [Readoptions] options
388
+ # @return [Iterator]
389
+ # @scope class
390
+ #
391
+ attach_function :create_iterator, :leveldb_create_iterator, [DB, Readoptions], Iterator.auto_ptr
392
+
393
+ # (Not documented)
394
+ #
395
+ # @method release_snapshot(db, snapshot)
396
+ # @param [DB] db
397
+ # @param [Snapshot] snapshot
398
+ # @return [nil]
399
+ # @scope class
400
+ #
401
+ attach_function :release_snapshot, :leveldb_release_snapshot, [DB, Snapshot], :void
402
+
403
+ # Returns NULL if property name is unknown.
404
+ # Else returns a pointer to a malloc()-ed null-terminated value.
405
+ #
406
+ # @method approximate_sizes(db, num_ranges, range_start_key, range_start_key_len, range_limit_key, range_limit_key_len, sizes)
407
+ # @param [DB] db
408
+ # @param [Integer] num_ranges
409
+ # @param [FFI::Pointer(**CharS)] range_start_key
410
+ # @param [FFI::Pointer(*Size)] range_start_key_len
411
+ # @param [FFI::Pointer(**CharS)] range_limit_key
412
+ # @param [FFI::Pointer(*Size)] range_limit_key_len
413
+ # @param [FFI::Pointer(*Uint64)] sizes
414
+ # @return [nil]
415
+ # @scope class
416
+ #
417
+ attach_function :approximate_sizes, :leveldb_approximate_sizes, [DB, :int, :pointer, :pointer, :pointer, :pointer, :pointer], :void
418
+
419
+ # Management operations
420
+ #
421
+ # @method destroy_db(options, name, errptr)
422
+ # @param [Options] options
423
+ # @param [String] name
424
+ # @param [FFI::Pointer(**CharS)] errptr
425
+ # @return [nil]
426
+ # @scope class
427
+ #
428
+ attach_function :destroy_db, :leveldb_destroy_db, [Options, :string, :pointer], :void
429
+
430
+ # Iterator
431
+ #
432
+ # @method iter_destroy(iterator)
433
+ # @param [Iterator] iterator
434
+ # @return [nil]
435
+ # @scope class
436
+ #
437
+ attach_function :iter_destroy, :leveldb_iter_destroy, [Iterator], :void
438
+
439
+ # (Not documented)
440
+ #
441
+ # @method iter_seek_to_first(iterator)
442
+ # @param [Iterator] iterator
443
+ # @return [nil]
444
+ # @scope class
445
+ #
446
+ attach_function :iter_seek_to_first, :leveldb_iter_seek_to_first, [Iterator], :void
447
+
448
+ # (Not documented)
449
+ #
450
+ # @method iter_seek(iterator, k, klen)
451
+ # @param [Iterator] iterator
452
+ # @param [String] k
453
+ # @param [Integer] klen
454
+ # @return [nil]
455
+ # @scope class
456
+ #
457
+ attach_function :iter_seek, :leveldb_iter_seek, [Iterator, :string, :ulong], :void
458
+
459
+ # (Not documented)
460
+ #
461
+ # @method iter_prev(iterator)
462
+ # @param [Iterator] iterator
463
+ # @return [nil]
464
+ # @scope class
465
+ #
466
+ attach_function :iter_prev, :leveldb_iter_prev, [Iterator], :void
467
+
468
+ # (Not documented)
469
+ #
470
+ # @method iter_value(iterator, vlen)
471
+ # @param [Iterator] iterator
472
+ # @param [FFI::Pointer(*Size)] vlen
473
+ # @return [String]
474
+ # @scope class
475
+ #
476
+ attach_function :iter_value, :leveldb_iter_value, [Iterator, :pointer], :string
477
+
478
+ # Write batch
479
+ #
480
+ # @method writebatch_create()
481
+ # @return [Writebatch]
482
+ # @scope class
483
+ #
484
+ attach_function :writebatch_create, :leveldb_writebatch_create, [], Writebatch.auto_ptr
485
+
486
+ # (Not documented)
487
+ #
488
+ # @method writebatch_clear(writebatch)
489
+ # @param [Writebatch] writebatch
490
+ # @return [nil]
491
+ # @scope class
492
+ #
493
+ attach_function :writebatch_clear, :leveldb_writebatch_clear, [Writebatch], :void
494
+
495
+ # (Not documented)
496
+ #
497
+ # @method writebatch_delete(writebatch, key, klen)
498
+ # @param [Writebatch] writebatch
499
+ # @param [String] key
500
+ # @param [Integer] klen
501
+ # @return [nil]
502
+ # @scope class
503
+ #
504
+ attach_function :writebatch_delete, :leveldb_writebatch_delete, [Writebatch, :string, :ulong], :void
505
+
506
+ # Options
507
+ #
508
+ # @method options_create()
509
+ # @return [Options]
510
+ # @scope class
511
+ #
512
+ attach_function :options_create, :leveldb_options_create, [], Options.auto_ptr
513
+
514
+ # (Not documented)
515
+ #
516
+ # @method options_set_comparator(options, comparator)
517
+ # @param [Options] options
518
+ # @param [Comparator] comparator
519
+ # @return [nil]
520
+ # @scope class
521
+ #
522
+ attach_function :options_set_comparator, :leveldb_options_set_comparator, [Options, Comparator], :void
523
+
524
+ # (Not documented)
525
+ #
526
+ # @method options_set_create_if_missing(options, u_char)
527
+ # @param [Options] options
528
+ # @param [Integer] u_char
529
+ # @return [nil]
530
+ # @scope class
531
+ #
532
+ attach_function :options_set_create_if_missing, :leveldb_options_set_create_if_missing, [Options, :uchar], :void
533
+
534
+ # (Not documented)
535
+ #
536
+ # @method options_set_paranoid_checks(options, u_char)
537
+ # @param [Options] options
538
+ # @param [Integer] u_char
539
+ # @return [nil]
540
+ # @scope class
541
+ #
542
+ attach_function :options_set_paranoid_checks, :leveldb_options_set_paranoid_checks, [Options, :uchar], :void
543
+
544
+ # (Not documented)
545
+ #
546
+ # @method options_set_info_log(options, logger)
547
+ # @param [Options] options
548
+ # @param [Logger] logger
549
+ # @return [nil]
550
+ # @scope class
551
+ #
552
+ attach_function :options_set_info_log, :leveldb_options_set_info_log, [Options, Logger], :void
553
+
554
+ # (Not documented)
555
+ #
556
+ # @method options_set_max_open_files(options, int)
557
+ # @param [Options] options
558
+ # @param [Integer] int
559
+ # @return [nil]
560
+ # @scope class
561
+ #
562
+ attach_function :options_set_max_open_files, :leveldb_options_set_max_open_files, [Options, :int], :void
563
+
564
+ # (Not documented)
565
+ #
566
+ # @method options_set_block_size(options, u_long)
567
+ # @param [Options] options
568
+ # @param [Integer] u_long
569
+ # @return [nil]
570
+ # @scope class
571
+ #
572
+ attach_function :options_set_block_size, :leveldb_options_set_block_size, [Options, :ulong], :void
573
+
574
+ # (Not documented)
575
+ #
576
+ # @method options_set_compression(options, int)
577
+ # @param [Options] options
578
+ # @param [Integer] int
579
+ # @return [nil]
580
+ # @scope class
581
+ #
582
+ attach_function :options_set_compression, :leveldb_options_set_compression, [Options, :int], :void
583
+
584
+ # Comparator
585
+ #
586
+ # @method comparator_destroy(comparator)
587
+ # @param [Comparator] comparator
588
+ # @return [nil]
589
+ # @scope class
590
+ #
591
+ attach_function :comparator_destroy, :leveldb_comparator_destroy, [Comparator], :void
592
+
593
+ # Filter policy
594
+ #
595
+ # @method filterpolicy_destroy(filterpolicy)
596
+ # @param [Filterpolicy] filterpolicy
597
+ # @return [nil]
598
+ # @scope class
599
+ #
600
+ attach_function :filterpolicy_destroy, :leveldb_filterpolicy_destroy, [Filterpolicy], :void
601
+
602
+ # Read options
603
+ #
604
+ # @method readoptions_create()
605
+ # @return [Readoptions]
606
+ # @scope class
607
+ #
608
+ attach_function :readoptions_create, :leveldb_readoptions_create, [], Readoptions.auto_ptr
609
+
610
+ # (Not documented)
611
+ #
612
+ # @method readoptions_set_verify_checksums(readoptions, u_char)
613
+ # @param [Readoptions] readoptions
614
+ # @param [Integer] u_char
615
+ # @return [nil]
616
+ # @scope class
617
+ #
618
+ attach_function :readoptions_set_verify_checksums, :leveldb_readoptions_set_verify_checksums, [Readoptions, :uchar], :void
619
+
620
+ # (Not documented)
621
+ #
622
+ # @method readoptions_set_snapshot(readoptions, snapshot)
623
+ # @param [Readoptions] readoptions
624
+ # @param [Snapshot] snapshot
625
+ # @return [nil]
626
+ # @scope class
627
+ #
628
+ attach_function :readoptions_set_snapshot, :leveldb_readoptions_set_snapshot, [Readoptions, Snapshot], :void
629
+
630
+ # Write options
631
+ #
632
+ # @method writeoptions_destroy(writeoptions)
633
+ # @param [Writeoptions] writeoptions
634
+ # @return [nil]
635
+ # @scope class
636
+ #
637
+ attach_function :writeoptions_destroy, :leveldb_writeoptions_destroy, [Writeoptions], :void
638
+
639
+ # Cache
640
+ #
641
+ # @method cache_create_lru(capacity)
642
+ # @param [Integer] capacity
643
+ # @return [Cache]
644
+ # @scope class
645
+ #
646
+ attach_function :cache_create_lru, :leveldb_cache_create_lru, [:ulong], Cache.auto_ptr
647
+
648
+ # Env
649
+ #
650
+ # @method create_default_env()
651
+ # @return [Env]
652
+ # @scope class
653
+ #
654
+ attach_function :create_default_env, :leveldb_create_default_env, [], Env.auto_ptr
655
+
656
+ # Calls free(ptr).
657
+ # REQUIRES: ptr was malloc()-ed and returned by one of the routines
658
+ # in this file. Note that in certain cases (typically on Windows), you
659
+ # may need to call this routine instead of free(ptr) to dispose of
660
+ # malloc()-ed memory returned by this library.
661
+ #
662
+ # @method free(ptr)
663
+ # @param [FFI::Pointer(*Void)] ptr
664
+ # @return [nil]
665
+ # @scope class
666
+ #
667
+ attach_function :free, :leveldb_free, [:pointer], :void
668
+
669
+ # Return the minor version number for this release.
670
+ #
671
+ # @method minor_version()
672
+ # @return [Integer]
673
+ # @scope class
674
+ #
675
+ attach_function :minor_version, :leveldb_minor_version, [], :int
676
+
677
+ # (Not documented)
678
+ #
679
+ # @method close(db)
680
+ # @param [DB] db
681
+ # @return [nil]
682
+ # @scope class
683
+ #
684
+ attach_function :close, :leveldb_close, [DB], :void
685
+
686
+ # Returns NULL if not found. A malloc()ed array otherwise.
687
+ # Stores the length of the array in *vallen.
688
+ #
689
+ # @method get(db, options, key, keylen, vallen, errptr)
690
+ # @param [DB] db
691
+ # @param [Readoptions] options
692
+ # @param [String] key
693
+ # @param [Integer] keylen
694
+ # @param [FFI::Pointer(*Size)] vallen
695
+ # @param [FFI::Pointer(**CharS)] errptr
696
+ # @return [String]
697
+ # @scope class
698
+ #
699
+ attach_function :get, :leveldb_get, [DB, Readoptions, :string, :ulong, :pointer, :pointer], :string
700
+
701
+ # Returns NULL if property name is unknown.
702
+ # Else returns a pointer to a malloc()-ed null-terminated value.
703
+ #
704
+ # @method property_value(db, propname)
705
+ # @param [DB] db
706
+ # @param [String] propname
707
+ # @return [String]
708
+ # @scope class
709
+ #
710
+ attach_function :property_value, :leveldb_property_value, [DB, :string], :string
711
+
712
+ # Management operations
713
+ #
714
+ # @method repair_db(options, name, errptr)
715
+ # @param [Options] options
716
+ # @param [String] name
717
+ # @param [FFI::Pointer(**CharS)] errptr
718
+ # @return [nil]
719
+ # @scope class
720
+ #
721
+ attach_function :repair_db, :leveldb_repair_db, [Options, :string, :pointer], :void
722
+
723
+ # Iterator
724
+ #
725
+ # @method iter_seek_to_last(iterator)
726
+ # @param [Iterator] iterator
727
+ # @return [nil]
728
+ # @scope class
729
+ #
730
+ attach_function :iter_seek_to_last, :leveldb_iter_seek_to_last, [Iterator], :void
731
+
732
+ # (Not documented)
733
+ #
734
+ # @method iter_key(iterator, klen)
735
+ # @param [Iterator] iterator
736
+ # @param [FFI::Pointer(*Size)] klen
737
+ # @return [String]
738
+ # @scope class
739
+ #
740
+ attach_function :iter_key, :leveldb_iter_key, [Iterator, :pointer], :string
741
+
742
+ # Write batch
743
+ #
744
+ # @method writebatch_destroy(writebatch)
745
+ # @param [Writebatch] writebatch
746
+ # @return [nil]
747
+ # @scope class
748
+ #
749
+ attach_function :writebatch_destroy, :leveldb_writebatch_destroy, [Writebatch], :void
750
+
751
+ # (Not documented)
752
+ #
753
+ # @method writebatch_iterate(writebatch, state, put, deleted)
754
+ # @param [Writebatch] writebatch
755
+ # @param [FFI::Pointer(*Void)] state
756
+ # @param [FFI::Pointer(*)] put
757
+ # @param [FFI::Pointer(*)] deleted
758
+ # @return [nil]
759
+ # @scope class
760
+ #
761
+ attach_function :writebatch_iterate, :leveldb_writebatch_iterate, [Writebatch, :pointer, :pointer, :pointer], :void
762
+
763
+ # Options
764
+ #
765
+ # @method options_set_filter_policy(options, filterpolicy)
766
+ # @param [Options] options
767
+ # @param [Filterpolicy] filterpolicy
768
+ # @return [nil]
769
+ # @scope class
770
+ #
771
+ attach_function :options_set_filter_policy, :leveldb_options_set_filter_policy, [Options, Filterpolicy], :void
772
+
773
+ # (Not documented)
774
+ #
775
+ # @method options_set_env(options, env)
776
+ # @param [Options] options
777
+ # @param [Env] env
778
+ # @return [nil]
779
+ # @scope class
780
+ #
781
+ attach_function :options_set_env, :leveldb_options_set_env, [Options, Env], :void
782
+
783
+ # (Not documented)
784
+ #
785
+ # @method options_set_cache(options, cache)
786
+ # @param [Options] options
787
+ # @param [Cache] cache
788
+ # @return [nil]
789
+ # @scope class
790
+ #
791
+ attach_function :options_set_cache, :leveldb_options_set_cache, [Options, Cache], :void
792
+
793
+ # Comparator
794
+ #
795
+ # @method comparator_create(state, destructor, compare, name)
796
+ # @param [FFI::Pointer(*Void)] state
797
+ # @param [FFI::Pointer(*)] destructor
798
+ # @param [FFI::Pointer(*)] compare
799
+ # @param [FFI::Pointer(*)] name
800
+ # @return [Comparator]
801
+ # @scope class
802
+ #
803
+ attach_function :comparator_create, :leveldb_comparator_create, [:pointer, :pointer, :pointer, :pointer], Comparator.auto_ptr
804
+
805
+ # Filter policy
806
+ #
807
+ # @method filterpolicy_create_bloom(bits_per_key)
808
+ # @param [Integer] bits_per_key
809
+ # @return [Filterpolicy]
810
+ # @scope class
811
+ #
812
+ attach_function :filterpolicy_create_bloom, :leveldb_filterpolicy_create_bloom, [:int], Filterpolicy.auto_ptr
813
+
814
+ # Read options
815
+ #
816
+ # @method readoptions_set_fill_cache(readoptions, u_char)
817
+ # @param [Readoptions] readoptions
818
+ # @param [Integer] u_char
819
+ # @return [nil]
820
+ # @scope class
821
+ #
822
+ attach_function :readoptions_set_fill_cache, :leveldb_readoptions_set_fill_cache, [Readoptions, :uchar], :void
823
+
824
+ # Write options
825
+ #
826
+ # @method writeoptions_set_sync(writeoptions, u_char)
827
+ # @param [Writeoptions] writeoptions
828
+ # @param [Integer] u_char
829
+ # @return [nil]
830
+ # @scope class
831
+ #
832
+ attach_function :writeoptions_set_sync, :leveldb_writeoptions_set_sync, [Writeoptions, :uchar], :void
833
+
834
+ # Env
835
+ #
836
+ # @method env_destroy(env)
837
+ # @param [Env] env
838
+ # @return [nil]
839
+ # @scope class
840
+ #
841
+ attach_function :env_destroy, :leveldb_env_destroy, [Env], :void
842
+
843
+ # (Not documented)
844
+ #
845
+ # @method delete(db, options, key, keylen, errptr)
846
+ # @param [DB] db
847
+ # @param [Writeoptions] options
848
+ # @param [String] key
849
+ # @param [Integer] keylen
850
+ # @param [FFI::Pointer(**CharS)] errptr
851
+ # @return [nil]
852
+ # @scope class
853
+ #
854
+ attach_function :delete, :leveldb_delete, [DB, Writeoptions, :string, :ulong, :pointer], :void
855
+
856
+ # Returns NULL if property name is unknown.
857
+ # Else returns a pointer to a malloc()-ed null-terminated value.
858
+ #
859
+ # @method compact_range(db, start_key, start_key_len, limit_key, limit_key_len)
860
+ # @param [DB] db
861
+ # @param [String] start_key
862
+ # @param [Integer] start_key_len
863
+ # @param [String] limit_key
864
+ # @param [Integer] limit_key_len
865
+ # @return [nil]
866
+ # @scope class
867
+ #
868
+ attach_function :compact_range, :leveldb_compact_range, [DB, :string, :ulong, :string, :ulong], :void
869
+
870
+ # Iterator
871
+ #
872
+ # @method iter_next(iterator)
873
+ # @param [Iterator] iterator
874
+ # @return [nil]
875
+ # @scope class
876
+ #
877
+ attach_function :iter_next, :leveldb_iter_next, [Iterator], :void
878
+
879
+ # Write batch
880
+ #
881
+ # @method writebatch_put(writebatch, key, klen, val, vlen)
882
+ # @param [Writebatch] writebatch
883
+ # @param [String] key
884
+ # @param [Integer] klen
885
+ # @param [String] val
886
+ # @param [Integer] vlen
887
+ # @return [nil]
888
+ # @scope class
889
+ #
890
+ attach_function :writebatch_put, :leveldb_writebatch_put, [Writebatch, :string, :ulong, :string, :ulong], :void
891
+
892
+ # Options
893
+ #
894
+ # @method options_set_error_if_exists(options, u_char)
895
+ # @param [Options] options
896
+ # @param [Integer] u_char
897
+ # @return [nil]
898
+ # @scope class
899
+ #
900
+ attach_function :options_set_error_if_exists, :leveldb_options_set_error_if_exists, [Options, :uchar], :void
901
+
902
+ # (Not documented)
903
+ #
904
+ # @method options_set_block_restart_interval(options, int)
905
+ # @param [Options] options
906
+ # @param [Integer] int
907
+ # @return [nil]
908
+ # @scope class
909
+ #
910
+ attach_function :options_set_block_restart_interval, :leveldb_options_set_block_restart_interval, [Options, :int], :void
911
+
912
+ # Read options
913
+ #
914
+ # @method readoptions_destroy(readoptions)
915
+ # @param [Readoptions] readoptions
916
+ # @return [nil]
917
+ # @scope class
918
+ #
919
+ attach_function :readoptions_destroy, :leveldb_readoptions_destroy, [Readoptions], :void
920
+
921
+ # Cache
922
+ #
923
+ # @method cache_destroy(cache)
924
+ # @param [Cache] cache
925
+ # @return [nil]
926
+ # @scope class
927
+ #
928
+ attach_function :cache_destroy, :leveldb_cache_destroy, [Cache], :void
929
+
930
+ # (Not documented)
931
+ #
932
+ # @method create_snapshot(db)
933
+ # @param [DB] db
934
+ # @return [Snapshot]
935
+ # @scope class
936
+ #
937
+ attach_function :create_snapshot, :leveldb_create_snapshot, [DB], Snapshot.auto_ptr
938
+
939
+ # Iterator
940
+ #
941
+ # @method iter_get_error(iterator, errptr)
942
+ # @param [Iterator] iterator
943
+ # @param [FFI::Pointer(**CharS)] errptr
944
+ # @return [nil]
945
+ # @scope class
946
+ #
947
+ attach_function :iter_get_error, :leveldb_iter_get_error, [Iterator, :pointer], :void
948
+
949
+ # Options
950
+ #
951
+ # @method options_set_write_buffer_size(options, u_long)
952
+ # @param [Options] options
953
+ # @param [Integer] u_long
954
+ # @return [nil]
955
+ # @scope class
956
+ #
957
+ attach_function :options_set_write_buffer_size, :leveldb_options_set_write_buffer_size, [Options, :ulong], :void
958
+
959
+ # Write options
960
+ #
961
+ # @method writeoptions_create()
962
+ # @return [Writeoptions]
963
+ # @scope class
964
+ #
965
+ attach_function :writeoptions_create, :leveldb_writeoptions_create, [], Writeoptions.auto_ptr
966
+
967
+ # (Not documented)
968
+ #
969
+ # @method iter_valid(iterator)
970
+ # @param [Iterator] iterator
971
+ # @return [Integer]
972
+ # @scope class
973
+ #
974
+ attach_function :iter_valid, :leveldb_iter_valid, [Iterator], :uchar
975
+
976
+ # Filter policy
977
+ #
978
+ # @method filterpolicy_create(state, destructor, create_filter, key_may_match, name)
979
+ # @param [FFI::Pointer(*Void)] state
980
+ # @param [FFI::Pointer(*)] destructor
981
+ # @param [FFI::Pointer(*)] create_filter
982
+ # @param [FFI::Pointer(*)] key_may_match
983
+ # @param [FFI::Pointer(*)] name
984
+ # @return [Filterpolicy]
985
+ # @scope class
986
+ #
987
+ attach_function :filterpolicy_create, :leveldb_filterpolicy_create, [:pointer, :pointer, :pointer, :pointer, :pointer], Filterpolicy.auto_ptr
988
+
989
+ # (Not documented)
990
+ #
991
+ # @method options_destroy(options)
992
+ # @param [Options] options
993
+ # @return [nil]
994
+ # @scope class
995
+ #
996
+ attach_function :options_destroy, :leveldb_options_destroy, [Options], :void
997
+
998
+ # Return the major version number for this release.
999
+ #
1000
+ # @method major_version()
1001
+ # @return [Integer]
1002
+ # @scope class
1003
+ #
1004
+ attach_function :major_version, :leveldb_major_version, [], :int
1005
+
1006
+ end