Shifting

info.fingo.spata.io.Reader.Shifting
final class Shifting[F[_]] extends Reader[F]

Reader which shifts I/O operations to a thread pool provided for blocking operations. Uses the built-in internal blocking thread pool.

Type parameters

F

the effect type, with type classes providing support for suspended execution (typically cats.effect.IO), Async execution environment with blocking and non-blocking thread pools (to shift back and forth) and logging (provided internally by spata).

Value parameters

chunkSize

size of data chunk

Attributes

Graph
Supertypes
trait Reader[F]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def read(source: Source): Stream[F, Char]

Reads a CSV source and returns a stream of character.

Reads a CSV source and returns a stream of character.

The caller of this function is responsible for proper resource acquisition and release. This may be done with fs2.Stream.bracket.

Character encoding has to be handled while creating scala.io.Source.

Attributes

Note

This function may be less efficient than its non-shifting counterpart Plain.read, especially for small chunk sizes. This is due to scala.io.Source character-based iterator, which causes frequent thread shifts.

Example
val stream = Stream
 .bracket(IO(Source.fromFile("input.csv")))(source => IO(source.close()))
 .flatMap(Reader.shifting[IO].read)
def read(fis: F[InputStream])(using codec: Codec): Stream[F, Char]

Reads a CSV source and returns a stream of character.

Reads a CSV source and returns a stream of character.

Attributes

def read(is: InputStream)(using codec: Codec): Stream[F, Char]

Reads a CSV source and returns a stream of character.

Reads a CSV source and returns a stream of character.

Attributes

def read(path: Path)(using codec: Codec): Stream[F, Char]

Reads a CSV file and returns a stream of character.

Reads a CSV file and returns a stream of character.

Attributes

Example
given codec = new Codec(Charset.forName("ISO-8859-2"))
val path = Path.of("data.csv")
val stream = Reader.shifting[IO].read(path)

Inherited methods

def apply(fis: F[InputStream])(using codec: Codec): Stream[F, Char]

Alias for read.

Alias for read.

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

fis

input stream containing CSV content, wrapped in effect F to defer its creation

Attributes

Returns

the stream of characters

Inherited from:
Reader
def apply[A : CSV](csv: A)(implicit evidence$1: CSV[A], codec: Codec): Stream[F, Char]

Alias for various read methods.

Alias for various read methods.

Type parameters

A

type of source

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

csv

the CSV data

Attributes

Returns

the stream of characters

Inherited from:
Reader
def by[A : CSV](implicit evidence$2: CSV[A], codec: Codec): (F, A) => Char

Pipe converting stream with CSV source to stream of characters.

Pipe converting stream with CSV source to stream of characters.

Type parameters

A

type of source

Value parameters

codec

codec used to convert bytes to characters, with default JVM charset as fallback

Attributes

Returns

a pipe to converter CSV source into scala.Chars

Example
val stream = Stream
 .bracket(IO(Source.fromFile("input.csv")))(source => IO(source.close()))
 .through(Reader[IO].by)
Inherited from:
Reader

Concrete fields

override val chunkSize: Int

Size of data chunk loaded at once when reading from source. See also FS2 Chunks.

Size of data chunk loaded at once when reading from source. See also FS2 Chunks.

Attributes