Call remote tasks of service workspace #75
@ -1,15 +1,11 @@
|
||||
|
||||
package space.kscience.dataforge.distributed.serialization
|
||||
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
There is existing class for that There is existing class for that
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
There is existing class for that There is existing class for that
|
||||
import kotlinx.coroutines.Deferred
|
||||
There is existing class for that There is existing class for that
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import space.kscience.dataforge.data.Data
|
||||
import space.kscience.dataforge.data.Goal
|
||||
There is existing class for that There is existing class for that
|
||||
import space.kscience.dataforge.data.StaticData
|
||||
There is existing class for that There is existing class for that
|
||||
import space.kscience.dataforge.data.await
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
There is existing class for that There is existing class for that
|
||||
import space.kscience.dataforge.meta.MetaSerializer
|
||||
import kotlin.reflect.KType
|
||||
|
||||
@ -22,10 +18,10 @@ internal data class DataPrototype(
|
||||
There is existing class for that There is existing class for that
There is existing class for that There is existing class for that
|
||||
val data: String,
|
||||
) {
|
||||
fun <T : Any> toData(type: KType, serializer: KSerializer<T>): Data<T> =
|
||||
SimpleData(
|
||||
There is existing class for that There is existing class for that
|
||||
StaticData(
|
||||
There is existing class for that There is existing class for that
|
||||
type = type,
|
||||
value = Json.decodeFromString(serializer, data),
|
||||
There is existing class for that There is existing class for that
|
||||
meta = Json.decodeFromString(MetaSerializer, meta),
|
||||
data = Json.decodeFromString(serializer, data)
|
||||
There is existing class for that There is existing class for that
|
||||
)
|
||||
|
||||
companion object {
|
||||
@ -36,21 +32,3 @@ internal data class DataPrototype(
|
||||
There is existing class for that There is existing class for that
There is existing class for that There is existing class for that
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
There is existing class for that There is existing class for that
|
||||
/**
|
||||
There is existing class for that There is existing class for that
|
||||
* Trivial [Data] implementation.
|
||||
There is existing class for that There is existing class for that
|
||||
*/
|
||||
There is existing class for that There is existing class for that
|
||||
private class SimpleData<T : Any>(
|
||||
There is existing class for that There is existing class for that
|
||||
override val type: KType,
|
||||
There is existing class for that There is existing class for that
|
||||
override val meta: Meta,
|
||||
There is existing class for that There is existing class for that
|
||||
val data: T,
|
||||
There is existing class for that There is existing class for that
|
||||
) : Data<T> {
|
||||
There is existing class for that There is existing class for that
|
||||
override val dependencies: Collection<Goal<*>>
|
||||
There is existing class for that There is existing class for that
|
||||
get() = emptyList()
|
||||
There is existing class for that There is existing class for that
|
||||
|
||||
There is existing class for that There is existing class for that
|
||||
override val deferred: Deferred<T>
|
||||
There is existing class for that There is existing class for that
|
||||
get() = CompletableDeferred(data)
|
||||
There is existing class for that There is existing class for that
|
||||
|
||||
There is existing class for that There is existing class for that
|
||||
override fun async(coroutineScope: CoroutineScope): Deferred<T> = deferred
|
||||
There is existing class for that There is existing class for that
|
||||
override fun reset() = Unit
|
||||
There is existing class for that There is existing class for that
|
||||
}
|
||||
There is existing class for that There is existing class for that
|
||||
|
||||
There is existing class for that There is existing class for that
There is existing class for that There is existing class for that
|
@ -10,6 +10,7 @@ import space.kscience.dataforge.data.NamedData
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
import space.kscience.dataforge.data.asIterable
|
||||
import space.kscience.dataforge.data.component1
|
||||
import space.kscience.dataforge.data.component2
|
||||
import space.kscience.dataforge.data.named
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.dataforge.names.Name
|
||||
import kotlin.reflect.KType
|
||||
@ -23,7 +24,7 @@ internal data class DataSetPrototype(val meta: Meta, val data: Map<String, DataP
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
val data = data
|
||||
.mapKeys { (name, _) -> Name.of(name) }
|
||||
.mapValues { (_, dataPrototype) -> dataPrototype.toData(type, serializer) }
|
||||
return SerializableDataSetImpl(type, data, meta)
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
return SimpleDataSet(type, data, meta)
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -40,22 +41,16 @@ internal data class DataSetPrototype(val meta: Meta, val data: Map<String, DataP
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
/**
|
||||
* Trivial [DataSet] implementation.
|
||||
*/
|
||||
private class SerializableDataSetImpl<T : Any>(
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
private class SimpleDataSet<T : Any>(
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
override val dataType: KType,
|
||||
private val data: Map<Name, Data<T>>,
|
||||
override val meta: Meta,
|
||||
) : DataSet<T> {
|
||||
|
||||
/**
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
* Trivial named data implementation.
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
*/
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
private class SimpleNamedData<T : Any>(override val name: Name, override val data: Data<T>) :
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
NamedData<T>, Data<T> by data
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
override fun iterator(): Iterator<NamedData<T>> =
|
||||
data
|
||||
.asSequence()
|
||||
.map { (name, data) -> SimpleNamedData(name, data) }
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
.map { (name, data) -> data.named(name) }
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
||||
.iterator()
|
||||
|
||||
override fun get(name: Name): Data<T>? = data[name]
|
||||
|
||||
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
Again, you do not need a separate structure. All you need is a generic DataSet with serializer. Again, you do not need a separate structure. All you need is a generic DataSet with serializer.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
When When `ServiceWorkspace.execute` returns result to the client, it do not know yet about serializer for the `T`. Then `RemoteTask` uses serializer to deserialize DataSet from prototype.
|
There is existing class for that
There is existing class for that