From d8d77293cf52a5c896a9f91c01303519b78552dc Mon Sep 17 00:00:00 2001 From: peng Date: Thu, 8 Feb 2024 14:03:10 -0500 Subject: [PATCH] resource metadata is now sorted by key --- .../tribbloids/spookystuff/utils/io/Resource.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/parent/commons/src/main/scala/com/tribbloids/spookystuff/utils/io/Resource.scala b/parent/commons/src/main/scala/com/tribbloids/spookystuff/utils/io/Resource.scala index e9dd71bea..742f79d8b 100644 --- a/parent/commons/src/main/scala/com/tribbloids/spookystuff/utils/io/Resource.scala +++ b/parent/commons/src/main/scala/com/tribbloids/spookystuff/utils/io/Resource.scala @@ -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 @@ -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 }