filename.h 3.7 KB
Newer Older
1 2 3 4 5
//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the root directory of this source tree. An additional grant
//  of patent rights can be found in the PATENTS file in the same directory.
//
J
jorlow@chromium.org 已提交
6 7 8 9 10 11
// 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

12
#pragma once
J
jorlow@chromium.org 已提交
13 14
#include <stdint.h>
#include <string>
15 16
#include "rocksdb/slice.h"
#include "rocksdb/status.h"
J
jorlow@chromium.org 已提交
17 18
#include "port/port.h"

19
namespace rocksdb {
J
jorlow@chromium.org 已提交
20 21 22 23 24 25 26 27 28 29

class Env;

enum FileType {
  kLogFile,
  kDBLockFile,
  kTableFile,
  kDescriptorFile,
  kCurrentFile,
  kTempFile,
K
Kosie van der Merwe 已提交
30 31
  kInfoLogFile,  // Either the current one, or an old one
  kMetaDatabase
J
jorlow@chromium.org 已提交
32 33 34 35 36 37 38
};

// 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);

39 40 41 42
static const std::string ARCHIVAL_DIR = "archive";

extern std::string ArchivalDirectory(const std::string& dbname);

43 44 45 46 47
//  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);

J
jorlow@chromium.org 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
// 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".
H
heyongqiang 已提交
73 74
extern std::string InfoLogFileName(const std::string& dbname,
    const std::string& db_path="", const std::string& log_dir="");
J
jorlow@chromium.org 已提交
75 76

// Return the name of the old info log file for "dbname".
H
heyongqiang 已提交
77 78
extern std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
    const std::string& db_path="", const std::string& log_dir="");
J
jorlow@chromium.org 已提交
79

K
Kosie van der Merwe 已提交
80 81 82 83 84
// 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);

85
// If filename is a rocksdb file, store the type of the file in *type.
D
dgrogan@chromium.org 已提交
86 87
// The number encoded in the filename is stored in *number.  If the
// filename was successfully parsed, returns true.  Else return false.
J
jorlow@chromium.org 已提交
88 89 90 91 92 93 94 95 96 97
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);


98
}  // namespace rocksdb