Created
August 19, 2014 12:05
-
-
Save rnewson/27de51b81ad0541e8a94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12:37 <Baz___> Specifically, I have ratings ({ accountID, itemID, rating }) and am trying to find out how many times pairs of users rated the same items: [{ accountID1, accountID2, numTimesRatedSameItem }] | |
map: | |
emit([doc.itemID, doc.accountID]); | |
reduce: | |
var permute = function(arr) { | |
// return an array of every pair of values in arr, | |
// each array item is sorted. | |
}; | |
if (!rereduce) { | |
var result = []; | |
var items = unique values from all keys[0]; | |
for (var item in items) { | |
var accountsForItem = sorted array of accountID's for this item | |
for (var permutation in permute(accountsForItem)) { | |
emit(permutation, 1); | |
} | |
} | |
return result; | |
} else { | |
return sum(values); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment