Эх сурвалжийг харах

[livy] Allow negative offsets to scroll backwards through a log

Erick Tryzelaar 10 жил өмнө
parent
commit
6eb58e6c93

+ 5 - 1
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/batch/BatchServlet.scala

@@ -109,8 +109,12 @@ private object Serializers {
                      fromOpt: Option[Int],
                      fromOpt: Option[Int],
                      sizeOpt: Option[Int]): JValue = {
                      sizeOpt: Option[Int]): JValue = {
     val lines = batch.lines
     val lines = batch.lines
+
     val size = sizeOpt.getOrElse(10)
     val size = sizeOpt.getOrElse(10)
-    val from = fromOpt.getOrElse(math.max(0, lines.length - 10))
+    var from = fromOpt.getOrElse(-1)
+    if (from < 0) {
+      from = math.min(0, lines.length - size)
+    }
     val until = from + size
     val until = from + size
 
 
     ("id", batch.id) ~
     ("id", batch.id) ~