function sum_single_bin(s)

    local function mapper(rec)
    	return rec['aggbin']
    end

    local function reducer(val1, val2)
        return val1 + val2
    end

    return s : map(mapper) : reduce(reducer)
end

local function mapper(rec)
	return rec['aggbin']
end

local function reducer(val1, val2)
	return val1 + val2
end

function sum_single_bin(stream)
	return stream : map(mapper) : reduce(reducer)
end

Put mapper and reducer out main example function for performance reasons.
Put mapper and reducer out main example function for performance reasons.
