10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

85 рядки
3.0 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. // File names used by DB code
  6. #ifndef STORAGE_LEVELDB_DB_FILENAME_H_
  7. #define STORAGE_LEVELDB_DB_FILENAME_H_
  8. #include <stdint.h>
  9. #include <string>
  10. #include "leveldb/slice.h"
  11. #include "leveldb/status.h"
  12. #include "port/port.h"
  13. namespace leveldb {
  14. class Env;
  15. enum FileType {
  16. kLogFile,
  17. kDBLockFile,
  18. kTableFile,
  19. kDescriptorFile,
  20. kCurrentFile,
  21. kTempFile,
  22. kInfoLogFile // Either the current one, or an old one
  23. };
  24. // Return the name of the log file with the specified number
  25. // in the db named by "dbname". The result will be prefixed with
  26. // "dbname".
  27. extern std::string LogFileName(const std::string& dbname, uint64_t number);
  28. // Return the name of the sstable with the specified number
  29. // in the db named by "dbname". The result will be prefixed with
  30. // "dbname".
  31. extern std::string TableFileName(const std::string& dbname, uint64_t number);
  32. // Return the legacy file name for an sstable with the specified number
  33. // in the db named by "dbname". The result will be prefixed with
  34. // "dbname".
  35. extern std::string SSTTableFileName(const std::string& dbname, uint64_t number);
  36. // Return the name of the descriptor file for the db named by
  37. // "dbname" and the specified incarnation number. The result will be
  38. // prefixed with "dbname".
  39. extern std::string DescriptorFileName(const std::string& dbname,
  40. uint64_t number);
  41. // Return the name of the current file. This file contains the name
  42. // of the current manifest file. The result will be prefixed with
  43. // "dbname".
  44. extern std::string CurrentFileName(const std::string& dbname);
  45. // Return the name of the lock file for the db named by
  46. // "dbname". The result will be prefixed with "dbname".
  47. extern std::string LockFileName(const std::string& dbname);
  48. // Return the name of a temporary file owned by the db named "dbname".
  49. // The result will be prefixed with "dbname".
  50. extern std::string TempFileName(const std::string& dbname, uint64_t number);
  51. // Return the name of the info log file for "dbname".
  52. extern std::string InfoLogFileName(const std::string& dbname);
  53. // Return the name of the old info log file for "dbname".
  54. extern std::string OldInfoLogFileName(const std::string& dbname);
  55. // If filename is a leveldb file, store the type of the file in *type.
  56. // The number encoded in the filename is stored in *number. If the
  57. // filename was successfully parsed, returns true. Else return false.
  58. extern bool ParseFileName(const std::string& filename,
  59. uint64_t* number,
  60. FileType* type);
  61. // Make the CURRENT file point to the descriptor file with the
  62. // specified number.
  63. extern Status SetCurrentFile(Env* env, const std::string& dbname,
  64. uint64_t descriptor_number);
  65. } // namespace leveldb
  66. #endif // STORAGE_LEVELDB_DB_FILENAME_H_