github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/include/libroach.h (about)

     1  // Copyright 2014 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  #pragma once
    12  
    13  #include <stdbool.h>
    14  #include <stddef.h>
    15  #include <stdint.h>
    16  
    17  #ifdef __cplusplus
    18  extern "C" {
    19  #endif
    20  
    21  // A DBSlice contains read-only data that does not need to be freed.
    22  typedef struct {
    23    char* data;
    24    size_t len;
    25  } DBSlice;
    26  
    27  // A DBString is structurally identical to a DBSlice, but the data it
    28  // contains must be freed via a call to free().
    29  typedef struct {
    30    char* data;
    31    size_t len;
    32  } DBString;
    33  
    34  // A DBStatus is an alias for DBString and is used to indicate that
    35  // the return value indicates the success or failure of an
    36  // operation. If DBStatus.data == NULL the operation succeeded.
    37  typedef DBString DBStatus;
    38  
    39  typedef struct {
    40    DBSlice key;
    41    int64_t wall_time;
    42    int32_t logical;
    43  } DBKey;
    44  
    45  typedef struct {
    46    int64_t wall_time;
    47    int32_t logical;
    48  } DBTimestamp;
    49  
    50  typedef struct {
    51    bool prefix;
    52    DBKey lower_bound;
    53    DBKey upper_bound;
    54    bool with_stats;
    55    DBTimestamp min_timestamp_hint;
    56    DBTimestamp max_timestamp_hint;
    57  } DBIterOptions;
    58  
    59  typedef struct {
    60    bool valid;
    61    DBKey key;
    62    DBSlice value;
    63    DBStatus status;
    64  } DBIterState;
    65  
    66  // A DBIgnoredSeqNumRange is an alias for the Go struct
    67  // IgnoredSeqNumRange. It must have exactly the same memory
    68  // layout.
    69  typedef struct {
    70    int32_t start_seqnum;
    71    int32_t end_seqnum;
    72  } DBIgnoredSeqNumRange;
    73  
    74  typedef struct {
    75    DBIgnoredSeqNumRange* ranges;
    76    int len;
    77  } DBIgnoredSeqNums;
    78  
    79  typedef struct DBCache DBCache;
    80  typedef struct DBEngine DBEngine;
    81  typedef struct DBIterator DBIterator;
    82  typedef void* DBWritableFile;
    83  typedef void* DBReadableFile;
    84  typedef void* DBDirectory;
    85  
    86  // DBOptions contains local database options.
    87  typedef struct {
    88    DBCache* cache;
    89    int num_cpu;
    90    int max_open_files;
    91    bool use_file_registry;
    92    bool must_exist;
    93    bool read_only;
    94    DBSlice rocksdb_options;
    95    DBSlice extra_options;
    96  } DBOptions;
    97  
    98  // Create a new cache with the specified size.
    99  DBCache* DBNewCache(uint64_t size);
   100  
   101  // Add a reference to an existing cache. Note that the underlying
   102  // RocksDB cache is shared between the original and new reference.
   103  DBCache* DBRefCache(DBCache* cache);
   104  
   105  // Release a cache, decrementing the reference count on the underlying
   106  // RocksDB cache. Note that the RocksDB cache will not be freed until
   107  // all of the references have been released.
   108  void DBReleaseCache(DBCache* cache);
   109  
   110  // Opens the database located in "dir", creating it if it doesn't
   111  // exist.
   112  DBStatus DBOpen(DBEngine** db, DBSlice dir, DBOptions options);
   113  
   114  // Creates a RocksDB checkpoint in the specified directory (which must not exist).
   115  // A checkpoint is a logical copy of the database, though it will hardlink the
   116  // SSTs references by it (when possible), thus avoiding duplication of any of
   117  // the actual data.
   118  DBStatus DBCreateCheckpoint(DBEngine* db, DBSlice dir);
   119  
   120  // Set a callback to be invoked during DBOpen that can make changes to RocksDB
   121  // initialization. Used by CCL code to install additional features.
   122  //
   123  // The callback must be a pointer to a C++ function of type DBOpenHook. The type
   124  // is declared in db.cc. It cannot be part of the public C API as it refers to
   125  // C++ types.
   126  void DBSetOpenHook(void* hook);
   127  
   128  // Destroys the database located in "dir". As the name implies, this
   129  // operation is destructive. Use with caution.
   130  DBStatus DBDestroy(DBSlice dir);
   131  
   132  // Closes the database, freeing memory and other resources.
   133  DBStatus DBClose(DBEngine* db);
   134  
   135  // Flushes all mem-table data to disk, blocking until the operation is
   136  // complete.
   137  DBStatus DBFlush(DBEngine* db);
   138  
   139  // Syncs the RocksDB WAL ensuring all data is persisted to
   140  // disk. Blocks until the operation is complete.
   141  DBStatus DBSyncWAL(DBEngine* db);
   142  
   143  // Forces an immediate compaction over all keys.
   144  DBStatus DBCompact(DBEngine* db);
   145  
   146  // Forces an immediate compaction over keys in the specified range.
   147  // Note that if start is empty, it indicates the start of the database.
   148  // If end is empty, it indicates the end of the database.
   149  DBStatus DBCompactRange(DBEngine* db, DBSlice start, DBSlice end, bool force_bottommost);
   150  
   151  // Disable/enable automatic compactions. Automatic compactions are
   152  // enabled by default. Disabling is provided for testing purposes so
   153  // that automatic compactions do not interfere with test expectations.
   154  DBStatus DBDisableAutoCompaction(DBEngine* db);
   155  DBStatus DBEnableAutoCompaction(DBEngine* db);
   156  
   157  // Stores the approximate on-disk size of the given key range into the
   158  // supplied uint64.
   159  DBStatus DBApproximateDiskBytes(DBEngine* db, DBKey start, DBKey end, uint64_t* size);
   160  
   161  // Sets the database entry for "key" to "value".
   162  DBStatus DBPut(DBEngine* db, DBKey key, DBSlice value);
   163  
   164  // Merge the database entry (if any) for "key" with "value".
   165  DBStatus DBMerge(DBEngine* db, DBKey key, DBSlice value);
   166  
   167  // Retrieves the database entry for "key".
   168  DBStatus DBGet(DBEngine* db, DBKey key, DBString* value);
   169  
   170  // Deletes the database entry for "key".
   171  DBStatus DBDelete(DBEngine* db, DBKey key);
   172  
   173  // Deletes the most recent database entry for "key". See the following
   174  // documentation for details on the subtleties of this operation:
   175  // https://github.com/facebook/rocksdb/wiki/Single-Delete.
   176  DBStatus DBSingleDelete(DBEngine* db, DBKey key);
   177  
   178  // Deletes a range of keys from start (inclusive) to end (exclusive).
   179  DBStatus DBDeleteRange(DBEngine* db, DBKey start, DBKey end);
   180  
   181  // Deletes a range of keys from start (inclusive) to end
   182  // (exclusive). Unlike DBDeleteRange, this function finds the keys to
   183  // delete by iterating over the supplied iterator and creating
   184  // tombstones for the individual keys.
   185  DBStatus DBDeleteIterRange(DBEngine* db, DBIterator* iter, DBKey start, DBKey end);
   186  
   187  // Applies a batch of operations (puts, merges and deletes) to the
   188  // database atomically and closes the batch. It is only valid to call
   189  // this function on an engine created by DBNewBatch. If an error is
   190  // returned, the batch is not closed and it is the caller's
   191  // responsibility to call DBClose.
   192  DBStatus DBCommitAndCloseBatch(DBEngine* db, bool sync);
   193  
   194  // ApplyBatchRepr applies a batch of mutations encoded using that
   195  // batch representation returned by DBBatchRepr(). It is only valid to
   196  // call this function on an engine created by DBOpen() or DBNewBatch()
   197  // (i.e. not a snapshot).
   198  DBStatus DBApplyBatchRepr(DBEngine* db, DBSlice repr, bool sync);
   199  
   200  // Returns the internal batch representation. The returned value is
   201  // only valid until the next call to a method using the DBEngine and
   202  // should thus be copied immediately. It is only valid to call this
   203  // function on an engine created by DBNewBatch.
   204  DBSlice DBBatchRepr(DBEngine* db);
   205  
   206  // Creates a new snapshot of the database for use in DBGet() and
   207  // DBNewIter(). It is the caller's responsibility to call DBClose().
   208  DBEngine* DBNewSnapshot(DBEngine* db);
   209  
   210  // Creates a new batch for performing a series of operations
   211  // atomically. Use DBCommitBatch() on the returned engine to apply the
   212  // batch to the database. The writeOnly parameter controls whether the
   213  // batch can be used for reads or only for writes. A writeOnly batch
   214  // does not need to index keys for reading and can be faster if the
   215  // number of keys is large (and reads are not necessary). It is the
   216  // caller's responsibility to call DBClose().
   217  DBEngine* DBNewBatch(DBEngine* db, bool writeOnly);
   218  
   219  // Creates a new database iterator.
   220  //
   221  // When iter_options.prefix is true, Seek will use the user-key prefix of the
   222  // key supplied to DBIterSeek() to restrict which sstables are searched, but
   223  // iteration (using Next) over keys without the same user-key prefix will not
   224  // work correctly (keys may be skipped).
   225  //
   226  // When iter_options.upper_bound is non-nil, the iterator will become invalid
   227  // after seeking past the provided upper bound. This can drastically improve
   228  // performance when seeking within a region covered by range deletion
   229  // tombstones. See #24029 for discussion.
   230  //
   231  // When iter_options.with_stats is true, the iterator will collect RocksDB
   232  // performance counters which can be retrieved via `DBIterStats`.
   233  //
   234  // It is the caller's responsibility to call DBIterDestroy().
   235  DBIterator* DBNewIter(DBEngine* db, DBIterOptions iter_options);
   236  
   237  // Destroys an iterator, freeing up any associated memory.
   238  void DBIterDestroy(DBIterator* iter);
   239  
   240  // Positions the iterator at the first key that is >= "key".
   241  DBIterState DBIterSeek(DBIterator* iter, DBKey key);
   242  
   243  // Positions the iterator at the first key that is <= "key".
   244  DBIterState DBIterSeekForPrev(DBIterator* iter, DBKey key);
   245  
   246  typedef struct {
   247    uint64_t internal_delete_skipped_count;
   248    // the number of SSTables touched (only for time bound iterators).
   249    // This field is populated from the table filter, not from the
   250    // RocksDB perf counters.
   251    //
   252    // TODO(tschottdorf): populate this field for all iterators.
   253    uint64_t timebound_num_ssts;
   254    // New fields added here must also be added in various other places;
   255    // just grep the repo for internal_delete_skipped_count. Sorry.
   256  } IteratorStats;
   257  
   258  IteratorStats DBIterStats(DBIterator* iter);
   259  
   260  // Positions the iterator at the first key in the database.
   261  DBIterState DBIterSeekToFirst(DBIterator* iter);
   262  
   263  // Positions the iterator at the last key in the database.
   264  DBIterState DBIterSeekToLast(DBIterator* iter);
   265  
   266  // Advances the iterator to the next key. If skip_current_key_versions
   267  // is true, any remaining versions for the current key are
   268  // skipped. After this call, DBIterValid() returns 1 iff the iterator
   269  // was not positioned at the last key.
   270  DBIterState DBIterNext(DBIterator* iter, bool skip_current_key_versions);
   271  
   272  // Moves the iterator back to the previous key. If
   273  // skip_current_key_versions is true, any remaining versions for the
   274  // current key are skipped. After this call, DBIterValid() returns 1
   275  // iff the iterator was not positioned at the first key.
   276  DBIterState DBIterPrev(DBIterator* iter, bool skip_current_key_versions);
   277  
   278  // DBIterSetLowerBound updates this iterator's lower bound.
   279  void DBIterSetLowerBound(DBIterator* iter, DBKey key);
   280  
   281  // DBIterSetUpperBound updates this iterator's upper bound.
   282  void DBIterSetUpperBound(DBIterator* iter, DBKey key);
   283  
   284  // Implements the merge operator on a single pair of values. update is
   285  // merged with existing. This method is provided for invocation from
   286  // Go code.
   287  DBStatus DBMergeOne(DBSlice existing, DBSlice update, DBString* new_value);
   288  
   289  // Implements the partial merge operator on a single pair of values. update is
   290  // merged with existing. This method is provided for invocation from Go code.
   291  DBStatus DBPartialMergeOne(DBSlice existing, DBSlice update, DBString* new_value);
   292  
   293  // NB: The function (cStatsToGoStats) that converts these to the go
   294  // representation is unfortunately duplicated in engine and engineccl. If this
   295  // struct is changed, both places need to be updated.
   296  typedef struct {
   297    DBStatus status;
   298    int64_t live_bytes;
   299    int64_t key_bytes;
   300    int64_t val_bytes;
   301    int64_t intent_bytes;
   302    int64_t live_count;
   303    int64_t key_count;
   304    int64_t val_count;
   305    int64_t intent_count;
   306    int64_t intent_age;
   307    int64_t gc_bytes_age;
   308    int64_t sys_bytes;
   309    int64_t sys_count;
   310    int64_t last_update_nanos;
   311  } MVCCStatsResult;
   312  
   313  MVCCStatsResult MVCCComputeStats(DBIterator* iter, DBKey start, DBKey end, int64_t now_nanos);
   314  
   315  // DBCheckForKeyCollisions runs both iterators in lockstep and errors out at the
   316  // first key collision, where a collision refers to any two MVCC keys with the
   317  // same user key, and with a different timestamp or value.
   318  //
   319  // An exception is made when the latest version of the colliding key is a
   320  // tombstone from an MVCC delete in the existing data. If the timestamp of the
   321  // SST key is greater than or equal to the timestamp of the tombstone, then it
   322  // is not considered a collision and we continue iteration from the next key in
   323  // the existing data.
   324  DBIterState DBCheckForKeyCollisions(DBIterator* existingIter, DBIterator* sstIter,
   325                                      MVCCStatsResult* skippedKVStats, DBString* write_intent);
   326  
   327  bool MVCCIsValidSplitKey(DBSlice key);
   328  DBStatus MVCCFindSplitKey(DBIterator* iter, DBKey start, DBKey min_split, int64_t target_size,
   329                            DBString* split_key);
   330  
   331  // DBTxn contains the fields from a roachpb.Transaction that are
   332  // necessary for MVCC Get and Scan operations. Note that passing a
   333  // serialized roachpb.Transaction appears to be a non-starter as an
   334  // alternative due to the performance overhead.
   335  //
   336  // TODO(peter): We could investigate using
   337  // https://github.com/petermattis/cppgo to generate C++ code that can
   338  // read the Go roachpb.Transaction structure.
   339  typedef struct {
   340    DBSlice id;
   341    uint32_t epoch;
   342    int32_t sequence;
   343    DBTimestamp max_timestamp;
   344    DBIgnoredSeqNums ignored_seqnums;
   345  } DBTxn;
   346  
   347  typedef struct {
   348    DBSlice* bufs;
   349    // len is the number of DBSlices in bufs.
   350    int32_t len;
   351    // count is the number of key/value pairs in bufs.
   352    int32_t count;
   353    // bytes is the number of bytes (as measured by TargetSize) in bufs.
   354    int64_t bytes;
   355  } DBChunkedBuffer;
   356  
   357  // DBScanResults contains the key/value pairs and intents encoded
   358  // using the RocksDB batch repr format.
   359  typedef struct {
   360    DBStatus status;
   361    DBChunkedBuffer data;
   362    DBSlice intents;
   363    DBTimestamp write_too_old_timestamp;
   364    DBTimestamp uncertainty_timestamp;
   365    DBSlice resume_key;
   366  } DBScanResults;
   367  
   368  DBScanResults MVCCGet(DBIterator* iter, DBSlice key, DBTimestamp timestamp, DBTxn txn,
   369                        bool inconsistent, bool tombstones, bool fail_on_more_recent);
   370  DBScanResults MVCCScan(DBIterator* iter, DBSlice start, DBSlice end, DBTimestamp timestamp,
   371                         int64_t max_keys, int64_t target_bytes, DBTxn txn, bool inconsistent,
   372                         bool reverse, bool tombstones, bool fail_on_more_recent);
   373  
   374  // DBStatsResult contains various runtime stats for RocksDB.
   375  typedef struct {
   376    int64_t block_cache_hits;
   377    int64_t block_cache_misses;
   378    size_t block_cache_usage;
   379    size_t block_cache_pinned_usage;
   380    int64_t bloom_filter_prefix_checked;
   381    int64_t bloom_filter_prefix_useful;
   382    int64_t memtable_total_size;
   383    int64_t flushes;
   384    int64_t flush_bytes;
   385    int64_t compactions;
   386    int64_t compact_read_bytes;
   387    int64_t compact_write_bytes;
   388    int64_t table_readers_mem_estimate;
   389    int64_t pending_compaction_bytes_estimate;
   390    int64_t l0_file_count;
   391  } DBStatsResult;
   392  
   393  typedef struct {
   394    DBString name;
   395    uint64_t value;
   396  } TickerInfo;
   397  
   398  typedef struct {
   399    DBString name;
   400    double mean;
   401    double p50;
   402    double p95;
   403    double p99;
   404    double max;
   405    uint64_t count;
   406    uint64_t sum;
   407  } HistogramInfo;
   408  
   409  typedef struct {
   410    TickerInfo* tickers;
   411    size_t tickers_len;
   412    HistogramInfo* histograms;
   413    size_t histograms_len;
   414  } DBTickersAndHistogramsResult;
   415  
   416  // DBEnvStatsResult contains Env stats (filesystem layer).
   417  typedef struct {
   418    // Basic file encryption stats:
   419    // Files/bytes across all rocksdb files.
   420    uint64_t total_files;
   421    uint64_t total_bytes;
   422    // Files/bytes using the active data key.
   423    uint64_t active_key_files;
   424    uint64_t active_key_bytes;
   425    // Enum of the encryption algorithm in use.
   426    int32_t encryption_type;
   427    // encryption status (CCL only).
   428    // This is a serialized enginepbccl/stats.proto:EncryptionStatus
   429    DBString encryption_status;
   430  } DBEnvStatsResult;
   431  
   432  // DBEncryptionRegistries contains file and key registries.
   433  typedef struct {
   434    // File registry.
   435    DBString file_registry;
   436    // Key registry (with actual keys scrubbed).
   437    DBString key_registry;
   438  } DBEncryptionRegistries;
   439  
   440  DBStatus DBGetStats(DBEngine* db, DBStatsResult* stats);
   441  DBStatus DBGetTickersAndHistograms(DBEngine* db, DBTickersAndHistogramsResult* stats);
   442  DBString DBGetCompactionStats(DBEngine* db);
   443  DBStatus DBGetEnvStats(DBEngine* db, DBEnvStatsResult* stats);
   444  DBStatus DBGetEncryptionRegistries(DBEngine* db, DBEncryptionRegistries* result);
   445  
   446  typedef struct {
   447    int level;
   448    uint64_t size;
   449    DBKey start_key;
   450    DBKey end_key;
   451  } DBSSTable;
   452  
   453  // Retrieve stats about all of the live sstables. Note that the tables
   454  // array must be freed along with the start_key and end_key of each
   455  // table.
   456  DBSSTable* DBGetSSTables(DBEngine* db, int* n);
   457  
   458  typedef struct {
   459    uint64_t log_number;
   460    uint64_t size;
   461  } DBWALFile;
   462  
   463  // Retrieve information about all of the write-ahead log files in order from
   464  // oldest to newest. The files array must be freed.
   465  DBStatus DBGetSortedWALFiles(DBEngine* db, DBWALFile** files, int* n);
   466  
   467  // DBGetUserProperties fetches the user properties stored in each sstable's
   468  // metadata. These are returned as a serialized SSTUserPropertiesCollection
   469  // proto.
   470  DBString DBGetUserProperties(DBEngine* db);
   471  
   472  // Bulk adds the files at the given paths to a database, all atomically. See the
   473  // RocksDB documentation on `IngestExternalFile` for the various restrictions on
   474  // what can be added. If move_files is true, the files will be moved instead of
   475  // copied.
   476  //
   477  // Using this function is only safe if the data will only ever be read by Rocks
   478  // version >= 5.16 as older versions would be looking for seq_no in the SST and
   479  // we don't write it.
   480  DBStatus DBIngestExternalFiles(DBEngine* db, char** paths, size_t len, bool move_files);
   481  
   482  typedef struct DBSstFileWriter DBSstFileWriter;
   483  
   484  // Creates a new SstFileWriter with the default configuration.
   485  DBSstFileWriter* DBSstFileWriterNew();
   486  
   487  // Opens an in-memory file for output of an sstable.
   488  DBStatus DBSstFileWriterOpen(DBSstFileWriter* fw);
   489  
   490  // Adds a kv entry to the sstable being built. An error is returned if it is
   491  // not greater than any previously added entry (according to the comparator
   492  // configured during writer creation). `Open` must have been called. `Close`
   493  // cannot have been called.
   494  DBStatus DBSstFileWriterAdd(DBSstFileWriter* fw, DBKey key, DBSlice val);
   495  
   496  // Adds a deletion tombstone to the sstable being built. See DBSstFileWriterAdd for more.
   497  DBStatus DBSstFileWriterDelete(DBSstFileWriter* fw, DBKey key);
   498  
   499  // Adds a range deletion tombstone to the sstable being built. This function
   500  // can be called at any time with respect to DBSstFileWriter{Put,Merge,Delete}
   501  // (I.E. does not have to be greater than any previously added entry). Range
   502  // deletion tombstones do not take precedence over other Puts in the same SST.
   503  // `Open` must have been called. `Close` cannot have been called.
   504  DBStatus DBSstFileWriterDeleteRange(DBSstFileWriter* fw, DBKey start, DBKey end);
   505  
   506  // Truncates the writer and stores the constructed file's contents in *data.
   507  // May be called multiple times. The returned data won't necessarily reflect
   508  // the latest writes, only the keys whose underlying RocksDB blocks have been
   509  // flushed. Close cannot have been called.
   510  DBStatus DBSstFileWriterTruncate(DBSstFileWriter* fw, DBString* data);
   511  
   512  // Finalizes the writer and stores the constructed file's contents in *data. At
   513  // least one kv entry must have been added. May only be called once.
   514  DBStatus DBSstFileWriterFinish(DBSstFileWriter* fw, DBString* data);
   515  
   516  // Closes the writer and frees memory and other resources. May only be called
   517  // once.
   518  void DBSstFileWriterClose(DBSstFileWriter* fw);
   519  
   520  void DBRunLDB(int argc, char** argv);
   521  void DBRunSSTDump(int argc, char** argv);
   522  
   523  // DBEnvWriteFile writes the given data as a new "file" in the given engine.
   524  DBStatus DBEnvWriteFile(DBEngine* db, DBSlice path, DBSlice contents);
   525  
   526  // DBEnvOpenFile opens a DBWritableFile as a new "file" in the given engine.
   527  DBStatus DBEnvOpenFile(DBEngine* db, DBSlice path, uint64_t bytes_per_sync,
   528                         DBWritableFile* file);
   529  
   530  // DBEnvReadFile reads the file with the given path in the given engine.
   531  DBStatus DBEnvReadFile(DBEngine* db, DBSlice path, DBSlice* contents);
   532  
   533  // DBEnvAppendFile appends the given data to the given DBWritableFile in the
   534  // given engine.
   535  DBStatus DBEnvAppendFile(DBEngine* db, DBWritableFile file, DBSlice contents);
   536  
   537  // DBEnvSyncFile synchronously writes the data of the file to the disk.
   538  DBStatus DBEnvSyncFile(DBEngine* db, DBWritableFile file);
   539  
   540  // DBEnvCloseFile closes the given DBWritableFile in the given engine.
   541  DBStatus DBEnvCloseFile(DBEngine* db, DBWritableFile file);
   542  
   543  // DBEnvDeleteFile deletes the file with the given filename in the given engine.
   544  DBStatus DBEnvDeleteFile(DBEngine* db, DBSlice path);
   545  
   546  // DBEnvDeleteDirAndFiles deletes the directory with the given dir name and any
   547  // files it contains but not subdirectories in the given engine.
   548  DBStatus DBEnvDeleteDirAndFiles(DBEngine* db, DBSlice dir);
   549  
   550  // DBEnvLinkFile creates 'newname' as a hard link to 'oldname using the given engine.
   551  DBStatus DBEnvLinkFile(DBEngine* db, DBSlice oldname, DBSlice newname);
   552  
   553  // DBFileLock contains various parameters set during DBLockFile and required for DBUnlockFile.
   554  typedef void* DBFileLock;
   555  
   556  // DBLockFile sets a lock on the specified file using RocksDB's file locking interface.
   557  DBStatus DBLockFile(DBSlice filename, DBFileLock* lock);
   558  
   559  // DBUnlockFile unlocks the file associated with the specified lock and GCs any allocated memory for
   560  // the lock.
   561  DBStatus DBUnlockFile(DBFileLock lock);
   562  
   563  // DBExportToSst exports changes over the keyrange and time interval between the
   564  // start and end DBKeys to an SSTable using an IncrementalIterator.
   565  //
   566  // If target_size is positive, it indicates that the export should produce SSTs
   567  // which are roughly target size. Specifically, it will return an SST such that
   568  // the last key is responsible for exceeding the targetSize. If the resume_key
   569  // is non-NULL then the returns sst will exceed the targetSize.
   570  //
   571  // If max_size is positive, it is an absolute maximum on byte size for the
   572  // returned sst. If it is the case that the versions of the last key will lead
   573  // to an SST that exceeds maxSize, an error will be returned. This parameter
   574  // exists to prevent creating SSTs which are too large to be used.
   575  DBStatus DBExportToSst(DBKey start, DBKey end, bool export_all_revisions, 
   576                         uint64_t target_size, uint64_t max_size,
   577                         DBIterOptions iter_opts, DBEngine* engine, DBString* data,
   578                         DBString* write_intent, DBString* summary, DBString* resume);
   579  
   580  // DBEnvOpenReadableFile opens a DBReadableFile in the given engine.
   581  DBStatus DBEnvOpenReadableFile(DBEngine* db, DBSlice path, DBReadableFile* file);
   582  
   583  // DBEnvReadAtFile reads from the DBReadableFile into buffer, at the given offset,
   584  // and returns the bytes read in n.
   585  DBStatus DBEnvReadAtFile(DBEngine* db, DBReadableFile file, DBSlice buffer, int64_t offset, int* n);
   586  
   587  // DBEnvCloseReadableFile closes a DBReadableFile in the given engine.
   588  DBStatus DBEnvCloseReadableFile(DBEngine* db, DBReadableFile file);
   589  
   590  // DBEnvOpenDirectory opens a DBDirectory in the given engine.
   591  DBStatus DBEnvOpenDirectory(DBEngine* db, DBSlice path, DBDirectory* file);
   592  
   593  // DBEnvSyncDirectory syncs a DBDirectory in the given engine.
   594  DBStatus DBEnvSyncDirectory(DBEngine* db, DBDirectory file);
   595  
   596  // DBEnvCloseDirectory closes a DBDirectory in the given engine.
   597  DBStatus DBEnvCloseDirectory(DBEngine* db, DBDirectory file);
   598  
   599  // DBEnvRenameFile renames oldname to newname using the given engine.
   600  DBStatus DBEnvRenameFile(DBEngine* db, DBSlice oldname, DBSlice newname);
   601  
   602  // DBEnvCreateDir creates a directory with name.
   603  DBStatus DBEnvCreateDir(DBEngine* db, DBSlice name);
   604  
   605  // DBEnvDeleteDir deletes the directory with name.
   606  DBStatus DBEnvDeleteDir(DBEngine* db, DBSlice name);
   607  
   608  // DBListDirResults is the contents of a directory.
   609  typedef struct {
   610    DBStatus status;
   611    DBString* names;
   612    int n;
   613  } DBListDirResults;
   614  
   615  // DBEnvListDir lists the contents of the directory with name.
   616  DBListDirResults DBEnvListDir(DBEngine* db, DBSlice name);
   617  
   618  
   619  // DBDumpThreadStacks returns the stacks for all threads. The stacks
   620  // are raw addresses, and do not contain symbols. Use addr2line (or
   621  // atos on Darwin) to symbolize.
   622  DBString DBDumpThreadStacks();
   623  
   624  #ifdef __cplusplus
   625  }  // extern "C"
   626  #endif