@@ -20,14 +20,14 @@ import magnolify.jmh.MagnolifyBench.nested
20
20
import magnolify .parquet .{MagnolifyParquetProperties , ParquetType , TestInputFile , TestOutputFile }
21
21
22
22
import java .util .concurrent .TimeUnit
23
- import magnolify .scalacheck .auto .*
24
- import magnolify .test .Simple .*
23
+ import magnolify .scalacheck .auto ._
24
+ import magnolify .test .Simple ._
25
25
import org .apache .hadoop .conf .Configuration
26
26
import org .apache .parquet .hadoop .{ParquetReader , ParquetWriter }
27
- import org .scalacheck .*
28
- import org .openjdk .jmh .annotations .*
27
+ import org .scalacheck ._
28
+ import org .openjdk .jmh .annotations ._
29
29
30
- import scala .jdk .CollectionConverters .*
30
+ import scala .jdk .CollectionConverters ._
31
31
32
32
object MagnolifyBench {
33
33
val seed : rng.Seed = rng.Seed (0 )
@@ -94,7 +94,7 @@ class AvroBench {
94
94
}
95
95
96
96
@ State (Scope .Benchmark )
97
- class ParquetReadState ()( implicit pt : ParquetType [Nested ]) {
97
+ class ParquetReadState (pt : ParquetType [Nested ]) {
98
98
var out : TestOutputFile = null
99
99
var reader : ParquetReader [Nested ] = null
100
100
@@ -116,7 +116,7 @@ class ParquetReadState()(implicit pt: ParquetType[Nested]) {
116
116
}
117
117
118
118
@ State (Scope .Benchmark )
119
- class ParquetWriteState ()( implicit pt : ParquetType [Nested ]) {
119
+ class ParquetWriteState (pt : ParquetType [Nested ]) {
120
120
var writer : ParquetWriter [Nested ] = null
121
121
122
122
@ Setup (Level .Invocation )
@@ -131,29 +131,37 @@ class ParquetWriteState()(implicit pt: ParquetType[Nested]) {
131
131
}
132
132
}
133
133
134
+ object ParquetStates {
135
+ def confWithGroupedArraysProp (propValue : Boolean ): Configuration = {
136
+ val conf = new Configuration ()
137
+ conf.setBoolean(MagnolifyParquetProperties .WriteGroupedArrays , propValue)
138
+ conf
139
+ }
140
+ class DefaultParquetReadState extends ParquetReadState (ParquetType [Nested ](confWithGroupedArraysProp(false )))
141
+ class DefaultParquetWriteState extends ParquetWriteState (ParquetType [Nested ](confWithGroupedArraysProp(false )))
142
+
143
+ class ParquetAvroCompatReadState extends ParquetReadState (ParquetType [Nested ](confWithGroupedArraysProp(true )))
144
+ class ParquetAvroCompatWriteState extends ParquetWriteState (ParquetType [Nested ](confWithGroupedArraysProp(true )))
145
+ }
134
146
135
147
@ BenchmarkMode (Array (Mode .AverageTime ))
136
148
@ OutputTimeUnit (TimeUnit .NANOSECONDS )
137
149
@ State (Scope .Thread )
138
150
class ParquetBench {
139
151
import MagnolifyBench ._
140
- implicit val pt : ParquetType [Nested ] = ParquetType [Nested ]
141
152
142
- @ Benchmark def parquetWrite (state : ParquetWriteState ): Unit = state.writer.write(nested)
143
- @ Benchmark def parquetRead (state : ParquetReadState ): Nested = state.reader.read()
153
+ @ Benchmark def parquetWrite (state : ParquetStates . DefaultParquetWriteState ): Unit = state.writer.write(nested)
154
+ @ Benchmark def parquetRead (state : ParquetStates . DefaultParquetReadState ): Nested = state.reader.read()
144
155
}
145
156
146
157
@ BenchmarkMode (Array (Mode .AverageTime ))
147
158
@ OutputTimeUnit (TimeUnit .NANOSECONDS )
148
159
@ State (Scope .Thread )
149
160
class ParquetAvroCompatBench {
150
161
import MagnolifyBench ._
151
- val conf = new Configuration ()
152
- conf.setBoolean(MagnolifyParquetProperties .WriteGroupedArrays , MagnolifyParquetProperties .WriteGroupedArraysDefault )
153
- implicit val pt : ParquetType [Nested ] = ParquetType [Nested ](conf)
154
162
155
- @ Benchmark def parquetWrite (state : ParquetWriteState ): Unit = state.writer.write(nested)
156
- @ Benchmark def parquetRead (state : ParquetReadState ): Nested = state.reader.read()
163
+ @ Benchmark def parquetWrite (state : ParquetStates . ParquetAvroCompatWriteState ): Unit = state.writer.write(nested)
164
+ @ Benchmark def parquetRead (state : ParquetStates . ParquetAvroCompatReadState ): Nested = state.reader.read()
157
165
}
158
166
159
167
@ BenchmarkMode (Array (Mode .AverageTime ))
0 commit comments