Skip to content

Commit 69f5b19

Browse files
author
Ubuntu
committed
remove unused code
1 parent ea461ee commit 69f5b19

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/state/StateDataSource.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
6666
StateSourceOptions.apply(session, hadoopConf, properties))
6767
val stateConf = buildStateStoreConf(sourceOptions.resolvedCpLocation, sourceOptions.batchId)
6868
if (sourceOptions.readAllColumnFamilies) {
69-
// For readAllColumnFamilies mode, we don't need specific metadata
69+
// For readAllColumnFamilies mode, we don't need specific encoder because it returns raw data
7070
val keyStateEncoderSpec = NoPrefixKeyStateEncoderSpec(new StructType())
7171
new StateTable(session, schema, sourceOptions, stateConf, keyStateEncoderSpec,
7272
None, None, None, None)

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/state/StatePartitionReader.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.spark.sql.execution.streaming.operators.stateful.join.Symmetri
2626
import org.apache.spark.sql.execution.streaming.operators.stateful.transformwithstate.{StateVariableType, TransformWithStateVariableInfo}
2727
import org.apache.spark.sql.execution.streaming.state._
2828
import org.apache.spark.sql.execution.streaming.state.RecordType.{getRecordTypeAsString, RecordType}
29-
import org.apache.spark.sql.types.{BinaryType, NullType, StructField, StructType}
29+
import org.apache.spark.sql.types.{NullType, StructField, StructType}
3030
import org.apache.spark.unsafe.types.UTF8String
3131
import org.apache.spark.util.{NextIterator, SerializableConfiguration}
3232

@@ -85,20 +85,16 @@ abstract class StatePartitionReaderBase(
8585
private val schemaForValueRow: StructType =
8686
StructType(Array(StructField("__dummy__", NullType)))
8787

88-
protected val keySchema = {
88+
protected lazy val keySchema = {
8989
if (SchemaUtil.checkVariableType(stateVariableInfoOpt, StateVariableType.MapState)) {
9090
SchemaUtil.getCompositeKeySchema(schema, partition.sourceOptions)
91-
} else if (partition.sourceOptions.readAllColumnFamilies) {
92-
new StructType().add("keyBytes", BinaryType, nullable = false)
9391
} else {
9492
SchemaUtil.getSchemaAsDataType(schema, "key").asInstanceOf[StructType]
9593
}
9694
}
9795

98-
protected val valueSchema = if (stateVariableInfoOpt.isDefined) {
96+
protected lazy val valueSchema = if (stateVariableInfoOpt.isDefined) {
9997
schemaForValueRow
100-
} else if (partition.sourceOptions.readAllColumnFamilies) {
101-
new StructType().add("valueBytes", BinaryType, nullable = false)
10298
} else {
10399
SchemaUtil.getSchemaAsDataType(
104100
schema, "value").asInstanceOf[StructType]
@@ -289,9 +285,10 @@ class StatePartitionReaderAllColumnFamilies(
289285
// loading data from disk, so we disable it for raw bytes mode.
290286
val modifiedStoreConf = storeConf.withFormatValidationDisabled()
291287

292-
val keyStateEncoderSpec = NoPrefixKeyStateEncoderSpec(keySchema)
288+
val keyStateEncoderSpec = NoPrefixKeyStateEncoderSpec(new StructType())
289+
// Pass in empty keySchema, valueSchema and dummy encoder because we don't encode any data
293290
val provider = StateStoreProvider.createAndInit(
294-
stateStoreProviderId, keySchema, valueSchema, keyStateEncoderSpec,
291+
stateStoreProviderId, new StructType(), new StructType(), keyStateEncoderSpec,
295292
useColumnFamilies = colFamilyNames.nonEmpty, modifiedStoreConf, hadoopConf.value, false, None)
296293

297294
provider

0 commit comments

Comments
 (0)