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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81b89ea5959e4b60215fed39fadbddf1a75bac83
4
+ data.tar.gz: 03b75e199e7b944525d611a5dc402dc5bea3334d
5
+ SHA512:
6
+ metadata.gz: bd7ee6bc335740240553b41c422a7ea8fb5591a4b5cdbf5cda65e9cd8bcfc841264ddb3c8687674279d5e10e03a7b49b4cc5653c80621729aa20d3f6a377e54c
7
+ data.tar.gz: 038d6bf18789e79919113430dde4d34f796ee96e4843c6cffc01ee6c04fff9b51c6f345e7fc6d8960f2469b9ecb35925c39ddd57914c8a2c725c085780bac830
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Davide D'Agostino
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Leveldb
2
+
3
+ Experimental FFI bindings for leveldb
4
+
5
+ ## Documentation
6
+
7
+ * [Website](http://daddye.it/leveldb)
8
+ * [Api Doc](http://daddye.it/leveldb/doc)
9
+
10
+ ## Installation
11
+
12
+ $ brew install snappy
13
+ $ git clone git://github.com/DAddYE/leveldb.git
14
+ $ cd leveldb
15
+ $ rake compile
16
+ $ rake console
17
+
18
+ ## Usage
19
+
20
+ Here a basic usage, for more advanced please see the doc.
21
+
22
+ Right now is very **low** level, I'm planning to add an higher layer api.
23
+
24
+ ### Prepare
25
+
26
+ If you plan to hack in a console ...
27
+
28
+ Remember that `err` is important, we are going to use this var in all our calls
29
+
30
+ ```rb
31
+ require 'leveldb'
32
+
33
+ include Leveldb
34
+
35
+ err = err_create
36
+ ```
37
+
38
+ ### Open
39
+
40
+ ```ruby
41
+ options = options_create
42
+ options.set_create_if_missing 1
43
+ db = open options, './tmp/testdb', err
44
+
45
+ abort err.message unless err.null?
46
+ ```
47
+
48
+ ### Write
49
+
50
+ ```ruby
51
+ write_opts = writeoptions_create
52
+ put(db, write_opts, "key", "value", err)
53
+
54
+ abort err.message unless err.null?
55
+ ```
56
+
57
+ ### Read
58
+
59
+ ```ruby
60
+ read_opts = readoptions_create
61
+ read = get(db, read_opts, "key", 3, read_len, err)
62
+
63
+ abort err.message unless err.null?
64
+ puts "Key is: #{read}"
65
+ ```
66
+
67
+ ### Delete
68
+
69
+ ```ruby
70
+ delete(db, write_opts, "key", 3, err)
71
+
72
+ abort err.message unless err.null?
73
+ ```
74
+
75
+ ### Close (connection)
76
+
77
+ ```ruby
78
+ db.close
79
+ ```
80
+
81
+ ### Destroy (database)
82
+
83
+ ```ruby
84
+ destroy_db(options, './tmp/testdb', err)
85
+
86
+ abort err.message unless err.null?
87
+ ```
88
+
89
+ ## Contributing
90
+
91
+ 1. Fork it
92
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
93
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
94
+ 4. Push to the branch (`git push origin my-new-feature`)
95
+ 5. Create new Pull Request
data/ext/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ task :default do
2
+ leveldb_dir = File.expand_path('../leveldb', __FILE__)
3
+
4
+ unless File.directory?(leveldb_dir)
5
+ STDERR.puts "ext/leveldb missing, please checkout its submodule..."
6
+ exit 1
7
+ end
8
+
9
+ # Make sure leveldb is built...
10
+ sh "cd #{leveldb_dir} && make"
11
+ end
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above
10
+ copyright notice, this list of conditions and the following disclaimer
11
+ in the documentation and/or other materials provided with the
12
+ distribution.
13
+ * Neither the name of Google Inc. nor the names of its
14
+ contributors may be used to endorse or promote products derived from
15
+ this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,206 @@
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
+ #-----------------------------------------------
6
+ # Uncomment exactly one of the lines labelled (A), (B), and (C) below
7
+ # to switch between compilation modes.
8
+
9
+ OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
10
+ # OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
11
+ # OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
12
+ #-----------------------------------------------
13
+
14
+ # detect what platform we're building on
15
+ $(shell CC="$(CC)" CXX="$(CXX)" TARGET_OS="$(TARGET_OS)" \
16
+ ./build_detect_platform build_config.mk ./)
17
+ # this file is generated by the previous line to set build flags and sources
18
+ include build_config.mk
19
+
20
+ CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
21
+ CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
22
+
23
+ LDFLAGS += $(PLATFORM_LDFLAGS)
24
+ LIBS += $(PLATFORM_LIBS)
25
+
26
+ LIBOBJECTS = $(SOURCES:.cc=.o)
27
+ MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
28
+
29
+ TESTUTIL = ./util/testutil.o
30
+ TESTHARNESS = ./util/testharness.o $(TESTUTIL)
31
+
32
+ TESTS = \
33
+ arena_test \
34
+ bloom_test \
35
+ c_test \
36
+ cache_test \
37
+ coding_test \
38
+ corruption_test \
39
+ crc32c_test \
40
+ db_test \
41
+ dbformat_test \
42
+ env_test \
43
+ filename_test \
44
+ filter_block_test \
45
+ issue178_test \
46
+ log_test \
47
+ memenv_test \
48
+ skiplist_test \
49
+ table_test \
50
+ version_edit_test \
51
+ version_set_test \
52
+ write_batch_test
53
+
54
+ PROGRAMS = db_bench leveldbutil $(TESTS)
55
+ BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
56
+
57
+ LIBRARY = libleveldb.a
58
+ MEMENVLIBRARY = libmemenv.a
59
+
60
+ default: all
61
+
62
+ # Should we build shared libraries?
63
+ ifneq ($(PLATFORM_SHARED_EXT),)
64
+
65
+ ifneq ($(PLATFORM_SHARED_VERSIONED),true)
66
+ SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
67
+ SHARED2 = $(SHARED1)
68
+ SHARED3 = $(SHARED1)
69
+ SHARED = $(SHARED1)
70
+ else
71
+ # Update db.h if you change these.
72
+ SHARED_MAJOR = 1
73
+ SHARED_MINOR = 12
74
+ SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
75
+ SHARED2 = $(SHARED1).$(SHARED_MAJOR)
76
+ SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
77
+ SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
78
+ $(SHARED1): $(SHARED3)
79
+ ln -fs $(SHARED3) $(SHARED1)
80
+ $(SHARED2): $(SHARED3)
81
+ ln -fs $(SHARED3) $(SHARED2)
82
+ endif
83
+
84
+ $(SHARED3):
85
+ $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3) $(LIBS)
86
+
87
+ endif # PLATFORM_SHARED_EXT
88
+
89
+ all: $(SHARED) $(LIBRARY)
90
+
91
+ check: all $(PROGRAMS) $(TESTS)
92
+ for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
93
+
94
+ clean:
95
+ -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
96
+ -rm -rf ios-x86/* ios-arm/*
97
+
98
+ $(LIBRARY): $(LIBOBJECTS)
99
+ rm -f $@
100
+ $(AR) -rs $@ $(LIBOBJECTS)
101
+
102
+ db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
103
+ $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
104
+
105
+ db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
106
+ $(CXX) $(LDFLAGS) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lsqlite3 $(LIBS)
107
+
108
+ db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
109
+ $(CXX) $(LDFLAGS) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ -lkyotocabinet $(LIBS)
110
+
111
+ leveldbutil: db/leveldb_main.o $(LIBOBJECTS)
112
+ $(CXX) $(LDFLAGS) db/leveldb_main.o $(LIBOBJECTS) -o $@ $(LIBS)
113
+
114
+ arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
115
+ $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
116
+
117
+ bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
118
+ $(CXX) $(LDFLAGS) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
119
+
120
+ c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
121
+ $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
122
+
123
+ cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
124
+ $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
125
+
126
+ coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
127
+ $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
128
+
129
+ corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
130
+ $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
131
+
132
+ crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
133
+ $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
134
+
135
+ db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
136
+ $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
137
+
138
+ dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
139
+ $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
140
+
141
+ env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
142
+ $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
143
+
144
+ filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
145
+ $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
146
+
147
+ filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
148
+ $(CXX) $(LDFLAGS) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
149
+
150
+ issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
151
+ $(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
152
+
153
+ log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
154
+ $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
155
+
156
+ table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
157
+ $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
158
+
159
+ skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
160
+ $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
161
+
162
+ version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
163
+ $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
164
+
165
+ version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
166
+ $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
167
+
168
+ write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
169
+ $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
170
+
171
+ $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
172
+ rm -f $@
173
+ $(AR) -rs $@ $(MEMENVOBJECTS)
174
+
175
+ memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
176
+ $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
177
+
178
+ ifeq ($(PLATFORM), IOS)
179
+ # For iOS, create universal object files to be used on both the simulator and
180
+ # a device.
181
+ PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
182
+ SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
183
+ DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
184
+ IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
185
+
186
+ .cc.o:
187
+ mkdir -p ios-x86/$(dir $@)
188
+ $(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
189
+ mkdir -p ios-arm/$(dir $@)
190
+ $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
191
+ lipo ios-x86/$@ ios-arm/$@ -create -output $@
192
+
193
+ .c.o:
194
+ mkdir -p ios-x86/$(dir $@)
195
+ $(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
196
+ mkdir -p ios-arm/$(dir $@)
197
+ $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
198
+ lipo ios-x86/$@ ios-arm/$@ -create -output $@
199
+
200
+ else
201
+ .cc.o:
202
+ $(CXX) $(CXXFLAGS) -c $< -o $@
203
+
204
+ .c.o:
205
+ $(CC) $(CFLAGS) -c $< -o $@
206
+ endif
@@ -0,0 +1,13 @@
1
+ SOURCES=db/builder.cc db/c.cc db/db_impl.cc db/db_iter.cc db/dbformat.cc db/filename.cc db/log_reader.cc db/log_writer.cc db/memtable.cc db/repair.cc db/table_cache.cc db/version_edit.cc db/version_set.cc db/write_batch.cc table/block.cc table/block_builder.cc table/filter_block.cc table/format.cc table/iterator.cc table/merger.cc table/table.cc table/table_builder.cc table/two_level_iterator.cc util/arena.cc util/bloom.cc util/cache.cc util/coding.cc util/comparator.cc util/crc32c.cc util/env.cc util/env_posix.cc util/filter_policy.cc util/hash.cc util/histogram.cc util/logging.cc util/options.cc util/status.cc port/port_posix.cc
2
+ MEMENV_SOURCES=helpers/memenv/memenv.cc
3
+ CC=cc
4
+ CXX=c++
5
+ PLATFORM=OS_MACOSX
6
+ PLATFORM_LDFLAGS=
7
+ PLATFORM_LIBS= -lsnappy
8
+ PLATFORM_CCFLAGS= -DOS_MACOSX -DLEVELDB_PLATFORM_POSIX -DSNAPPY
9
+ PLATFORM_CXXFLAGS= -DOS_MACOSX -DLEVELDB_PLATFORM_POSIX -DSNAPPY
10
+ PLATFORM_SHARED_CFLAGS=-fPIC
11
+ PLATFORM_SHARED_EXT=dylib
12
+ PLATFORM_SHARED_LDFLAGS=-dynamiclib -install_name /usr/src/extras/leveldb/ext/leveldb/
13
+ PLATFORM_SHARED_VERSIONED=true
@@ -0,0 +1,88 @@
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 "db/builder.h"
6
+
7
+ #include "db/filename.h"
8
+ #include "db/dbformat.h"
9
+ #include "db/table_cache.h"
10
+ #include "db/version_edit.h"
11
+ #include "leveldb/db.h"
12
+ #include "leveldb/env.h"
13
+ #include "leveldb/iterator.h"
14
+
15
+ namespace leveldb {
16
+
17
+ Status BuildTable(const std::string& dbname,
18
+ Env* env,
19
+ const Options& options,
20
+ TableCache* table_cache,
21
+ Iterator* iter,
22
+ FileMetaData* meta) {
23
+ Status s;
24
+ meta->file_size = 0;
25
+ iter->SeekToFirst();
26
+
27
+ std::string fname = TableFileName(dbname, meta->number);
28
+ if (iter->Valid()) {
29
+ WritableFile* file;
30
+ s = env->NewWritableFile(fname, &file);
31
+ if (!s.ok()) {
32
+ return s;
33
+ }
34
+
35
+ TableBuilder* builder = new TableBuilder(options, file);
36
+ meta->smallest.DecodeFrom(iter->key());
37
+ for (; iter->Valid(); iter->Next()) {
38
+ Slice key = iter->key();
39
+ meta->largest.DecodeFrom(key);
40
+ builder->Add(key, iter->value());
41
+ }
42
+
43
+ // Finish and check for builder errors
44
+ if (s.ok()) {
45
+ s = builder->Finish();
46
+ if (s.ok()) {
47
+ meta->file_size = builder->FileSize();
48
+ assert(meta->file_size > 0);
49
+ }
50
+ } else {
51
+ builder->Abandon();
52
+ }
53
+ delete builder;
54
+
55
+ // Finish and check for file errors
56
+ if (s.ok()) {
57
+ s = file->Sync();
58
+ }
59
+ if (s.ok()) {
60
+ s = file->Close();
61
+ }
62
+ delete file;
63
+ file = NULL;
64
+
65
+ if (s.ok()) {
66
+ // Verify that the table is usable
67
+ Iterator* it = table_cache->NewIterator(ReadOptions(),
68
+ meta->number,
69
+ meta->file_size);
70
+ s = it->status();
71
+ delete it;
72
+ }
73
+ }
74
+
75
+ // Check for input iterator errors
76
+ if (!iter->status().ok()) {
77
+ s = iter->status();
78
+ }
79
+
80
+ if (s.ok() && meta->file_size > 0) {
81
+ // Keep it
82
+ } else {
83
+ env->DeleteFile(fname);
84
+ }
85
+ return s;
86
+ }
87
+
88
+ } // namespace leveldb
@@ -0,0 +1,34 @@
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_DB_BUILDER_H_
6
+ #define STORAGE_LEVELDB_DB_BUILDER_H_
7
+
8
+ #include "leveldb/status.h"
9
+
10
+ namespace leveldb {
11
+
12
+ struct Options;
13
+ struct FileMetaData;
14
+
15
+ class Env;
16
+ class Iterator;
17
+ class TableCache;
18
+ class VersionEdit;
19
+
20
+ // Build a Table file from the contents of *iter. The generated file
21
+ // will be named according to meta->number. On success, the rest of
22
+ // *meta will be filled with metadata about the generated table.
23
+ // If no data is present in *iter, meta->file_size will be set to
24
+ // zero, and no Table file will be produced.
25
+ extern Status BuildTable(const std::string& dbname,
26
+ Env* env,
27
+ const Options& options,
28
+ TableCache* table_cache,
29
+ Iterator* iter,
30
+ FileMetaData* meta);
31
+
32
+ } // namespace leveldb
33
+
34
+ #endif // STORAGE_LEVELDB_DB_BUILDER_H_