TheNeuralBit commented on a change in pull request #16762:
URL: https://github.com/apache/beam/pull/16762#discussion_r810282399
##########
File path:
buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
##########
@@ -656,6 +657,7 @@ class BeamModulePlugin implements Plugin<Project> {
proto_google_cloud_spanner_v1 :
"com.google.api.grpc:proto-google-cloud-spanner-v1", //
google_cloud_platform_libraries_bom sets version
proto_google_cloud_spanner_admin_database_v1:
"com.google.api.grpc:proto-google-cloud-spanner-admin-database-v1", //
google_cloud_platform_libraries_bom sets version
proto_google_common_protos :
"com.google.api.grpc:proto-google-common-protos", //
google_cloud_platform_libraries_bom sets version
+ sbe_tool :
"uk.co.real-logic:sbe-tool:$sbe_tool_version",
Review comment:
Does the real logic SBE implementation have an acceptable licesnse?
##########
File path:
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/SbeSchema.java
##########
@@ -0,0 +1,252 @@
+/*
+ * 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.extensions.sbe;
+
+import static
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkState;
+
+import com.google.auto.value.AutoValue;
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.io.payloads.PayloadSerializerProvider;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import uk.co.real_logic.sbe.ir.Ir;
+
+/**
+ * Represents an SBE schema that can be translated to a Beam {@link Schema}
and {@link
+ * PayloadSerializerProvider}.
+ *
+ * <p>The schema represents a single SBE message. If the XML schema contains
more than one message,
+ * then a new instance must be created for each message that the pipeline will
work with.
+ *
+ * <p>The currently supported ways of generating a schema are:
+ *
+ * <ul>
+ * <li>Through an intermediate representation ({@link Ir}).
+ * </ul>
+ *
+ * <h3>Intermediate Representation</h3>
+ *
+ * <p>An {@link Ir} allows for a reflection-less way of getting a very
accurate representation of
+ * the SBE schema, since it is a tokenized form of the original XML schema. To
help deal with some
+ * ambiguities, such as which message to base the schema around, passing
{@link IrOptions} is
+ * required. See the Javadoc for the options for more details.
+ *
+ * <p>At this time, we cannot support serialization to an SBE message through
IR. As a result, the
+ * {@code byte[]} output from the {@link PayloadSerializerProvider} serializer
will be from a JSON
Review comment:
nit: wouldn't this be more straightforward?
```suggestion
* {@code byte[]} output from the {@link PayloadSerializer} will be from a
JSON
```
I'm a little confused by this statement in general, how would a user create
a `PayloadSerializerProvider` that produces JSON? Are you suggesting they would
take a Schema generated from SBE and pass it to the
`JsonPayloadSerializerProvider`?
##########
File path:
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/SbeSchema.java
##########
@@ -0,0 +1,252 @@
+/*
+ * 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.extensions.sbe;
+
+import static
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkState;
+
+import com.google.auto.value.AutoValue;
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.io.payloads.PayloadSerializerProvider;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import uk.co.real_logic.sbe.ir.Ir;
+
+/**
+ * Represents an SBE schema that can be translated to a Beam {@link Schema}
and {@link
+ * PayloadSerializerProvider}.
+ *
+ * <p>The schema represents a single SBE message. If the XML schema contains
more than one message,
+ * then a new instance must be created for each message that the pipeline will
work with.
+ *
+ * <p>The currently supported ways of generating a schema are:
+ *
+ * <ul>
+ * <li>Through an intermediate representation ({@link Ir}).
+ * </ul>
+ *
+ * <h3>Intermediate Representation</h3>
+ *
+ * <p>An {@link Ir} allows for a reflection-less way of getting a very
accurate representation of
+ * the SBE schema, since it is a tokenized form of the original XML schema. To
help deal with some
+ * ambiguities, such as which message to base the schema around, passing
{@link IrOptions} is
+ * required. See the Javadoc for the options for more details.
+ *
+ * <p>At this time, we cannot support serialization to an SBE message through
IR. As a result, the
+ * {@code byte[]} output from the {@link PayloadSerializerProvider} serializer
will be from a JSON
+ * representation of the message, not an SBE-serialized message. Downstream
systems will need to
+ * account for this.
+ */
+@Experimental(Kind.SCHEMAS)
+public final class SbeSchema implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final @Nullable SerializableIr ir;
+ private final @Nullable IrOptions irOptions;
+ private final ImmutableList<SbeField> sbeFields;
+
+ private SbeSchema(
+ @Nullable SerializableIr ir,
+ @Nullable IrOptions irOptions,
+ ImmutableList<SbeField> sbeFields) {
+ this.ir = ir;
+ this.irOptions = irOptions;
+ this.sbeFields = sbeFields;
+ }
+
+ /**
+ * Creates a new {@link SbeSchema} from the given intermediate
representation.
+ *
+ * <p>This makes no guarantees about the state of the returned instance.
That is, it may or may
+ * not have the generated SBE schema representation, and it may or may not
have translated the SBE
+ * schema into a Beam schema.
+ *
+ * @param ir the intermediate representation of the SBE schema.
Modifications to the passed-in
+ * value will not be reflected in the returned instance.
+ * @param irOptions options for configuring how to deal with cases where the
desired behavior is
+ * ambiguous.
+ * @return a new {@link SbeSchema} instance
+ */
+ public static SbeSchema fromIr(Ir ir, IrOptions irOptions) {
+ ImmutableList<SbeField> sbeFields = IrFieldGenerator.generateFields(ir,
irOptions);
+
+ Ir copy =
+ new Ir(
+ ir.packageName(),
+ ir.namespaceName(),
+ ir.id(),
+ ir.version(),
+ ir.description(),
+ ir.semanticVersion(),
+ ir.byteOrder(),
+ ImmutableList.copyOf(ir.headerStructure().tokens()));
+
+ return new SbeSchema(SerializableIr.fromIr(copy), irOptions, sbeFields);
+ }
+
+ @VisibleForTesting
+ @Nullable
+ Ir getIr() {
+ return ir == null ? null : ir.ir();
+ }
+
+ @VisibleForTesting
+ @Nullable
+ IrOptions getIrOptions() {
+ return irOptions;
+ }
+
+ @VisibleForTesting
+ ImmutableList<SbeField> getSbeFields() {
+ return sbeFields;
+ }
+
+ /**
+ * Options for controlling what to do with unsigned types, specifically
whether to use a higher
+ * bit count or, in the case of uint64, a string.
+ */
+ @AutoValue
+ public abstract static class UnsignedOptions implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public abstract Boolean useMoreBitsForUint8();
+
+ public abstract Boolean useMoreBitsForUint16();
+
+ public abstract Boolean useMoreBitsForUint32();
+
+ public abstract Boolean useStringForUint64();
Review comment:
+1 on making this configurable!
I'd prefer enumerated types over booleans here though. Booleans are
restricted to two options and can't be expanded without a major refactor, but
if these were enums you could easily add another option in the future (e.g.
maybe map to BigDecimal or floating point). I'd suggest having an option for
each bit width with the same enumerated settings like "COERCE_TO_UNSINGED",
"HIGHER _BITWDITH_SIGNED", "STRING". HIGHER_BITWIDTH_SIGNED could raise for
Uint64.
##########
File path:
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/SbeSchema.java
##########
@@ -0,0 +1,252 @@
+/*
+ * 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.extensions.sbe;
+
+import static
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkState;
+
+import com.google.auto.value.AutoValue;
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.io.payloads.PayloadSerializerProvider;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import uk.co.real_logic.sbe.ir.Ir;
+
+/**
+ * Represents an SBE schema that can be translated to a Beam {@link Schema}
and {@link
+ * PayloadSerializerProvider}.
+ *
+ * <p>The schema represents a single SBE message. If the XML schema contains
more than one message,
+ * then a new instance must be created for each message that the pipeline will
work with.
+ *
+ * <p>The currently supported ways of generating a schema are:
+ *
+ * <ul>
+ * <li>Through an intermediate representation ({@link Ir}).
+ * </ul>
+ *
+ * <h3>Intermediate Representation</h3>
+ *
+ * <p>An {@link Ir} allows for a reflection-less way of getting a very
accurate representation of
+ * the SBE schema, since it is a tokenized form of the original XML schema. To
help deal with some
+ * ambiguities, such as which message to base the schema around, passing
{@link IrOptions} is
+ * required. See the Javadoc for the options for more details.
+ *
+ * <p>At this time, we cannot support serialization to an SBE message through
IR. As a result, the
+ * {@code byte[]} output from the {@link PayloadSerializerProvider} serializer
will be from a JSON
+ * representation of the message, not an SBE-serialized message. Downstream
systems will need to
+ * account for this.
+ */
+@Experimental(Kind.SCHEMAS)
+public final class SbeSchema implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final @Nullable SerializableIr ir;
+ private final @Nullable IrOptions irOptions;
+ private final ImmutableList<SbeField> sbeFields;
+
+ private SbeSchema(
+ @Nullable SerializableIr ir,
+ @Nullable IrOptions irOptions,
+ ImmutableList<SbeField> sbeFields) {
+ this.ir = ir;
+ this.irOptions = irOptions;
+ this.sbeFields = sbeFields;
+ }
+
+ /**
+ * Creates a new {@link SbeSchema} from the given intermediate
representation.
+ *
+ * <p>This makes no guarantees about the state of the returned instance.
That is, it may or may
+ * not have the generated SBE schema representation, and it may or may not
have translated the SBE
+ * schema into a Beam schema.
+ *
+ * @param ir the intermediate representation of the SBE schema.
Modifications to the passed-in
+ * value will not be reflected in the returned instance.
+ * @param irOptions options for configuring how to deal with cases where the
desired behavior is
+ * ambiguous.
+ * @return a new {@link SbeSchema} instance
+ */
+ public static SbeSchema fromIr(Ir ir, IrOptions irOptions) {
+ ImmutableList<SbeField> sbeFields = IrFieldGenerator.generateFields(ir,
irOptions);
+
+ Ir copy =
+ new Ir(
+ ir.packageName(),
+ ir.namespaceName(),
+ ir.id(),
+ ir.version(),
+ ir.description(),
+ ir.semanticVersion(),
+ ir.byteOrder(),
+ ImmutableList.copyOf(ir.headerStructure().tokens()));
+
+ return new SbeSchema(SerializableIr.fromIr(copy), irOptions, sbeFields);
+ }
+
+ @VisibleForTesting
+ @Nullable
+ Ir getIr() {
+ return ir == null ? null : ir.ir();
+ }
+
+ @VisibleForTesting
+ @Nullable
+ IrOptions getIrOptions() {
+ return irOptions;
+ }
+
+ @VisibleForTesting
+ ImmutableList<SbeField> getSbeFields() {
+ return sbeFields;
+ }
+
+ /**
+ * Options for controlling what to do with unsigned types, specifically
whether to use a higher
+ * bit count or, in the case of uint64, a string.
+ */
+ @AutoValue
+ public abstract static class UnsignedOptions implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public abstract Boolean useMoreBitsForUint8();
+
+ public abstract Boolean useMoreBitsForUint16();
+
+ public abstract Boolean useMoreBitsForUint32();
+
+ public abstract Boolean useStringForUint64();
+
+ /**
+ * Returns options for using the same bit size for all unsigned types.
+ *
+ * <p>This means that if an unsigned value from SBE comes in with a value
outside the signed
+ * range, then the negative equivalent (in terms of bits) will be used.
+ */
+ public static UnsignedOptions usingSameBitSize() {
+ return UnsignedOptions.builder()
+ .setUseMoreBitsForUint8(false)
+ .setUseMoreBitsForUint16(false)
+ .setUseMoreBitsForUint32(false)
+ .setUseStringForUint64(false)
+ .build();
+ }
+
+ /**
+ * Returns options for using a higher bit count for unsigned types.
+ *
+ * <p>This means that if an unsigned value is encountered, it will always
use the higher bit
+ * count, even if that higher bit count is unnecessary. However, this
means that if it is
+ * necessary, then the proper value will be returned rather than the
negative equivalent (in
+ * terms of bits).
+ *
+ * <p>The {@code includeUint64} controls the behavior of 64-bit values,
since no properly
+ * higher-bit-numeric type exists. If true, then this will be converted
into a string that must
+ * be parsed if intended to be used as a number. Otherwise, it will still
be a 64-bit type and
+ * may return negative values.
+ */
+ public static UnsignedOptions usingHigherBitSize(boolean includeUint64) {
+ return UnsignedOptions.builder()
+ .setUseMoreBitsForUint8(true)
+ .setUseMoreBitsForUint16(true)
+ .setUseMoreBitsForUint32(true)
+ .setUseStringForUint64(includeUint64)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_SbeSchema_UnsignedOptions.Builder();
+ }
+
+ /** Builder for {@link UnsignedOptions}. */
Review comment:
I think it would be more straightforward, and acceptable, if this were
just a schema level option. Also, it's odd as it is, since it's defined here in
SbeSchema, but only used in the SbeFieldOptions
##########
File path:
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/SbeSchema.java
##########
@@ -0,0 +1,252 @@
+/*
+ * 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.extensions.sbe;
+
+import static
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkState;
+
+import com.google.auto.value.AutoValue;
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.schemas.Schema;
+import org.apache.beam.sdk.schemas.io.payloads.PayloadSerializerProvider;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import uk.co.real_logic.sbe.ir.Ir;
+
+/**
+ * Represents an SBE schema that can be translated to a Beam {@link Schema}
and {@link
+ * PayloadSerializerProvider}.
+ *
+ * <p>The schema represents a single SBE message. If the XML schema contains
more than one message,
+ * then a new instance must be created for each message that the pipeline will
work with.
+ *
+ * <p>The currently supported ways of generating a schema are:
+ *
+ * <ul>
+ * <li>Through an intermediate representation ({@link Ir}).
+ * </ul>
+ *
+ * <h3>Intermediate Representation</h3>
+ *
+ * <p>An {@link Ir} allows for a reflection-less way of getting a very
accurate representation of
+ * the SBE schema, since it is a tokenized form of the original XML schema. To
help deal with some
+ * ambiguities, such as which message to base the schema around, passing
{@link IrOptions} is
+ * required. See the Javadoc for the options for more details.
+ *
+ * <p>At this time, we cannot support serialization to an SBE message through
IR. As a result, the
+ * {@code byte[]} output from the {@link PayloadSerializerProvider} serializer
will be from a JSON
+ * representation of the message, not an SBE-serialized message. Downstream
systems will need to
+ * account for this.
+ */
+@Experimental(Kind.SCHEMAS)
+public final class SbeSchema implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private final @Nullable SerializableIr ir;
+ private final @Nullable IrOptions irOptions;
+ private final ImmutableList<SbeField> sbeFields;
+
+ private SbeSchema(
+ @Nullable SerializableIr ir,
+ @Nullable IrOptions irOptions,
+ ImmutableList<SbeField> sbeFields) {
+ this.ir = ir;
+ this.irOptions = irOptions;
+ this.sbeFields = sbeFields;
+ }
+
+ /**
+ * Creates a new {@link SbeSchema} from the given intermediate
representation.
+ *
+ * <p>This makes no guarantees about the state of the returned instance.
That is, it may or may
+ * not have the generated SBE schema representation, and it may or may not
have translated the SBE
+ * schema into a Beam schema.
+ *
+ * @param ir the intermediate representation of the SBE schema.
Modifications to the passed-in
+ * value will not be reflected in the returned instance.
+ * @param irOptions options for configuring how to deal with cases where the
desired behavior is
+ * ambiguous.
+ * @return a new {@link SbeSchema} instance
+ */
+ public static SbeSchema fromIr(Ir ir, IrOptions irOptions) {
+ ImmutableList<SbeField> sbeFields = IrFieldGenerator.generateFields(ir,
irOptions);
+
+ Ir copy =
+ new Ir(
+ ir.packageName(),
+ ir.namespaceName(),
+ ir.id(),
+ ir.version(),
+ ir.description(),
+ ir.semanticVersion(),
+ ir.byteOrder(),
+ ImmutableList.copyOf(ir.headerStructure().tokens()));
+
+ return new SbeSchema(SerializableIr.fromIr(copy), irOptions, sbeFields);
+ }
+
+ @VisibleForTesting
+ @Nullable
+ Ir getIr() {
+ return ir == null ? null : ir.ir();
+ }
+
+ @VisibleForTesting
+ @Nullable
+ IrOptions getIrOptions() {
+ return irOptions;
+ }
+
+ @VisibleForTesting
+ ImmutableList<SbeField> getSbeFields() {
+ return sbeFields;
+ }
+
+ /**
+ * Options for controlling what to do with unsigned types, specifically
whether to use a higher
+ * bit count or, in the case of uint64, a string.
+ */
+ @AutoValue
+ public abstract static class UnsignedOptions implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public abstract Boolean useMoreBitsForUint8();
+
+ public abstract Boolean useMoreBitsForUint16();
+
+ public abstract Boolean useMoreBitsForUint32();
+
+ public abstract Boolean useStringForUint64();
+
+ /**
+ * Returns options for using the same bit size for all unsigned types.
+ *
+ * <p>This means that if an unsigned value from SBE comes in with a value
outside the signed
+ * range, then the negative equivalent (in terms of bits) will be used.
+ */
+ public static UnsignedOptions usingSameBitSize() {
+ return UnsignedOptions.builder()
+ .setUseMoreBitsForUint8(false)
+ .setUseMoreBitsForUint16(false)
+ .setUseMoreBitsForUint32(false)
+ .setUseStringForUint64(false)
+ .build();
+ }
+
+ /**
+ * Returns options for using a higher bit count for unsigned types.
+ *
+ * <p>This means that if an unsigned value is encountered, it will always
use the higher bit
+ * count, even if that higher bit count is unnecessary. However, this
means that if it is
+ * necessary, then the proper value will be returned rather than the
negative equivalent (in
+ * terms of bits).
+ *
+ * <p>The {@code includeUint64} controls the behavior of 64-bit values,
since no properly
+ * higher-bit-numeric type exists. If true, then this will be converted
into a string that must
+ * be parsed if intended to be used as a number. Otherwise, it will still
be a 64-bit type and
+ * may return negative values.
+ */
+ public static UnsignedOptions usingHigherBitSize(boolean includeUint64) {
+ return UnsignedOptions.builder()
+ .setUseMoreBitsForUint8(true)
+ .setUseMoreBitsForUint16(true)
+ .setUseMoreBitsForUint32(true)
+ .setUseStringForUint64(includeUint64)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_SbeSchema_UnsignedOptions.Builder();
+ }
+
+ /** Builder for {@link UnsignedOptions}. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder setUseMoreBitsForUint8(Boolean value);
+
+ public abstract Builder setUseMoreBitsForUint16(Boolean value);
+
+ public abstract Builder setUseMoreBitsForUint32(Boolean value);
+
+ public abstract Builder setUseStringForUint64(Boolean value);
+
+ public abstract UnsignedOptions build();
+ }
+ }
+
+ /**
+ * Options for configuring schema generation from an {@link Ir}.
+ *
+ * <p>The default options make the following assumptions:
+ *
+ * <ul>
+ * <p>There is only message in the XML schema. In order to override this,
either {@link
+ * IrOptions#messageId()} or {@link IrOptions#messageName()} must be set,
but not both.
+ * </ul>
+ */
+ @AutoValue
+ public abstract static class IrOptions implements Serializable {
Review comment:
I'm not sure if this is your intention or not but these could be mapped
to/from table params in the PayloadSerializerProvider:
https://github.com/apache/beam/blob/30b440faa78f66fefd9b64be743d11021c998e82/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/io/payloads/PayloadSerializerProvider.java#L36
##########
File path:
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/SbeFieldUtils.java
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.extensions.sbe;
+
+import org.apache.beam.sdk.extensions.sbe.SbeSchema.UnsignedOptions;
+import org.apache.beam.sdk.schemas.Schema.FieldType;
+import uk.co.real_logic.sbe.PrimitiveType;
+
+/** Utilities for working with SBE fields. */
+final class SbeFieldUtils {
+ private SbeFieldUtils() {}
+
+ /**
+ * Converts a SBE {@link PrimitiveType} to a Beam {@link FieldType}.
+ *
+ * <p>"Signed" in this case simply means that it isn't one of the unsigned
types (uint8, uint16,
+ * uint32, uint64). This includes the char type.
+ *
+ * @param sbePrimitive the signed {@link PrimitiveType}
+ * @return the Beam equivalent of the SBE type
+ */
+ static FieldType signedSbePrimitiveToBeamPrimitive(PrimitiveType
sbePrimitive) {
Review comment:
I'd prefer if these were just private helpers (or even inlined) in
`PrimitiveSbeField`. It looks like they're only called there and in tests. The
tests could just verify the higher-level public API instead.
--
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]