aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/table
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-10-16 12:23:50 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2014-10-16 12:23:50 -0700
commit5b9f8425a515739e2149bf5bfb2ae6ed60bfbaf2 (patch)
treebacc7dd4d2f77da27499000d6f12655a3f6463f3 /src/leveldb/table
parente8f6d54f1f58d9a5998e37367b84b427e51e1ad7 (diff)
parent4b0e2d75d78036e7e76fd9584e17b0379ba08d24 (diff)
Merge src/leveldb changes for LevelDB 1.18.
Diffstat (limited to 'src/leveldb/table')
-rw-r--r--src/leveldb/table/block.cc2
-rw-r--r--src/leveldb/table/block_builder.h2
-rw-r--r--src/leveldb/table/format.cc2
-rw-r--r--src/leveldb/table/table.cc14
4 files changed, 15 insertions, 5 deletions
diff --git a/src/leveldb/table/block.cc b/src/leveldb/table/block.cc
index 79ea9d9ee5..43e402c9c0 100644
--- a/src/leveldb/table/block.cc
+++ b/src/leveldb/table/block.cc
@@ -46,7 +46,7 @@ Block::~Block() {
// Helper routine: decode the next block entry starting at "p",
// storing the number of shared key bytes, non_shared key bytes,
// and the length of the value in "*shared", "*non_shared", and
-// "*value_length", respectively. Will not derefence past "limit".
+// "*value_length", respectively. Will not dereference past "limit".
//
// If any errors are detected, returns NULL. Otherwise, returns a
// pointer to the key delta (just past the three decoded values).
diff --git a/src/leveldb/table/block_builder.h b/src/leveldb/table/block_builder.h
index 5b545bd1af..4fbcb33972 100644
--- a/src/leveldb/table/block_builder.h
+++ b/src/leveldb/table/block_builder.h
@@ -21,7 +21,7 @@ class BlockBuilder {
// Reset the contents as if the BlockBuilder was just constructed.
void Reset();
- // REQUIRES: Finish() has not been callled since the last call to Reset().
+ // REQUIRES: Finish() has not been called since the last call to Reset().
// REQUIRES: key is larger than any previously added key
void Add(const Slice& key, const Slice& value);
diff --git a/src/leveldb/table/format.cc b/src/leveldb/table/format.cc
index cda1decdf3..aa63144c9e 100644
--- a/src/leveldb/table/format.cc
+++ b/src/leveldb/table/format.cc
@@ -48,7 +48,7 @@ Status Footer::DecodeFrom(Slice* input) {
const uint64_t magic = ((static_cast<uint64_t>(magic_hi) << 32) |
(static_cast<uint64_t>(magic_lo)));
if (magic != kTableMagicNumber) {
- return Status::InvalidArgument("not an sstable (bad magic number)");
+ return Status::Corruption("not an sstable (bad magic number)");
}
Status result = metaindex_handle_.DecodeFrom(input);
diff --git a/src/leveldb/table/table.cc b/src/leveldb/table/table.cc
index 71c1756e5f..dff8a82590 100644
--- a/src/leveldb/table/table.cc
+++ b/src/leveldb/table/table.cc
@@ -41,7 +41,7 @@ Status Table::Open(const Options& options,
Table** table) {
*table = NULL;
if (size < Footer::kEncodedLength) {
- return Status::InvalidArgument("file is too short to be an sstable");
+ return Status::Corruption("file is too short to be an sstable");
}
char footer_space[Footer::kEncodedLength];
@@ -58,7 +58,11 @@ Status Table::Open(const Options& options,
BlockContents contents;
Block* index_block = NULL;
if (s.ok()) {
- s = ReadBlock(file, ReadOptions(), footer.index_handle(), &contents);
+ ReadOptions opt;
+ if (options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
+ s = ReadBlock(file, opt, footer.index_handle(), &contents);
if (s.ok()) {
index_block = new Block(contents);
}
@@ -92,6 +96,9 @@ void Table::ReadMeta(const Footer& footer) {
// TODO(sanjay): Skip this if footer.metaindex_handle() size indicates
// it is an empty block.
ReadOptions opt;
+ if (rep_->options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
BlockContents contents;
if (!ReadBlock(rep_->file, opt, footer.metaindex_handle(), &contents).ok()) {
// Do not propagate errors since meta info is not needed for operation
@@ -120,6 +127,9 @@ void Table::ReadFilter(const Slice& filter_handle_value) {
// We might want to unify with ReadBlock() if we start
// requiring checksum verification in Table::Open.
ReadOptions opt;
+ if (rep_->options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
BlockContents block;
if (!ReadBlock(rep_->file, opt, filter_handle, &block).ok()) {
return;