Packages

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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CursoredStatement
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def apply[T](rowsPerFetch: Int, params: Parameter*)(f: (Row) => T): Future[CursorResult[T]]

    Executes the cursored statement with the given params and lazily maps f over the rows as they are streamed from the database.

    Executes the cursored statement with the given params and lazily maps f 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

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final def asJava: AsJava

    Provides a Java-friendly API for this CursoredStatement.

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped