Class PbCodegenUtils
- java.lang.Object
-
- org.apache.flink.formats.protobuf.util.PbCodegenUtils
-
public class PbCodegenUtils extends Object
Codegen utils only used in protobuf format.
-
-
Constructor Summary
Constructors Constructor Description PbCodegenUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClasscompileClass(ClassLoader classloader, String className, String code)static StringconvertFlinkArrayElementToPbWithDefaultValueCode(String flinkArrDataVar, String iVar, String resultPbVar, com.google.protobuf.Descriptors.FieldDescriptor elementPbFd, org.apache.flink.table.types.logical.LogicalType elementDataType, PbFormatContext pbFormatContext, int indent)This method will be called from serializer of flink array/map type because flink contains both array/map type in array format.static StringflinkContainerElementCode(String flinkContainerCode, String index, org.apache.flink.table.types.logical.LogicalType eleType)static StringgetTypeStrFromLogicType(org.apache.flink.table.types.logical.LogicalType type)Get java type str fromLogicalTypewhich directly fetched from flink type.static StringgetTypeStrFromProto(com.google.protobuf.Descriptors.FieldDescriptor fd, boolean isList)Get java type str fromDescriptors.FieldDescriptorwhich directly fetched from protobuf object.static booleanneedToSplit(int noSplitCodeSize)static StringpbDefaultValueCode(com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor, PbFormatContext pbFormatContext)Get protobuf default value fromDescriptors.FieldDescriptor.
-
-
-
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 sectionsindex- the index number in flink container typeeleType- the element type
-
getTypeStrFromProto
public static String getTypeStrFromProto(com.google.protobuf.Descriptors.FieldDescriptor fd, boolean isList) throws PbCodegenException
Get java type str fromDescriptors.FieldDescriptorwhich 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 fromLogicalTypewhich 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 fromDescriptors.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 arrDataVarresultPbVar- the returned pb variable name in codegen.elementPbFd-Descriptors.FieldDescriptorof element type in proto objectelementDataType-LogicalTypeof element type in flink object- Returns:
- The java code segment which represents field value retrieval.
- Throws:
PbCodegenException
-
compileClass
public static Class compileClass(ClassLoader classloader, String className, String code) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
needToSplit
public static boolean needToSplit(int noSplitCodeSize)
-
-