File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
scala/org/locationtech/rasterframes/util/debug Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 11rasterframes {
22 nominal-tile-size = 256
3- prefer-gdal = true
3+ prefer-gdal = false
44 showable-tiles = false
55 showable-max-cells = 20
66 max-truncate-row-element-length = 40
Original file line number Diff line number Diff line change 2121
2222package org .locationtech .rasterframes .util
2323
24+ import java .lang .reflect .{AccessibleObject , Modifier }
25+
26+ import org .apache .spark .Partition
27+ import org .apache .spark .rdd .RDD
28+
29+ import scala .util .Try
30+
2431/**
2532 * Additional debugging routines. No guarantees these are or will remain stable.
2633 *
2734 * @since 4/6/18
2835 */
2936package object debug {
37+
38+ implicit class DescribeablePartition (val p : Partition ) extends AnyVal {
39+ def describe : String = Try {
40+ def acc [A <: AccessibleObject ](a : A ): A = {
41+ a.setAccessible(true ); a
42+ }
43+
44+ val getters = p.getClass.getDeclaredMethods
45+ .filter(_.getParameterCount == 0 )
46+ .filter(m ⇒ (m.getModifiers & Modifier .PUBLIC ) > 0 )
47+ .filterNot(_.getName == " hashCode" )
48+ .map(acc)
49+ .map(m ⇒ m.getName + " =" + String .valueOf(m.invoke(p)))
50+
51+ val fields = p.getClass.getDeclaredFields
52+ .filter(f ⇒ (f.getModifiers & Modifier .PUBLIC ) > 0 )
53+ .map(acc)
54+ .map(m ⇒ m.getName + " =" + String .valueOf(m.get(p)))
55+
56+ p.getClass.getSimpleName + " (" + (fields ++ getters).mkString(" , " ) + " )"
57+
58+ }.getOrElse(p.toString)
59+ }
60+
61+ implicit class RDDWithPartitionDescribe (val r : RDD [_]) extends AnyVal {
62+ def describePartitions : String = r.partitions.map(p ⇒ (" Partition " + p.index) -> p.describe).mkString(" \n " )
63+ }
64+
3065}
66+
You can’t perform that action at this time.
0 commit comments