作者: 韩晨旭 10225101440 李畅 10225102463
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

101 行
3.5 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)
10 年前
  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. //
  5. // An iterator yields a sequence of key/value pairs from a source.
  6. // The following class defines the interface. Multiple implementations
  7. // are provided by this library. In particular, iterators are provided
  8. // to access the contents of a Table or a DB.
  9. //
  10. // Multiple threads can invoke const methods on an Iterator without
  11. // external synchronization, but if any of the threads may call a
  12. // non-const method, all threads accessing the same Iterator must use
  13. // external synchronization.
  14. #ifndef STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
  15. #define STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
  16. #include "leveldb/export.h"
  17. #include "leveldb/slice.h"
  18. #include "leveldb/status.h"
  19. namespace leveldb {
  20. class LEVELDB_EXPORT Iterator {
  21. public:
  22. Iterator();
  23. virtual ~Iterator();
  24. // An iterator is either positioned at a key/value pair, or
  25. // not valid. This method returns true iff the iterator is valid.
  26. virtual bool Valid() const = 0;
  27. // Position at the first key in the source. The iterator is Valid()
  28. // after this call iff the source is not empty.
  29. virtual void SeekToFirst() = 0;
  30. // Position at the last key in the source. The iterator is
  31. // Valid() after this call iff the source is not empty.
  32. virtual void SeekToLast() = 0;
  33. // Position at the first key in the source that is at or past target.
  34. // The iterator is Valid() after this call iff the source contains
  35. // an entry that comes at or past target.
  36. virtual void Seek(const Slice& target) = 0;
  37. // Moves to the next entry in the source. After this call, Valid() is
  38. // true iff the iterator was not positioned at the last entry in the source.
  39. // REQUIRES: Valid()
  40. virtual void Next() = 0;
  41. // Moves to the previous entry in the source. After this call, Valid() is
  42. // true iff the iterator was not positioned at the first entry in source.
  43. // REQUIRES: Valid()
  44. virtual void Prev() = 0;
  45. // Return the key for the current entry. The underlying storage for
  46. // the returned slice is valid only until the next modification of
  47. // the iterator.
  48. // REQUIRES: Valid()
  49. virtual Slice key() const = 0;
  50. // Return the value for the current entry. The underlying storage for
  51. // the returned slice is valid only until the next modification of
  52. // the iterator.
  53. // REQUIRES: Valid()
  54. virtual Slice value() const = 0;
  55. // If an error has occurred, return it. Else return an ok status.
  56. virtual Status status() const = 0;
  57. // Clients are allowed to register function/arg1/arg2 triples that
  58. // will be invoked when this iterator is destroyed.
  59. //
  60. // Note that unlike all of the preceding methods, this method is
  61. // not abstract and therefore clients should not override it.
  62. typedef void (*CleanupFunction)(void* arg1, void* arg2);
  63. void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
  64. private:
  65. struct Cleanup {
  66. CleanupFunction function;
  67. void* arg1;
  68. void* arg2;
  69. Cleanup* next;
  70. };
  71. Cleanup cleanup_;
  72. // No copying allowed
  73. Iterator(const Iterator&);
  74. void operator=(const Iterator&);
  75. };
  76. // Return an empty iterator (yields nothing).
  77. LEVELDB_EXPORT Iterator* NewEmptyIterator();
  78. // Return an empty iterator with the specified status.
  79. LEVELDB_EXPORT Iterator* NewErrorIterator(const Status& status);
  80. } // namespace leveldb
  81. #endif // STORAGE_LEVELDB_INCLUDE_ITERATOR_H_