Packages
rocksdb
0.26.2
3.1.1
3.1.0
3.0.0
2.6.2
2.6.1
retired
2.6.0
retired
2.5.0
2.4.1
2.4.0
2.3.0
2.2.0
2.1.0
2.0.0
1.9.0
1.8.0
1.7.0
1.6.0
1.5.1
1.5.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.1
1.1.0
1.0.0
0.26.2
0.26.1
0.26.0
0.25.0
0.24.0
0.23.3
0.23.2
0.23.1
0.23.0
0.22.0
0.21.0
0.20.1
0.20.0
0.19.0
0.18.0
0.17.0
0.16.0
0.15.0
0.14.0
0.13.1
0.13.0
0.12.0
0.11.0
0.10.0
0.9.1
0.9.0
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
RocksDB for Erlang
Current section
Files
Jump to
Current section
Files
src/rocksdb_sst_file_manager.erl
%%% -*- erlang -*-
%%
%% Copyright (c) 2018 Benoit Chesneau
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
-module(rocksdb_sst_file_manager).
-export([
set_max_allowed_usage/2,
set_compaction_buffer_size/2,
is_max_allowed_space_reached/1,
is_max_allowed_space_reached_including_compactions/1,
get_total_size/1,
get_delete_rate_bytes_per_second/1,
set_delete_rate_bytes_per_second/2,
get_max_trash_db_ratio/1,
set_max_trash_db_ratio/2,
get_total_trash_size/1
]).
%% @doc Update the maximum allowed space that should be used by RocksDB, if
%% the total size of the SST files exceeds MaxAllowedSpace, writes to
%% RocksDB will fail.
%%
%% setting MaxAllowedSpace to 0 will disable this feature; maximum allowed
%% pace will be infinite (Default value).
-spec set_max_allowed_usage(rocksdb:sst_file_manager(), non_neg_integer()) -> ok.
set_max_allowed_usage(SstFileManager, MaxAllowedSpace) when is_integer(MaxAllowedSpace) ->
rocksdb:sst_file_manager_set(SstFileManager, "MaxAllowedSpaceUsage", MaxAllowedSpace).
%% @doc Set the amount of buffer room each compaction should be able to leave.
%% In other words, at its maximum disk space consumption, the compaction
%% should still leave compaction_buffer_size available on the disk so that
%% other background functions may continue, such as logging and flushing.
-spec set_compaction_buffer_size(rocksdb:sst_file_manager(), non_neg_integer()) -> ok.
set_compaction_buffer_size(SstFileManager, CompactionBufferSize) when is_integer(CompactionBufferSize) > 0 ->
rocksdb:sst_file_manager_set(SstFileManager, "CompactionBufferSize", CompactionBufferSize).
%% @doc Return true if the total size of SST files exceeded the maximum allowed
%% space usage.
-spec is_max_allowed_space_reached(rocksdb:sst_file_manager()) -> boolean().
is_max_allowed_space_reached(SstFileManager) ->
rocksdb:sst_file_manager_is(SstFileManager, "MaxAllowedSpaceReached").
%% @doc Returns true if the total size of SST files as well as estimated size
%% of ongoing compactions exceeds the maximums allowed space usage.
-spec is_max_allowed_space_reached_including_compactions(rocksdb:sst_file_manager()) -> boolean().
is_max_allowed_space_reached_including_compactions(SstFileManager) ->
rocksdb:sst_file_manager_is(SstFileManager, "MaxAllowedSpaceReachedIncludingCompactions").
%% @doc Return the total size of all tracked files.
-spec get_total_size(rocksdb:sst_file_manager()) -> non_neg_integer().
get_total_size(SstFileManager) ->
rocksdb:sst_file_manager_get(SstFileManager, "TotalSize").
%% @doc Return delete rate limit in bytes per second.
-spec get_delete_rate_bytes_per_second(rocksdb:sst_file_manager()) -> non_neg_integer().
get_delete_rate_bytes_per_second(SstFileManager) ->
rocksdb:sst_file_manager_get(SstFileManager, "DeleteRateBytesPerSecond").
%% @doc Update the delete rate limit in bytes per second.
%% zero means disable delete rate limiting and delete files immediately
-spec set_delete_rate_bytes_per_second(rocksdb:sst_file_manager(), non_neg_integer()) -> ok.
set_delete_rate_bytes_per_second(SstFileManager, DeleteRate) ->
rocksdb:sst_file_manager_set(SstFileManager, "DeleteRateBytesPerSecond", DeleteRate).
%% @doc Return trash/DB size ratio where new files will be deleted immediately
-spec get_max_trash_db_ratio(rocksdb:sst_file_manager()) -> float().
get_max_trash_db_ratio(SstFileManager) ->
rocksdb:sst_file_manager_get(SstFileManager, "MaxTrashDBRatio").
%% @doc Update trash/DB size ratio where new files will be deleted immediately
-spec set_max_trash_db_ratio(rocksdb:sst_file_manager(), float()) -> ok.
set_max_trash_db_ratio(SstFileManager, Ratio) ->
rocksdb:sst_file_manager_set(SstFileManager, "MaxTrashDBRatio", Ratio).
%% @doc Return the total size of trash files
-spec get_total_trash_size(rocksdb:sst_file_manager()) -> non_neg_integer().
get_total_trash_size(SstFileManager) ->
rocksdb:sst_file_manager_get(SstFileManager, "TotalTrashSize").