trait CursoredStatement extends AnyRef
A CursoredStatement
represents a parameterized SQL statement
applied concurrently with varying parameters and yields
a lazy stream of rows.
These are SQL statements with ?
's used for the parameters which are
"filled in" per usage by apply
.
- See also
Client.cursor(String
PreparedStatement for eager processing of Rows.
- Alphabetic
- By Inheritance
- CursoredStatement
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def apply[T](rowsPerFetch: Int, params: Parameter*)(f: (Row) => T): Future[CursorResult[T]]
Executes the cursored statement with the given
params
and lazily mapsf
over the rows as they are streamed from the database.Executes the cursored statement with the given
params
and lazily mapsf
over the rows as they are streamed from the database.For Scala users, you can use the implicit conversions to Parameter by importing
Parameter._
. For example:import com.twitter.finagle.mysql.{Client, CursorResult, CursoredStatement} import com.twitter.finagle.mysql.Parameter._ import com.twitter.concurrent.AsyncStream import com.twitter.util.Future val client: Client = ??? val cursoredStatement: CursoredStatement = client.cursor("SELECT int_column FROM a_table WHERE string_column = ?") val rowsToFetch = 100 val futureCursorResult: Future[CursorResult[Int]] = // note the implicit conversions of the String to Parameter cursoredStatement(rowsToFetch, "cool example") { row => row.intOrZero } futureCursorResult.foreach { cursorResult => val stream: AsyncStream[Int] = cursorResult.stream stream.take(5).foreach { i => println(s"Read int_column = '$i'"); }.ensure { cursorResult.close() } }
Java users, see asJava and use CursoredStatement.AsJava.execute.
- rowsPerFetch
should be picked to balance the minimum number of round trips to the database, and the maximum amount of memory used by an individual fetch.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def asJava: AsJava
Provides a Java-friendly API for this CursoredStatement.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()