YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/plain_table_factory.cc
Line
Count
Source (jump to first uncovered line)
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
// The following only applies to changes made to this file as part of YugaByte development.
6
//
7
// Portions Copyright (c) YugaByte, Inc.
8
//
9
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
10
// in compliance with the License.  You may obtain a copy of the License at
11
//
12
// http://www.apache.org/licenses/LICENSE-2.0
13
//
14
// Unless required by applicable law or agreed to in writing, software distributed under the License
15
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
16
// or implied.  See the License for the specific language governing permissions and limitations
17
// under the License.
18
//
19
20
#ifndef ROCKSDB_LITE
21
#include "yb/rocksdb/table/plain_table_factory.h"
22
23
#include <stdint.h>
24
#include <memory>
25
26
#include "yb/rocksdb/db/dbformat.h"
27
#include "yb/rocksdb/table/plain_table_builder.h"
28
#include "yb/rocksdb/table/plain_table_reader.h"
29
#include "yb/rocksdb/port/port.h"
30
31
namespace rocksdb {
32
33
Status PlainTableFactory::NewTableReader(
34
    const TableReaderOptions& table_reader_options,
35
    unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
36
2.89k
    unique_ptr<TableReader>* table) const {
37
2.89k
  return PlainTableReader::Open(
38
2.89k
      table_reader_options.ioptions, table_reader_options.env_options,
39
2.89k
      table_reader_options.internal_comparator, std::move(file), file_size,
40
2.89k
      table, table_options_.bloom_bits_per_key, table_options_.hash_table_ratio,
41
2.89k
      table_options_.index_sparseness, table_options_.huge_page_tlb_size,
42
2.89k
      table_options_.full_scan_mode);
43
2.89k
}
44
45
TableBuilder* PlainTableFactory::NewTableBuilder(const TableBuilderOptions &table_builder_options,
46
2.06k
    uint32_t column_family_id, WritableFileWriter *base_file, WritableFileWriter *data_file) const {
47
  // This table factory doesn't support separate files for metadata and data.
48
2.06k
  assert(data_file == nullptr);
49
  // Ignore the skip_filters flag. PlainTable format is optimized for small
50
  // in-memory dbs. The skip_filters optimization is not useful for plain
51
  // tables
52
  //
53
2.06k
  return new PlainTableBuilder(
54
2.06k
      table_builder_options.ioptions,
55
2.06k
      *table_builder_options.int_tbl_prop_collector_factories,
56
2.06k
      column_family_id,
57
2.06k
      base_file,
58
2.06k
      table_options_.user_key_len,
59
2.06k
      table_options_.encoding_type,
60
2.06k
      table_options_.index_sparseness,
61
2.06k
      table_options_.bloom_bits_per_key,
62
2.06k
      6,
63
2.06k
      table_options_.huge_page_tlb_size,
64
2.06k
      table_options_.hash_table_ratio,
65
2.06k
      table_options_.store_index_in_file);
66
2.06k
}
67
68
1.34k
std::string PlainTableFactory::GetPrintableTableOptions() const {
69
1.34k
  std::string ret;
70
1.34k
  ret.reserve(20000);
71
1.34k
  const int kBufferSize = 200;
72
1.34k
  char buffer[kBufferSize];
73
74
1.34k
  snprintf(buffer, kBufferSize, "  user_key_len: %u\n",
75
1.34k
           table_options_.user_key_len);
76
1.34k
  ret.append(buffer);
77
1.34k
  snprintf(buffer, kBufferSize, "  bloom_bits_per_key: %d\n",
78
1.34k
           table_options_.bloom_bits_per_key);
79
1.34k
  ret.append(buffer);
80
1.34k
  snprintf(buffer, kBufferSize, "  hash_table_ratio: %lf\n",
81
1.34k
           table_options_.hash_table_ratio);
82
1.34k
  ret.append(buffer);
83
1.34k
  snprintf(buffer, kBufferSize, "  index_sparseness: %" ROCKSDB_PRIszt "\n",
84
1.34k
           table_options_.index_sparseness);
85
1.34k
  ret.append(buffer);
86
1.34k
  snprintf(buffer, kBufferSize, "  huge_page_tlb_size: %" ROCKSDB_PRIszt "\n",
87
1.34k
           table_options_.huge_page_tlb_size);
88
1.34k
  ret.append(buffer);
89
1.34k
  snprintf(buffer, kBufferSize, "  encoding_type: %d\n",
90
1.34k
           table_options_.encoding_type);
91
1.34k
  ret.append(buffer);
92
1.34k
  snprintf(buffer, kBufferSize, "  full_scan_mode: %d\n",
93
1.34k
           table_options_.full_scan_mode);
94
1.34k
  ret.append(buffer);
95
1.34k
  snprintf(buffer, kBufferSize, "  store_index_in_file: %d\n",
96
1.34k
           table_options_.store_index_in_file);
97
1.34k
  ret.append(buffer);
98
1.34k
  return ret;
99
1.34k
}
100
101
0
const PlainTableOptions& PlainTableFactory::table_options() const {
102
0
  return table_options_;
103
0
}
104
105
327
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
106
327
  return new PlainTableFactory(options);
107
327
}
108
109
const char PlainTablePropertyNames::kPrefixExtractorName[] =
110
    "rocksdb.prefix.extractor.name";
111
112
const char PlainTablePropertyNames::kEncodingType[] =
113
    "rocksdb.plain.table.encoding.type";
114
115
const char PlainTablePropertyNames::kBloomVersion[] =
116
    "rocksdb.plain.table.bloom.version";
117
118
const char PlainTablePropertyNames::kNumBloomBlocks[] =
119
    "rocksdb.plain.table.bloom.numblocks";
120
121
}  // namespace rocksdb
122
#endif  // ROCKSDB_LITE