derrickaw commented on code in PR #35435: URL: https://github.com/apache/beam/pull/35435#discussion_r2167626003
########## sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableSimpleWriteSchemaTransformProvider.java: ########## @@ -0,0 +1,217 @@ +/* + * 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.beam.sdk.io.gcp.bigtable; + +import static java.util.Optional.ofNullable; +import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; + +import com.google.auto.service.AutoService; +import com.google.bigtable.v2.Mutation; +import com.google.bigtable.v2.TimestampRange; +import com.google.protobuf.ByteString; + +import java.nio.charset.Charset; +import java.util.Objects; +import org.apache.beam.sdk.io.gcp.bigtable.BigtableWriteSchemaTransformProvider.BigtableWriteSchemaTransformConfiguration; +import org.apache.beam.sdk.schemas.transforms.SchemaTransform; +import org.apache.beam.sdk.schemas.transforms.SchemaTransformProvider; +import org.apache.beam.sdk.schemas.transforms.TypedSchemaTransformProvider; +import org.apache.beam.sdk.transforms.GroupByKey; +import org.apache.beam.sdk.transforms.MapElements; +import org.apache.beam.sdk.values.KV; +import org.apache.beam.sdk.values.PCollection; +import org.apache.beam.sdk.values.PCollectionRowTuple; +import org.apache.beam.sdk.values.Row; +import org.apache.beam.sdk.values.TypeDescriptor; +import org.apache.beam.sdk.values.TypeDescriptors; + +/** + * An implementation of {@link TypedSchemaTransformProvider} for Bigtable Write jobs configured via + * {@link BigtableWriteSchemaTransformConfiguration}. + * + * <p><b>Internal only:</b> This class is actively being worked on, and it will likely change. We + * provide no backwards compatibility guarantees, and it should not be implemented outside the Beam + * repository. + */ +@AutoService(SchemaTransformProvider.class) +public class BigtableSimpleWriteSchemaTransformProvider + extends TypedSchemaTransformProvider<BigtableWriteSchemaTransformConfiguration> { + + private static final String INPUT_TAG = "input"; + + @Override + protected SchemaTransform from(BigtableWriteSchemaTransformConfiguration configuration) { + return new BigtableSimpleWriteSchemaTransform(configuration); + } + + @Override + public String identifier() { + return "beam:schematransform:org.apache.beam:bigtable_simple_write:v1"; + } + + /** + * A {@link SchemaTransform} for Bigtable writes, configured with {@link + * BigtableWriteSchemaTransformConfiguration} and instantiated by {@link + * BigtableWriteSchemaTransformProvider}. + */ + private static class BigtableSimpleWriteSchemaTransform extends SchemaTransform { + private final BigtableWriteSchemaTransformConfiguration configuration; + + BigtableSimpleWriteSchemaTransform(BigtableWriteSchemaTransformConfiguration configuration) { + configuration.validate(); + this.configuration = configuration; + } + + @Override + public PCollectionRowTuple expand(PCollectionRowTuple input) { + checkArgument( + input.has(INPUT_TAG), + String.format( + "Could not find expected input [%s] to %s.", INPUT_TAG, getClass().getSimpleName())); + + PCollection<Row> beamRowMutationsList = input.getSinglePCollection(); + System.out.println("Input PCollection Schema: " + beamRowMutationsList.getSchema()); Review Comment: remove -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org