Class LoadedOptions
- Namespace
- RocksDbNet
- Assembly
- RocksDb.Net.dll
The options a database was last opened with, read back from the
OPTIONS- file RocksDb writes into its directory.
public sealed class LoadedOptions : IDisposable
- Inheritance
-
LoadedOptions
- Implements
- Inherited Members
Remarks
For reopening a database you did not configure. Without this the choice is to guess, or to hard-code options that then have to be kept in step with whoever created the database — and getting the comparator wrong is not a configuration mistake but a corrupt read. It is also the honest way to write a diagnostic or repair tool against a database you have been handed.
Everything here is freed as a unit. RocksDb allocates the database options, the column family names and the per-family options in one call and takes them back in one call, so the DbOptions this exposes are not yours to dispose: disposing this releases all of them, and using one afterwards throws ObjectDisposedException rather than reading freed memory.
Partial parity with what other bindings offer, and worth being explicit about: RocksDb's C API exposes only "load the latest options from a database directory". There is no equivalent of loading a named options file, or of asking which options file is the latest, so neither is here.
Properties
ColumnFamilyNames
The column families the database was last opened with, in order.
public IReadOnlyList<string> ColumnFamilyNames { get; }
Property Value
DatabaseOptions
The database-wide options the database was last opened with.
public DbOptions DatabaseOptions { get; }
Property Value
Remarks
Database-wide only. RocksDb builds this from the file's DBOptions combined with a default set of column family options, so anything column-family scoped — the write buffer size, compression, the comparator — reads back as its default here and is not what the database was using. Those live in ColumnFamilyOptions(int), one set per family.
Methods
ColumnFamilyOptions(int)
The options for the column family at index.
public DbOptions ColumnFamilyOptions(int index)
Parameters
indexint
Returns
Remarks
Indexed the same as ColumnFamilyNames, and owned by this object like DatabaseOptions. This is where every column-family setting is: the write buffer size, compression, the comparator, the merge operator by name. Reading them from DatabaseOptions gives defaults instead.
Dispose()
Releases the options, the names and the per-family options together.
public void Dispose()
LoadLatest(string, Env?, Cache?, bool)
Reads the latest OPTIONS- file from the database directory at
dbPath.
public static LoadedOptions LoadLatest(string dbPath, Env? env = null, Cache? cache = null, bool ignoreUnknownOptions = false)
Parameters
dbPathstringA database directory, which must already exist.
envEnvThe environment to read the file through. The process default when null.
cacheCacheThe block cache the loaded options should use. One is created when null. RocksDb needs it at load time rather than after, because the table factory it reconstructs from the file holds it.
ignoreUnknownOptionsboolWhether an option RocksDb no longer recognises is skipped rather than failing the load. Useful when reading a database written by a newer version than this one.
Returns
Exceptions
- RocksDbException
The directory has no options file, or the file cannot be parsed.