rox v2.3.0 Rox
Elixir wrapper for RocksDB.
Link to this section Summary
Functions
Gets an existing ColumnFamily.t from the database or snapshot.
Return the approximate number of keys in the database or specified column family.
Create a column family in db with name and opts.
Creates a point-in-time snapshot of the given DB.
Deletes the specified key from the provided database or column family.
Get a key/value pair in the given column family of the given snapshot or database with the
specified key.
Lists the existing column family names of the database at the given path.
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.
Returns a Cursor.t which will iterate keys from the provided database or column family.
Link to this section Types
access_hint()
access_hint() :: :normal | :sequential | :willneed | :none
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()
]
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
compaction_style() :: :level | :universal | :fifo | :none
compression_type()
compression_type() :: :snappy | :zlib | :bzip2 | :lz4 | :lz4h | :none
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(),
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(),
use_direct_io_for_flush_and_compaction: boolean()
]
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(), 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(), use_direct_io_for_flush_and_compaction: boolean() ]
file_path()
file_path() :: String.t()
file_path() :: String.t()
key()
read_options()
snapshot_handle() (opaque)
value()
value() :: any()
value() :: any()
wal_recovery_mode()
wal_recovery_mode() ::
:tolerate_corrupted_tail_records
| :absolute_consistency
| :point_in_time_recovery
| :skip_any_corrupted_records
wal_recovery_mode() :: :tolerate_corrupted_tail_records | :absolute_consistency | :point_in_time_recovery | :skip_any_corrupted_records
write_options()
Link to this section Functions
cf_handle(db, name)
cf_handle(Rox.DB.t() | Rox.Snapshot.t(), Rox.ColumnFamily.name()) ::
{:ok, Rox.ColumnFamily.t()} | {:error, any()}
cf_handle(Rox.DB.t() | Rox.Snapshot.t(), Rox.ColumnFamily.name()) :: {:ok, Rox.ColumnFamily.t()} | {:error, any()}
Gets an existing ColumnFamily.t from the database or snapshot.
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()}
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_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.
create_snapshot(db)
create_snapshot(Rox.DB.t()) :: {:ok, Rox.Snapshot.t()} | {:error, any()}
create_snapshot(Rox.DB.t()) :: {:ok, Rox.Snapshot.t()} | {:error, any()}
Creates a point-in-time snapshot of the given DB.
Snapshots are read only views of the database at a point in time - no changes to the database will be reflected in the view of the snapshot.
delete(db_or_cf, key, write_opts \\ [])
delete(Rox.DB.t() | Rox.ColumnFamily.t(), key(), write_options()) ::
:ok | {:error, any()}
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_snapshot_or_cf, key, opts \\ [])
get(
Rox.DB.t() | Rox.ColumnFamily.t() | Rox.Snapshot.t(),
key(),
read_options()
) :: {:ok, value()} | :not_found | {:error, any()}
get( Rox.DB.t() | Rox.ColumnFamily.t() | Rox.Snapshot.t(), key(), read_options() ) :: {:ok, value()} | :not_found | {:error, any()}
Get a key/value pair in the given column family of the given snapshot or database with the
specified key.
Optionally takes a list of read_options.
For non-binary terms that were stored, they will be automatically decoded.
list_cf(path, opts \\ [])
list_cf(file_path(), db_options()) :: {:ok, Enum.t()} | {:error, any()}
list_cf(file_path(), db_options()) :: {:ok, Enum.t()} | {:error, any()}
Lists the existing column family names of the database at the given path.
open(path, db_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(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(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(), Rox.Cursor.mode()) ::
Rox.Cursor.t() | {:error, any()}
stream(Rox.DB.t() | Rox.ColumnFamily.t(), Rox.Cursor.mode()) :: Rox.Cursor.t() | {:error, any()}
Returns a Cursor.t which will iterate records from the provided database or
column family.
Optionally takes an Rox.Cursor.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.
stream_keys(db_or_cf, mode \\ :start)
stream_keys(Rox.DB.t() | Rox.ColumnFamily.t(), Rox.Cursor.mode()) ::
Rox.Cursor.t() | {:error, any()}
stream_keys(Rox.DB.t() | Rox.ColumnFamily.t(), Rox.Cursor.mode()) :: Rox.Cursor.t() | {:error, any()}
Returns a Cursor.t which will iterate keys from the provided database or column family.
Optionally takes a Rox.Cursor.mode, which defaults to :start.
Note: The result of stream_keys 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.