Skip to content

Commit

Permalink
Merge pull request #379 from s22s/fix/293.1
Browse files Browse the repository at this point in the history
Reworking of logging usage to fix #293
  • Loading branch information
metasim authored Oct 7, 2019
2 parents 5c8467e + 6362d9e commit 855fba8
Show file tree
Hide file tree
Showing 26 changed files with 131 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@

package org.locationtech.rasterframes.expressions

import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.raster.Tile
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
import org.apache.spark.sql.catalyst.expressions.BinaryExpression
import org.apache.spark.sql.rf.TileUDT
import org.apache.spark.sql.types.DataType
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import org.slf4j.LoggerFactory

/** Operation combining two tiles or a tile and a scalar into a new tile. */
trait BinaryLocalRasterOp extends BinaryExpression with LazyLogging {
trait BinaryLocalRasterOp extends BinaryExpression {

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


override def dataType: DataType = left.dataType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@

package org.locationtech.rasterframes.expressions

import org.locationtech.rasterframes.expressions.DynamicExtractors.tileExtractor
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.raster.Tile
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
import org.apache.spark.sql.catalyst.expressions.BinaryExpression
import org.apache.spark.sql.rf.TileUDT
import org.apache.spark.sql.types.DataType
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors.tileExtractor
import org.slf4j.LoggerFactory

/** Operation combining two tiles into a new tile. */
trait BinaryRasterOp extends BinaryExpression with LazyLogging {
trait BinaryRasterOp extends BinaryExpression {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))

override def dataType: DataType = left.dataType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@

package org.locationtech.rasterframes.expressions

import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.raster.Tile
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
import org.apache.spark.sql.catalyst.expressions.UnaryExpression
import org.apache.spark.sql.rf.TileUDT
import org.apache.spark.sql.types.DataType
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import org.slf4j.LoggerFactory

/** Operation on a tile returning a tile. */
trait UnaryLocalRasterOp extends UnaryExpression with LazyLogging {
trait UnaryLocalRasterOp extends UnaryExpression {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))

override def dataType: DataType = child.dataType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@

package org.locationtech.rasterframes.expressions.generators

import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
import org.apache.spark.sql.types.{DataType, StructField, StructType}
import org.apache.spark.sql.{Column, TypedColumn}
import org.locationtech.rasterframes
import org.locationtech.rasterframes.RasterSourceType
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.generators.RasterSourceToRasterRefs.bandNames
import org.locationtech.rasterframes.model.TileDimensions
import org.locationtech.rasterframes.tiles.ProjectedRasterTile
import org.locationtech.rasterframes.util._
import org.locationtech.rasterframes.RasterSourceType
import org.slf4j.LoggerFactory

import scala.util.Try
import scala.util.control.NonFatal
Expand All @@ -45,7 +46,9 @@ import scala.util.control.NonFatal
* @since 9/6/18
*/
case class RasterSourceToTiles(children: Seq[Expression], bandIndexes: Seq[Int], subtileDims: Option[TileDimensions] = None) extends Expression
with Generator with CodegenFallback with ExpectsInputTypes with LazyLogging {
with Generator with CodegenFallback with ExpectsInputTypes {

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

override def inputTypes: Seq[DataType] = Seq.fill(children.size)(RasterSourceType)
override def nodeName: String = "rf_raster_source_to_tiles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

package org.locationtech.rasterframes.expressions.transformers

import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import org.locationtech.rasterframes.expressions.row
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.raster
import geotrellis.raster.Tile
import geotrellis.raster.mapalgebra.local.{Defined, InverseMask => gtInverseMask, Mask => gtMask}
Expand All @@ -35,9 +32,16 @@ import org.apache.spark.sql.catalyst.expressions.{Expression, ExpressionDescript
import org.apache.spark.sql.rf.TileUDT
import org.apache.spark.sql.types.DataType
import org.apache.spark.sql.{Column, TypedColumn}
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import org.locationtech.rasterframes.expressions.row
import org.slf4j.LoggerFactory

abstract class Mask(val left: Expression, val middle: Expression, val right: Expression, inverse: Boolean)
extends TernaryExpression with CodegenFallback with Serializable with LazyLogging {
extends TernaryExpression with CodegenFallback with Serializable {

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


override def children: Seq[Expression] = Seq(left, middle, right)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,27 @@

package org.locationtech.rasterframes.expressions.transformers

import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.row
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, UnaryExpression}
import org.apache.spark.sql.rf._
import org.apache.spark.sql.types.DataType
import org.apache.spark.sql.{Column, TypedColumn}
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.row
import org.locationtech.rasterframes.ref.RasterRef
import org.locationtech.rasterframes.tiles.ProjectedRasterTile
import org.slf4j.LoggerFactory

/**
* Realizes a RasterRef into a Tile.
*
* @since 11/2/18
*/
case class RasterRefToTile(child: Expression) extends UnaryExpression
with CodegenFallback with ExpectsInputTypes with LazyLogging {
with CodegenFallback with ExpectsInputTypes {

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

override def nodeName: String = "raster_ref_to_tile"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

package org.locationtech.rasterframes.expressions.transformers

import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.spark.sql.Column
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
Expand All @@ -33,6 +33,7 @@ import org.apache.spark.sql.types._
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import org.locationtech.rasterframes.expressions.DynamicExtractors._
import org.locationtech.rasterframes.expressions.row
import org.slf4j.LoggerFactory

@ExpressionDescription(
usage = "_FUNC_(tile, value) - Set the NoData value for the given tile.",
Expand All @@ -45,7 +46,8 @@ import org.locationtech.rasterframes.expressions.row
> SELECT _FUNC_(tile, 1.5);
..."""
)
case class SetNoDataValue(left: Expression, right: Expression) extends BinaryExpression with CodegenFallback with LazyLogging {
case class SetNoDataValue(left: Expression, right: Expression) extends BinaryExpression with CodegenFallback {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))

override val nodeName: String = "rf_with_no_data"
override def dataType: DataType = left.dataType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ package org.locationtech.rasterframes.expressions.transformers

import java.net.URI

import org.locationtech.rasterframes.RasterSourceType
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
import org.apache.spark.sql.catalyst.expressions.{ExpectsInputTypes, Expression, UnaryExpression}
import org.apache.spark.sql.types.{DataType, StringType}
import org.apache.spark.sql.{Column, TypedColumn}
import org.apache.spark.unsafe.types.UTF8String
import org.locationtech.rasterframes.RasterSourceType
import org.locationtech.rasterframes.ref.RasterSource
import org.slf4j.LoggerFactory

/**
* Catalyst generator to convert a geotiff download URL into a series of rows
Expand All @@ -39,7 +40,9 @@ import org.locationtech.rasterframes.ref.RasterSource
* @since 5/4/18
*/
case class URIToRasterSource(override val child: Expression)
extends UnaryExpression with ExpectsInputTypes with CodegenFallback with LazyLogging {
extends UnaryExpression with ExpectsInputTypes with CodegenFallback {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))


override def nodeName: String = "rf_uri_to_raster_source"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ package org.locationtech.rasterframes.extensions

import java.time.ZonedDateTime

import org.locationtech.rasterframes.util._
import org.locationtech.rasterframes.RasterFrameLayer
import com.typesafe.scalalogging.Logger
import geotrellis.proj4.CRS
import geotrellis.raster.resample.{NearestNeighbor, ResampleMethod}
import geotrellis.raster.{MultibandTile, ProjectedRaster, Tile, TileLayout}
Expand All @@ -37,12 +36,13 @@ import org.apache.spark.annotation.Experimental
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.{Metadata, TimestampType}
import spray.json._
import org.locationtech.rasterframes.encoders.StandardEncoders._
import org.locationtech.rasterframes.{MetadataKeys, RasterFrameLayer}
import org.locationtech.rasterframes.encoders.StandardEncoders.PrimitiveEncoders._
import com.typesafe.scalalogging.LazyLogging
import org.locationtech.rasterframes.MetadataKeys
import org.locationtech.rasterframes.encoders.StandardEncoders._
import org.locationtech.rasterframes.tiles.ShowableTile
import org.locationtech.rasterframes.util._
import org.slf4j.LoggerFactory
import spray.json._

import scala.reflect.runtime.universe._

Expand All @@ -52,9 +52,11 @@ import scala.reflect.runtime.universe._
* @since 7/18/17
*/
trait RasterFrameLayerMethods extends MethodExtensions[RasterFrameLayer]
with RFSpatialColumnMethods with MetadataKeys with LazyLogging {
with RFSpatialColumnMethods with MetadataKeys {
import Implicits.{WithDataFrameMethods, WithRasterFrameLayerMethods}

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

/**
* A convenience over `DataFrame.withColumnRenamed` whereby the `RasterFrameLayer` type is maintained.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

package org.locationtech
import com.typesafe.config.ConfigFactory
import com.typesafe.scalalogging.LazyLogging
import geotrellis.raster.isData
import geotrellis.raster.{Tile, TileFeature}
import com.typesafe.scalalogging.Logger
import geotrellis.raster.{Tile, TileFeature, isData}
import geotrellis.spark.{ContextRDD, Metadata, SpaceTimeKey, SpatialKey, TileLayerMetadata}
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.rf.{RasterSourceUDT, TileUDT}
Expand All @@ -33,6 +32,7 @@ import org.locationtech.rasterframes.encoders.StandardEncoders
import org.locationtech.rasterframes.extensions.Implicits
import org.locationtech.rasterframes.model.TileDimensions
import org.locationtech.rasterframes.util.ZeroSevenCompatibilityKit
import org.slf4j.LoggerFactory
import shapeless.tag.@@

import scala.reflect.runtime.universe._
Expand All @@ -43,8 +43,10 @@ package object rasterframes extends StandardColumns
with Implicits
with rasterframes.jts.Implicits
with StandardEncoders
with DataFrameFunctions.Library
with LazyLogging {
with DataFrameFunctions.Library {

// Don't make this a `lazy val`... breaks Spark assemblies for some reason.
protected def logger: Logger = Logger(LoggerFactory.getLogger(getClass.getName))

@transient
private[rasterframes]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@

package org.locationtech.rasterframes.ref

import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.proj4.CRS
import geotrellis.raster.{CellType, GridBounds, MultibandTile, Raster}
import geotrellis.raster.io.geotiff.Tags
import geotrellis.raster.io.geotiff.reader.GeoTiffReader
import geotrellis.raster.{CellType, GridBounds, MultibandTile, Raster}
import geotrellis.util.RangeReader
import geotrellis.vector.Extent
import org.locationtech.rasterframes.util.GeoTiffInfoSupport
import org.slf4j.LoggerFactory

trait RangeReaderRasterSource extends RasterSource with GeoTiffInfoSupport {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))

trait RangeReaderRasterSource extends RasterSource with GeoTiffInfoSupport with LazyLogging {
protected def rangeReader: RangeReader

private def realInfo =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import scala.Boolean.box
* @since 12/18/17
*/
package object util extends DataFrameRenderers {
@transient
protected lazy val logger: Logger =
// Don't make this a `lazy val`... breaks Spark assemblies for some reason.
protected def logger: Logger =
Logger(LoggerFactory.getLogger("org.locationtech.rasterframes"))

import reflect.ClassTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.locationtech.rasterframes

import java.nio.file.{Files, Path}

import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import geotrellis.raster.testkit.RasterMatchers
import org.apache.spark.sql._
import org.apache.spark.sql.functions.col
Expand All @@ -33,9 +33,11 @@ import org.locationtech.rasterframes.util._
import org.scalactic.Tolerance
import org.scalatest._
import org.scalatest.matchers.{MatchResult, Matcher}
import org.slf4j.LoggerFactory

trait TestEnvironment extends FunSpec
with Matchers with Inspectors with Tolerance with RasterMatchers with LazyLogging {
with Matchers with Inspectors with Tolerance with RasterMatchers {
@transient protected lazy val logger = Logger(LoggerFactory.getLogger(getClass.getName))

lazy val scratchDir: Path = {
val outputDir = Files.createTempDirectory("rf-scratch-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@ import _root_.geotrellis.proj4.CRS
import _root_.geotrellis.raster.io.geotiff.compression._
import _root_.geotrellis.raster.io.geotiff.tags.codes.ColorSpace
import _root_.geotrellis.raster.io.geotiff.{GeoTiffOptions, MultibandGeoTiff, Tags, Tiled}
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.spark.sql._
import org.apache.spark.sql.sources.{BaseRelation, CreatableRelationProvider, DataSourceRegister, RelationProvider}
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource._
import org.locationtech.rasterframes.expressions.aggregates.TileRasterizerAggregate
import org.locationtech.rasterframes.model.{LazyCRS, TileDimensions}
import org.locationtech.rasterframes.util._
import org.slf4j.LoggerFactory

/**
* Spark SQL data source over GeoTIFF files.
*/
class GeoTiffDataSource
extends DataSourceRegister with RelationProvider with CreatableRelationProvider with DataSourceOptions with LazyLogging {
extends DataSourceRegister with RelationProvider with CreatableRelationProvider with DataSourceOptions {
import GeoTiffDataSource._

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


def shortName() = GeoTiffDataSource.SHORT_NAME

def createRelation(sqlContext: SQLContext, parameters: Map[String, String]) = {
Expand Down
Loading

0 comments on commit 855fba8

Please sign in to comment.