Use MapReduce or other distributed computation method for an analytics calculation?
===

Let's say I have three basic models: a User, a Company, and a Visit.   Every time a User goes to a Company, a Visit is recorded in this format `(user_id, company_id, visit_date)`.

I'd like to be able to calculate the average time between visits for a company.  Not visits overall, but specifically how long on average one of their customers waits before returning to the store.

For example, if one user visited on Tuesday, Wednesday, and Friday that gives one "gap" of one day, and one "gap" of two days => (1, 2).  If another user visited on Monday and Friday, that gives one gap of 4 days => (4).  If a third user visited only once, he should not be considered.  The average time between user visits for the company is (1 + 2 + 4) / 3 = 2.333 days.

If I have thousands of users, taps, and companies and I want to calculate a single figure for each company, how should I go about this?  I've only done basic MapReduce applications before and I can't figure out what my Map and Reduce steps would be to get this done.  Can anyone help me figure out a MapReduce in pseudocode?  Or is there some other method of distributed calculation I can reasonably perform?  For the record, I'd like to perform this operation on my database every night.