<commit_before>
-module(ddfs_master).
-behaviour(gen_server).

-export([start_link/0, stop/0]).
-export([get_tags/1,
         get_nodeinfo/1,
         get_read_nodes/0,
         choose_write_nodes/2,
         new_blob/3,
         tag_operation/2, tag_operation/3,
         update_nodes/1
        ]).
-export([init/1,
         handle_call/3,
         handle_cast/2,
         handle_info/2,
         terminate/2,
         code_change/3]).

-define(WEB_PORT, 8011).

-include("config.hrl").

-type node_info() :: {node(), {non_neg_integer(), non_neg_integer()}}.
-record(state, {nodes :: [node_info()],
                tags :: gb_tree(),
                tag_cache :: 'false' | gb_set(),
                write_blacklist :: [node()],
                read_blacklist :: [node()]}).
-type state() :: #state{}.
-type replyto() :: {pid(), reference()}.

%% ===================================================================
%% API functions

start_link() ->
    error_logger:info_report([{"DDFS master starts"}]),
    case gen_server:start_link({local, ?MODULE}, ?MODULE, [], []) of
        {ok, Server} -> {ok, Server};
        {error, {already_started, Server}} -> {ok, Server}
    end.

stop() -> not_implemented.

-spec tag_operation(term(), nonempty_string() | binary()) -> term().
tag_operation(Op, Tag) ->
    gen_server:call(?MODULE, {tag, Op, Tag}).
-spec tag_operation(term(), nonempty_string() | binary(), non_neg_integer()) ->
                           term().
tag_operation(Op, Tag, Timeout) ->
    gen_server:call(?MODULE, {tag, Op, Tag}, Timeout).

-spec get_nodeinfo('all'|'filter') -> {'ok', {[node()], [node()], [binary()]}};
                  ('safe') -> {'ok', [binary()]} | 'too_many_failed_nodes'.

get_nodeinfo(Mode) ->
    gen_server:call(?MODULE, {get_nodeinfo, Mode}).

-spec get_read_nodes() -> {'ok', [node()], non_neg_integer()}.
get_read_nodes() ->
    gen_server:call(?MODULE, get_read_nodes).<commit_msg>dialyzer: fix an incorrect spec, and optimize a call<commit_after>-module(ddfs_master).
-behaviour(gen_server).

-export([start_link/0, stop/0]).
-export([get_tags/1,
         get_nodeinfo/1,
         get_read_nodes/0,
         choose_write_nodes/2,
         new_blob/3,
         tag_operation/2, tag_operation/3,
         update_nodes/1
        ]).
-export([init/1,
         handle_call/3,
         handle_cast/2,
         handle_info/2,
         terminate/2,
         code_change/3]).

-define(WEB_PORT, 8011).

-include("config.hrl").

-type node_info() :: {node(), {non_neg_integer(), non_neg_integer()}}.
-record(state, {nodes :: [node_info()],
                tags :: gb_tree(),
                tag_cache :: 'false' | gb_set(),
                write_blacklist :: [node()],
                read_blacklist :: [node()]}).
-type state() :: #state{}.
-type replyto() :: {pid(), reference()}.

%% ===================================================================
%% API functions

start_link() ->
    error_logger:info_report([{"DDFS master starts"}]),
    case gen_server:start_link({local, ?MODULE}, ?MODULE, [], []) of
        {ok, Server} -> {ok, Server};
        {error, {already_started, Server}} -> {ok, Server}
    end.

stop() -> not_implemented.

-spec tag_operation(term(), nonempty_string() | binary()) -> term().
tag_operation(Op, Tag) ->
    gen_server:call(?MODULE, {tag, Op, Tag}).
-spec tag_operation(term(), nonempty_string() | binary(), non_neg_integer()) ->
                           term().
tag_operation(Op, Tag, Timeout) ->
    gen_server:call(?MODULE, {tag, Op, Tag}, Timeout).

-spec get_nodeinfo('all') -> {'ok', [node_info()]}.
get_nodeinfo(all) ->
    gen_server:call(?MODULE, {get_nodeinfo, all}).

-spec get_read_nodes() -> {'ok', [node()], non_neg_integer()}.
get_read_nodes() ->
    gen_server:call(?MODULE, get_read_nodes).
{'fraction_non_alphanumeric': 0.22128333773435438, 'fraction_numerical': 0.010562450488513335, 'mean_word_length': 3.004228329809725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3690014', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1250, 'n_words': 232}