Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: rboccuzziIf performance isn't a concern, you can create a BRAINscript/dict solution using an agg. The problem with this solution is, the dict has to get re-created each iteration through, which could get expensive, depending on the number of values.
You would peg the GroupBy to 1, and here is the BRAINscript code for the agg node:
key = 'type'
value = id
if firstExec then
{
d = dict()
l = list()
}
if not d.inDict(key) then
{
l = l.append(key)
d = d.dictStore(key, value)
}
else
d = d.dictStore(key, value + d.dictRetrieve(key))
output 1 {
emit key, value
where False
}
if lastInGroup then {
i = 0
e = len(l)
while (i < e) {
key = l[i]
value = d.dictRetrieve(key)
do output 1 {
emit key, value
}
i = i + 1
}
}