ebils -erlangバイナリ軽量検索
純粋なエルランへの大規模で巨大なバイナリの単一のバイナリ検索で、これは単一のプロセスを使用してそれらを検索し、メインプロセスにメッセージを配信するために、小さなバイナリを使用します。
大型バイナリの単一のテストでは、この方法は単一のbinary:match 、プロセスで結果を求めます。
単一の例:
1 > { ok , File } = file : read_file ( " test.data " ).
{ ok ,<< " AAAAAAAA|J|89 n BBBBBBBB|J|89 n CCCCCCC|J|89 n DDDDDDDD|J|89 n EEEEEEE|J|89 n FFFFFFFF|J|89 n " ...>>}
2 > byte_size ( File ).
234179947
3 > ebils : load ( File , << " n " >>).
true
4 > timer : tc ( ebils , search , [<< " ZbZbZbZbZb " >>]).
{ 4031 ,{{ ok ,{ 2341677 , 13 }, < 0.161 . 0 > }}
5 > { Found , Pid } = ebils : search (<< " ZbZbZbZbZb " >>).
{ ok ,{ 2341677 , 13 }, < 0.160 . 0 > }
6 > ebils : fetch ( Pid , { get , { found , Found }, 4 }).
{ ok ,<< " ZbZbZbZbZb|J|89 " >>}例では:
試合を求めるために使用するためにバイナリをシステムにロードします。労働者の名前、バイナリを処理するために作成された労働者の長さ、パターンを分割するためにパターンを指定できます。
ebils:load(Binary::binary(), Pattern::binary()) -> true
ebils:load(Name::atom(), Binary::binary(), Pattern::binary()) -> true
ebils:load(Name::atom(), Binary::binary(), Pattern::binary(), Workers::non_neg_integer()) -> true
プリロードされたバイナリに単一のバイナリを検索すると、労働者の名前と名前を指定できます(ebilsのデフォルト名、ebils:search/1)
ebils:search(Binary::binary()) -> {ok, {non_neg_integer(), non_neg_integer()}, pid()}
ebils:search(Name::atom(), Binary()) -> {ok, {non_neg_integer(), non_neg_integer()}, pid()}
バイナリが見つかったプロセスからデータを取得します。見つけたデータと検出されたデータのタプルを見つけたPIDを使用して、単純なgen_serverコールを使用します。また、取得するデータのサイズを含む3番目のパラメーターを提供する必要があります。
ebils:fetch(pid(), {get, {found, {non_neg_integer(), non_neg_integer}}, integer}) -> {ok, binary()}
プロセスに保持されているすべてのデータをアンロードしてプロセスを殺し、労働者の名前を指定できます。この方法はデータを再実行するのに役立ちます(バイナリが変更された場合)
ebils:unload() -> ok
ebils:unload(Name::atom()) -> ok
彼らの州の新しいバイナリでチャンクと労働者(プロセス)をリフレッシュする
ebils:reload(Binary :: binary() | [binary(), ...], Pattern :: binary()) -> ok
ebils:reload(Name :: atom(), Binary :: binary() | [binary(), ...], Pattern :: binary()) -> ok
ebils:reload(Name :: atom(), Binary :: binary() | [binary(), ...], Pattern :: binary(), Workers :: non_neg_integer()) -> ok