Browse Source

Merge #12518: [0.16] Bump leveldb subtree

835a21b Squashed 'src/leveldb/' changes from c521b3ac65..64052c76c5 (MarcoFalke)

Pull request description:

  The leveldb bump is the same branch/commit as in #12451

Tree-SHA512: 585a55747c75e990c9fd73399e98e548c01bef8b960c0a99844326de43663d004d2211b4689518f2d3e51cc48a732e9c92082939c356793143db411224fa75fa
0.16
Wladimir J. van der Laan 7 years ago
parent
commit
a17fecfdf0
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 2
      src/leveldb/db/db_impl.cc
  2. 1
      src/leveldb/db/leveldbutil.cc
  3. 2
      src/leveldb/db/log_reader.cc
  4. 2
      src/leveldb/db/repair.cc
  5. 3
      src/leveldb/helpers/memenv/memenv.cc
  6. 9
      src/leveldb/include/leveldb/env.h
  7. 10
      src/leveldb/table/format.cc
  8. 8
      src/leveldb/util/env_posix.cc
  9. 3
      src/leveldb/util/env_win.cc

2
src/leveldb/db/db_impl.cc

@ -414,7 +414,7 @@ Status DBImpl::RecoverLogFile(uint64_t log_number, bool last_log,
status.ok()) { status.ok()) {
if (record.size() < 12) { if (record.size() < 12) {
reporter.Corruption( reporter.Corruption(
record.size(), Status::Corruption("log record too small")); record.size(), Status::Corruption("log record too small", fname));
continue; continue;
} }
WriteBatchInternal::SetContents(&batch, record); WriteBatchInternal::SetContents(&batch, record);

1
src/leveldb/db/leveldbutil.cc

@ -19,6 +19,7 @@ class StdoutPrinter : public WritableFile {
virtual Status Close() { return Status::OK(); } virtual Status Close() { return Status::OK(); }
virtual Status Flush() { return Status::OK(); } virtual Status Flush() { return Status::OK(); }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() { return Status::OK(); }
virtual std::string GetName() const { return "[stdout]"; }
}; };
bool HandleDumpCommand(Env* env, char** files, int num) { bool HandleDumpCommand(Env* env, char** files, int num) {

2
src/leveldb/db/log_reader.cc

@ -186,7 +186,7 @@ uint64_t Reader::LastRecordOffset() {
} }
void Reader::ReportCorruption(uint64_t bytes, const char* reason) { void Reader::ReportCorruption(uint64_t bytes, const char* reason) {
ReportDrop(bytes, Status::Corruption(reason)); ReportDrop(bytes, Status::Corruption(reason, file_->GetName()));
} }
void Reader::ReportDrop(uint64_t bytes, const Status& reason) { void Reader::ReportDrop(uint64_t bytes, const Status& reason) {

2
src/leveldb/db/repair.cc

@ -203,7 +203,7 @@ class Repairer {
while (reader.ReadRecord(&record, &scratch)) { while (reader.ReadRecord(&record, &scratch)) {
if (record.size() < 12) { if (record.size() < 12) {
reporter.Corruption( reporter.Corruption(
record.size(), Status::Corruption("log record too small")); record.size(), Status::Corruption("log record too small", logname));
continue; continue;
} }
WriteBatchInternal::SetContents(&batch, record); WriteBatchInternal::SetContents(&batch, record);

3
src/leveldb/helpers/memenv/memenv.cc vendored

@ -176,6 +176,7 @@ class SequentialFileImpl : public SequentialFile {
return Status::OK(); return Status::OK();
} }
virtual std::string GetName() const { return "[memenv]"; }
private: private:
FileState* file_; FileState* file_;
uint64_t pos_; uint64_t pos_;
@ -196,6 +197,7 @@ class RandomAccessFileImpl : public RandomAccessFile {
return file_->Read(offset, n, result, scratch); return file_->Read(offset, n, result, scratch);
} }
virtual std::string GetName() const { return "[memenv]"; }
private: private:
FileState* file_; FileState* file_;
}; };
@ -218,6 +220,7 @@ class WritableFileImpl : public WritableFile {
virtual Status Flush() { return Status::OK(); } virtual Status Flush() { return Status::OK(); }
virtual Status Sync() { return Status::OK(); } virtual Status Sync() { return Status::OK(); }
virtual std::string GetName() const { return "[memenv]"; }
private: private:
FileState* file_; FileState* file_;
}; };

9
src/leveldb/include/leveldb/env.h

@ -191,6 +191,9 @@ class SequentialFile {
// REQUIRES: External synchronization // REQUIRES: External synchronization
virtual Status Skip(uint64_t n) = 0; virtual Status Skip(uint64_t n) = 0;
// Get a name for the file, only for error reporting
virtual std::string GetName() const = 0;
private: private:
// No copying allowed // No copying allowed
SequentialFile(const SequentialFile&); SequentialFile(const SequentialFile&);
@ -215,6 +218,9 @@ class RandomAccessFile {
virtual Status Read(uint64_t offset, size_t n, Slice* result, virtual Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const = 0; char* scratch) const = 0;
// Get a name for the file, only for error reporting
virtual std::string GetName() const = 0;
private: private:
// No copying allowed // No copying allowed
RandomAccessFile(const RandomAccessFile&); RandomAccessFile(const RandomAccessFile&);
@ -234,6 +240,9 @@ class WritableFile {
virtual Status Flush() = 0; virtual Status Flush() = 0;
virtual Status Sync() = 0; virtual Status Sync() = 0;
// Get a name for the file, only for error reporting
virtual std::string GetName() const = 0;
private: private:
// No copying allowed // No copying allowed
WritableFile(const WritableFile&); WritableFile(const WritableFile&);

10
src/leveldb/table/format.cc

@ -82,7 +82,7 @@ Status ReadBlock(RandomAccessFile* file,
} }
if (contents.size() != n + kBlockTrailerSize) { if (contents.size() != n + kBlockTrailerSize) {
delete[] buf; delete[] buf;
return Status::Corruption("truncated block read"); return Status::Corruption("truncated block read", file->GetName());
} }
// Check the crc of the type and the block contents // Check the crc of the type and the block contents
@ -92,7 +92,7 @@ Status ReadBlock(RandomAccessFile* file,
const uint32_t actual = crc32c::Value(data, n + 1); const uint32_t actual = crc32c::Value(data, n + 1);
if (actual != crc) { if (actual != crc) {
delete[] buf; delete[] buf;
s = Status::Corruption("block checksum mismatch"); s = Status::Corruption("block checksum mismatch", file->GetName());
return s; return s;
} }
} }
@ -119,13 +119,13 @@ Status ReadBlock(RandomAccessFile* file,
size_t ulength = 0; size_t ulength = 0;
if (!port::Snappy_GetUncompressedLength(data, n, &ulength)) { if (!port::Snappy_GetUncompressedLength(data, n, &ulength)) {
delete[] buf; delete[] buf;
return Status::Corruption("corrupted compressed block contents"); return Status::Corruption("corrupted compressed block contents", file->GetName());
} }
char* ubuf = new char[ulength]; char* ubuf = new char[ulength];
if (!port::Snappy_Uncompress(data, n, ubuf)) { if (!port::Snappy_Uncompress(data, n, ubuf)) {
delete[] buf; delete[] buf;
delete[] ubuf; delete[] ubuf;
return Status::Corruption("corrupted compressed block contents"); return Status::Corruption("corrupted compressed block contents", file->GetName());
} }
delete[] buf; delete[] buf;
result->data = Slice(ubuf, ulength); result->data = Slice(ubuf, ulength);
@ -135,7 +135,7 @@ Status ReadBlock(RandomAccessFile* file,
} }
default: default:
delete[] buf; delete[] buf;
return Status::Corruption("bad block type"); return Status::Corruption("bad block type", file->GetName());
} }
return Status::OK(); return Status::OK();

8
src/leveldb/util/env_posix.cc

@ -121,6 +121,8 @@ class PosixSequentialFile: public SequentialFile {
} }
return Status::OK(); return Status::OK();
} }
virtual std::string GetName() const { return filename_; }
}; };
// pread() based random-access // pread() based random-access
@ -172,6 +174,8 @@ class PosixRandomAccessFile: public RandomAccessFile {
} }
return s; return s;
} }
virtual std::string GetName() const { return filename_; }
}; };
// mmap() based random-access // mmap() based random-access
@ -206,6 +210,8 @@ class PosixMmapReadableFile: public RandomAccessFile {
} }
return s; return s;
} }
virtual std::string GetName() const { return filename_; }
}; };
class PosixWritableFile : public WritableFile { class PosixWritableFile : public WritableFile {
@ -287,6 +293,8 @@ class PosixWritableFile : public WritableFile {
} }
return s; return s;
} }
virtual std::string GetName() const { return filename_; }
}; };
static int LockOrUnlock(int fd, bool lock) { static int LockOrUnlock(int fd, bool lock) {

3
src/leveldb/util/env_win.cc

@ -78,6 +78,7 @@ public:
virtual Status Read(size_t n, Slice* result, char* scratch); virtual Status Read(size_t n, Slice* result, char* scratch);
virtual Status Skip(uint64_t n); virtual Status Skip(uint64_t n);
BOOL isEnable(); BOOL isEnable();
virtual std::string GetName() const { return _filename; }
private: private:
BOOL _Init(); BOOL _Init();
void _CleanUp(); void _CleanUp();
@ -94,6 +95,7 @@ public:
virtual ~Win32RandomAccessFile(); virtual ~Win32RandomAccessFile();
virtual Status Read(uint64_t offset, size_t n, Slice* result,char* scratch) const; virtual Status Read(uint64_t offset, size_t n, Slice* result,char* scratch) const;
BOOL isEnable(); BOOL isEnable();
virtual std::string GetName() const { return _filename; }
private: private:
BOOL _Init(LPCWSTR path); BOOL _Init(LPCWSTR path);
void _CleanUp(); void _CleanUp();
@ -114,6 +116,7 @@ public:
virtual Status Flush(); virtual Status Flush();
virtual Status Sync(); virtual Status Sync();
BOOL isEnable(); BOOL isEnable();
virtual std::string GetName() const { return filename_; }
private: private:
std::string filename_; std::string filename_;
::HANDLE _hFile; ::HANDLE _hFile;

Loading…
Cancel
Save