-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaggregrator.erl
40 lines (32 loc) · 1.32 KB
/
aggregrator.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
%%%----------------------------------------------------
%%% Copyright AnalyzERL 2011
%%% All rights reserved. No part of this computer programs(s) may be
%%% used, reproduced,stored in any retrieval system, or transmitted,
%%% in any form or by any means, electronic, mechanical, photocopying,
%%% recording, or otherwise without prior written permission of
%%% the authors
%%%---------------------------------------------------------------------
%%%---------------------------------------------------------------------
%%% Revision History
%%%---------------------------------------------------------------------
%%% Revision 1.0 Author: Souvik Ray ([email protected])
%%%---------------------------------------------------------------------
-module(aggregrator).
-compile(export_all).
-define(DEBUGFILE, "debug.txt").
% This is the aggregrator
% Data is of the format: ["word",freq]
init(Data) ->
["empty",erlang:list_to_integer(Data)].
terminate() ->
ok.
handle_event(Event, Data) ->
{ok, Fdd} = file:open(?DEBUGFILE, [append]),
io:fwrite(Fdd, "~p~n", ["Aggregrator: Event handling"]),
io:fwrite(Fdd, "~p~n", [Event]),
io:fwrite(Fdd, "~p~n", [Data]),
file:close(Fdd),
[Event, lists:nth(2,Data) + 1].
%Data is of the format [Word, Freq]
output(Data) ->
{erlang:integer_to_list(random:uniform(3)),"wordfreqsort",Data}.