Skip to content

Commit

Permalink
More info for running examples from Scala.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalohlava committed Mar 19, 2014
1 parent b745c47 commit fedf6b6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions h2o-scala/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ You can start REPL via ``sbt``:

sbt run

Launch Examples
-----------
Shalala provides a convenient way to run examples via ``sbt``:

::

sbt runExamples


Key points of implementation
----------------------------
Expand Down
8 changes: 8 additions & 0 deletions h2o-scala/src/main/scala/water/api/dsl/MRLegos.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package water.api.dsl

/**
* Created by michal on 3/19/14.
*/
class MRLegos {

}
35 changes: 35 additions & 0 deletions h2o-scala/src/main/scala/water/api/dsl/SMRTask.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package water.api.dsl

import water.fvec.Chunk
import water.MRTask2

abstract class SMRTask[T] extends MRTask2[T] {
def iterator(chunks:Array[Chunk]) : Iterator[Row] = new RowIterator(chunks)

private class RowIterator (private val chunks:Array[Chunk]) extends Iterator[Row] {
private var rowNum: Int = -1
private val row = new CRow
def next() : Row = {
rowNum += 1
return if (rowNum < chunks(0)._len) row else null
}
def hasNext() : Boolean = rowNum+1 < chunks(0)._len

/** Array of chunks encapsulation */
class CRow extends Row {
override def d(ncol: Int): scala.Double = chunks(ncol).at0 (rowNum)
override def l(ncol: Int): scala.Long = chunks(ncol).at80(rowNum)
override def ncols(): Int = chunks.length
}
}

/** Row accessor. */
trait Row {
def d(ncol:Int):scala.Double
def l(ncol:Int):scala.Long
def ncols() : Int
}
}



0 comments on commit fedf6b6

Please sign in to comment.