added more test cases for MongoStorage and fixed bug in getMapStorageRangeFor

This commit is contained in:
debasishg 2009-08-13 16:41:14 +05:30
parent cbb1dc1de2
commit b7ef738c83
2 changed files with 125 additions and 30 deletions

View file

@ -104,6 +104,7 @@ object MongoStorage extends MapStorage
override def getMapStorageRangeFor(name: String, start: Option[AnyRef],
finish: Option[AnyRef],
count: Int): List[Tuple2[AnyRef, AnyRef]] = {
// @fixme: currently ignores finish
val m =
nullSafeFindOne(name) match {
case None =>
@ -113,7 +114,7 @@ object MongoStorage extends MapStorage
}
val s = start.get.asInstanceOf[Int]
val n =
List(m.keySet.toArray: _*).asInstanceOf[List[String]].slice(s, s + count)
List(m.keySet.toArray: _*).asInstanceOf[List[String]].sort((e1, e2) => (e1 compareTo e2) < 0).slice(s, s + count)
val vals =
for(s <- n)
yield (s, serializer.in(m.get(s).asInstanceOf[Array[Byte]], None))