Skip to content

Commit

Permalink
resource metadata is now sorted by key
Browse files Browse the repository at this point in the history
  • Loading branch information
tribbloid committed Feb 8, 2024
1 parent 5800f96 commit d8d7729
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.apache.commons.io.output.NullOutputStream
import org.apache.spark.ml.dsl.utils.LazyVar

import java.io.{IOException, InputStream, OutputStream}
import scala.collection.immutable.ListMap
import scala.language.implicitConversions
import scala.util.Try

Expand Down Expand Up @@ -91,17 +92,19 @@ abstract class Resource extends LocalCleanable {

final lazy val all: ResourceMetadata = {

val grouped = children
val grouped: Map[String, Seq[ResourceMetadata]] = children
.map(exe => exe.input(in => in.metadata.root))
.groupBy(_.asMap("Type").toString)

val childMaps: Map[String, Seq[Map[String, Any]]] = grouped.view.mapValues {
val childMaps = grouped.view.mapValues {
_.map { md =>
md.asMap
}
}.toMap
}

val result = root :++ ResourceMetadata._EAV(childMaps)
val sorted = ListMap(childMaps.toSeq.sortBy(_._1): _*)

val result = root :++ ResourceMetadata._EAV(sorted)
result
}

Expand Down

0 comments on commit d8d7729

Please sign in to comment.