Skip to content

Commit c19ad68

Browse files
committed
Changed CatalystSerialize implementations to store scheams as fields
rather than methods.
1 parent 1c1db3c commit c19ad68

File tree

11 files changed

+29
-30
lines changed

11 files changed

+29
-30
lines changed

core/src/main/scala/org/apache/spark/sql/rf/RasterSourceUDT.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object RasterSourceUDT {
7373

7474
implicit val rasterSourceSerializer: CatalystSerializer[RasterSource] = new CatalystSerializer[RasterSource] {
7575

76-
override def schema: StructType = StructType(Seq(
76+
override val schema: StructType = StructType(Seq(
7777
StructField("raster_source_kryo", BinaryType, false)
7878
))
7979

core/src/main/scala/org/apache/spark/sql/rf/TileUDT.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ case object TileUDT {
7474

7575
implicit def tileSerializer: CatalystSerializer[Tile] = new CatalystSerializer[Tile] {
7676

77-
override def schema: StructType = StructType(Seq(
77+
override val schema: StructType = StructType(Seq(
7878
StructField("cell_context", schemaOf[TileDataContext], false),
7979
StructField("cell_data", schemaOf[Cells], false)
8080
))

core/src/main/scala/org/locationtech/rasterframes/encoders/StandardSerializers.scala

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.locationtech.rasterframes.model.LazyCRS
3737
trait StandardSerializers {
3838

3939
implicit val envelopeSerializer: CatalystSerializer[Envelope] = new CatalystSerializer[Envelope] {
40-
override def schema: StructType = StructType(Seq(
40+
override val schema: StructType = StructType(Seq(
4141
StructField("minX", DoubleType, false),
4242
StructField("maxX", DoubleType, false),
4343
StructField("minY", DoubleType, false),
@@ -54,7 +54,7 @@ trait StandardSerializers {
5454
}
5555

5656
implicit val extentSerializer: CatalystSerializer[Extent] = new CatalystSerializer[Extent] {
57-
override def schema: StructType = StructType(Seq(
57+
override val schema: StructType = StructType(Seq(
5858
StructField("xmin", DoubleType, false),
5959
StructField("ymin", DoubleType, false),
6060
StructField("xmax", DoubleType, false),
@@ -72,7 +72,7 @@ trait StandardSerializers {
7272
}
7373

7474
implicit val gridBoundsSerializer: CatalystSerializer[GridBounds] = new CatalystSerializer[GridBounds] {
75-
override def schema: StructType = StructType(Seq(
75+
override val schema: StructType = StructType(Seq(
7676
StructField("colMin", IntegerType, false),
7777
StructField("rowMin", IntegerType, false),
7878
StructField("colMax", IntegerType, false),
@@ -92,7 +92,7 @@ trait StandardSerializers {
9292
}
9393

9494
implicit val crsSerializer: CatalystSerializer[CRS] = new CatalystSerializer[CRS] {
95-
override def schema: StructType = StructType(Seq(
95+
override val schema: StructType = StructType(Seq(
9696
StructField("crsProj4", StringType, false)
9797
))
9898
override def to[R](t: CRS, io: CatalystIO[R]): R = io.create(
@@ -107,20 +107,19 @@ trait StandardSerializers {
107107
}
108108

109109
implicit val cellTypeSerializer: CatalystSerializer[CellType] = new CatalystSerializer[CellType] {
110-
111-
112-
override def schema: StructType = StructType(Seq(
110+
import StandardSerializers._
111+
override val schema: StructType = StructType(Seq(
113112
StructField("cellTypeName", StringType, false)
114113
))
115114
override def to[R](t: CellType, io: CatalystIO[R]): R = io.create(
116-
io.encode(StandardSerializers.ct2sCache.get(t))
115+
io.encode(ct2sCache.get(t))
117116
)
118117
override def from[R](row: R, io: CatalystIO[R]): CellType =
119-
StandardSerializers.s2ctCache.get(io.getString(row, 0))
118+
s2ctCache.get(io.getString(row, 0))
120119
}
121120

122121
implicit val projectedExtentSerializer: CatalystSerializer[ProjectedExtent] = new CatalystSerializer[ProjectedExtent] {
123-
override def schema: StructType = StructType(Seq(
122+
override val schema: StructType = StructType(Seq(
124123
StructField("extent", schemaOf[Extent], false),
125124
StructField("crs", schemaOf[CRS], false)
126125
))
@@ -137,7 +136,7 @@ trait StandardSerializers {
137136
}
138137

139138
implicit val spatialKeySerializer: CatalystSerializer[SpatialKey] = new CatalystSerializer[SpatialKey] {
140-
override def schema: StructType = StructType(Seq(
139+
override val schema: StructType = StructType(Seq(
141140
StructField("col", IntegerType, false),
142141
StructField("row", IntegerType, false)
143142
))
@@ -154,7 +153,7 @@ trait StandardSerializers {
154153
}
155154

156155
implicit val spacetimeKeySerializer: CatalystSerializer[SpaceTimeKey] = new CatalystSerializer[SpaceTimeKey] {
157-
override def schema: StructType = StructType(Seq(
156+
override val schema: StructType = StructType(Seq(
158157
StructField("col", IntegerType, false),
159158
StructField("row", IntegerType, false),
160159
StructField("instant", LongType, false)
@@ -174,7 +173,7 @@ trait StandardSerializers {
174173
}
175174

176175
implicit val cellSizeSerializer: CatalystSerializer[CellSize] = new CatalystSerializer[CellSize] {
177-
override def schema: StructType = StructType(Seq(
176+
override val schema: StructType = StructType(Seq(
178177
StructField("width", DoubleType, false),
179178
StructField("height", DoubleType, false)
180179
))
@@ -191,7 +190,7 @@ trait StandardSerializers {
191190
}
192191

193192
implicit val tileLayoutSerializer: CatalystSerializer[TileLayout] = new CatalystSerializer[TileLayout] {
194-
override def schema: StructType = StructType(Seq(
193+
override val schema: StructType = StructType(Seq(
195194
StructField("layoutCols", IntegerType, false),
196195
StructField("layoutRows", IntegerType, false),
197196
StructField("tileCols", IntegerType, false),
@@ -214,7 +213,7 @@ trait StandardSerializers {
214213
}
215214

216215
implicit val layoutDefinitionSerializer = new CatalystSerializer[LayoutDefinition] {
217-
override def schema: StructType = StructType(Seq(
216+
override val schema: StructType = StructType(Seq(
218217
StructField("extent", schemaOf[Extent], true),
219218
StructField("tileLayout", schemaOf[TileLayout], true)
220219
))
@@ -231,7 +230,7 @@ trait StandardSerializers {
231230
}
232231

233232
implicit def boundsSerializer[T >: Null: CatalystSerializer]: CatalystSerializer[KeyBounds[T]] = new CatalystSerializer[KeyBounds[T]] {
234-
override def schema: StructType = StructType(Seq(
233+
override val schema: StructType = StructType(Seq(
235234
StructField("minKey", schemaOf[T], true),
236235
StructField("maxKey", schemaOf[T], true)
237236
))
@@ -248,7 +247,7 @@ trait StandardSerializers {
248247
}
249248

250249
def tileLayerMetadataSerializer[T >: Null: CatalystSerializer]: CatalystSerializer[TileLayerMetadata[T]] = new CatalystSerializer[TileLayerMetadata[T]] {
251-
override def schema: StructType = StructType(Seq(
250+
override val schema: StructType = StructType(Seq(
252251
StructField("cellType", schemaOf[CellType], false),
253252
StructField("layout", schemaOf[LayoutDefinition], false),
254253
StructField("extent", schemaOf[Extent], false),
@@ -276,7 +275,7 @@ trait StandardSerializers {
276275
implicit def rasterSerializer: CatalystSerializer[Raster[Tile]] = new CatalystSerializer[Raster[Tile]] {
277276
import org.apache.spark.sql.rf.TileUDT.tileSerializer
278277

279-
override def schema: StructType = StructType(Seq(
278+
override val schema: StructType = StructType(Seq(
280279
StructField("tile", TileType, false),
281280
StructField("extent", schemaOf[Extent], false)
282281
))

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/ProjectedLayerMetadataAggregate.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ object ProjectedLayerMetadataAggregate {
118118
private[expressions]
119119
object InputRecord {
120120
implicit val serializer: CatalystSerializer[InputRecord] = new CatalystSerializer[InputRecord]{
121-
override def schema: StructType = StructType(Seq(
121+
override val schema: StructType = StructType(Seq(
122122
StructField("extent", CatalystSerializer[Extent].schema, false),
123123
StructField("crs", CatalystSerializer[CRS].schema, false),
124124
StructField("cellType", CatalystSerializer[CellType].schema, false),
@@ -147,7 +147,7 @@ object ProjectedLayerMetadataAggregate {
147147
}
148148

149149
def write(buffer: MutableAggregationBuffer): Unit = {
150-
val encoded = (this).toRow
150+
val encoded = this.toRow
151151
for(i <- 0 until encoded.size) {
152152
buffer(i) = encoded(i)
153153
}
@@ -157,7 +157,7 @@ object ProjectedLayerMetadataAggregate {
157157
private[expressions]
158158
object BufferRecord {
159159
implicit val serializer: CatalystSerializer[BufferRecord] = new CatalystSerializer[BufferRecord] {
160-
override def schema: StructType = StructType(Seq(
160+
override val schema: StructType = StructType(Seq(
161161
StructField("extent", CatalystSerializer[Extent].schema, true),
162162
StructField("cellType", CatalystSerializer[CellType].schema, true),
163163
StructField("cellSize", CatalystSerializer[CellSize].schema, true)

core/src/main/scala/org/locationtech/rasterframes/model/CellContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import CatalystSerializer._
2929
case class CellContext(tileContext: TileContext, tileDataContext: TileDataContext, colIndex: Short, rowIndex: Short)
3030
object CellContext {
3131
implicit val serializer: CatalystSerializer[CellContext] = new CatalystSerializer[CellContext] {
32-
override def schema: StructType = StructType(Seq(
32+
override val schema: StructType = StructType(Seq(
3333
StructField("tileContext", schemaOf[TileContext], false),
3434
StructField("tileDataContext", schemaOf[TileDataContext], false),
3535
StructField("colIndex", ShortType, false),

core/src/main/scala/org/locationtech/rasterframes/model/Cells.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object Cells {
6868
}
6969

7070
implicit def cellsSerializer: CatalystSerializer[Cells] = new CatalystSerializer[Cells] {
71-
override def schema: StructType =
71+
override val schema: StructType =
7272
StructType(
7373
Seq(
7474
StructField("cells", BinaryType, true),

core/src/main/scala/org/locationtech/rasterframes/model/TileContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object TileContext {
4141
case _ => None
4242
}
4343
implicit val serializer: CatalystSerializer[TileContext] = new CatalystSerializer[TileContext] {
44-
override def schema: StructType = StructType(Seq(
44+
override val schema: StructType = StructType(Seq(
4545
StructField("extent", schemaOf[Extent], false),
4646
StructField("crs", schemaOf[CRS], false)
4747
))

core/src/main/scala/org/locationtech/rasterframes/model/TileDataContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object TileDataContext {
4141
}
4242

4343
implicit val serializer: CatalystSerializer[TileDataContext] = new CatalystSerializer[TileDataContext] {
44-
override def schema: StructType = StructType(Seq(
44+
override val schema: StructType = StructType(Seq(
4545
StructField("cellType", schemaOf[CellType], false),
4646
StructField("dimensions", schemaOf[TileDimensions], false)
4747
))

core/src/main/scala/org/locationtech/rasterframes/model/TileDimensions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object TileDimensions {
3838
def apply(colsRows: (Int, Int)): TileDimensions = new TileDimensions(colsRows._1, colsRows._2)
3939

4040
implicit val serializer: CatalystSerializer[TileDimensions] = new CatalystSerializer[TileDimensions] {
41-
override def schema: StructType = StructType(Seq(
41+
override val schema: StructType = StructType(Seq(
4242
StructField("cols", ShortType, false),
4343
StructField("rows", ShortType, false)
4444
))

core/src/main/scala/org/locationtech/rasterframes/ref/RasterRef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ object RasterRef extends LazyLogging {
7676

7777
implicit val rasterRefSerializer: CatalystSerializer[RasterRef] = new CatalystSerializer[RasterRef] {
7878
val rsType = new RasterSourceUDT()
79-
override def schema: StructType = StructType(Seq(
79+
override val schema: StructType = StructType(Seq(
8080
StructField("source", rsType.sqlType, false),
8181
StructField("bandIndex", IntegerType, false),
8282
StructField("subextent", schemaOf[Extent], true),

0 commit comments

Comments
 (0)