NuDB Logo

PrevUpHomeNext

verify

Verify consistency of the key and data files.

template<
    class Hasher,
    class Progress>
void
verify(
    verify_info& info,
    path_type const& dat_path,
    path_type const& key_path,
    std::size_t bufferSize,
    Progress&& progress,
    error_code& ec);

This function opens the key and data files, and performs the following checks on the contents:

Undefined behavior results when verifying a database that still has a log file. Use recover on such databases first.

This function selects one of two algorithms to use, the normal version, and a faster version that can take advantage of a buffer of sufficient size. Depending on the value of the bufferSize argument, the appropriate algorithm is chosen.

A good value of bufferSize is one that is a large fraction of the key file size. For example, 20% of the size of the key file. Larger is better, with the highest usable value depending on the size of the key file. If presented with a buffer size that is too large to be of extra use, the fast algorithm will simply allocate what it needs.

Template Parameters

Hasher

The hash function to use. This type must meet the requirements of HashFunction. The hash function must be the same as that used to create the database, or else an error is returned.

Parameters

info

A structure which will be default constructed inside this function, and filled in if the operation completes successfully. If an error is indicated, the contents of this variable are undefined.

dat_path

The path to the data file.

key_path

The path to the key file.

bufferSize

The number of bytes to allocate for the buffer. If this number is too small, or zero, a slower algorithm will be used that does not require a buffer.

progress

A function which will be called periodically as the algorithm proceeds. The equivalent signature of the progress function must be:

void progress(
    std::uint64_t amount,   // Amount of work done so far
    std::uint64_t total     // Total amount of work to do
);
ec

Set to the error, if any occurred.

Requirements

Header: nudb/verify.hpp


PrevUpHomeNext