使用聚合框架,获取每个分组最大字段值的文档的最佳方法是什么,因此使用下面的集合我希望能够为每个具有最新日期的group_id返回一个文档.第二个清单显示了所需的结果.
group_id date
1 11/1/12
1 11/2/12
1 11/3/12
2 11/1/12
3 11/2/12
3 11/3/12
Run Code Online (Sandbox Code Playgroud)
期望的结果
group_id date
1 11/3/12
2 11/1/12
3 11/3/12
Run Code Online (Sandbox Code Playgroud) 鉴于以前在此处发布的问题的以下答案,我如何更改fac函数以获取构造函数参数?
class BalanceActor[T <: Actor](val fac: () => T) extends Actor {
val workers: Int = 10
private lazy val actors = new Array[T](workers)
override def start() = {
for (i <- 0 to (workers - 1)) {
actors(i) = fac() //use the factory method to instantiate a T
actors(i).start
}
super.start()
}
}
Run Code Online (Sandbox Code Playgroud)