Skip to content

Commit 69c6d38

Browse files
reverting disastrous MOE commit, returning to r21
git-svn-id: https://leveldb.googlecode.com/svn/trunk@23 62dab493-f737-651d-591e-8d6aee1b9529
1 parent b743906 commit 69c6d38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1628
-253
lines changed

leveldb/AUTHORS AUTHORS

File renamed without changes.

leveldb/LICENSE LICENSE

File renamed without changes.

leveldb/Makefile Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ LIBOBJECTS = \
2727
./db/version_set.o \
2828
./db/write_batch.o \
2929
./port/port_posix.o \
30+
./port/sha1_portable.o \
3031
./table/block.o \
3132
./table/block_builder.o \
3233
./table/format.o \
@@ -62,6 +63,7 @@ TESTS = \
6263
env_test \
6364
filename_test \
6465
log_test \
66+
sha1_test \
6567
skiplist_test \
6668
table_test \
6769
version_edit_test \
@@ -113,6 +115,9 @@ log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
113115
table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
114116
$(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
115117

118+
sha1_test: port/sha1_test.o $(LIBOBJECTS) $(TESTHARNESS)
119+
$(CC) $(LDFLAGS) port/sha1_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
120+
116121
skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
117122
$(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
118123

leveldb/README README

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ leveldb: A key-value store
22
Authors: Sanjay Ghemawat ([email protected]) and Jeff Dean ([email protected])
33

44
The code under this directory implements a system for maintaining a
5-
persistent key/value store.
5+
persistent key/value store.
66

77
See doc/index.html for more explanation.
8-
See doc/impl.html for a brief overview of the implementation.
8+
See doc/db_layout.txt for a brief overview of the implementation.
99

1010
The public interface is in include/*.h. Callers should not include or
1111
rely on the details of any other header files in this package. Those

leveldb/TODO TODO

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ db
88
object stores, etc. can be done in the background anyway, so
99
probably not that important.
1010

11-
api changes:
12-
- Make it wrappable
11+
api changes?
12+
- Efficient large value reading and writing
1313

1414
Faster Get implementation

leveldb/db/builder.cc db/builder.cc

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ Status BuildTable(const std::string& dbname,
3838
for (; iter->Valid(); iter->Next()) {
3939
Slice key = iter->key();
4040
meta->largest.DecodeFrom(key);
41+
if (ExtractValueType(key) == kTypeLargeValueRef) {
42+
if (iter->value().size() != LargeValueRef::ByteSize()) {
43+
s = Status::Corruption("invalid indirect reference hash value (L0)");
44+
break;
45+
}
46+
edit->AddLargeValueRef(LargeValueRef::FromRef(iter->value()),
47+
meta->number,
48+
iter->key());
49+
}
4150
builder->Add(key, iter->value());
4251
}
4352

leveldb/db/builder.h db/builder.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class VersionEdit;
2020
// Build a Table file from the contents of *iter. The generated file
2121
// will be named according to meta->number. On success, the rest of
2222
// *meta will be filled with metadata about the generated table, and
23-
// the file information will be added to *edit. If no data is present
24-
// in *iter, meta->file_size will be set to zero, and no Table file
25-
// will be produced.
23+
// large value refs and the added file information will be added to
24+
// *edit. If no data is present in *iter, meta->file_size will be set
25+
// to zero, and no Table file will be produced.
2626
extern Status BuildTable(const std::string& dbname,
2727
Env* env,
2828
const Options& options,

leveldb/db/corruption_test.cc db/corruption_test.cc

+25-1
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ class CorruptionTest {
121121
std::vector<std::string> filenames;
122122
ASSERT_OK(env_.GetChildren(dbname_, &filenames));
123123
uint64_t number;
124+
LargeValueRef large_ref;
124125
FileType type;
125126
std::vector<std::string> candidates;
126127
for (int i = 0; i < filenames.size(); i++) {
127-
if (ParseFileName(filenames[i], &number, &type) &&
128+
if (ParseFileName(filenames[i], &number, &large_ref, &type) &&
128129
type == filetype) {
129130
candidates.push_back(dbname_ + "/" + filenames[i]);
130131
}
@@ -275,6 +276,29 @@ TEST(CorruptionTest, SequenceNumberRecovery) {
275276
ASSERT_EQ("v6", v);
276277
}
277278

279+
TEST(CorruptionTest, LargeValueRecovery) {
280+
Options options;
281+
options.large_value_threshold = 10000;
282+
Reopen(&options);
283+
284+
Random rnd(301);
285+
std::string big;
286+
ASSERT_OK(db_->Put(WriteOptions(),
287+
"foo", test::RandomString(&rnd, 100000, &big)));
288+
std::string v;
289+
ASSERT_OK(db_->Get(ReadOptions(), "foo", &v));
290+
ASSERT_EQ(big, v);
291+
292+
RepairDB();
293+
Reopen();
294+
ASSERT_OK(db_->Get(ReadOptions(), "foo", &v));
295+
ASSERT_EQ(big, v);
296+
297+
Reopen();
298+
ASSERT_OK(db_->Get(ReadOptions(), "foo", &v));
299+
ASSERT_EQ(big, v);
300+
}
301+
278302
TEST(CorruptionTest, CorruptedDescriptor) {
279303
ASSERT_OK(db_->Put(WriteOptions(), "foo", "hello"));
280304
DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);

leveldb/db/db_bench.cc db/db_bench.cc

+22
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// readreverse -- read N values in reverse order
2929
// readrandom -- read N values in random order
3030
// crc32c -- repeated crc32c of 4K of data
31+
// sha1 -- repeated SHA1 computation over 4K of data
3132
// Meta operations:
3233
// compact -- Compact the entire DB
3334
// stats -- Print DB stats
@@ -47,6 +48,7 @@ static const char* FLAGS_benchmarks =
4748
"readreverse,"
4849
"fill100K,"
4950
"crc32c,"
51+
"sha1,"
5052
"snappycomp,"
5153
"snappyuncomp,"
5254
;
@@ -364,6 +366,8 @@ class Benchmark {
364366
Compact();
365367
} else if (name == Slice("crc32c")) {
366368
Crc32c(4096, "(4K per op)");
369+
} else if (name == Slice("sha1")) {
370+
SHA1(4096, "(4K per op)");
367371
} else if (name == Slice("snappycomp")) {
368372
SnappyCompress();
369373
} else if (name == Slice("snappyuncomp")) {
@@ -402,6 +406,24 @@ class Benchmark {
402406
message_ = label;
403407
}
404408

409+
void SHA1(int size, const char* label) {
410+
// SHA1 about 100MB of data total
411+
std::string data(size, 'x');
412+
int64_t bytes = 0;
413+
char sha1[20];
414+
while (bytes < 100 * 1048576) {
415+
port::SHA1_Hash(data.data(), size, sha1);
416+
FinishedSingleOp();
417+
bytes += size;
418+
}
419+
420+
// Print so result is not dead
421+
fprintf(stderr, "... sha1=%02x...\r", static_cast<unsigned int>(sha1[0]));
422+
423+
bytes_ = bytes;
424+
message_ = label;
425+
}
426+
405427
void SnappyCompress() {
406428
Slice input = gen_.Generate(Options().block_size);
407429
int64_t bytes = 0;

0 commit comments

Comments
 (0)