leveldb-ruby 0.14 → 0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/LICENSE +24 -0
  2. data/README +60 -16
  3. data/ext/leveldb/extconf.rb +1 -1
  4. data/ext/leveldb/leveldb.cc +187 -18
  5. data/leveldb/Makefile +82 -96
  6. data/leveldb/build_detect_platform +137 -51
  7. data/leveldb/db/c.cc +110 -0
  8. data/leveldb/db/db_bench.cc +105 -4
  9. data/leveldb/db/db_impl.cc +135 -45
  10. data/leveldb/db/db_impl.h +12 -10
  11. data/leveldb/db/db_test.cc +666 -431
  12. data/leveldb/db/dbformat.cc +20 -0
  13. data/leveldb/db/dbformat.h +12 -0
  14. data/leveldb/db/repair.cc +3 -1
  15. data/leveldb/db/skiplist.h +2 -1
  16. data/leveldb/db/table_cache.cc +42 -16
  17. data/leveldb/db/table_cache.h +11 -0
  18. data/leveldb/db/version_set.cc +46 -41
  19. data/leveldb/db/version_set.h +9 -0
  20. data/leveldb/db/write_batch.cc +13 -4
  21. data/leveldb/db/write_batch_internal.h +2 -0
  22. data/leveldb/db/write_batch_test.cc +31 -0
  23. data/leveldb/include/leveldb/c.h +29 -0
  24. data/leveldb/include/leveldb/db.h +2 -1
  25. data/leveldb/include/leveldb/filter_policy.h +70 -0
  26. data/leveldb/include/leveldb/options.h +8 -0
  27. data/leveldb/include/leveldb/status.h +6 -0
  28. data/leveldb/include/leveldb/table.h +15 -0
  29. data/leveldb/include/leveldb/table_builder.h +1 -0
  30. data/leveldb/port/atomic_pointer.h +13 -5
  31. data/leveldb/port/port.h +0 -2
  32. data/leveldb/port/port_example.h +10 -0
  33. data/leveldb/port/port_posix.cc +4 -0
  34. data/leveldb/port/port_posix.h +24 -9
  35. data/leveldb/table/block.cc +8 -4
  36. data/leveldb/table/block.h +3 -2
  37. data/leveldb/table/filter_block.cc +111 -0
  38. data/leveldb/table/filter_block.h +68 -0
  39. data/leveldb/table/filter_block_test.cc +128 -0
  40. data/leveldb/table/format.cc +17 -7
  41. data/leveldb/table/format.h +9 -4
  42. data/leveldb/table/table.cc +107 -6
  43. data/leveldb/table/table_builder.cc +49 -6
  44. data/leveldb/table/table_test.cc +8 -24
  45. data/leveldb/util/bloom.cc +95 -0
  46. data/leveldb/util/bloom_test.cc +159 -0
  47. data/leveldb/util/coding_test.cc +23 -0
  48. data/leveldb/util/comparator.cc +8 -3
  49. data/leveldb/util/env_posix.cc +46 -4
  50. data/leveldb/util/filter_policy.cc +11 -0
  51. data/leveldb/util/options.cc +2 -1
  52. data/lib/leveldb.rb +31 -5
  53. metadata +227 -109
  54. data/leveldb/port/port_android.cc +0 -64
  55. data/leveldb/port/port_android.h +0 -156
@@ -1,64 +0,0 @@
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 "port/port_android.h"
6
-
7
- #include <cstdlib>
8
-
9
- extern "C" {
10
- size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d) {
11
- return fread(a, b, c, d);
12
- }
13
-
14
- size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d) {
15
- return fwrite(a, b, c, d);
16
- }
17
-
18
- int fflush_unlocked(FILE *f) {
19
- return fflush(f);
20
- }
21
-
22
- int fdatasync(int fd) {
23
- return fsync(fd);
24
- }
25
- }
26
-
27
- namespace leveldb {
28
- namespace port {
29
-
30
- static void PthreadCall(const char* label, int result) {
31
- if (result != 0) {
32
- fprintf(stderr, "pthread %s: %s\n", label, strerror(result));
33
- abort();
34
- }
35
- }
36
-
37
- Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); }
38
- Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); }
39
- void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); }
40
- void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); }
41
-
42
- CondVar::CondVar(Mutex* mu)
43
- : mu_(mu) {
44
- PthreadCall("init cv", pthread_cond_init(&cv_, NULL));
45
- }
46
-
47
- CondVar::~CondVar() {
48
- PthreadCall("destroy cv", pthread_cond_destroy(&cv_));
49
- }
50
-
51
- void CondVar::Wait() {
52
- PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_));
53
- }
54
-
55
- void CondVar::Signal(){
56
- PthreadCall("signal", pthread_cond_signal(&cv_));
57
- }
58
-
59
- void CondVar::SignalAll() {
60
- PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
61
- }
62
-
63
- } // namespace port
64
- } // namespace leveldb
@@ -1,156 +0,0 @@
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
- // See port_example.h for documentation for the following types/functions.
6
-
7
- #ifndef STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
8
- #define STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
9
-
10
- #include <endian.h>
11
- #include <pthread.h>
12
- #include <stdint.h>
13
- #include <cstdatomic>
14
- #include <string>
15
- #include <cctype>
16
-
17
- // Collapse the plethora of ARM flavors available to an easier to manage set
18
- // Defs reference is at https://wiki.edubuntu.org/ARM/Thumb2PortingHowto
19
- #if defined(__ARM_ARCH_6__) || \
20
- defined(__ARM_ARCH_6J__) || \
21
- defined(__ARM_ARCH_6K__) || \
22
- defined(__ARM_ARCH_6Z__) || \
23
- defined(__ARM_ARCH_6T2__) || \
24
- defined(__ARM_ARCH_6ZK__) || \
25
- defined(__ARM_ARCH_7__) || \
26
- defined(__ARM_ARCH_7R__) || \
27
- defined(__ARM_ARCH_7A__)
28
- #define ARMV6_OR_7 1
29
- #endif
30
-
31
- extern "C" {
32
- size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d);
33
- size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d);
34
- int fflush_unlocked(FILE *f);
35
- int fdatasync (int fd);
36
- }
37
-
38
- namespace leveldb {
39
- namespace port {
40
-
41
- static const bool kLittleEndian = __BYTE_ORDER == __LITTLE_ENDIAN;
42
-
43
- class CondVar;
44
-
45
- class Mutex {
46
- public:
47
- Mutex();
48
- ~Mutex();
49
-
50
- void Lock();
51
- void Unlock();
52
- void AssertHeld() {
53
- //TODO(gabor): How can I implement this?
54
- }
55
-
56
- private:
57
- friend class CondVar;
58
- pthread_mutex_t mu_;
59
-
60
- // No copying
61
- Mutex(const Mutex&);
62
- void operator=(const Mutex&);
63
- };
64
-
65
- class CondVar {
66
- public:
67
- explicit CondVar(Mutex* mu);
68
- ~CondVar();
69
- void Wait();
70
- void Signal();
71
- void SignalAll();
72
- private:
73
- Mutex* mu_;
74
- pthread_cond_t cv_;
75
- };
76
-
77
- #ifndef ARMV6_OR_7
78
- // On ARM chipsets <V6, 0xffff0fa0 is the hard coded address of a
79
- // memory barrier function provided by the kernel.
80
- typedef void (*LinuxKernelMemoryBarrierFunc)(void);
81
- LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier ATTRIBUTE_WEAK =
82
- (LinuxKernelMemoryBarrierFunc) 0xffff0fa0;
83
- #endif
84
-
85
- // Storage for a lock-free pointer
86
- class AtomicPointer {
87
- private:
88
- void* rep_;
89
-
90
- inline void MemoryBarrier() const {
91
- // TODO(gabor): This only works on Android instruction sets >= V6
92
- #ifdef ARMV6_OR_7
93
- __asm__ __volatile__("dmb" : : : "memory");
94
- #else
95
- pLinuxKernelMemoryBarrier();
96
- #endif
97
- }
98
-
99
- public:
100
- AtomicPointer() { }
101
- explicit AtomicPointer(void* v) : rep_(v) { }
102
- inline void* Acquire_Load() const {
103
- void* r = rep_;
104
- MemoryBarrier();
105
- return r;
106
- }
107
- inline void Release_Store(void* v) {
108
- MemoryBarrier();
109
- rep_ = v;
110
- }
111
- inline void* NoBarrier_Load() const {
112
- void* r = rep_;
113
- return r;
114
- }
115
- inline void NoBarrier_Store(void* v) {
116
- rep_ = v;
117
- }
118
- };
119
-
120
- // TODO(gabor): Implement compress
121
- inline bool Snappy_Compress(
122
- const char* input,
123
- size_t input_length,
124
- std::string* output) {
125
- return false;
126
- }
127
-
128
- // TODO(gabor): Implement uncompress
129
- inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
130
- size_t* result) {
131
- return false;
132
- }
133
-
134
- // TODO(gabor): Implement uncompress
135
- inline bool Snappy_Uncompress(
136
- const char* input_data,
137
- size_t input_length,
138
- char* output) {
139
- return false;
140
- }
141
-
142
- inline uint64_t ThreadIdentifier() {
143
- pthread_t tid = pthread_self();
144
- uint64_t r = 0;
145
- memcpy(&r, &tid, sizeof(r) < sizeof(tid) ? sizeof(r) : sizeof(tid));
146
- return r;
147
- }
148
-
149
- inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
150
- return false;
151
- }
152
-
153
- } // namespace port
154
- } // namespace leveldb
155
-
156
- #endif // STORAGE_LEVELDB_PORT_PORT_ANDROID_H_