小组成员:10215300402-朱维清 & 10222140408 谷杰
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

112 linhas
3.7 KiB

Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
há 10 anos
  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. #ifndef STORAGE_LEVELDB_DB_LOG_READER_H_
  5. #define STORAGE_LEVELDB_DB_LOG_READER_H_
  6. #include <cstdint>
  7. #include "db/log_format.h"
  8. #include "leveldb/slice.h"
  9. #include "leveldb/status.h"
  10. namespace leveldb {
  11. class SequentialFile;
  12. namespace log {
  13. class Reader {
  14. public:
  15. // Interface for reporting errors.
  16. class Reporter {
  17. public:
  18. virtual ~Reporter();
  19. // Some corruption was detected. "bytes" is the approximate number
  20. // of bytes dropped due to the corruption.
  21. virtual void Corruption(size_t bytes, const Status& status) = 0;
  22. };
  23. // Create a reader that will return log records from "*file".
  24. // "*file" must remain live while this Reader is in use.
  25. //
  26. // If "reporter" is non-null, it is notified whenever some data is
  27. // dropped due to a detected corruption. "*reporter" must remain
  28. // live while this Reader is in use.
  29. //
  30. // If "checksum" is true, verify checksums if available.
  31. //
  32. // The Reader will start reading at the first record located at physical
  33. // position >= initial_offset within the file.
  34. Reader(SequentialFile* file, Reporter* reporter, bool checksum,
  35. uint64_t initial_offset);
  36. Reader(const Reader&) = delete;
  37. Reader& operator=(const Reader&) = delete;
  38. ~Reader();
  39. // Read the next record into *record. Returns true if read
  40. // successfully, false if we hit end of the input. May use
  41. // "*scratch" as temporary storage. The contents filled in *record
  42. // will only be valid until the next mutating operation on this
  43. // reader or the next mutation to *scratch.
  44. bool ReadRecord(Slice* record, std::string* scratch);
  45. // Returns the physical offset of the last record returned by ReadRecord.
  46. //
  47. // Undefined before the first call to ReadRecord.
  48. uint64_t LastRecordOffset();
  49. private:
  50. // Extend record types with the following special values
  51. enum {
  52. kEof = kMaxRecordType + 1,
  53. // Returned whenever we find an invalid physical record.
  54. // Currently there are three situations in which this happens:
  55. // * The record has an invalid CRC (ReadPhysicalRecord reports a drop)
  56. // * The record is a 0-length record (No drop is reported)
  57. // * The record is below constructor's initial_offset (No drop is reported)
  58. kBadRecord = kMaxRecordType + 2
  59. };
  60. // Skips all blocks that are completely before "initial_offset_".
  61. //
  62. // Returns true on success. Handles reporting.
  63. bool SkipToInitialBlock();
  64. // Return type, or one of the preceding special values
  65. unsigned int ReadPhysicalRecord(Slice* result);
  66. // Reports dropped bytes to the reporter.
  67. // buffer_ must be updated to remove the dropped bytes prior to invocation.
  68. void ReportCorruption(uint64_t bytes, const char* reason);
  69. void ReportDrop(uint64_t bytes, const Status& reason);
  70. SequentialFile* const file_;
  71. Reporter* const reporter_;
  72. bool const checksum_;
  73. char* const backing_store_;
  74. Slice buffer_;
  75. bool eof_; // Last Read() indicated EOF by returning < kBlockSize
  76. // Offset of the last record returned by ReadRecord.
  77. uint64_t last_record_offset_;
  78. // Offset of the first location past the end of buffer_.
  79. uint64_t end_of_buffer_offset_;
  80. // Offset at which to start looking for the first record to return
  81. uint64_t const initial_offset_;
  82. // True if we are resynchronizing after a seek (initial_offset_ > 0). In
  83. // particular, a run of kMiddleType and kLastType records can be silently
  84. // skipped in this mode
  85. bool resyncing_;
  86. };
  87. } // namespace log
  88. } // namespace leveldb
  89. #endif // STORAGE_LEVELDB_DB_LOG_READER_H_