2018-01-18 03:14:13 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
2018-02-04 03:22:01 +01:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2017-03-31 00:57:08 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_DB_OPTS_H
|
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd::db
|
|
|
|
{
|
|
|
|
struct sopts;
|
|
|
|
struct gopts;
|
2022-07-02 20:37:49 +02:00
|
|
|
struct options;
|
|
|
|
}
|
2017-09-22 05:08:11 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Options for setting (writes)
|
|
|
|
struct ircd::db::sopts
|
|
|
|
{
|
|
|
|
/// Uses kernel filesystem synchronization after this write (slow).
|
|
|
|
bool fsync {false};
|
2017-09-22 05:08:11 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Write Ahead Log (WAL) for some crash recovery.
|
|
|
|
bool journal {true};
|
2017-09-22 05:08:11 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Set to false to fail if write would block.
|
|
|
|
bool blocking {true};
|
2017-03-31 00:57:08 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Mark for low priority behavior.
|
|
|
|
bool prio_low {false};
|
2017-03-31 00:57:08 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Mark for high priority behavior.
|
|
|
|
bool prio_high {false};
|
2017-03-31 01:20:01 +02:00
|
|
|
};
|
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Options for getting (reads)
|
|
|
|
struct ircd::db::gopts
|
2017-03-31 01:20:01 +02:00
|
|
|
{
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Keep iter data in memory for iter lifetime (good for lots ++/--).
|
|
|
|
bool pin {false};
|
2017-09-22 05:08:11 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Fill the cache with results.
|
|
|
|
bool cache {true};
|
2017-09-22 05:08:11 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Allow query to continue after cache miss.
|
|
|
|
bool blocking {true};
|
2017-03-31 01:20:01 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Submit requests in parallel (relevant to db::row).
|
|
|
|
bool parallel {true};
|
2017-03-31 01:20:01 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// (prefix_same_as_start); automatic for index columns with pfx.
|
|
|
|
bool prefix {false};
|
|
|
|
|
|
|
|
/// (total_order_seek); relevant to index columns.
|
|
|
|
bool ordered {false};
|
|
|
|
|
|
|
|
/// Ensures no snapshot is used; this iterator will have the latest data.
|
|
|
|
bool tailing {false};
|
|
|
|
|
|
|
|
/// 1 = Throw exceptions more than usual.
|
|
|
|
/// 0 = Throw exceptions less than usual.
|
|
|
|
int8_t throwing {-1};
|
|
|
|
|
|
|
|
/// 1 = Integrity of data will be checked (overrides conf).
|
|
|
|
/// 0 = Checksums will not be checked (overrides conf).
|
|
|
|
int8_t checksum {-1};
|
|
|
|
|
|
|
|
/// Readahead bytes.
|
|
|
|
size_t readahead {0};
|
2017-03-31 01:20:01 +02:00
|
|
|
|
2022-07-02 20:37:49 +02:00
|
|
|
/// Bounding keys
|
|
|
|
const rocksdb::Slice
|
|
|
|
*lower_bound {nullptr},
|
|
|
|
*upper_bound {nullptr};
|
|
|
|
|
|
|
|
/// Attached snapshot
|
|
|
|
database::snapshot snapshot;
|
2017-03-31 01:20:01 +02:00
|
|
|
};
|
|
|
|
|
2018-12-12 18:53:16 +01:00
|
|
|
/// options <-> string
|
|
|
|
struct ircd::db::options
|
|
|
|
:std::string
|
|
|
|
{
|
|
|
|
struct map;
|
|
|
|
|
|
|
|
// Output of options structures from this string
|
|
|
|
explicit operator rocksdb::Options() const;
|
|
|
|
operator rocksdb::DBOptions() const;
|
|
|
|
operator rocksdb::ColumnFamilyOptions() const;
|
|
|
|
operator rocksdb::PlainTableOptions() const;
|
|
|
|
operator rocksdb::BlockBasedTableOptions() const;
|
|
|
|
|
|
|
|
// Input of options structures output to this string
|
|
|
|
explicit options(const rocksdb::ColumnFamilyOptions &);
|
|
|
|
explicit options(const rocksdb::DBOptions &);
|
|
|
|
explicit options(const database::column &);
|
|
|
|
explicit options(const database &);
|
|
|
|
|
|
|
|
// Input of options string from user
|
|
|
|
options(std::string string)
|
|
|
|
:std::string{std::move(string)}
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// options <-> map
|
|
|
|
struct ircd::db::options::map
|
|
|
|
:std::unordered_map<std::string, std::string>
|
|
|
|
{
|
2023-02-28 04:58:11 +01:00
|
|
|
// Merge output of options structures from map (map takes precedence).
|
|
|
|
rocksdb::DBOptions merge(const rocksdb::DBOptions &) const;
|
|
|
|
rocksdb::ColumnFamilyOptions merge(const rocksdb::ColumnFamilyOptions &) const;
|
|
|
|
rocksdb::PlainTableOptions merge(const rocksdb::PlainTableOptions &) const;
|
|
|
|
rocksdb::BlockBasedTableOptions merge(const rocksdb::BlockBasedTableOptions &) const;
|
|
|
|
|
2018-12-12 18:53:16 +01:00
|
|
|
// Output of options structures from map
|
|
|
|
operator rocksdb::DBOptions() const;
|
|
|
|
operator rocksdb::ColumnFamilyOptions() const;
|
|
|
|
operator rocksdb::PlainTableOptions() const;
|
|
|
|
operator rocksdb::BlockBasedTableOptions() const;
|
|
|
|
|
|
|
|
// Convert option string to map
|
|
|
|
map(const options &);
|
|
|
|
|
|
|
|
// Input of options map from user
|
2023-02-28 04:58:11 +01:00
|
|
|
map(std::unordered_map<std::string, std::string> m = {})
|
2018-12-12 18:53:16 +01:00
|
|
|
:std::unordered_map<std::string, std::string>{std::move(m)}
|
|
|
|
{}
|
|
|
|
};
|