小组成员:谢瑞阳、徐翔宇
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

49 řádky
1.3 KiB

  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. // WriteBatch holds a collection of updates to apply atomically to a DB.
  6. //
  7. // The updates are applied in the order in which they are added
  8. // to the WriteBatch. For example, the value of "key" will be "v3"
  9. // after the following batch is written:
  10. //
  11. // batch.Put("key", "v1");
  12. // batch.Delete("key");
  13. // batch.Put("key", "v2");
  14. // batch.Put("key", "v3");
  15. #ifndef STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_
  16. #define STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_
  17. #include <string>
  18. namespace leveldb {
  19. class Slice;
  20. class WriteBatch {
  21. public:
  22. WriteBatch();
  23. ~WriteBatch();
  24. // Store the mapping "key->value" in the database.
  25. void Put(const Slice& key, const Slice& value);
  26. // If the database contains a mapping for "key", erase it. Else do nothing.
  27. void Delete(const Slice& key);
  28. // Clear all updates buffered in this batch.
  29. void Clear();
  30. private:
  31. friend class WriteBatchInternal;
  32. std::string rep_; // See comment in write_batch.cc for the format of rep_
  33. // Intentionally copyable
  34. };
  35. }
  36. #endif // STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_