leveldb 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/leveldb/Makefile +7 -3
- data/ext/leveldb/db/db_iter.cc +5 -4
- data/ext/leveldb/db/db_test.cc +35 -1
- data/ext/leveldb/db/filename.cc +7 -2
- data/ext/leveldb/db/filename.h +5 -0
- data/ext/leveldb/db/filename_test.cc +1 -0
- data/ext/leveldb/db/repair.cc +8 -0
- data/ext/leveldb/db/table_cache.cc +6 -0
- data/ext/leveldb/include/leveldb/db.h +1 -1
- data/ext/leveldb/issues/issue200_test.cc +59 -0
- data/ext/leveldb/util/arena.cc +1 -1
- data/lib/leveldb/version.rb +1 -1
- metadata +3 -3
- data/ext/leveldb/build_config.mk +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39f09bcd9ed833797306c673c09e81482afedfe8
|
4
|
+
data.tar.gz: 08c71c65dcf4ac2ec68c62bf6173467ed3e07301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: affebf16615c3dcba550d756c44254641b1efc1f21c0f035754079b4ae5e4e5a7fd5ec496c1bb5b36199bedac54ee9dff0388ce0a5fd34140897e50949842359
|
7
|
+
data.tar.gz: 333c4c2eaf9e834c65849e5d46f10126d1b74944a24a799b4c0038ecf45e77d9c1b55c31f9506bc898fe887a02d56067510ff0fa749b321850f9166d5a45c0e4
|
data/ext/leveldb/Makefile
CHANGED
@@ -44,6 +44,7 @@ TESTS = \
|
|
44
44
|
filename_test \
|
45
45
|
filter_block_test \
|
46
46
|
issue178_test \
|
47
|
+
issue200_test \
|
47
48
|
log_test \
|
48
49
|
memenv_test \
|
49
50
|
skiplist_test \
|
@@ -71,7 +72,7 @@ SHARED = $(SHARED1)
|
|
71
72
|
else
|
72
73
|
# Update db.h if you change these.
|
73
74
|
SHARED_MAJOR = 1
|
74
|
-
SHARED_MINOR =
|
75
|
+
SHARED_MINOR = 14
|
75
76
|
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
|
76
77
|
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
|
77
78
|
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
|
@@ -154,6 +155,9 @@ filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
|
154
155
|
issue178_test: issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
155
156
|
$(CXX) $(LDFLAGS) issues/issue178_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
156
157
|
|
158
|
+
issue200_test: issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
159
|
+
$(CXX) $(LDFLAGS) issues/issue200_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
160
|
+
|
157
161
|
log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
158
162
|
$(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LIBS)
|
159
163
|
|
@@ -191,14 +195,14 @@ IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBu
|
|
191
195
|
mkdir -p ios-x86/$(dir $@)
|
192
196
|
$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
|
193
197
|
mkdir -p ios-arm/$(dir $@)
|
194
|
-
$(
|
198
|
+
xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
|
195
199
|
lipo ios-x86/$@ ios-arm/$@ -create -output $@
|
196
200
|
|
197
201
|
.c.o:
|
198
202
|
mkdir -p ios-x86/$(dir $@)
|
199
203
|
$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
|
200
204
|
mkdir -p ios-arm/$(dir $@)
|
201
|
-
$(
|
205
|
+
xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
|
202
206
|
lipo ios-x86/$@ ios-arm/$@ -create -output $@
|
203
207
|
|
204
208
|
else
|
data/ext/leveldb/db/db_iter.cc
CHANGED
@@ -161,12 +161,13 @@ void DBIter::Next() {
|
|
161
161
|
saved_key_.clear();
|
162
162
|
return;
|
163
163
|
}
|
164
|
+
// saved_key_ already contains the key to skip past.
|
165
|
+
} else {
|
166
|
+
// Store in saved_key_ the current key so we skip it below.
|
167
|
+
SaveKey(ExtractUserKey(iter_->key()), &saved_key_);
|
164
168
|
}
|
165
169
|
|
166
|
-
|
167
|
-
std::string* skip = &saved_key_;
|
168
|
-
SaveKey(ExtractUserKey(iter_->key()), skip);
|
169
|
-
FindNextUserEntry(true, skip);
|
170
|
+
FindNextUserEntry(true, &saved_key_);
|
170
171
|
}
|
171
172
|
|
172
173
|
void DBIter::FindNextUserEntry(bool skipping, std::string* skip) {
|
data/ext/leveldb/db/db_test.cc
CHANGED
@@ -147,7 +147,7 @@ class SpecialEnv : public EnvWrapper {
|
|
147
147
|
|
148
148
|
Status s = target()->NewWritableFile(f, r);
|
149
149
|
if (s.ok()) {
|
150
|
-
if (strstr(f.c_str(), ".
|
150
|
+
if (strstr(f.c_str(), ".ldb") != NULL) {
|
151
151
|
*r = new SSTableFile(this, *r);
|
152
152
|
} else if (strstr(f.c_str(), "MANIFEST") != NULL) {
|
153
153
|
*r = new ManifestFile(this, *r);
|
@@ -484,6 +484,24 @@ class DBTest {
|
|
484
484
|
}
|
485
485
|
return false;
|
486
486
|
}
|
487
|
+
|
488
|
+
// Returns number of files renamed.
|
489
|
+
int RenameLDBToSST() {
|
490
|
+
std::vector<std::string> filenames;
|
491
|
+
ASSERT_OK(env_->GetChildren(dbname_, &filenames));
|
492
|
+
uint64_t number;
|
493
|
+
FileType type;
|
494
|
+
int files_renamed = 0;
|
495
|
+
for (size_t i = 0; i < filenames.size(); i++) {
|
496
|
+
if (ParseFileName(filenames[i], &number, &type) && type == kTableFile) {
|
497
|
+
const std::string from = TableFileName(dbname_, number);
|
498
|
+
const std::string to = SSTTableFileName(dbname_, number);
|
499
|
+
ASSERT_OK(env_->RenameFile(from, to));
|
500
|
+
files_renamed++;
|
501
|
+
}
|
502
|
+
}
|
503
|
+
return files_renamed;
|
504
|
+
}
|
487
505
|
};
|
488
506
|
|
489
507
|
TEST(DBTest, Empty) {
|
@@ -1632,6 +1650,22 @@ TEST(DBTest, MissingSSTFile) {
|
|
1632
1650
|
<< s.ToString();
|
1633
1651
|
}
|
1634
1652
|
|
1653
|
+
TEST(DBTest, StillReadSST) {
|
1654
|
+
ASSERT_OK(Put("foo", "bar"));
|
1655
|
+
ASSERT_EQ("bar", Get("foo"));
|
1656
|
+
|
1657
|
+
// Dump the memtable to disk.
|
1658
|
+
dbfull()->TEST_CompactMemTable();
|
1659
|
+
ASSERT_EQ("bar", Get("foo"));
|
1660
|
+
Close();
|
1661
|
+
ASSERT_GT(RenameLDBToSST(), 0);
|
1662
|
+
Options options = CurrentOptions();
|
1663
|
+
options.paranoid_checks = true;
|
1664
|
+
Status s = TryReopen(&options);
|
1665
|
+
ASSERT_TRUE(s.ok());
|
1666
|
+
ASSERT_EQ("bar", Get("foo"));
|
1667
|
+
}
|
1668
|
+
|
1635
1669
|
TEST(DBTest, FilesDeletedAfterCompaction) {
|
1636
1670
|
ASSERT_OK(Put("foo", "v2"));
|
1637
1671
|
Compact("a", "z");
|
data/ext/leveldb/db/filename.cc
CHANGED
@@ -30,6 +30,11 @@ std::string LogFileName(const std::string& name, uint64_t number) {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
std::string TableFileName(const std::string& name, uint64_t number) {
|
33
|
+
assert(number > 0);
|
34
|
+
return MakeFileName(name, number, "ldb");
|
35
|
+
}
|
36
|
+
|
37
|
+
std::string SSTTableFileName(const std::string& name, uint64_t number) {
|
33
38
|
assert(number > 0);
|
34
39
|
return MakeFileName(name, number, "sst");
|
35
40
|
}
|
@@ -71,7 +76,7 @@ std::string OldInfoLogFileName(const std::string& dbname) {
|
|
71
76
|
// dbname/LOG
|
72
77
|
// dbname/LOG.old
|
73
78
|
// dbname/MANIFEST-[0-9]+
|
74
|
-
// dbname/[0-9]+.(log|sst)
|
79
|
+
// dbname/[0-9]+.(log|sst|ldb)
|
75
80
|
bool ParseFileName(const std::string& fname,
|
76
81
|
uint64_t* number,
|
77
82
|
FileType* type) {
|
@@ -106,7 +111,7 @@ bool ParseFileName(const std::string& fname,
|
|
106
111
|
Slice suffix = rest;
|
107
112
|
if (suffix == Slice(".log")) {
|
108
113
|
*type = kLogFile;
|
109
|
-
} else if (suffix == Slice(".sst")) {
|
114
|
+
} else if (suffix == Slice(".sst") || suffix == Slice(".ldb")) {
|
110
115
|
*type = kTableFile;
|
111
116
|
} else if (suffix == Slice(".dbtmp")) {
|
112
117
|
*type = kTempFile;
|
data/ext/leveldb/db/filename.h
CHANGED
@@ -37,6 +37,11 @@ extern std::string LogFileName(const std::string& dbname, uint64_t number);
|
|
37
37
|
// "dbname".
|
38
38
|
extern std::string TableFileName(const std::string& dbname, uint64_t number);
|
39
39
|
|
40
|
+
// Return the legacy file name for an sstable with the specified number
|
41
|
+
// in the db named by "dbname". The result will be prefixed with
|
42
|
+
// "dbname".
|
43
|
+
extern std::string SSTTableFileName(const std::string& dbname, uint64_t number);
|
44
|
+
|
40
45
|
// Return the name of the descriptor file for the db named by
|
41
46
|
// "dbname" and the specified incarnation number. The result will be
|
42
47
|
// prefixed with "dbname".
|
data/ext/leveldb/db/repair.cc
CHANGED
@@ -263,6 +263,12 @@ class Repairer {
|
|
263
263
|
std::string fname = TableFileName(dbname_, t->meta.number);
|
264
264
|
int counter = 0;
|
265
265
|
Status status = env_->GetFileSize(fname, &t->meta.file_size);
|
266
|
+
if (!status.ok()) {
|
267
|
+
fname = SSTTableFileName(dbname_, t->meta.number);
|
268
|
+
Status s2 = env_->GetFileSize(fname, &t->meta.file_size);
|
269
|
+
if (s2.ok())
|
270
|
+
status = Status::OK();
|
271
|
+
}
|
266
272
|
if (status.ok()) {
|
267
273
|
Iterator* iter = table_cache_->NewIterator(
|
268
274
|
ReadOptions(), t->meta.number, t->meta.file_size);
|
@@ -293,6 +299,8 @@ class Repairer {
|
|
293
299
|
}
|
294
300
|
delete iter;
|
295
301
|
}
|
302
|
+
// If there was trouble opening an .sst file this will report that the .ldb
|
303
|
+
// file was not found, which is kind of lame but shouldn't happen often.
|
296
304
|
Log(options_.info_log, "Table #%llu: %d entries %s",
|
297
305
|
(unsigned long long) t->meta.number,
|
298
306
|
counter,
|
@@ -54,6 +54,12 @@ Status TableCache::FindTable(uint64_t file_number, uint64_t file_size,
|
|
54
54
|
RandomAccessFile* file = NULL;
|
55
55
|
Table* table = NULL;
|
56
56
|
s = env_->NewRandomAccessFile(fname, &file);
|
57
|
+
if (!s.ok()) {
|
58
|
+
std::string old_fname = SSTTableFileName(dbname_, file_number);
|
59
|
+
if (env_->NewRandomAccessFile(old_fname, &file).ok()) {
|
60
|
+
s = Status::OK();
|
61
|
+
}
|
62
|
+
}
|
57
63
|
if (s.ok()) {
|
58
64
|
s = Table::Open(*options_, file, file_size, &table);
|
59
65
|
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// Copyright (c) 2013 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
|
+
// Test for issue 200: when iterator switches direction from backward
|
6
|
+
// to forward, the current key can be yielded unexpectedly if a new
|
7
|
+
// mutation has been added just before the current key.
|
8
|
+
|
9
|
+
#include "leveldb/db.h"
|
10
|
+
#include "util/testharness.h"
|
11
|
+
|
12
|
+
namespace leveldb {
|
13
|
+
|
14
|
+
class Issue200 { };
|
15
|
+
|
16
|
+
TEST(Issue200, Test) {
|
17
|
+
// Get rid of any state from an old run.
|
18
|
+
std::string dbpath = test::TmpDir() + "/leveldb_issue200_test";
|
19
|
+
DestroyDB(dbpath, Options());
|
20
|
+
|
21
|
+
DB *db;
|
22
|
+
Options options;
|
23
|
+
options.create_if_missing = true;
|
24
|
+
ASSERT_OK(DB::Open(options, dbpath, &db));
|
25
|
+
|
26
|
+
WriteOptions write_options;
|
27
|
+
ASSERT_OK(db->Put(write_options, "1", "b"));
|
28
|
+
ASSERT_OK(db->Put(write_options, "2", "c"));
|
29
|
+
ASSERT_OK(db->Put(write_options, "3", "d"));
|
30
|
+
ASSERT_OK(db->Put(write_options, "4", "e"));
|
31
|
+
ASSERT_OK(db->Put(write_options, "5", "f"));
|
32
|
+
|
33
|
+
ReadOptions read_options;
|
34
|
+
Iterator *iter = db->NewIterator(read_options);
|
35
|
+
|
36
|
+
// Add an element that should not be reflected in the iterator.
|
37
|
+
ASSERT_OK(db->Put(write_options, "25", "cd"));
|
38
|
+
|
39
|
+
iter->Seek("5");
|
40
|
+
ASSERT_EQ(iter->key().ToString(), "5");
|
41
|
+
iter->Prev();
|
42
|
+
ASSERT_EQ(iter->key().ToString(), "4");
|
43
|
+
iter->Prev();
|
44
|
+
ASSERT_EQ(iter->key().ToString(), "3");
|
45
|
+
iter->Next();
|
46
|
+
ASSERT_EQ(iter->key().ToString(), "4");
|
47
|
+
iter->Next();
|
48
|
+
ASSERT_EQ(iter->key().ToString(), "5");
|
49
|
+
|
50
|
+
delete iter;
|
51
|
+
delete db;
|
52
|
+
DestroyDB(dbpath, options);
|
53
|
+
}
|
54
|
+
|
55
|
+
} // namespace leveldb
|
56
|
+
|
57
|
+
int main(int argc, char** argv) {
|
58
|
+
return leveldb::test::RunAllTests();
|
59
|
+
}
|
data/ext/leveldb/util/arena.cc
CHANGED
@@ -40,7 +40,7 @@ char* Arena::AllocateFallback(size_t bytes) {
|
|
40
40
|
}
|
41
41
|
|
42
42
|
char* Arena::AllocateAligned(size_t bytes) {
|
43
|
-
const int align = sizeof(void*)
|
43
|
+
const int align = (sizeof(void*) > 8) ? sizeof(void*) : 8;
|
44
44
|
assert((align & (align-1)) == 0); // Pointer size should be a power of 2
|
45
45
|
size_t current_mod = reinterpret_cast<uintptr_t>(alloc_ptr_) & (align-1);
|
46
46
|
size_t slop = (current_mod == 0 ? 0 : align - current_mod);
|
data/lib/leveldb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leveldb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DAddYE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddler-rb
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ext/leveldb/helpers/memenv/memenv.cc
|
122
122
|
- ext/leveldb/helpers/memenv/memenv_test.cc
|
123
123
|
- ext/leveldb/issues/issue178_test.cc
|
124
|
+
- ext/leveldb/issues/issue200_test.cc
|
124
125
|
- ext/leveldb/port/port_posix.cc
|
125
126
|
- ext/leveldb/table/block.cc
|
126
127
|
- ext/leveldb/table/block_builder.cc
|
@@ -208,7 +209,6 @@ files:
|
|
208
209
|
- ext/leveldb/util/random.h
|
209
210
|
- ext/leveldb/util/testharness.h
|
210
211
|
- ext/leveldb/util/testutil.h
|
211
|
-
- ext/leveldb/build_config.mk
|
212
212
|
- ext/leveldb/LICENSE
|
213
213
|
- ext/leveldb/Makefile
|
214
214
|
- lib/leveldb/batch.rb
|
data/ext/leveldb/build_config.mk
DELETED
@@ -1,13 +0,0 @@
|
|
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
|