Class LengthPrefixUnknownCoders


  • public class LengthPrefixUnknownCoders
    extends java.lang.Object
    Utilities for replacing or wrapping unknown coders with LengthPrefixCoder.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addKnownCoderUrn​(java.lang.String urn)
      Registers a coder as being of known type and as such not meriting length prefixing.
      static java.lang.String addLengthPrefixedCoder​(java.lang.String coderId, org.apache.beam.model.pipeline.v1.RunnerApi.Components.Builder components, boolean replaceWithByteArrayCoder)
      Recursively traverses the coder tree and wraps the first unknown coder in every branch with a LengthPrefixCoder unless an ancestor coder is itself a LengthPrefixCoder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LengthPrefixUnknownCoders

        public LengthPrefixUnknownCoders()
    • Method Detail

      • addKnownCoderUrn

        public static void addKnownCoderUrn​(java.lang.String urn)
        Registers a coder as being of known type and as such not meriting length prefixing.
        Parameters:
        urn - The urn of the coder that should not be length prefixed.
      • addLengthPrefixedCoder

        public static java.lang.String addLengthPrefixedCoder​(java.lang.String coderId,
                                                              org.apache.beam.model.pipeline.v1.RunnerApi.Components.Builder components,
                                                              boolean replaceWithByteArrayCoder)
        Recursively traverses the coder tree and wraps the first unknown coder in every branch with a LengthPrefixCoder unless an ancestor coder is itself a LengthPrefixCoder. If replaceWithByteArrayCoder is set, then replaces that unknown coder with a ByteArrayCoder. Registers the new coders in the given RunnerApi.Components.Builder. Note that no ids that are generated will collide with the ids supplied within the coder map key space.
        Parameters:
        coderId - The root coder contained within coders to start the recursive descent from.
        components - Components builder that initially contains the root coder and all component coders, and will be modified to contain all the necessary additional coders (including the resulting coder).
        replaceWithByteArrayCoder - whether to replace an unknown coder with a ByteArrayCoder.
        Returns:
        Id of the original coder (if unchanged) or the newly generated length-prefixed coder.