From edf28d9e3461fc21de89e08fd022642afd3eb4ee Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Tue, 14 May 2024 11:00:44 -0600 Subject: [PATCH] address feedback --- spark/src/test/scala/org/apache/comet/CometCastSuite.scala | 2 +- spark/src/test/scala/org/apache/comet/DataGenerator.scala | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala index 6e7b2c0d3..50311a9b5 100644 --- a/spark/src/test/scala/org/apache/comet/CometCastSuite.scala +++ b/spark/src/test/scala/org/apache/comet/CometCastSuite.scala @@ -36,7 +36,7 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper { import testImplicits._ /** Create a data generator using a fixed seed so that tests are reproducible */ - private val gen = new DataGenerator(new Random(42)) + private val gen = DataGenerator.DEFAULT /** Number of random data items to generate in each test */ private val dataSize = 10000 diff --git a/spark/src/test/scala/org/apache/comet/DataGenerator.scala b/spark/src/test/scala/org/apache/comet/DataGenerator.scala index 19ef9eb9d..691a371b5 100644 --- a/spark/src/test/scala/org/apache/comet/DataGenerator.scala +++ b/spark/src/test/scala/org/apache/comet/DataGenerator.scala @@ -21,6 +21,13 @@ package org.apache.comet import scala.util.Random +object DataGenerator { + // note that we use `def` rather than `val` intentionally here so that + // each test suite starts with a fresh data generator to help ensure + // that tests are deterministic + def DEFAULT = new DataGenerator(new Random(42)) +} + class DataGenerator(r: Random) { /** Generate a random string using the specified characters */