Commit 7f76ee7e authored by Noric Couderc's avatar Noric Couderc

Improved code for function

uses flatmap instead of mapvalues and them toList
parent 1e09195c
......@@ -47,17 +47,18 @@ class TraceLoader {
else CSVParser(reader, CSVFormat.DEFAULT.withHeader())
// We group traces by : location (in the code) and target type.
val grouped =
parser.groupBy { r -> ImmutablePair(r["location"], r["id"])}
val grouped = parser.groupBy {r -> r["id"]}
return grouped.flatMap { e ->
val location = e.value.first()["location"]!!
val objectId = Integer.parseInt(e.key)
val targetType = e.value.first()["target_type"]!!
val methods = e.value.sortedBy { it["step"] }
.map { it["method"]!!}
listOf(TraceData(location, objectId, targetType, methods.toMutableList()))
}
}
val traces = grouped.mapValues {
e -> val location = e.key.left!!
val object_id = Integer.parseInt(e.key.right)
val target_type = e.value.first()["target_type"]!!
val methods = e.value.sortedBy { it["step"] }
.map { it["method"]!!}
TraceData(location, object_id, target_type, methods)
}.toList().map { it.second }
return traces
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment