add reduce

add reduce and countBy.