Skip to content

Commit bf9497b

Browse files
authored
Reformat with sbt scalafmtall (#1014)
scala fmt all
1 parent 29d86b5 commit bf9497b

28 files changed

+516
-344
lines changed

aggregator/src/test/scala/ai/chronon/aggregator/test/ApproxHistogramTest.scala

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ class ApproxHistogramTest extends TestCase {
4141
assertTrue(ir2.isApprox)
4242

4343
val ir = approxHistogram.merge(ir1, ir2)
44-
assertEquals(toHashMap(Map(
45-
"4" -> 8,
46-
"6" -> 6,
47-
"5" -> 5
48-
)),
44+
assertEquals(toHashMap(
45+
Map(
46+
"4" -> 8,
47+
"6" -> 6,
48+
"5" -> 5
49+
)),
4950
approxHistogram.finalize(ir))
5051
assertTrue(ir.isApprox)
5152
assertTrue(ir.histogram.isEmpty)
@@ -64,11 +65,13 @@ class ApproxHistogramTest extends TestCase {
6465

6566
val ir = approxHistogram.merge(ir1, ir2)
6667

67-
assertEquals(toHashMap(Map(
68-
"2" -> 4,
69-
"4" -> 4,
70-
"3" -> 3
71-
)), approxHistogram.finalize(ir))
68+
assertEquals(toHashMap(
69+
Map(
70+
"2" -> 4,
71+
"4" -> 4,
72+
"3" -> 3
73+
)),
74+
approxHistogram.finalize(ir))
7275
assertTrue(!ir.isApprox)
7376
assertTrue(ir.sketch.isEmpty)
7477
}
@@ -86,11 +89,13 @@ class ApproxHistogramTest extends TestCase {
8689

8790
val ir = approxHistogram.merge(ir1, ir2)
8891

89-
assertEquals(toHashMap(Map(
90-
"4" -> 4,
91-
"3" -> 3,
92-
"2" -> 2
93-
)), approxHistogram.finalize(ir))
92+
assertEquals(toHashMap(
93+
Map(
94+
"4" -> 4,
95+
"3" -> 3,
96+
"2" -> 2
97+
)),
98+
approxHistogram.finalize(ir))
9499

95100
assertTrue(ir.isApprox)
96101
assertTrue(ir.histogram.isEmpty)
@@ -109,11 +114,13 @@ class ApproxHistogramTest extends TestCase {
109114

110115
val ir = approxHistogram.merge(ir1, ir2)
111116

112-
assertEquals(toHashMap(Map(
113-
"5" -> 5,
114-
"2" -> 4,
115-
"3" -> 3
116-
)), approxHistogram.finalize(ir))
117+
assertEquals(toHashMap(
118+
Map(
119+
"5" -> 5,
120+
"2" -> 4,
121+
"3" -> 3
122+
)),
123+
approxHistogram.finalize(ir))
117124
assertTrue(ir.isApprox)
118125
assert(ir.histogram.isEmpty)
119126
}

aggregator/src/test/scala/ai/chronon/aggregator/test/BoundedUniqueCountTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class BoundedUniqueCountTest extends TestCase {
153153
val boundedDistinctCount = new BoundedUniqueCount[Array[Byte]](BinaryType, 5)
154154
val bytes1 = Array[Byte](1, 2, 3)
155155
val bytes2 = Array[Byte](4, 5, 6)
156-
156+
157157
var ir = boundedDistinctCount.prepare(bytes1)
158158
ir = boundedDistinctCount.update(ir, bytes1)
159159
ir = boundedDistinctCount.update(ir, bytes2)
@@ -200,8 +200,8 @@ class BoundedUniqueCountTest extends TestCase {
200200
assertEquals(ai.chronon.api.ListType(DoubleType), doubleBoundedDistinctCount.irType)
201201
assertEquals(ai.chronon.api.ListType(FloatType), floatBoundedDistinctCount.irType)
202202
assertEquals(ai.chronon.api.ListType(BinaryType), binaryBoundedDistinctCount.irType)
203-
203+
204204
// For non-numeric types, irType should be ListType(StringType)
205205
assertEquals(ai.chronon.api.ListType(StringType), stringBoundedDistinctCount.irType)
206206
}
207-
}
207+
}

aggregator/src/test/scala/ai/chronon/aggregator/test/DataGen.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ object CStream {
135135
Option(rollFloat(max, 1, nullRate = nullRate)).map(java.lang.Float.valueOf(_)).orNull
136136
}
137137

138-
139138
class ZippedStream(streams: CStream[Any]*)(tsIndex: Int) extends CStream[TestRow] {
140139
override def next(): TestRow =
141140
new TestRow(streams.map(_.next()).toArray: _*)(tsIndex)
@@ -163,7 +162,7 @@ case class Column(name: String, `type`: DataType, cardinality: Int, chunkSize: I
163162
}
164163
case IntType => new IntStream(cardinality, nullRate)
165164
case DoubleType => new DoubleStream(cardinality, nullRate)
166-
case FloatType => new FloatStream(cardinality, nullRate)
165+
case FloatType => new FloatStream(cardinality, nullRate)
167166
case LongType =>
168167
name match {
169168
case Constants.TimeColumn => new TimeStream(new Window(cardinality, TimeUnit.DAYS))

aggregator/src/test/scala/ai/chronon/aggregator/test/RowAggregatorTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class RowAggregatorTest extends TestCase {
8585
val mapAvg = new java.util.HashMap[String, Double]()
8686
mapAvg.put("A", 3.0)
8787
mapAvg.put("B", 1.0)
88-
mapAvg.put("D", 3.0) // sum = -3 / count = -1
88+
mapAvg.put("D", 3.0) // sum = -3 / count = -1
8989
mapAvg.put(null, 2.0)
9090

9191
val specsAndExpected: Array[(AggregationPart, Any)] = Array(

aggregator/src/test/scala/ai/chronon/aggregator/test/SawtoothOnlineAggregatorTest.scala

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,68 +48,74 @@ class SawtoothOnlineAggregatorTest extends TestCase {
4848

4949
val aggregations: Seq[Aggregation] = Seq(
5050
Builders.Aggregation(
51-
operation = Operation.COUNT,
52-
inputColumn = "num",
53-
windows = Seq(new Window(14, TimeUnit.DAYS), new Window(20, TimeUnit.HOURS), new Window(6, TimeUnit.DAYS), new Window(7, TimeUnit.DAYS))
51+
operation = Operation.COUNT,
52+
inputColumn = "num",
53+
windows = Seq(new Window(14, TimeUnit.DAYS),
54+
new Window(20, TimeUnit.HOURS),
55+
new Window(6, TimeUnit.DAYS),
56+
new Window(7, TimeUnit.DAYS))
5457
),
5558
Builders.Aggregation(
56-
operation = Operation.AVERAGE,
57-
inputColumn = "num",
58-
windows = Seq(new Window(14, TimeUnit.DAYS), new Window(20, TimeUnit.HOURS), new Window(6, TimeUnit.DAYS), new Window(7, TimeUnit.DAYS))
59+
operation = Operation.AVERAGE,
60+
inputColumn = "num",
61+
windows = Seq(new Window(14, TimeUnit.DAYS),
62+
new Window(20, TimeUnit.HOURS),
63+
new Window(6, TimeUnit.DAYS),
64+
new Window(7, TimeUnit.DAYS))
5965
),
6066
Builders.Aggregation(
61-
operation = Operation.FIRST,
62-
inputColumn = "ts_col",
63-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
64-
argMap = Map("k" -> "4")
67+
operation = Operation.FIRST,
68+
inputColumn = "ts_col",
69+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
70+
argMap = Map("k" -> "4")
6571
),
6672
Builders.Aggregation(
67-
operation = Operation.LAST,
68-
inputColumn = "ts_col",
69-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
73+
operation = Operation.LAST,
74+
inputColumn = "ts_col",
75+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
7076
),
7177
Builders.Aggregation(
72-
operation = Operation.SUM,
73-
inputColumn = "num",
74-
windows = null
78+
operation = Operation.SUM,
79+
inputColumn = "num",
80+
windows = null
7581
),
7682
Builders.Aggregation(
77-
operation = Operation.UNIQUE_COUNT,
78-
inputColumn = "user",
79-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
83+
operation = Operation.UNIQUE_COUNT,
84+
inputColumn = "user",
85+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
8086
),
8187
Builders.Aggregation(
82-
operation = Operation.APPROX_UNIQUE_COUNT,
83-
inputColumn = "user",
84-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
88+
operation = Operation.APPROX_UNIQUE_COUNT,
89+
inputColumn = "user",
90+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
8591
),
8692
Builders.Aggregation(
87-
operation = Operation.LAST_K,
88-
inputColumn = "user",
89-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
90-
argMap = Map("k" -> "4")
93+
operation = Operation.LAST_K,
94+
inputColumn = "user",
95+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
96+
argMap = Map("k" -> "4")
9197
),
9298
Builders.Aggregation(
93-
operation = Operation.FIRST_K,
94-
inputColumn = "user",
95-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
96-
argMap = Map("k" -> "4")
99+
operation = Operation.FIRST_K,
100+
inputColumn = "user",
101+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
102+
argMap = Map("k" -> "4")
97103
),
98104
Builders.Aggregation(
99-
operation = Operation.TOP_K,
100-
inputColumn = "num",
101-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
102-
argMap = Map("k" -> "4")
105+
operation = Operation.TOP_K,
106+
inputColumn = "num",
107+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS)),
108+
argMap = Map("k" -> "4")
103109
),
104110
Builders.Aggregation(
105-
operation = Operation.MIN,
106-
inputColumn = "num",
107-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
111+
operation = Operation.MIN,
112+
inputColumn = "num",
113+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
108114
),
109115
Builders.Aggregation(
110-
operation = Operation.MAX,
111-
inputColumn = "num",
112-
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
116+
operation = Operation.MAX,
117+
inputColumn = "num",
118+
windows = Seq(new Window(23, TimeUnit.HOURS), new Window(14, TimeUnit.DAYS))
113119
)
114120
)
115121

aggregator/src/test/scala/ai/chronon/aggregator/test/TwoStackLiteAggregatorTest.scala

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ package ai.chronon.aggregator.test
1818

1919
import ai.chronon.aggregator.base.{Sum, TopK}
2020
import ai.chronon.aggregator.test.SawtoothAggregatorTest.sawtoothAggregate
21-
import ai.chronon.aggregator.windowing.{TwoStackLiteAggregator, TwoStackLiteAggregationBuffer, FiveMinuteResolution, SawtoothAggregator}
21+
import ai.chronon.aggregator.windowing.{
22+
TwoStackLiteAggregator,
23+
TwoStackLiteAggregationBuffer,
24+
FiveMinuteResolution,
25+
SawtoothAggregator
26+
}
2227
import ai.chronon.api.{Aggregation, Builders, IntType, LongType, Operation, StructField, StructType, TimeUnit, Window}
2328
import junit.framework.TestCase
2429
import org.junit.Assert._
@@ -27,24 +32,23 @@ import com.google.gson.Gson
2732

2833
import scala.collection.Seq
2934

30-
class TwoStackLiteAggregatorTest extends TestCase{
35+
class TwoStackLiteAggregatorTest extends TestCase {
3136
def testBufferWithTopK(): Unit = {
3237
val topK = new TopK[Integer](IntType, 2)
3338
val bankersBuffer = new TwoStackLiteAggregationBuffer(topK, 5)
3439
assertEquals(null, bankersBuffer.query) // null
3540
Seq(7, 8, 9).map(x => new Integer(x)).foreach(i => bankersBuffer.push(i))
3641
def assertBufferEquals(a: Seq[Int], b: java.util.ArrayList[Integer]): Unit = {
37-
if(a==null || b == null) {
42+
if (a == null || b == null) {
3843
assertEquals(a, b)
3944
} else {
40-
assertArrayEquals(
41-
Option(a).map(_.map(x => new Integer(x).asInstanceOf[AnyRef]).toArray).orNull,
42-
Option(b).map(_.toArray).orNull)
45+
assertArrayEquals(Option(a).map(_.map(x => new Integer(x).asInstanceOf[AnyRef]).toArray).orNull,
46+
Option(b).map(_.toArray).orNull)
4347
}
4448
}
4549
assertBufferEquals(Seq(8, 9), bankersBuffer.query)
4650
bankersBuffer.pop()
47-
assertBufferEquals(Seq(8, 9),bankersBuffer.query)
51+
assertBufferEquals(Seq(8, 9), bankersBuffer.query)
4852
bankersBuffer.pop()
4953
assertBufferEquals(Seq(9), bankersBuffer.query)
5054
bankersBuffer.pop()
@@ -66,18 +70,13 @@ class TwoStackLiteAggregatorTest extends TestCase{
6670
Operation.AVERAGE,
6771
"num",
6872
Seq(new Window(1, TimeUnit.DAYS), new Window(1, TimeUnit.HOURS), new Window(30, TimeUnit.DAYS))),
69-
Builders.Aggregation(
70-
Operation.AVERAGE,
71-
"num"),
73+
Builders.Aggregation(Operation.AVERAGE, "num"),
7274
Builders.Aggregation(
7375
Operation.TOP_K,
7476
"num",
7577
Seq(new Window(1, TimeUnit.DAYS), new Window(1, TimeUnit.HOURS), new Window(30, TimeUnit.DAYS)),
7678
argMap = Map("k" -> "300")),
77-
Builders.Aggregation(
78-
Operation.TOP_K,
79-
"num",
80-
argMap = Map("k" -> "300"))
79+
Builders.Aggregation(Operation.TOP_K, "num", argMap = Map("k" -> "300"))
8180
)
8281

8382
timer.publish("setup")
@@ -94,12 +93,13 @@ class TwoStackLiteAggregatorTest extends TestCase{
9493
// )
9594
// val naiveIrs = naiveAggregator.aggregate(events, queries).map(sawtoothAggregator.windowedAggregator.finalize)
9695
// timer.publish("naive")
97-
val bankersAggregator = new TwoStackLiteAggregator(
98-
StructType("", columns.map(c => StructField(c.name, c.`type`)).toArray),
99-
aggregations)
96+
val bankersAggregator =
97+
new TwoStackLiteAggregator(StructType("", columns.map(c => StructField(c.name, c.`type`)).toArray), aggregations)
10098

10199
// will finalize by default
102-
val bankersIrs = bankersAggregator.slidingSawtoothWindow(queries.sorted.iterator, events.sortBy(_.ts).iterator, events.length).toArray
100+
val bankersIrs = bankersAggregator
101+
.slidingSawtoothWindow(queries.sorted.iterator, events.sortBy(_.ts).iterator, events.length)
102+
.toArray
103103
timer.publish("sorting + banker")
104104

105105
val sawtoothIrs = sawtoothAggregate(events, queries, aggregations, schema)
@@ -112,8 +112,9 @@ class TwoStackLiteAggregatorTest extends TestCase{
112112
// sawtooth 914 ms
113113

114114
val gson = new Gson()
115-
bankersIrs.zip(sawtoothIrs).foreach{case (bankers, sawtooth) =>
116-
assertEquals(gson.toJson(sawtooth), gson.toJson(bankers))
115+
bankersIrs.zip(sawtoothIrs).foreach {
116+
case (bankers, sawtooth) =>
117+
assertEquals(gson.toJson(sawtooth), gson.toJson(bankers))
117118
}
118119
}
119120

api/src/test/scala/ai/chronon/api/test/DataTypeConversionTest.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@ class DataTypeConversionTest {
3131
val dType = StructType(
3232
"root",
3333
Array(
34-
StructField("map", MapType(
35-
StructType("key", Array(
36-
StructField("a", IntType),
37-
StructField("b", FloatType)
38-
)),
39-
StructType("value", Array(
40-
StructField("c", StructType("inner",
41-
Array(StructField("d", IntType)))))
42-
)
34+
StructField(
35+
"map",
36+
MapType(
37+
StructType("key",
38+
Array(
39+
StructField("a", IntType),
40+
StructField("b", FloatType)
41+
)),
42+
StructType("value", Array(StructField("c", StructType("inner", Array(StructField("d", IntType))))))
4343
)
44-
)))
44+
))
45+
)
4546
val thriftType = DataType.toTDataType(dType)
4647

4748
// serialize with TSimpleJson - this is what python code will do

api/src/test/scala/ai/chronon/api/test/ExtensionsTest.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ class ExtensionsTest {
203203
val join = Builders.Join(
204204
left = Builders.Source.events(query = null, table = "db.join_table", topic = "test.join_topic"),
205205
joinParts = Seq(Builders.JoinPart(groupBy = groupBy)),
206-
metaData = metadata)
206+
metaData = metadata
207+
)
207208
assertEquals(join.semanticHash(excludeTopic = true), join.semanticHash(excludeTopic = true))
208209
assertEquals(join.semanticHash(excludeTopic = false), join.semanticHash(excludeTopic = false))
209210
}
@@ -218,7 +219,8 @@ class ExtensionsTest {
218219
val join1 = Builders.Join(
219220
left = Builders.Source.events(query = null, table = "db.join_table", topic = "test.join_topic"),
220221
joinParts = Seq(Builders.JoinPart(groupBy = groupBy)),
221-
metaData = metadata)
222+
metaData = metadata
223+
)
222224
val join2 = join1.deepCopy()
223225
join2.joinParts.get(0).groupBy.setKeyColumns(Seq("b", "c").toJava)
224226
assertNotEquals(join1.semanticHash(excludeTopic = true), join2.semanticHash(excludeTopic = true))
@@ -236,8 +238,8 @@ class ExtensionsTest {
236238
left = Builders.Source.events(query = null, table = "db.join_table", topic = "test.join_topic"),
237239
joinParts = Seq(Builders.JoinPart(groupBy = groupBy)),
238240
metaData = metadata,
239-
derivations = Seq(
240-
Builders.Derivation(name="*", expression="*", metaData = metadata)))
241+
derivations = Seq(Builders.Derivation(name = "*", expression = "*", metaData = metadata))
242+
)
241243
val updatedMetadata = Builders.MetaData(name = "test", description = "other description")
242244
val join2 = join1.deepCopy()
243245
join2.setMetaData(updatedMetadata)

0 commit comments

Comments
 (0)