Skip to content

Commit 7f5e078

Browse files
committed
withNewChildrenInternal
1 parent ff00b41 commit 7f5e078

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+248
-146
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/BinaryRasterFunction.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ import com.typesafe.scalalogging.Logger
2525
import geotrellis.raster.Tile
2626
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
2727
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
28-
import org.apache.spark.sql.catalyst.expressions.BinaryExpression
28+
import org.apache.spark.sql.catalyst.expressions.{BinaryExpression, Expression}
2929
import org.apache.spark.sql.types.DataType
3030
import org.locationtech.rasterframes.expressions.DynamicExtractors._
3131
import org.slf4j.LoggerFactory
3232

3333
/** Operation combining two tiles or a tile and a scalar into a new tile. */
34-
trait BinaryRasterFunction extends BinaryExpression with RasterResult {
34+
trait BinaryRasterFunction extends BinaryExpression with RasterResult { self: HasBinaryExpressionCopy =>
35+
override protected def withNewChildrenInternal(newLeft: Expression, newRight: Expression): Expression = copy(newLeft, newRight)
3536

3637
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))
3738

core/src/main/scala/org/locationtech/rasterframes/expressions/OnCellGridExpression.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ import geotrellis.raster.CellGrid
2626
import org.apache.spark.sql.catalyst.InternalRow
2727
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
2828
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
29-
import org.apache.spark.sql.catalyst.expressions.UnaryExpression
29+
import org.apache.spark.sql.catalyst.expressions.{Expression, UnaryExpression}
3030

3131
/**
3232
* Implements boilerplate for subtype expressions processing TileUDT, RasterSourceUDT, and RasterRefs
3333
* as Grid types.
3434
*
3535
* @since 11/4/18
3636
*/
37-
trait OnCellGridExpression extends UnaryExpression {
37+
trait OnCellGridExpression extends UnaryExpression { self: HasUnaryExpressionCopy =>
38+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
3839

3940
private lazy val fromRow: InternalRow => CellGrid[Int] = {
4041
if (child.resolved) gridExtractor(child.dataType)

core/src/main/scala/org/locationtech/rasterframes/expressions/OnTileContextExpression.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.locationtech.rasterframes.expressions.DynamicExtractors._
2525
import org.apache.spark.sql.catalyst.InternalRow
2626
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
2727
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
28-
import org.apache.spark.sql.catalyst.expressions.UnaryExpression
28+
import org.apache.spark.sql.catalyst.expressions.{Expression, UnaryExpression}
2929
import org.locationtech.rasterframes.model.TileContext
3030

3131
/**
@@ -34,7 +34,8 @@ import org.locationtech.rasterframes.model.TileContext
3434
*
3535
* @since 11/3/18
3636
*/
37-
trait OnTileContextExpression extends UnaryExpression {
37+
trait OnTileContextExpression extends UnaryExpression { self: HasUnaryExpressionCopy =>
38+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
3839

3940
override def checkInputDataTypes(): TypeCheckResult = {
4041
if (!projectedRasterLikeExtractor.isDefinedAt(child.dataType)) {

core/src/main/scala/org/locationtech/rasterframes/expressions/SpatialRelation.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ import org.locationtech.geomesa.spark.jts.udf.SpatialRelationFunctions._
3939
*
4040
* @since 12/28/17
4141
*/
42-
abstract class SpatialRelation extends BinaryExpression with CodegenFallback {
42+
abstract class SpatialRelation extends BinaryExpression with CodegenFallback { this: HasBinaryExpressionCopy =>
43+
44+
override protected def withNewChildrenInternal(newLeft: Expression, newRight: Expression): Expression =
45+
copy(left = newLeft, right = newRight)
4346

4447
def extractGeometry(expr: Expression, input: Any): Geometry = {
4548
input match {
@@ -72,8 +75,11 @@ object SpatialRelation {
7275
type RelationPredicate = (Geometry, Geometry) => java.lang.Boolean
7376

7477
case class Intersects(left: Expression, right: Expression) extends SpatialRelation {
75-
override def nodeName = "intersects"
78+
override def nodeName: String = "intersects"
7679
val relation = ST_Intersects
80+
81+
override protected def withNewChildrenInternal(newLeft: Expression, newRight: Expression): Expression =
82+
copy(left = newLeft, right = newRight)
7783
}
7884
case class Contains(left: Expression, right: Expression) extends SpatialRelation {
7985
override def nodeName = "contains"

core/src/main/scala/org/locationtech/rasterframes/expressions/TileAssembler.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ case class TileAssembler(
140140

141141
def serialize(buffer: TileBuffer): Array[Byte] = buffer.serialize()
142142
def deserialize(storageFormat: Array[Byte]): TileBuffer = new TileBuffer(storageFormat)
143+
144+
override protected def withNewChildrenInternal(newChildren: IndexedSeq[Expression]): Expression = copy(
145+
colIndex = newChildren(0),
146+
rowIndex = newChildren(1),
147+
cellValue = newChildren(2),
148+
tileCols = newChildren(3),
149+
tileRows = newChildren(4)
150+
)
143151
}
144152

145153
object TileAssembler {

core/src/main/scala/org/locationtech/rasterframes/expressions/UnaryRasterFunction.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ import org.locationtech.rasterframes.expressions.DynamicExtractors._
2525
import geotrellis.raster.Tile
2626
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
2727
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
28-
import org.apache.spark.sql.catalyst.expressions.UnaryExpression
28+
import org.apache.spark.sql.catalyst.expressions.{Expression, UnaryExpression}
2929
import org.locationtech.rasterframes.model.TileContext
3030

3131
/** Boilerplate for expressions operating on a single Tile-like . */
32-
trait UnaryRasterFunction extends UnaryExpression {
32+
trait UnaryRasterFunction extends UnaryExpression { self: HasUnaryExpressionCopy =>
33+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
34+
3335
override def checkInputDataTypes(): TypeCheckResult = {
3436
if (!tileExtractor.isDefinedAt(child.dataType)) {
3537
TypeCheckFailure(s"Input type '${child.dataType}' does not conform to a raster type.")

core/src/main/scala/org/locationtech/rasterframes/expressions/UnaryRasterOp.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ package org.locationtech.rasterframes.expressions
2323

2424
import com.typesafe.scalalogging.Logger
2525
import geotrellis.raster.Tile
26+
import org.apache.spark.sql.catalyst.expressions.Expression
2627
import org.apache.spark.sql.types.DataType
2728
import org.locationtech.rasterframes.model.TileContext
2829
import org.slf4j.LoggerFactory
2930

3031
/** Operation on a tile returning a tile. */
31-
trait UnaryRasterOp extends UnaryRasterFunction with RasterResult {
32+
trait UnaryRasterOp extends UnaryRasterFunction with RasterResult { this: HasUnaryExpressionCopy =>
3233
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))
3334

3435
def dataType: DataType = child.dataType
@@ -37,5 +38,7 @@ trait UnaryRasterOp extends UnaryRasterFunction with RasterResult {
3738
toInternalRow(op(tile), ctx)
3839

3940
protected def op(child: Tile): Tile
41+
42+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
4043
}
4144

core/src/main/scala/org/locationtech/rasterframes/expressions/accessors/GetCRS.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ case class GetCRS(child: Expression) extends UnaryExpression with CodegenFallbac
9797
}
9898
}
9999

100+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
100101
}
101102

102103
object GetCRS {

core/src/main/scala/org/locationtech/rasterframes/expressions/accessors/GetCellType.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ case class GetCellType(child: Expression) extends OnCellGridExpression with Code
5555

5656
/** Implemented by subtypes to process incoming ProjectedRasterLike entity. */
5757
def eval(cg: CellGrid[Int]): Any = resultConverter(cg.cellType)
58+
59+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
5860
}
5961

6062
object GetCellType {

core/src/main/scala/org/locationtech/rasterframes/expressions/accessors/GetEnvelope.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ case class GetEnvelope(child: Expression) extends UnaryExpression with CodegenFa
5757
}
5858

5959
def dataType: DataType = envelopeEncoder.schema
60+
61+
override protected def withNewChildInternal(newChild: Expression): Expression = copy(newChild)
6062
}
6163

6264
object GetEnvelope {

0 commit comments

Comments
 (0)