com.azure.cosmos.spark.ItemsBatchWriter.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-cosmos-spark_3-5_2-12 Show documentation
Show all versions of azure-cosmos-spark_3-5_2-12 Show documentation
OLTP Spark 3.5 Connector for Azure Cosmos DB SQL API
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.spark
import com.azure.cosmos.spark.diagnostics.LoggerHelper
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.sql.connector.write.streaming.{StreamingDataWriterFactory, StreamingWrite}
import org.apache.spark.sql.connector.write.{BatchWrite, DataWriterFactory, PhysicalWriteInfo, WriterCommitMessage}
import org.apache.spark.sql.types.StructType
private class ItemsBatchWriter
(
userConfig: Map[String, String],
inputSchema: StructType,
cosmosClientStateHandles: Broadcast[CosmosClientMetadataCachesSnapshots],
diagnosticsConfig: DiagnosticsConfig,
sparkEnvironmentInfo: String
)
extends BatchWrite
with StreamingWrite {
@transient private lazy val log = LoggerHelper.getLogger(diagnosticsConfig, this.getClass)
log.logTrace(s"Instantiated ${this.getClass.getSimpleName}")
override def createBatchWriterFactory(physicalWriteInfo: PhysicalWriteInfo): DataWriterFactory = {
new ItemsDataWriteFactory(
userConfig,
inputSchema,
cosmosClientStateHandles,
diagnosticsConfig,
sparkEnvironmentInfo)
}
override def createStreamingWriterFactory(physicalWriteInfo: PhysicalWriteInfo): StreamingDataWriterFactory = {
new ItemsDataWriteFactory(
userConfig,
inputSchema,
cosmosClientStateHandles,
diagnosticsConfig,
sparkEnvironmentInfo)
}
override def useCommitCoordinator(): Boolean = {
return false
// TODO
}
override def commit(writerCommitMessages: Array[WriterCommitMessage]): Unit = {
// TODO
}
override def commit(epochId: Long, writerCommitMessages: Array[WriterCommitMessage]): Unit = {
// TODO
}
override def abort(writerCommitMessages: Array[WriterCommitMessage]): Unit = {
// TODO
}
override def abort(epochId: Long, writerCommitMessages: Array[WriterCommitMessage]): Unit = {
// TODO
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy