-
Notifications
You must be signed in to change notification settings - Fork 187
Asynchronous iterators
Flavian Alexandru edited this page May 30, 2016
·
3 revisions
Phantom comes packed with CQL rows asynchronous lazy iterators to help you deal with billions of records. phantom iterators are based on Play iterators with very lightweight integration.
The functionality is identical with respect to asynchronous, lazy behaviour and available methods. For more on this, see this Play tutorial
Usage is trivial. If you want to use slice, take or drop
with iterators, the partitioner needs to be ordered. This is an extremely important easy to neglect fact. Do not rely on Cassandra to guarantee that data will be retrieved in the same order you write it in as the default Murmur3Partitioner
doesn't do that.
import scala.concurrent.Await
import scala.concurrent.duration._
import com.websudos.phantom.dsl._
sealed class ExampleRecord3 extends CassandraTable[ExampleRecord3, ExampleModel] {
object id extends UUIDColumn(this) with PartitionKey[UUID]
object order_id extends LongColumn(this) with ClusteringOrder[Long] with Descending
object timestamp extends DateTimeColumn(this) with PrimaryKey[DateTime]
object name extends StringColumn(this) with PrimaryKey[String]
object props extends MapColumn[ExampleRecord2, ExampleRecord, String, String](this)
object test extends OptionalIntColumn(this)
override def fromRow(row: Row): ExampleModel = {
ExampleModel(id(row), name(row), props(row), timestamp(row), test(row));
}
}
object ExampleRecord3 extends ExampleRecord3 {
def getRecords(start: Int, limit: Int): Future[Set[ExampleModel]] = {
select.fetchEnumerator.slice(start, limit).collect
}
}
To stay up-to-date with our latest releases and news, follow us on Twitter: @outworkers.
- Issues and questions
- Adopters
- Roadmap
- Changelog
- Tutorials
- Commercial support
- Using phantom in your project
- Primitive columns
- Optional primitive columns
- Collection columns
- Collection operators
- Automated schema generation
- Indexing columns
- Data modeling with phantom
- Querying with phantom
- Asynchronous iterators
- Batch statements
- Apache Thrift integration
- Apache ZooKeeper integration
- The phantom testkit