OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction Class Reference
+ Inheritance diagram for com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction:
+ Collaboration diagram for com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction:

Public Member Functions

List< String > getParamNames ()
 
List< FunctionParameter > getParameters ()
 
SqlReturnTypeInference getRowTypeInference ()
 
Set< RelColumnMapping > getColumnMappings ()
 
String getExtendedSignature ()
 
List< String > getExtendedParamNames ()
 
int hashCode ()
 
boolean equals (final Object obj)
 
String toString ()
 

Package Functions

 ExtTableFunction (final String name, final ExtensionFunction sig)
 
Map< String, List
< ExtArgumentType > > 
getCursorFieldTypes ()
 
List< ExtArgumentTypegetArgTypes ()
 

Private Member Functions

void debugPrint (String msg, Boolean debugMode)
 

Private Attributes

final List< ExtArgumentTypearg_types
 
final List< ExtArgumentTypeouts
 
final List< String > arg_names
 
final List< String > pretty_arg_names
 
final List< String > out_names
 
final Map< String, String > options
 
final Map< String, List
< ExtArgumentType > > 
cursor_field_types
 

Detailed Description

Definition at line 2706 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.ExtTableFunction ( final String  name,
final ExtensionFunction  sig 
)
inlinepackage

Definition at line 2707 of file HeavyDBSqlOperatorTable.java.

2707  {
2708  super(name,
2709  SqlKind.OTHER_FUNCTION,
2710  ReturnTypes.CURSOR,
2711  null,
2712  new ExtTableFunctionTypeChecker(HeavyDBSqlOperatorTable.this),
2713  SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
2714  arg_types = sig.getArgs();
2715  outs = sig.getOuts();
2716  out_names = sig.getOutNames();
2717  arg_names = sig.getArgNames();
2718  // pretty_arg_names will be same as arg_names, except with
2719  // arg names for cursors stripped of array elements, i.e
2720  // my_cursor_input[x, y, z] => my_cursor_input
2721  pretty_arg_names = sig.getPrettyArgNames();
2722  options = sig.getOptions();
2723  cursor_field_types = sig.getCursorFieldTypes();
2724  }
string name
Definition: setup.in.py:72

Member Function Documentation

void com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.debugPrint ( String  msg,
Boolean  debugMode 
)
inlineprivate

Definition at line 2801 of file HeavyDBSqlOperatorTable.java.

2801  {
2802  if (debugMode) {
2803  System.out.println(msg);
2804  }
2805  }
boolean com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.equals ( final Object  obj)
inline

Definition at line 2918 of file HeavyDBSqlOperatorTable.java.

References Cursor.

2918  {
2919  if (obj == null) {
2920  return false;
2921  }
2922 
2923  if (getClass() != obj.getClass()) {
2924  return false;
2925  }
2926 
2927  if (this == obj) {
2928  return true;
2929  }
2930 
2931  final ExtTableFunction other = (ExtTableFunction) obj;
2932  if (!this.getName().equals(other.getName())) {
2933  return false;
2934  }
2935  if (arg_types.size() != other.arg_types.size()) {
2936  return false;
2937  }
2938 
2939  for (int i = 0; i < arg_types.size(); i++) {
2940  if (arg_types.get(i) != other.arg_types.get(i)) {
2941  return false;
2942  }
2943  if (arg_types.get(i) == ExtArgumentType.Cursor) {
2944  String paramName = this.arg_names.get(i);
2945  String otherParamName = other.getExtendedParamNames().get(i);
2946  if (!paramName.equals(otherParamName)) {
2947  return false;
2948  }
2949 
2950  List<ExtArgumentType> field_types = this.getCursorFieldTypes().get(paramName);
2951  List<ExtArgumentType> other_field_types =
2952  other.getCursorFieldTypes().get(paramName);
2953  if (field_types.size() != other_field_types.size()) {
2954  return false;
2955  }
2956  for (int j = 0; j < field_types.size(); j++) {
2957  if (field_types.get(j) != other_field_types.get(j)) {
2958  return false;
2959  }
2960  }
2961  }
2962  }
2963  return true;
2964  }
ExtTableFunction(final String name, final ExtensionFunction sig)
List<ExtArgumentType> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getArgTypes ( )
inlinepackage

Definition at line 2980 of file HeavyDBSqlOperatorTable.java.

Referenced by com.mapd.calcite.parser.ExtTableFunctionTypeChecker.doesOperandTypeMatch().

2980  {
2981  return arg_types;
2982  }

+ Here is the caller graph for this function:

Set<RelColumnMapping> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getColumnMappings ( )
inline

Definition at line 2807 of file HeavyDBSqlOperatorTable.java.

References Integer.

2807  {
2808  final Boolean debugMode = false;
2809  Set<RelColumnMapping> s = new HashSet<RelColumnMapping>();
2810  debugPrint("getNameAsId() -> " + getNameAsId() + ", arg_names=" + arg_names
2811  + ", out_names=" + out_names,
2812  debugMode);
2813  if (Integer.valueOf(options.getOrDefault("filter_table_function_transpose", "0"))
2814  == 1) {
2815  debugPrint("getNameAsId() -> " + getNameAsId(), debugMode);
2816  int rel_idx = -1;
2817  for (int arg_idx = 0; arg_idx < arg_names.size(); ++arg_idx) {
2818  String arg_name = arg_names.get(arg_idx);
2819  String[] fields;
2820  int start = arg_name.indexOf("[");
2821  if (start != -1) {
2822  rel_idx += 1;
2823  int end = arg_name.lastIndexOf("]");
2824  fields = arg_name.substring(start + 1, end)
2825  .replaceAll("\\s+", "")
2826  .split(",", 0);
2827  } else {
2828  fields = new String[] {arg_name};
2829  }
2830  debugPrint("fields=" + Arrays.toString(fields), debugMode);
2831  for (int field_idx = 0; field_idx < fields.length; ++field_idx) {
2832  int out_idx = out_names.indexOf(fields[field_idx]);
2833  if (out_idx >= 0) {
2834  s.add(new RelColumnMapping(out_idx, rel_idx, field_idx, false));
2835  debugPrint("out_idx, arg_idx/rel_idx, field_idx=" + out_idx + ", " + arg_idx
2836  + "/" + rel_idx + ", " + field_idx,
2837  debugMode);
2838  }
2839  }
2840  }
2841  }
2842  return s;
2843  }
Map<String, List<ExtArgumentType> > com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getCursorFieldTypes ( )
inlinepackage

Definition at line 2976 of file HeavyDBSqlOperatorTable.java.

2976  {
2977  return cursor_field_types;
2978  }
List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getExtendedParamNames ( )
inline

Definition at line 2904 of file HeavyDBSqlOperatorTable.java.

2904  {
2905  return this.arg_names;
2906  }
String com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getExtendedSignature ( )
inline

Definition at line 2854 of file HeavyDBSqlOperatorTable.java.

References File_Namespace.append(), and run_benchmark_import.type.

2854  {
2855  StringBuilder ret = new StringBuilder();
2856  ret.append("'");
2857  ret.append(this.getName());
2858  ret.append("(");
2859 
2860  for (int i = 0; i < this.arg_types.size(); i++) {
2861  if (i > 0) {
2862  ret.append(", ");
2863  }
2864 
2865  ExtArgumentType type = arg_types.get(i);
2866  String paramName = arg_names.get(i);
2867  ret.append(paramName).append(" => ");
2868 
2869  final String t = type.toString().toUpperCase(Locale.ROOT);
2870  ret.append("<").append(t);
2871  if (type == ExtArgumentType.Cursor) {
2872  List<ExtensionFunction.ExtArgumentType> field_types =
2873  cursor_field_types.get(paramName);
2874  ret.append("[");
2875  for (int j = 0; j < field_types.size(); j++) {
2876  if (j > 0) {
2877  ret.append(",");
2878  }
2879  ExtArgumentType field_type = field_types.get(j);
2880  ret.append(toSqlTypeName(field_type));
2881  if (isColumnListType(field_type)) {
2882  ExtArgumentType subtype = getValueType(field_type);
2883  ret.append("[");
2884  ret.append(toSqlTypeName(subtype));
2885  ret.append("]");
2886  } else if (isColumnArrayType(field_type) || isArrayType(field_type)) {
2887  ExtArgumentType subtype = getValueType(getValueType(field_type));
2888  ret.append("[");
2889  ret.append(toSqlTypeName(subtype));
2890  ret.append("]");
2891  }
2892  }
2893  ret.append("]");
2894  }
2895  ret.append(">");
2896  }
2897  ret.append(")'");
2898 
2899  return ret.toString();
2900  }
size_t append(FILE *f, const size_t size, const int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:178

+ Here is the call graph for this function:

List<FunctionParameter> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getParameters ( )
inline

Definition at line 2746 of file HeavyDBSqlOperatorTable.java.

References run_benchmark_import.type.

2746  {
2747  final Boolean has_names = this.pretty_arg_names != null
2748  && this.pretty_arg_names.size() == this.arg_types.size();
2749  final List<FunctionParameter> parameters = new java.util.ArrayList<>();
2750  for (int i = 0; i < this.arg_types.size(); i++) {
2751  final int arg_idx = i;
2752  parameters.add(new FunctionParameter() {
2753  public int getOrdinal() {
2754  return arg_idx;
2755  }
2756 
2757  public String getName() {
2758  if (has_names) {
2759  return pretty_arg_names.get(arg_idx);
2760  }
2761  return "arg" + arg_idx;
2762  }
2763 
2764  public RelDataType getType(RelDataTypeFactory typeFactory) {
2765  SqlTypeFamily type = toSqlTypeName(arg_types.get(arg_idx)).getFamily();
2766  return type.getDefaultConcreteType(typeFactory);
2767  }
2768 
2769  public boolean isOptional() {
2770  return false;
2771  }
2772  });
2773  }
2774  return parameters;
2775  }
List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getParamNames ( )
inline

Definition at line 2732 of file HeavyDBSqlOperatorTable.java.

SqlReturnTypeInference com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getRowTypeInference ( )
inline

Definition at line 2778 of file HeavyDBSqlOperatorTable.java.

References com.mapd.parser.server.ExtensionFunction.isColumnArrayType(), and run_benchmark_import.type.

2778  {
2779  return opBinding -> {
2780  RelDataTypeFactory fact = opBinding.getTypeFactory();
2781  FieldInfoBuilder ret = fact.builder();
2782  for (int out_idx = 0; out_idx < outs.size(); ++out_idx) {
2783  RelDataType type;
2784  if (toSqlTypeName(outs.get(out_idx)) == SqlTypeName.ARRAY) {
2785  ExtArgumentType extSubType = getValueType(outs.get(out_idx));
2786  if (ExtensionFunction.isColumnArrayType(outs.get(out_idx))) {
2787  extSubType = getValueType(extSubType);
2788  }
2789  RelDataType subtype = fact.createSqlType(toSqlTypeName(extSubType));
2790  type = fact.createArrayType(subtype, -1);
2791  } else {
2792  type = fact.createSqlType(toSqlTypeName(outs.get(out_idx)));
2793  }
2794  ret = ret.add(out_names.get(out_idx), type);
2795  ret = ret.nullable(true);
2796  }
2797  return ret.build();
2798  };
2799  }

+ Here is the call graph for this function:

int com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.hashCode ( )
inline

Definition at line 2910 of file HeavyDBSqlOperatorTable.java.

2910  {
2911  return this.getExtendedSignature().hashCode();
2912  }
String com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.toString ( )
inline

Definition at line 2967 of file HeavyDBSqlOperatorTable.java.

2967  {
2968  return new String(getName() + "("
2969  + String.join(",",
2970  this.arg_types.stream()
2971  .map(s -> s.toString())
2972  .collect(Collectors.toList()))
2973  + ")");
2974  }

Member Data Documentation

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.arg_names
private

Definition at line 2986 of file HeavyDBSqlOperatorTable.java.

final List<ExtArgumentType> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.arg_types
private

Definition at line 2984 of file HeavyDBSqlOperatorTable.java.

final Map<String, List<ExtArgumentType> > com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.cursor_field_types
private

Definition at line 2990 of file HeavyDBSqlOperatorTable.java.

final Map<String, String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.options
private

Definition at line 2989 of file HeavyDBSqlOperatorTable.java.

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.out_names
private

Definition at line 2988 of file HeavyDBSqlOperatorTable.java.

final List<ExtArgumentType> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.outs
private

Definition at line 2985 of file HeavyDBSqlOperatorTable.java.

final List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.pretty_arg_names
private

Definition at line 2987 of file HeavyDBSqlOperatorTable.java.


The documentation for this class was generated from the following file: