2011-03-18 23:37:00 +01: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
|
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
#pragma once
|
2011-03-18 23:37:00 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/slice.h"
|
|
|
|
#include "rocksdb/status.h"
|
2011-03-18 23:37:00 +01:00
|
|
|
#include "port/port.h"
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
class Env;
|
|
|
|
|
|
|
|
enum FileType {
|
|
|
|
kLogFile,
|
|
|
|
kDBLockFile,
|
|
|
|
kTableFile,
|
|
|
|
kDescriptorFile,
|
|
|
|
kCurrentFile,
|
|
|
|
kTempFile,
|
2012-12-17 20:26:59 +01:00
|
|
|
kInfoLogFile, // Either the current one, or an old one
|
|
|
|
kMetaDatabase
|
2011-03-18 23:37:00 +01: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".
|
|
|
|
extern std::string LogFileName(const std::string& dbname, uint64_t number);
|
|
|
|
|
2012-12-08 01:30:22 +01:00
|
|
|
static const std::string ARCHIVAL_DIR = "archive";
|
|
|
|
|
|
|
|
extern std::string ArchivalDirectory(const std::string& dbname);
|
|
|
|
|
2012-11-30 02:28:37 +01:00
|
|
|
// Return the name of the archived log file with the specified number
|
|
|
|
// in the db named by "dbname". The result will be prefixed with "dbname".
|
|
|
|
extern std::string ArchivedLogFileName(const std::string& dbname,
|
|
|
|
uint64_t num);
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// Return the name of the sstable with the specified number
|
|
|
|
// in the db named by "dbname". The result will be prefixed with
|
|
|
|
// "dbname".
|
|
|
|
extern std::string TableFileName(const std::string& dbname, uint64_t number);
|
|
|
|
|
|
|
|
// 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".
|
|
|
|
extern std::string DescriptorFileName(const std::string& dbname,
|
|
|
|
uint64_t number);
|
|
|
|
|
|
|
|
// Return the name of the current file. This file contains the name
|
|
|
|
// of the current manifest file. The result will be prefixed with
|
|
|
|
// "dbname".
|
|
|
|
extern std::string CurrentFileName(const std::string& dbname);
|
|
|
|
|
|
|
|
// Return the name of the lock file for the db named by
|
|
|
|
// "dbname". The result will be prefixed with "dbname".
|
|
|
|
extern std::string LockFileName(const std::string& dbname);
|
|
|
|
|
|
|
|
// Return the name of a temporary file owned by the db named "dbname".
|
|
|
|
// The result will be prefixed with "dbname".
|
|
|
|
extern std::string TempFileName(const std::string& dbname, uint64_t number);
|
|
|
|
|
|
|
|
// Return the name of the info log file for "dbname".
|
2012-09-06 02:44:13 +02:00
|
|
|
extern std::string InfoLogFileName(const std::string& dbname,
|
|
|
|
const std::string& db_path="", const std::string& log_dir="");
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
// Return the name of the old info log file for "dbname".
|
2012-09-06 02:44:13 +02:00
|
|
|
extern std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
|
|
|
|
const std::string& db_path="", const std::string& log_dir="");
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2012-12-17 20:26:59 +01:00
|
|
|
// Return the name to use for a metadatabase. The result will be prefixed with
|
|
|
|
// "dbname".
|
|
|
|
extern std::string MetaDatabaseName(const std::string& dbname,
|
|
|
|
uint64_t number);
|
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
// If filename is a rocksdb file, store the type of the file in *type.
|
2011-04-21 00:48:11 +02:00
|
|
|
// The number encoded in the filename is stored in *number. If the
|
|
|
|
// filename was successfully parsed, returns true. Else return false.
|
2011-03-18 23:37:00 +01:00
|
|
|
extern bool ParseFileName(const std::string& filename,
|
|
|
|
uint64_t* number,
|
|
|
|
FileType* type);
|
|
|
|
|
|
|
|
// Make the CURRENT file point to the descriptor file with the
|
|
|
|
// specified number.
|
|
|
|
extern Status SetCurrentFile(Env* env, const std::string& dbname,
|
|
|
|
uint64_t descriptor_number);
|
|
|
|
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
} // namespace rocksdb
|