taklwu commented on code in PR #168: URL: https://github.com/apache/hbase-connectors/pull/168#discussion_r4096972349
########## spark4/hbase-spark4/src/main/scala/org/apache/hadoop/hbase/spark/datasources/HBaseStreamingDataWriterFactory.scala: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.spark.datasources + +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.connector.write.DataWriter +import org.apache.spark.sql.connector.write.streaming.StreamingDataWriterFactory +import org.apache.spark.sql.types.StructType +import org.apache.yetus.audience.InterfaceAudience + +/** + * This is a new class in the spark4 module. Implements StreamingDataWriterFactory for the DS V2 + * streaming write path. Serialized to executors. Creates one HBaseDataWriter per Spark partition + * per micro-batch epoch. The epochId is not used because HBase puts are idempotent — a retried + * epoch writes the same rows with the same row keys, producing no duplicates. + * + * @param schema + * @param properties + * @param catalog + * @param wrappedConf + */ [email protected] +class HBaseStreamingDataWriterFactory( + schema: StructType, + properties: Map[String, String], + catalog: HBaseTableCatalog, + wrappedConf: SerializableConfiguration) + extends StreamingDataWriterFactory + with Serializable { + + override def createWriter( + partitionId: Int, + taskId: Long, + epochId: Long): DataWriter[InternalRow] = { + new HBaseDataWriter(schema, properties, catalog, wrappedConf) Review Comment: rewording the java seems the way to go. other than that, do we have unit tests that could define the right use cases? if not we can either do it in this PR or have a separate JIRA for it. -- 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]
