作者: 谢瑞阳 10225101483 徐翔宇 10225101535
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 rivejä
3.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. // 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 "include/slice.h"
  11. #include "include/status.h"
  12. #include "port/port.h"
  13. namespace leveldb {
  14. class Env;
  15. struct LargeValueRef;
  16. enum FileType {
  17. kLogFile,
  18. kDBLockFile,
  19. kTableFile,
  20. kLargeValueFile,
  21. kDescriptorFile,
  22. kCurrentFile,
  23. kTempFile,
  24. kInfoLogFile, // Either the current one, or an old one
  25. };
  26. // Return the name of the log file with the specified number
  27. // in the db named by "dbname". The result will be prefixed with
  28. // "dbname".
  29. extern std::string LogFileName(const std::string& dbname, uint64_t number);
  30. // Return the name of the sstable with the specified number
  31. // in the db named by "dbname". The result will be prefixed with
  32. // "dbname".
  33. extern std::string TableFileName(const std::string& dbname, uint64_t number);
  34. // Return the name of the large value file with the specified large
  35. // value reference in the db named by "dbname". The result will be
  36. // prefixed with "dbname".
  37. extern std::string LargeValueFileName(const std::string& dbname,
  38. const LargeValueRef& large_ref);
  39. // Return the name of the descriptor file for the db named by
  40. // "dbname" and the specified incarnation number. The result will be
  41. // prefixed with "dbname".
  42. extern std::string DescriptorFileName(const std::string& dbname,
  43. uint64_t number);
  44. // Return the name of the current file. This file contains the name
  45. // of the current manifest file. The result will be prefixed with
  46. // "dbname".
  47. extern std::string CurrentFileName(const std::string& dbname);
  48. // Return the name of the lock file for the db named by
  49. // "dbname". The result will be prefixed with "dbname".
  50. extern std::string LockFileName(const std::string& dbname);
  51. // Return the name of a temporary file owned by the db named "dbname".
  52. // The result will be prefixed with "dbname".
  53. extern std::string TempFileName(const std::string& dbname, uint64_t number);
  54. // Return the name of the info log file for "dbname".
  55. extern std::string InfoLogFileName(const std::string& dbname);
  56. // Return the name of the old info log file for "dbname".
  57. extern std::string OldInfoLogFileName(const std::string& dbname);
  58. // If filename is a leveldb file, store the type of the file in *type.
  59. // If *type is kLargeValueFile, then the large value reference data
  60. // from the filename is stored in "*large_ref. For all other types of
  61. // files, the number encoded in the filename is stored in *number. If
  62. // the filename was successfully parsed, returns true. Else return
  63. // false.
  64. extern bool ParseFileName(const std::string& filename,
  65. uint64_t* number,
  66. LargeValueRef* large_ref,
  67. FileType* type);
  68. // Make the CURRENT file point to the descriptor file with the
  69. // specified number.
  70. extern Status SetCurrentFile(Env* env, const std::string& dbname,
  71. uint64_t descriptor_number);
  72. }
  73. #endif // STORAGE_LEVELDB_DB_FILENAME_H_