|
1 | 1 | package me.mnedokushev.zio.apache.parquet.core.filter
|
2 | 2 |
|
| 3 | +import _root_.java.time.Instant |
3 | 4 | import me.mnedokushev.zio.apache.parquet.core.Value
|
4 | 5 | import org.apache.parquet.filter2.predicate.FilterApi
|
5 | 6 | import org.apache.parquet.filter2.predicate.Operators.{
|
6 | 7 | BinaryColumn,
|
7 | 8 | BooleanColumn,
|
8 | 9 | Column,
|
| 10 | + DoubleColumn, |
| 11 | + FloatColumn, |
9 | 12 | IntColumn,
|
10 | 13 | LongColumn,
|
11 | 14 | SupportsEqNotEq,
|
12 | 15 | SupportsLtGt
|
13 | 16 | }
|
14 | 17 | import org.apache.parquet.io.api.Binary
|
| 18 | +import zio.{ Chunk, Duration } |
15 | 19 |
|
| 20 | +import java.time.{ |
| 21 | + DayOfWeek, |
| 22 | + LocalDate, |
| 23 | + LocalDateTime, |
| 24 | + LocalTime, |
| 25 | + Month, |
| 26 | + MonthDay, |
| 27 | + OffsetDateTime, |
| 28 | + OffsetTime, |
| 29 | + Period, |
| 30 | + Year, |
| 31 | + YearMonth, |
| 32 | + ZoneId, |
| 33 | + ZoneOffset, |
| 34 | + ZonedDateTime |
| 35 | +} |
| 36 | +import java.util.UUID |
16 | 37 | import scala.jdk.CollectionConverters._
|
17 | 38 |
|
18 | 39 | trait TypeTag[+A]
|
@@ -93,35 +114,151 @@ object TypeTag {
|
93 | 114 |
|
94 | 115 | }
|
95 | 116 |
|
96 |
| - implicit val string: TypeTag.EqNotEq[String] = |
| 117 | + implicit val string: TypeTag.EqNotEq[String] = |
97 | 118 | eqnoteq[String, Binary, BinaryColumn](
|
98 | 119 | FilterApi.binaryColumn,
|
99 | 120 | Value.string(_).value
|
100 | 121 | )
|
101 |
| - implicit val boolean: TypeTag.EqNotEq[Boolean] = |
| 122 | + implicit val boolean: TypeTag.EqNotEq[Boolean] = |
102 | 123 | eqnoteq[Boolean, java.lang.Boolean, BooleanColumn](
|
103 | 124 | FilterApi.booleanColumn,
|
104 | 125 | Value.boolean(_).value
|
105 | 126 | )
|
106 |
| - implicit val byte: TypeTag.LtGt[Byte] = |
| 127 | + implicit val byte: TypeTag.LtGt[Byte] = |
107 | 128 | ltgt[Byte, java.lang.Integer, IntColumn](
|
108 | 129 | FilterApi.intColumn,
|
109 | 130 | Value.byte(_).value
|
110 | 131 | )
|
111 |
| - implicit val short: TypeTag.LtGt[Short] = |
| 132 | + implicit val short: TypeTag.LtGt[Short] = |
112 | 133 | ltgt[Short, java.lang.Integer, IntColumn](
|
113 | 134 | FilterApi.intColumn,
|
114 | 135 | Value.short(_).value
|
115 | 136 | )
|
116 |
| - implicit val int: TypeTag.LtGt[Int] = |
| 137 | + implicit val int: TypeTag.LtGt[Int] = |
117 | 138 | ltgt[Int, java.lang.Integer, IntColumn](
|
118 | 139 | FilterApi.intColumn,
|
119 | 140 | Value.int(_).value
|
120 | 141 | )
|
121 |
| - implicit val long: TypeTag.LtGt[Long] = |
| 142 | + implicit val long: TypeTag.LtGt[Long] = |
122 | 143 | ltgt[Long, java.lang.Long, LongColumn](
|
123 | 144 | FilterApi.longColumn,
|
124 | 145 | Value.long(_).value
|
125 | 146 | )
|
| 147 | + implicit val float: TypeTag.LtGt[Float] = |
| 148 | + ltgt[Float, java.lang.Float, FloatColumn]( |
| 149 | + FilterApi.floatColumn, |
| 150 | + Value.float(_).value |
| 151 | + ) |
| 152 | + implicit val double: TypeTag.LtGt[Double] = |
| 153 | + ltgt[Double, java.lang.Double, DoubleColumn]( |
| 154 | + FilterApi.doubleColumn, |
| 155 | + Value.double(_).value |
| 156 | + ) |
| 157 | + implicit val binary: TypeTag.EqNotEq[Chunk[Byte]] = |
| 158 | + eqnoteq[Chunk[Byte], Binary, BinaryColumn]( |
| 159 | + FilterApi.binaryColumn, |
| 160 | + Value.binary(_).value |
| 161 | + ) |
| 162 | + implicit val char: TypeTag.EqNotEq[Char] = |
| 163 | + eqnoteq[Char, java.lang.Integer, IntColumn]( |
| 164 | + FilterApi.intColumn, |
| 165 | + Value.char(_).value |
| 166 | + ) |
| 167 | + implicit val uuid: TypeTag.EqNotEq[UUID] = |
| 168 | + eqnoteq[UUID, Binary, BinaryColumn]( |
| 169 | + FilterApi.binaryColumn, |
| 170 | + Value.uuid(_).value |
| 171 | + ) |
| 172 | + implicit val bigDecimal: TypeTag.LtGt[java.math.BigDecimal] = |
| 173 | + ltgt[java.math.BigDecimal, java.lang.Long, LongColumn]( |
| 174 | + FilterApi.longColumn, |
| 175 | + Value.bigDecimal(_).value |
| 176 | + ) |
| 177 | + implicit val bigInteger: TypeTag.LtGt[java.math.BigInteger] = |
| 178 | + ltgt[java.math.BigInteger, Binary, BinaryColumn]( |
| 179 | + FilterApi.binaryColumn, |
| 180 | + Value.bigInteger(_).value |
| 181 | + ) |
| 182 | + implicit val dayOfWeek: TypeTag.LtGt[DayOfWeek] = |
| 183 | + ltgt[DayOfWeek, java.lang.Integer, IntColumn]( |
| 184 | + FilterApi.intColumn, |
| 185 | + Value.dayOfWeek(_).value |
| 186 | + ) |
| 187 | + implicit val month: TypeTag.LtGt[Month] = |
| 188 | + ltgt[Month, java.lang.Integer, IntColumn]( |
| 189 | + FilterApi.intColumn, |
| 190 | + Value.month(_).value |
| 191 | + ) |
| 192 | + implicit val monthDay: TypeTag.LtGt[MonthDay] = |
| 193 | + ltgt[MonthDay, Binary, BinaryColumn]( |
| 194 | + FilterApi.binaryColumn, |
| 195 | + Value.monthDay(_).value |
| 196 | + ) |
| 197 | + implicit val period: TypeTag.LtGt[Period] = |
| 198 | + ltgt[Period, Binary, BinaryColumn]( |
| 199 | + FilterApi.binaryColumn, |
| 200 | + Value.period(_).value |
| 201 | + ) |
| 202 | + implicit val year: TypeTag.LtGt[Year] = |
| 203 | + ltgt[Year, java.lang.Integer, IntColumn]( |
| 204 | + FilterApi.intColumn, |
| 205 | + Value.year(_).value |
| 206 | + ) |
| 207 | + implicit val yearMonth: TypeTag.LtGt[YearMonth] = |
| 208 | + ltgt[YearMonth, Binary, BinaryColumn]( |
| 209 | + FilterApi.binaryColumn, |
| 210 | + Value.yearMonth(_).value |
| 211 | + ) |
| 212 | + // NOTE: it is not implicit to make scalac happy since ZoneOffset is a subtype of ZoneId |
| 213 | + val zoneId: TypeTag.EqNotEq[ZoneId] = |
| 214 | + eqnoteq[ZoneId, Binary, BinaryColumn]( |
| 215 | + FilterApi.binaryColumn, |
| 216 | + Value.zoneId(_).value |
| 217 | + ) |
| 218 | + implicit val zoneOffset: TypeTag.EqNotEq[ZoneOffset] = |
| 219 | + eqnoteq[ZoneOffset, Binary, BinaryColumn]( |
| 220 | + FilterApi.binaryColumn, |
| 221 | + Value.zoneOffset(_).value |
| 222 | + ) |
| 223 | + implicit val duration: TypeTag.LtGt[Duration] = |
| 224 | + ltgt[Duration, java.lang.Long, LongColumn]( |
| 225 | + FilterApi.longColumn, |
| 226 | + Value.duration(_).value |
| 227 | + ) |
| 228 | + implicit val instant: TypeTag.LtGt[Instant] = |
| 229 | + ltgt[Instant, java.lang.Long, LongColumn]( |
| 230 | + FilterApi.longColumn, |
| 231 | + Value.instant(_).value |
| 232 | + ) |
| 233 | + implicit val localDate: TypeTag.LtGt[LocalDate] = |
| 234 | + ltgt[LocalDate, java.lang.Integer, IntColumn]( |
| 235 | + FilterApi.intColumn, |
| 236 | + Value.localDate(_).value |
| 237 | + ) |
| 238 | + implicit val localTime: TypeTag.LtGt[LocalTime] = |
| 239 | + ltgt[LocalTime, java.lang.Integer, IntColumn]( |
| 240 | + FilterApi.intColumn, |
| 241 | + Value.localTime(_).value |
| 242 | + ) |
| 243 | + implicit val localDateTime: TypeTag.LtGt[LocalDateTime] = |
| 244 | + ltgt[LocalDateTime, java.lang.Long, LongColumn]( |
| 245 | + FilterApi.longColumn, |
| 246 | + Value.localDateTime(_).value |
| 247 | + ) |
| 248 | + implicit val offsetTime: TypeTag.LtGt[OffsetTime] = |
| 249 | + ltgt[OffsetTime, java.lang.Integer, IntColumn]( |
| 250 | + FilterApi.intColumn, |
| 251 | + Value.offsetTime(_).value |
| 252 | + ) |
| 253 | + implicit val offsetDateTime: TypeTag.LtGt[OffsetDateTime] = |
| 254 | + ltgt[OffsetDateTime, java.lang.Long, LongColumn]( |
| 255 | + FilterApi.longColumn, |
| 256 | + Value.offsetDateTime(_).value |
| 257 | + ) |
| 258 | + implicit val zonedDateTime: TypeTag.LtGt[ZonedDateTime] = |
| 259 | + ltgt[ZonedDateTime, java.lang.Long, LongColumn]( |
| 260 | + FilterApi.longColumn, |
| 261 | + Value.zonedDateTime(_).value |
| 262 | + ) |
126 | 263 |
|
127 | 264 | }
|
0 commit comments