From 7a5c41e9bdeb8cfced0ca34c98b01a4deb59c754 Mon Sep 17 00:00:00 2001 From: Matt Hicks Date: Fri, 5 Apr 2024 20:26:48 -0500 Subject: [PATCH] Minor updates to benchmarking --- benchmark/src/main/scala/benchmark/IMDBBenchmark.scala | 4 ++-- .../src/main/scala/benchmark/LightDBImplementation.scala | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/benchmark/src/main/scala/benchmark/IMDBBenchmark.scala b/benchmark/src/main/scala/benchmark/IMDBBenchmark.scala index 247d4cbb..1c80b15a 100644 --- a/benchmark/src/main/scala/benchmark/IMDBBenchmark.scala +++ b/benchmark/src/main/scala/benchmark/IMDBBenchmark.scala @@ -77,11 +77,11 @@ object IMDBBenchmark { // extends IOApp { val io = for { _ <- implementation.init() _ = scribe.info("--- Stage 1 ---") - akasFile <- downloadFile(new File(baseDirectory, "title.akas.tsv"), Limit.Unlimited).elapsed + akasFile <- downloadFile(new File(baseDirectory, "title.akas.tsv"), Limit.OneMillion).elapsed _ = scribe.info("--- Stage 2 ---") totalAka <- process(akasFile.value, implementation.map2TitleAka, implementation.persistTitleAka).elapsed _ = scribe.info("--- Stage 3 ---") - basicsFile <- downloadFile(new File(baseDirectory, "title.basics.tsv"), Limit.Unlimited).elapsed + basicsFile <- downloadFile(new File(baseDirectory, "title.basics.tsv"), Limit.OneMillion).elapsed _ = scribe.info("--- Stage 4 ---") totalBasics <- process(basicsFile.value, implementation.map2TitleBasics, implementation.persistTitleBasics).elapsed _ = scribe.info("--- Stage 5 ---") diff --git a/benchmark/src/main/scala/benchmark/LightDBImplementation.scala b/benchmark/src/main/scala/benchmark/LightDBImplementation.scala index 1d3b50be..d4b04148 100644 --- a/benchmark/src/main/scala/benchmark/LightDBImplementation.scala +++ b/benchmark/src/main/scala/benchmark/LightDBImplementation.scala @@ -18,6 +18,8 @@ object LightDBImplementation extends BenchmarkImplementation { override def name: String = "LightDB" + override def init(): IO[Unit] = db.init(truncate = true) + override def map2TitleAka(map: Map[String, String]): TitleAkaLDB = TitleAkaLDB( titleId = map.value("titleId"), ordering = map.int("ordering"), @@ -55,7 +57,7 @@ object LightDBImplementation extends BenchmarkImplementation { override def get(id: String): IO[TitleAkaLDB] = db.titleAka.get(Id[TitleAkaLDB](id)).map(_.getOrElse(throw new RuntimeException(s"$id not found"))) - override def findByTitleId(titleId: String): IO[List[TitleAkaLDB]] = db.titleAka.query.filter(TitleAkaLDB.titleId === titleId).search().compile.toList.flatMap(_.map(_.get()).sequence) + override def findByTitleId(titleId: String): IO[List[TitleAkaLDB]] = db.titleAka.query.filter(TitleAkaLDB.titleId === titleId).documentsStream().compile.toList override def flush(): IO[Unit] = for { _ <- db.titleAka.commit()