Trait/Object

com.twitter.finagle.mysql

CursoredStatement

Related Docs: object CursoredStatement | package mysql

Permalink

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

PreparedStatement for eager processing of Rows.

Client.cursor(String

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. All

Abstract Value Members

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

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. final def asJava: AsJava

    Permalink

    Provides a Java-friendly API for this CursoredStatement.

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  17. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped