Guest User

Untitled

a guest
Feb 25th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. trait Result
  2. trait BatchableOp[T <: BatchableOp[T]] {
  3. def resolve(batch: Vector[T]): Vector[Result]
  4. }
  5.  
  6. def execute(operations: Vector[BatchableOp[_]]): Vector[Result] = {
  7. def helper[T <: BatchableOp[T]](clazz: Class[T], batch: Vector[T]): Vector[Result] =
  8. batch.head.resolve(batch)
  9.  
  10. operations
  11. .groupBy(_.getClass)
  12. .toVector
  13. .flatMap { case (clazz, batch) => helper(clazz, batch)}
  14. }
Add Comment
Please, Sign In to add comment