2011-03-19 06:37:00 +08:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
//
|
|
|
|
// File names used by DB code
|
|
|
|
|
|
|
|
#ifndef STORAGE_LEVELDB_DB_FILENAME_H_
|
|
|
|
#define STORAGE_LEVELDB_DB_FILENAME_H_
|
|
|
|
|
2020-04-30 03:59:39 +08:00
|
|
|
#include <cstdint>
|
2011-03-19 06:37:00 +08:00
|
|
|
#include <string>
|
2019-05-03 02:01:00 +08:00
|
|
|
|
2011-03-31 02:35:40 +08:00
|
|
|
#include "leveldb/slice.h"
|
|
|
|
#include "leveldb/status.h"
|
2011-03-19 06:37:00 +08:00
|
|
|
#include "port/port.h"
|
|
|
|
|
|
|
|
namespace leveldb {
|
|
|
|
|
|
|
|
class Env;
|
|
|
|
|
|
|
|
enum FileType {
|
|
|
|
kLogFile,
|
|
|
|
kDBLockFile,
|
|
|
|
kTableFile,
|
|
|
|
kDescriptorFile,
|
|
|
|
kCurrentFile,
|
|
|
|
kTempFile,
|
2011-07-20 07:36:47 +08:00
|
|
|
kInfoLogFile // Either the current one, or an old one
|
2011-03-19 06:37:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Return the name of the log file with the specified number
|
|
|
|
// in the db named by "dbname". The result will be prefixed with
|
|
|
|
// "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string LogFileName(const std::string& dbname, uint64_t number);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of the sstable with the specified number
|
|
|
|
// in the db named by "dbname". The result will be prefixed with
|
|
|
|
// "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string TableFileName(const std::string& dbname, uint64_t number);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2013-09-20 04:42:22 +08:00
|
|
|
// Return the legacy file name for an sstable with the specified number
|
|
|
|
// in the db named by "dbname". The result will be prefixed with
|
|
|
|
// "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string SSTTableFileName(const std::string& dbname, uint64_t number);
|
2013-09-20 04:42:22 +08:00
|
|
|
|
2011-03-19 06:37:00 +08:00
|
|
|
// Return the name of the descriptor file for the db named by
|
|
|
|
// "dbname" and the specified incarnation number. The result will be
|
|
|
|
// prefixed with "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string DescriptorFileName(const std::string& dbname, uint64_t number);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of the current file. This file contains the name
|
|
|
|
// of the current manifest file. The result will be prefixed with
|
|
|
|
// "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string CurrentFileName(const std::string& dbname);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of the lock file for the db named by
|
|
|
|
// "dbname". The result will be prefixed with "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string LockFileName(const std::string& dbname);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of a temporary file owned by the db named "dbname".
|
|
|
|
// The result will be prefixed with "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string TempFileName(const std::string& dbname, uint64_t number);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of the info log file for "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string InfoLogFileName(const std::string& dbname);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Return the name of the old info log file for "dbname".
|
2018-03-13 00:14:44 +08:00
|
|
|
std::string OldInfoLogFileName(const std::string& dbname);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// If filename is a leveldb file, store the type of the file in *type.
|
2011-04-21 06:48:11 +08:00
|
|
|
// The number encoded in the filename is stored in *number. If the
|
|
|
|
// filename was successfully parsed, returns true. Else return false.
|
2019-05-03 02:01:00 +08:00
|
|
|
bool ParseFileName(const std::string& filename, uint64_t* number,
|
2018-03-13 00:14:44 +08:00
|
|
|
FileType* type);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
// Make the CURRENT file point to the descriptor file with the
|
|
|
|
// specified number.
|
2018-03-13 00:14:44 +08:00
|
|
|
Status SetCurrentFile(Env* env, const std::string& dbname,
|
|
|
|
uint64_t descriptor_number);
|
2011-03-19 06:37:00 +08:00
|
|
|
|
2011-11-01 01:22:06 +08:00
|
|
|
} // namespace leveldb
|
2011-03-19 06:37:00 +08:00
|
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_DB_FILENAME_H_
|