rename type parameters and update doc to improve readability
add batching to avoid materializing input in memory
fix batching; add tests