YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/rocksdb/db/flush_job.h
Line
Count
Source
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under the BSD-style license found in the
3
//  LICENSE file in the root directory of this source tree. An additional grant
4
//  of patent rights can be found in the PATENTS file in the same directory.
5
//
6
// The following only applies to changes made to this file as part of YugaByte development.
7
//
8
// Portions Copyright (c) YugaByte, Inc.
9
//
10
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
11
// in compliance with the License.  You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software distributed under the License
16
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17
// or implied.  See the License for the specific language governing permissions and limitations
18
// under the License.
19
//
20
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
21
// Use of this source code is governed by a BSD-style license that can be
22
// found in the LICENSE file. See the AUTHORS file for names of contributors.
23
24
#ifndef YB_ROCKSDB_DB_FLUSH_JOB_H
25
#define YB_ROCKSDB_DB_FLUSH_JOB_H
26
27
#pragma once
28
29
#include <atomic>
30
#include <deque>
31
#include <limits>
32
#include <set>
33
#include <string>
34
#include <utility>
35
#include <vector>
36
37
#include "yb/rocksdb/db.h"
38
#include "yb/rocksdb/db/column_family.h"
39
#include "yb/rocksdb/db/dbformat.h"
40
#include "yb/rocksdb/db/job_context.h"
41
#include "yb/rocksdb/db/log_writer.h"
42
#include "yb/rocksdb/db/memtable_list.h"
43
#include "yb/rocksdb/db/version_edit.h"
44
#include "yb/rocksdb/db/write_controller.h"
45
#include "yb/rocksdb/db/write_thread.h"
46
#include "yb/rocksdb/env.h"
47
#include "yb/rocksdb/memtablerep.h"
48
#include "yb/rocksdb/port/port.h"
49
#include "yb/rocksdb/transaction_log.h"
50
#include "yb/rocksdb/util/autovector.h"
51
#include "yb/rocksdb/util/event_logger.h"
52
#include "yb/rocksdb/util/instrumented_mutex.h"
53
#include "yb/rocksdb/util/stop_watch.h"
54
#include "yb/rocksdb/util/thread_local.h"
55
56
namespace rocksdb {
57
58
using yb::Result;
59
60
class Arena;
61
class FileNumbersHolder;
62
class FileNumbersProvider;
63
class MemTable;
64
class TableCache;
65
class Version;
66
class VersionEdit;
67
class VersionSet;
68
69
class FlushJob {
70
 public:
71
  // TODO(icanadi) make effort to reduce number of parameters here
72
  // IMPORTANT: mutable_cf_options needs to be alive while FlushJob is alive
73
  FlushJob(const std::string& dbname, ColumnFamilyData* cfd,
74
           const DBOptions& db_options,
75
           const MutableCFOptions& mutable_cf_options,
76
           const EnvOptions& env_options, VersionSet* versions,
77
           InstrumentedMutex* db_mutex, std::atomic<bool>* shutting_down,
78
           std::atomic<bool>* disable_flush_on_shutdown_,
79
           std::vector<SequenceNumber> existing_snapshots,
80
           SequenceNumber earliest_write_conflict_snapshot,
81
           MemTableFilter mem_table_flush_filter,
82
           FileNumbersProvider* file_number_provider,
83
           JobContext* job_context, LogBuffer* log_buffer,
84
           Directory* db_directory, Directory* output_file_directory,
85
           CompressionType output_compression, Statistics* stats,
86
           EventLogger* event_logger);
87
88
  ~FlushJob();
89
90
  Result<FileNumbersHolder> Run(FileMetaData* file_meta = nullptr);
91
59.6k
  TableProperties GetTableProperties() const { return table_properties_; }
92
93
 private:
94
  void ReportStartedFlush();
95
  void RecordFlushIOStats();
96
  Result<FileNumbersHolder> WriteLevel0Table(
97
      const autovector<MemTable*>& mems, VersionEdit* edit, FileMetaData* meta);
98
  const std::string& dbname_;
99
  ColumnFamilyData* cfd_;
100
  const DBOptions& db_options_;
101
  const MutableCFOptions& mutable_cf_options_;
102
  const EnvOptions& env_options_;
103
  VersionSet* versions_;
104
  InstrumentedMutex* db_mutex_;
105
  std::atomic<bool>* shutting_down_;
106
  std::atomic<bool>* disable_flush_on_shutdown_;
107
  std::vector<SequenceNumber> existing_snapshots_;
108
  SequenceNumber earliest_write_conflict_snapshot_;
109
  MemTableFilter mem_table_flush_filter_;
110
  FileNumbersProvider* file_numbers_provider_;
111
  JobContext* job_context_;
112
  LogBuffer* log_buffer_;
113
  Directory* db_directory_;
114
  Directory* output_file_directory_;
115
  CompressionType output_compression_;
116
  Statistics* stats_;
117
  EventLogger* event_logger_;
118
  TableProperties table_properties_;
119
};
120
121
}  // namespace rocksdb
122
123
#endif // YB_ROCKSDB_DB_FLUSH_JOB_H