anishshri-db commented on code in PR #48686:
URL: https://github.com/apache/spark/pull/48686#discussion_r1821575322
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateInitialStateSuite.scala:
##########
@@ -194,6 +272,45 @@ class StatefulProcessorWithInitialStateProcTimerClass
}
}
+/**
+ * Class that updates all state variables.
+ */
+class StatefulProcessorWithAllStateVars extends RunningCountStatefulProcessor {
+ @transient private var _listState: ListState[Long] = _
+ @transient private var _mapState: MapState[String, Long] = _
+
+ override def init(
+ outputMode: OutputMode,
+ timeMode: TimeMode): Unit = {
+ _countState = getHandle.getValueState[Long]("countState",
Encoders.scalaLong)
+ _listState = getHandle.getListState[Long](
+ "listState", Encoders.scalaLong)
+ _mapState = getHandle.getMapState[String, Long](
+ "mapState", Encoders.STRING, Encoders.scalaLong)
+ }
+
+ override def handleInputRows(
+ key: String,
+ inputRows: Iterator[String],
+ timerValues: TimerValues): Iterator[(String, String)] = {
+ val curCountValue = if (_countState.exists()) {
+ _countState.get()
+ } else 0L
Review Comment:
nit: missing brace ?
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithStateInitialStateSuite.scala:
##########
@@ -194,6 +272,45 @@ class StatefulProcessorWithInitialStateProcTimerClass
}
}
+/**
+ * Class that updates all state variables.
+ */
+class StatefulProcessorWithAllStateVars extends RunningCountStatefulProcessor {
+ @transient private var _listState: ListState[Long] = _
+ @transient private var _mapState: MapState[String, Long] = _
+
+ override def init(
+ outputMode: OutputMode,
+ timeMode: TimeMode): Unit = {
+ _countState = getHandle.getValueState[Long]("countState",
Encoders.scalaLong)
+ _listState = getHandle.getListState[Long](
+ "listState", Encoders.scalaLong)
+ _mapState = getHandle.getMapState[String, Long](
+ "mapState", Encoders.STRING, Encoders.scalaLong)
+ }
+
+ override def handleInputRows(
+ key: String,
+ inputRows: Iterator[String],
+ timerValues: TimerValues): Iterator[(String, String)] = {
+ val curCountValue = if (_countState.exists()) {
+ _countState.get()
+ } else 0L
+ var cnt = curCountValue
+ inputRows.foreach { row =>
+ cnt += 1
+ _listState.appendValue(cnt)
+ val mapCurVal = if (_mapState.containsKey(row)) {
+ _mapState.getValue(row)
+ } else 0
Review Comment:
same here ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]