Parallel OLAP Cube Construction

Still tilting at windmills here, with my quest to calculate an OLAP cube still trotting along. Lately I’ve been using Erlang to see if I can use its concurrent programming abilities to scale the OLAP cube generation. The initial progress is promising, with clear concurrency complete.

I hope to post the majority of the code soon, after I run a few more tests. For now, here’s how I add two lists of numbers in Erlang. Please let me know if there’s a better way.

Update:

The best way to do this is (thanks to Daniel Larsson):


lists:zipwith(fun(X,Y) -> X+Y end, [1,2],[3,4])

Old ‘n busted way:


add_measures(OldMeasures, NewMeasures) ->
  add_measures(OldMeasures, NewMeasures, []).

add_measures([Old|OldRest], [New|NewRest], Accum) ->
  add_measures(OldRest, NewRest, [Old+New|Accum]);

add_measures([], [], Accum) -> lists:reverse(Accum).

4 Responses to “Parallel OLAP Cube Construction”

  1. Daniel Larsson Says:

    In haskell, there’s a function called zip which does what you want, not sure if Erlang has it, but I’d be a bit surprised if there wasn’t. Also, you’re not taking into account the case when the lists aren’t of equal length. Perhaps you know this can’t happen, but I’d stick in those cases too

  2. Daniel Larsson Says:

    Check lists:zipwith

  3. admin Says:

    Cool, I will! Thanks for the tip.

  4. admin Says:

    Clearly, I need to become more familiar with the erlang docs. :)

    lists:zipwith(fun(X, Y) -> X+Y end, [1,2,3], [4,5,6]).

Leave a Reply