Package space.kscience.dataforge.io

Types

Binary
Link copied to clipboard
common
interface Binary

Binary represents a fixed-size multi-read byte block, which is not attached to the Input which was used to create it. The binary could be associated with a resource, but it should guarantee that when someone is trying to read the binary, this resource is re-acquired.

BinaryView
Link copied to clipboard
common
class BinaryView(source: Binary, start: Int, size: Int) : Binary

View section of a Binary as an independent binary

Consumer
Link copied to clipboard
common
interface Consumer

A fire-and-forget consumer of messages

DoubleIOFormat
Link copied to clipboard
common
object DoubleIOFormat : IOFormat<Double> , IOFormatFactory<Double>
Envelope
Link copied to clipboard
common
interface Envelope
EnvelopeBuilder
Link copied to clipboard
common
class EnvelopeBuilder : Envelope
EnvelopeFormat
Link copied to clipboard
common
interface EnvelopeFormat : IOFormat<Envelope>
EnvelopeFormatFactory
Link copied to clipboard
common
@Type(id = "io.format.envelope")
interface EnvelopeFormatFactory : IOFormatFactory<Envelope> , EnvelopeFormat
EnvelopePart
Link copied to clipboard
common
data class EnvelopePart(binary: Binary, description: Meta?)
EnvelopeParts
Link copied to clipboard
common
typealias EnvelopeParts = List<EnvelopePart>
IOFormat
Link copied to clipboard
common
interface IOFormat<T : Any> : MetaRepr

And interface for reading and writing objects into with IO streams

IOFormatFactory
Link copied to clipboard
common
@Type(id = "io.format")
interface IOFormatFactory<T : Any> : Factory<IOFormat<T>> , Named, MetaRepr
IOPlugin
Link copied to clipboard
common
class IOPlugin(meta: Meta) : AbstractPlugin
JsonMetaFormat
Link copied to clipboard
common
class JsonMetaFormat(json: Json) : MetaFormat

A Json format for Meta representation

MetaFormat
Link copied to clipboard
common
interface MetaFormat : IOFormat<Meta>

A format for meta serialization

MetaFormatFactory
Link copied to clipboard
common
@Type(id = "io.format.meta")
interface MetaFormatFactory : IOFormatFactory<Meta> , MetaFormat
PartialEnvelope
Link copied to clipboard
common
data class PartialEnvelope(meta: Meta, dataOffset: UInt, dataSize: ULong?)

A partially read envelope with meta, but without data

ProxyEnvelope
Link copied to clipboard
common
class ProxyEnvelope(source: Envelope, meta: Meta) : Envelope

An envelope, which wraps existing envelope and adds one or several additional layers of meta

Responder
Link copied to clipboard
common
interface Responder

An object that could respond to external messages asynchronously

SimpleEnvelope
Link copied to clipboard
common
class SimpleEnvelope(meta: Meta, data: Binary?) : Envelope
TaggedEnvelopeFormat
Link copied to clipboard
common
class TaggedEnvelopeFormat(io: IOPlugin, version: TaggedEnvelopeFormat.VERSION) : EnvelopeFormat

A streaming-friendly envelope format with a short binary tag. TODO add description

TaglessEnvelopeFormat
Link copied to clipboard
common
class TaglessEnvelopeFormat(io: IOPlugin, meta: Meta) : EnvelopeFormat

A text envelope format with human-readable tag. TODO add description

Functions

append
Link copied to clipboard
fun Path.append(block: Output.() -> Unit)

Create a new file or append to exiting one with given output block

asBinary
Link copied to clipboard
fun Path.asBinary(): Binary
fun ByteArray.asBinary(): Binary
Binary
Link copied to clipboard
common
inline fun Binary(expectedSize: Int = 16, block: Output.() -> Unit): Binary
buildByteArray
Link copied to clipboard
common
inline fun buildByteArray(expectedSize: Int = 16, block: Output.() -> Unit): ByteArray
contentEquals
Link copied to clipboard
common
fun Envelope.contentEquals(other: Envelope): Boolean
dataEquals
Link copied to clipboard
common
fun Envelope.dataEquals(other: Envelope): Boolean
Envelope
Link copied to clipboard
common
fun EnvelopePart.envelope(format: EnvelopeFormat): Envelope
fun EnvelopePart.envelope(plugin: IOPlugin): Envelope

Represent envelope part by an envelope

envelopes
Link copied to clipboard
common
fun EnvelopeBuilder.envelopes(envelopes: List<Envelope>, format: EnvelopeFormat = TaggedEnvelopeFormat, separator: String = DEFAULT_MULTIPART_DATA_SEPARATOR)
get
Link copied to clipboard
common
operator fun Binary.get(range: IntRange): BinaryView
listOf
Link copied to clipboard
common
inline fun <T : Any> IOFormat.Companion.listOf(format: IOFormat<T>): IOFormat<List<T>>
metaEquals
Link copied to clipboard
common
fun Envelope.metaEquals(other: Envelope): Boolean
multipart
Link copied to clipboard
common
fun EnvelopeBuilder.multipart(parts: EnvelopeParts, separator: String = DEFAULT_MULTIPART_DATA_SEPARATOR)
parse
Link copied to clipboard
common
fun MetaFormat.parse(str: String): Meta
fun MetaFormatFactory.parse(str: String, formatMeta: Meta): Meta
parts
Link copied to clipboard
common
fun Envelope.parts(): EnvelopeParts
peekFileEnvelopeFormat
Link copied to clipboard
fun IOPlugin.peekFileEnvelopeFormat(path: Path): EnvelopeFormat?

Return inferred EnvelopeFormat if only one format could read given file. If no format accepts file, return null. If multiple formats accepts file, throw an error.

read
Link copied to clipboard
fun <R> Path.read(block: Input.() -> R): R
fun EnvelopeFormat.read(input: Input): Envelope
readBinary
Link copied to clipboard
common
fun Input.readBinary(size: Int): Binary
readEnvelope
Link copied to clipboard
fun Path.readEnvelope(format: EnvelopeFormat): Envelope
readEnvelopeFile
Link copied to clipboard
fun IOPlugin.readEnvelopeFile(path: Path, readNonEnvelopes: Boolean = false, formatPicker: IOPlugin.(Path) -> EnvelopeFormat? = IOPlugin::peekFileEnvelopeFormat): Envelope

Read and envelope from file if the file exists, return null if file does not exist.

readMetaFile
Link copied to clipboard
fun IOPlugin.readMetaFile(path: Path, formatOverride: MetaFormat? = null, descriptor: MetaDescriptor? = null): Meta

Read file containing meta using given formatOverride or file extension to infer meta type. If path is a directory search for file starting with meta in it

readObject
Link copied to clipboard
common
fun <T : Any> IOFormat<T>.readObject(binary: Binary): T
readRawString
Link copied to clipboard
common
fun Input.readRawString(size: Int): String
readSafeUtf8Line
Link copied to clipboard
common
fun Input.readSafeUtf8Line(): String
readUtf8String
Link copied to clipboard
common
fun Input.readUtf8String(): String
readWith
Link copied to clipboard
common
fun <T : Any> Input.readWith(format: IOFormat<T>): T
fun <T : Any> Binary.readWith(format: IOFormat<T>): T

Read given binary as object using given format

resolveIOFormat
Link copied to clipboard
inline fun <T : Any> IOPlugin.resolveIOFormat(): IOFormat<T>?

Resolve IOFormat based on type

rewrite
Link copied to clipboard
fun Path.rewrite(block: Output.() -> Unit)

Create a new file or replace existing one using given output block

toBinary
Link copied to clipboard
common
fun <T : Any> IOFormat<T>.toBinary(obj: T): Binary
toByteArray
Link copied to clipboard
common
fun Binary.toByteArray(): ByteArray

Produce a buildByteArray representing an exact copy of this Binary

toString
Link copied to clipboard
common
fun Meta.toString(format: MetaFormat): String
fun Meta.toString(formatFactory: MetaFormatFactory): String
view
Link copied to clipboard
common
fun Binary.view(start: Int, size: Int): BinaryView
withMetaLayers
Link copied to clipboard
common
fun Envelope.withMetaLayers(vararg layers: Meta): Envelope

Add few meta layers to existing envelope (on top of existing meta)

write
Link copied to clipboard
fun Path.write(block: Output.() -> Unit)

Write a live output to a newly created file. If file does not exist, throws error

writeBinary
Link copied to clipboard
common
fun Output.writeBinary(binary: Binary): Int

Direct write of binary to the output. Returns the number of bytes written

writeEnvelopeDirectory
Link copied to clipboard
fun IOPlugin.writeEnvelopeDirectory(path: Path, envelope: Envelope, metaFormat: MetaFormatFactory = JsonMetaFormat)

Write separate meta and data files to given directory path

writeEnvelopeFile
Link copied to clipboard
fun IOPlugin.writeEnvelopeFile(path: Path, envelope: Envelope, envelopeFormat: EnvelopeFormat = TaggedEnvelopeFormat, metaFormat: MetaFormatFactory? = null)

Write envelope file to given path using envelopeFormat and optional metaFormat

writeMetaFile
Link copied to clipboard
fun IOPlugin.writeMetaFile(path: Path, meta: Meta, metaFormat: MetaFormatFactory = JsonMetaFormat, descriptor: MetaDescriptor? = null)

Write meta to file using metaFormat. If path is a directory, write a file with name equals name of metaFormat. Like "meta.json"

writeRawString
Link copied to clipboard
common
fun Output.writeRawString(str: String)
writeToFile
Link copied to clipboard
fun <T : Any> IOFormat<T>.writeToFile(path: Path, obj: T)

Write a binary into file. Throws an error if file already exists

writeUtf8String
Link copied to clipboard
common
fun Output.writeUtf8String(str: String)
writeWith
Link copied to clipboard
common
fun <T : Any> Output.writeWith(format: IOFormat<T>, obj: T)

Properties

DATA_FILE_NAME
Link copied to clipboard
val IOPlugin.Companion.DATA_FILE_NAME: String
dataID
Link copied to clipboard
common
val Envelope.dataID: String?

An optional unique identifier that is used for data comparison. Data without identifier could not be compared to another data.

dataType
Link copied to clipboard
common
val Envelope.dataType: String?

The type of data encoding

description
Link copied to clipboard
common
val Envelope.description: String?

Textual user friendly description

io
Link copied to clipboard
common
val Context.io: IOPlugin
META_FILE_NAME
Link copied to clipboard
val IOPlugin.Companion.META_FILE_NAME: String
name
Link copied to clipboard
common
val EnvelopePart.name: String?
type
Link copied to clipboard
common
val Envelope.type: String?

The purpose of the envelope