ProductStream

com.phasmidsoftware.lascala.parser.ProductStream
See theProductStream companion object
trait ProductStream[X <: Product]

ProductStream is a monadic trait which provides a Stream of Tuples (tuples) and a Header (header). Thus it is well-suited for use as an ingest mechanism of CSV files.

The polymorphic type X is a Tuple of some count. Please note that type inference is not able to infer this type from reading the file (which doesn't happen until runtime). Therefore, the caller must supply the type of X. Please see ProductStreamSpec for exemplars.

Please see inline method documentation for details of other methods.

Type parameters

X

the underlying type of this product stream: must be a sub-type of Product, that's to say, a Tuple or something similar

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class TupleStreamBase[X]
class CSV[X]
class TupleStream[X]

Members list

Value members

Abstract methods

def asMaps: Try[Stream[Map[String, Scalar]]]

Attributes

Returns

a Try of a Stream of Maps, each map corresponding to a row, such that the keys are the column names (from the header) and the values are the tuple values

def carper(s: String): Unit
def header: Header

Attributes

Returns

a sequence of String corresponding to the column names (left to right)

def tuples: Stream[X]

Attributes

Returns

a Stream of tuples

Concrete methods

def filter(p: X => Boolean): ProductStream[X]

filter method

filter method

Value parameters

p

predicate to be applied to each tuple

Attributes

Returns

a product stream which contains all of the elements from this that satisfy the predicate

def flatMap[Y <: Product](f: X => IterableOnce[Y]): ProductStream[Y]

flatMap method

flatMap method

Value parameters

f

function to be applied to each tuple

Attributes

Returns

a ProductStream of transformed tuples

def get(i: Int): Option[X]

Value parameters

i

get the ith row as a tuple

Attributes

Returns

Some(tuple) if i is valid, else None

def map[Y <: Product](f: X => Y): ProductStream[Y]

map method

map method

Value parameters

f

function to be applied to each tuple

Attributes

Returns

a ProductStream of transformed tuples

def toMap[K](pk: X => K): Map[K, X]

toMap method

toMap method

Value parameters

pk

function to yield a primary key value from a tuple

Attributes

Returns

a Map where each element is of form pk->tuple

Concrete fields

lazy val asList: List[X]

Attributes

Returns

a materialized (non-lazy) List version of the tuples.