anishshri-db commented on code in PR #48728:
URL: https://github.com/apache/spark/pull/48728#discussion_r1828225419
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StatefulProcessorHandleImpl.scala:
##########
@@ -230,11 +205,39 @@ class StatefulProcessorHandleImpl(
}
}
- override def getListState[T](stateName: String, valEncoder: Encoder[T]):
ListState[T] = {
- verifyStateVarOperations("get_list_state", CREATED)
- val resultState = new ListStateImpl[T](store, stateName, keyEncoder,
valEncoder, metrics)
- TWSMetricsUtils.incrementMetric(metrics, "numListStateVars")
- resultState
+ override def getValueState[T](
+ stateName: String,
+ valEncoder: Encoder[T],
+ ttlConfig: TTLConfig): ValueState[T] = {
+ getValueState(stateName, ttlConfig)(valEncoder)
+ }
+
+ override def getValueState[T: Encoder](
+ stateName: String,
+ ttlConfig: TTLConfig): ValueState[T] = {
+ verifyStateVarOperations("get_value_state", CREATED)
+ val ttlEnabled = if (ttlConfig.ttlDuration != null &&
ttlConfig.ttlDuration.isZero) {
+ false
+ } else {
+ true
+ }
+
+ val stateEncoder = encoderFor[T].asInstanceOf[ExpressionEncoder[Any]]
+ val result = if (ttlEnabled) {
+ validateTTLConfig(ttlConfig, stateName)
+ assert(batchTimestampMs.isDefined)
+ val valueStateWithTTL = new ValueStateImplWithTTL[T](store, stateName,
+ keyEncoder, stateEncoder, ttlConfig, batchTimestampMs.get, metrics)
Review Comment:
Done
--
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]