作者: 韩晨旭 10225101440 李畅 10225102463
Você não pode selecionar mais de 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.

100 linhas
3.4 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 anos atrás
  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/slice.h"
  17. #include "leveldb/status.h"
  18. namespace leveldb {
  19. class Iterator {
  20. public:
  21. Iterator();
  22. virtual ~Iterator();
  23. // An iterator is either positioned at a key/value pair, or
  24. // not valid. This method returns true iff the iterator is valid.
  25. virtual bool Valid() const = 0;
  26. // Position at the first key in the source. The iterator is Valid()
  27. // after this call iff the source is not empty.
  28. virtual void SeekToFirst() = 0;
  29. // Position at the last key in the source. The iterator is
  30. // Valid() after this call iff the source is not empty.
  31. virtual void SeekToLast() = 0;
  32. // Position at the first key in the source that is at or past target.
  33. // The iterator is Valid() after this call iff the source contains
  34. // an entry that comes at or past target.
  35. virtual void Seek(const Slice& target) = 0;
  36. // Moves to the next entry in the source. After this call, Valid() is
  37. // true iff the iterator was not positioned at the last entry in the source.
  38. // REQUIRES: Valid()
  39. virtual void Next() = 0;
  40. // Moves to the previous entry in the source. After this call, Valid() is
  41. // true iff the iterator was not positioned at the first entry in source.
  42. // REQUIRES: Valid()
  43. virtual void Prev() = 0;
  44. // Return the key for the current entry. The underlying storage for
  45. // the returned slice is valid only until the next modification of
  46. // the iterator.
  47. // REQUIRES: Valid()
  48. virtual Slice key() const = 0;
  49. // Return the value for the current entry. The underlying storage for
  50. // the returned slice is valid only until the next modification of
  51. // the iterator.
  52. // REQUIRES: Valid()
  53. virtual Slice value() const = 0;
  54. // If an error has occurred, return it. Else return an ok status.
  55. virtual Status status() const = 0;
  56. // Clients are allowed to register function/arg1/arg2 triples that
  57. // will be invoked when this iterator is destroyed.
  58. //
  59. // Note that unlike all of the preceding methods, this method is
  60. // not abstract and therefore clients should not override it.
  61. typedef void (*CleanupFunction)(void* arg1, void* arg2);
  62. void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2);
  63. private:
  64. struct Cleanup {
  65. CleanupFunction function;
  66. void* arg1;
  67. void* arg2;
  68. Cleanup* next;
  69. };
  70. Cleanup cleanup_;
  71. // No copying allowed
  72. Iterator(const Iterator&);
  73. void operator=(const Iterator&);
  74. };
  75. // Return an empty iterator (yields nothing).
  76. extern Iterator* NewEmptyIterator();
  77. // Return an empty iterator with the specified status.
  78. extern Iterator* NewErrorIterator(const Status& status);
  79. } // namespace leveldb
  80. #endif // STORAGE_LEVELDB_INCLUDE_ITERATOR_H_