Class PbCodegenUtils


  • public class PbCodegenUtils
    extends Object
    Codegen utils only used in protobuf format.
    • Constructor Detail

      • PbCodegenUtils

        public PbCodegenUtils()
    • Method Detail

      • flinkContainerElementCode

        public static String flinkContainerElementCode​(String flinkContainerCode,
                                                       String index,
                                                       org.apache.flink.table.types.logical.LogicalType eleType)
        Parameters:
        flinkContainerCode - code phrase which represent flink container type like row/array in codegen sections
        index - the index number in flink container type
        eleType - the element type
      • getTypeStrFromProto

        public static String getTypeStrFromProto​(com.google.protobuf.Descriptors.FieldDescriptor fd,
                                                 boolean isList)
                                          throws PbCodegenException
        Get java type str from Descriptors.FieldDescriptor which directly fetched from protobuf object.
        Returns:
        The returned code phrase will be used as java type str in codegen sections.
        Throws:
        PbCodegenException
      • getTypeStrFromLogicType

        public static String getTypeStrFromLogicType​(org.apache.flink.table.types.logical.LogicalType type)
        Get java type str from LogicalType which directly fetched from flink type.
        Returns:
        The returned code phrase will be used as java type str in codegen sections.
      • pbDefaultValueCode

        public static String pbDefaultValueCode​(com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor,
                                                PbFormatContext pbFormatContext)
                                         throws PbCodegenException
        Get protobuf default value from Descriptors.FieldDescriptor.
        Returns:
        The java code phrase which represents default value calculation.
        Throws:
        PbCodegenException
      • convertFlinkArrayElementToPbWithDefaultValueCode

        public static String convertFlinkArrayElementToPbWithDefaultValueCode​(String flinkArrDataVar,
                                                                              String iVar,
                                                                              String resultPbVar,
                                                                              com.google.protobuf.Descriptors.FieldDescriptor elementPbFd,
                                                                              org.apache.flink.table.types.logical.LogicalType elementDataType,
                                                                              PbFormatContext pbFormatContext,
                                                                              int indent)
                                                                       throws PbCodegenException
        This method will be called from serializer of flink array/map type because flink contains both array/map type in array format. Map/Array cannot contain null value in pb object then we must do conversion in case of null values in map/array type.
        Parameters:
        flinkArrDataVar - code phrase represent arrayData of arr type or keyData/valueData in map type.
        iVar - the index in arrDataVar
        resultPbVar - the returned pb variable name in codegen.
        elementPbFd - Descriptors.FieldDescriptor of element type in proto object
        elementDataType - LogicalType of element type in flink object
        Returns:
        The java code segment which represents field value retrieval.
        Throws:
        PbCodegenException
      • needToSplit

        public static boolean needToSplit​(int noSplitCodeSize)