Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ trait StateStore {
*/
def abort(): Unit

/**
* Return an iterator containing all the key-value pairs in the SateStore. Implementations must
* ensure that updates (puts, removes) can be made while iterating over this iterator.
*/
def iterator(): Iterator[UnsafeRowPair]

/** Current metrics of the state store */
Expand Down Expand Up @@ -120,7 +124,12 @@ case class StateStoreMetrics(
* Name and description of custom implementation-specific metrics that a
* state store may wish to expose.
*/
case class StateStoreCustomMetric(name: String, desc: String)
trait StateStoreCustomMetric {
def name: String
def desc: String
}
case class StateStoreCustomSizeMetric(name: String, desc: String) extends StateStoreCustomMetric
case class StateStoreCustomTimingMetric(name: String, desc: String) extends StateStoreCustomMetric

/**
* Trait representing a provider that provide [[StateStore]] instances representing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ trait StateStoreWriter extends StatefulOperator { self: SparkPlan =>
* This should be called in that task after the store has been updated.
*/
protected def setStoreMetrics(store: StateStore): Unit = {

val storeMetrics = store.metrics
longMetric("numTotalStateRows") += storeMetrics.numKeys
longMetric("stateMemory") += storeMetrics.memoryUsedBytes
Expand All @@ -115,8 +114,12 @@ trait StateStoreWriter extends StatefulOperator { self: SparkPlan =>

private def stateStoreCustomMetrics: Map[String, SQLMetric] = {
val provider = StateStoreProvider.create(sqlContext.conf.stateStoreProviderClass)
provider.supportedCustomMetrics.map { m =>
m.name -> SQLMetrics.createTimingMetric(sparkContext, m.desc) }.toMap
provider.supportedCustomMetrics.map {
case StateStoreCustomSizeMetric(name, desc) =>
name -> SQLMetrics.createSizeMetric(sparkContext, desc)
case StateStoreCustomTimingMetric(name, desc) =>
name -> SQLMetrics.createTimingMetric(sparkContext, desc)
}.toMap
}
}

Expand Down