Column tables to kotlin

This commit is contained in:
Alexander Nozik 2018-08-30 22:07:09 +03:00
parent 4fd269e8ff
commit 9e3dcd08d1
2 changed files with 6 additions and 9 deletions

View File

@ -7,9 +7,7 @@ import hep.dataforge.meta.Meta
import hep.dataforge.names.Name import hep.dataforge.names.Name
import hep.dataforge.storage.Storage import hep.dataforge.storage.Storage
import hep.dataforge.storage.StorageElement import hep.dataforge.storage.StorageElement
import hep.dataforge.storage.StorageManager
import inr.numass.data.api.NumassSet import inr.numass.data.api.NumassSet
import inr.numass.data.storage.NumassDirectory.Companion.NUMASS_DIRECTORY_TYPE
import kotlinx.coroutines.experimental.runBlocking import kotlinx.coroutines.experimental.runBlocking
import kotlin.coroutines.experimental.buildSequence import kotlin.coroutines.experimental.buildSequence
@ -37,9 +35,8 @@ class NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
} }
override fun fill(builder: DataNodeEditor<NumassSet>, context: Context, meta: Meta) { override fun fill(builder: DataNodeEditor<NumassSet>, context: Context, meta: Meta) {
val newMeta = meta.builder.setValue("type", NUMASS_DIRECTORY_TYPE)
runBlocking { runBlocking {
val storage = context.load(StorageManager::class.java, Meta.empty()).create(newMeta) as Storage val storage = NumassDirectory.read(context,meta.getString("path")) as Storage
storage.sequence().forEach { pair -> storage.sequence().forEach { pair ->
val value = pair.second val value = pair.second
if (value is NumassSet) { if (value is NumassSet) {

View File

@ -39,6 +39,8 @@ object TransformDataAction : OneToOneAction<Table, Table>("numass.transform", Ta
override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table { override fun execute(context: Context, name: String, input: Table, meta: Laminate): Table {
var table = ColumnTable.copy(input)
val corrections = ArrayList<Correction>() val corrections = ArrayList<Correction>()
meta.optMeta("corrections").ifPresent { cors -> meta.optMeta("corrections").ifPresent { cors ->
@ -59,19 +61,17 @@ object TransformDataAction : OneToOneAction<Table, Table>("numass.transform", Ta
}) })
} }
var table = ColumnTable.copy(input)
for (correction in corrections) { for (correction in corrections) {
//adding correction columns //adding correction columns
if (!correction.isAnonymous) { if (!correction.isAnonymous) {
table = table.buildColumn(ColumnFormat.build(correction.name, NUMBER)) { correction.corr(it) } table = table.buildColumn(ColumnFormat.build(correction.name, NUMBER)) { correction.corr(this) }
if (correction.hasError()) { if (correction.hasError()) {
table = table.buildColumn(ColumnFormat.build(correction.name + ".err", NUMBER)) { correction.corrErr(it) } table = table.buildColumn(ColumnFormat.build(correction.name + ".err", NUMBER)) { correction.corrErr(this) }
} }
} }
} }
// adding original count rate and error columns // adding original count rate and error columns
table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_KEY.orig", NUMBER), table.getColumn(COUNT_RATE_KEY).stream())) table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_KEY.orig", NUMBER), table.getColumn(COUNT_RATE_KEY).stream()))
table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_ERROR_KEY.orig", NUMBER), table table = table.addColumn(ListColumn(ColumnFormat.build("$COUNT_RATE_ERROR_KEY.orig", NUMBER), table