rox v1.0.1 Rox

Elixir wrapper for RocksDB.

Summary

Functions

Gets an existing ColumnFamily.t from the database

Return the approximate number of keys in the database or specified column family

Create a column family in db with name and opts

Deletes the specified key from the provided database or column family

Get a key/value pair in the databse or column family with the specified key

Open a RocksDB with the optional db_opts and column_families

Put a key/value pair into the specified database or column family

Returns a Cursor.t which will iterate records from the provided database or column family

Types

access_hint()
access_hint() :: :normal | :sequential | :willneed | :none
block_based_table_options()
block_based_table_options() :: [no_block_cache: boolean, block_size: pos_integer, block_cache_size: pos_integer, bloom_filter_policy: bits_per_key :: pos_integer, format_version: 0 | 1 | 2, skip_table_builder_flush: boolean, cache_index_and_filter_blocks: boolean]
compaction_style()
compaction_style() :: :level | :universal | :fifo | :none
compression_type()
compression_type() :: :snappy | :zlib | :bzip2 | :lz4 | :lz4h | :none
db_options()
db_options() :: [total_threads: pos_integer, optimize_level_type_compaction_memtable_memory_budget: integer, auto_create_column_families: boolean, create_if_missing: boolean, max_open_files: pos_integer, compression_type: compression_type, use_fsync: boolean, bytes_per_sync: pos_integer, disable_data_sync: boolean, allow_os_buffer: boolean, table_cache_num_shard_bits: pos_integer, min_write_buffer_number: pos_integer, max_write_buffer_number: pos_integer, write_buffer_size: pos_integer, max_bytes_for_level_base: pos_integer, max_bytes_for_level_multiplier: pos_integer, max_manifest_file_size: pos_integer, target_file_size_base: pos_integer, min_write_buffer_number_to_merge: pos_integer, level_zero_file_num_compaction_trigger: non_neg_integer, level_zero_slowdown_writes_trigger: non_neg_integer, level_zero_stop_writes_trigger: non_neg_integer, compaction_style: compaction_style, max_background_compactions: pos_integer, max_background_flushes: pos_integer, disable_auto_compactions: boolean, report_bg_io_stats: boolean, num_levels: pos_integer]
file_path()
file_path() :: String.t
key()
key() :: String.t | binary
read_options()
read_options() :: [fill_cache: boolean, iterate_upper_bound: binary]
snapshot_handle()
value()
value() :: any
wal_recovery_mode()
wal_recovery_mode ::
  :tolerate_corrupted_tail_records |
  :absolute_consistency |
  :point_in_time_recovery |
  :skip_any_corrupted_records
write_options()
write_options() :: [sync: boolean, disable_wal: boolean]

Functions

cf_handle(db, name)
cf_handle(Rox.DB.t, Rox.ColumnFamily.name) ::
  {:ok, Rox.ColumnFamily.t} |
  {:error, any}

Gets an existing ColumnFamily.t from the database.

The column family must have been created via create_cf/2 or from open/3 with the auto_create_column_families option.

count(arg1)
count(Rox.DB.t | Rox.ColumnFamily.t) ::
  non_neg_integer |
  {:error, any}

Return the approximate number of keys in the database or specified column family.

Implemented by calling GetIntProperty with rocksdb.estimate-num-keys

create_cf(db, name, opts \\ [])
create_cf(Rox.DB.t, Rox.ColumnFamily.name, db_options) ::
  {:ok, Rox.ColumnFamily.t} |
  {:error, any}

Create a column family in db with name and opts.

delete(db_or_cf, key, write_opts \\ [])
delete(Rox.DB.t | Rox.ColumnFamily.t, key, write_options) ::
  :ok |
  {:error, any}

Deletes the specified key from the provided database or column family.

Optionally takes a list of write_opts.

get(db_or_cf, key, opts \\ [])
get(Rox.DB.t | Rox.ColumnFamily.t, key, read_options) ::
  {:ok, binary} |
  {:ok, value} |
  :not_found |
  {:error, any}

Get a key/value pair in the databse or column family with the specified key.

Optionally takes a list of read_options.

For non-binary terms that were stored, they will be automatically decoded.

open(path, raw_opts \\ [], column_families \\ [])
open(file_path, db_options, [Rox.ColumnFamily.name]) ::
  {:ok, Rox.DB.t} |
  {:ok, Rox.DB.t, %{optional(Rox.ColumnFamily.name) => Rox.ColumnFamily.t}} |
  {:error, any}

Open a RocksDB with the optional db_opts and column_families.

If column_families are provided, a 3 element tuple will be returned with the second element being a map of column family names to Rox.ColumnFamily handles. The column families must have already been created via create_cf or the option auto_create_column_families can be set to true. If it is, the db_opts will be used to create the column families.

The database will automatically be closed when the BEAM VM releases it for garbage collection.

put(db_or_cf, key, value, write_opts \\ [])
put(Rox.DB.t | Rox.ColumnFamily.t, key, value, write_options) ::
  :ok |
  {:error, any}

Put a key/value pair into the specified database or column family.

Optionally takes a list of write_options.

Non-binary values will automatically be encoded using the :erlang.term_to_binary/1 function.

stream(db_or_cf, mode \\ :start)
stream(Rox.DB.t | Rox.ColumnFamily.t, Iterator.mode) ::
  Rox.Cursor.t |
  {:error, any}

Returns a Cursor.t which will iterate records from the provided database or column family.

Optionally takes an Iterator.mode. Defaults to :start.

The default arguments of this function is used for the Enumerable implementation for DB and ColumnFamily structs.

Note: The result of stream is a cursor which is not meant to be shared across processes. Iterating over the cursor will result in an internal state in RocksDB being modified. If two processes try and use the same cursor, they will consume each others results. This may or may not be desired.