OmniSciDB  a987f07e93
 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 2693 of file HeavyDBSqlOperatorTable.java.

Constructor & Destructor Documentation

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

Definition at line 2694 of file HeavyDBSqlOperatorTable.java.

2694  {
2695  super(name,
2696  SqlKind.OTHER_FUNCTION,
2697  ReturnTypes.CURSOR,
2698  null,
2699  new ExtTableFunctionTypeChecker(HeavyDBSqlOperatorTable.this),
2700  SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
2701  arg_types = sig.getArgs();
2702  outs = sig.getOuts();
2703  out_names = sig.getOutNames();
2704  arg_names = sig.getArgNames();
2705  // pretty_arg_names will be same as arg_names, except with
2706  // arg names for cursors stripped of array elements, i.e
2707  // my_cursor_input[x, y, z] => my_cursor_input
2708  pretty_arg_names = sig.getPrettyArgNames();
2709  options = sig.getOptions();
2710  cursor_field_types = sig.getCursorFieldTypes();
2711  }
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 2788 of file HeavyDBSqlOperatorTable.java.

2788  {
2789  if (debugMode) {
2790  System.out.println(msg);
2791  }
2792  }
boolean com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.equals ( final Object  obj)
inline

Definition at line 2905 of file HeavyDBSqlOperatorTable.java.

References Cursor.

2905  {
2906  if (obj == null) {
2907  return false;
2908  }
2909 
2910  if (getClass() != obj.getClass()) {
2911  return false;
2912  }
2913 
2914  if (this == obj) {
2915  return true;
2916  }
2917 
2918  final ExtTableFunction other = (ExtTableFunction) obj;
2919  if (!this.getName().equals(other.getName())) {
2920  return false;
2921  }
2922  if (arg_types.size() != other.arg_types.size()) {
2923  return false;
2924  }
2925 
2926  for (int i = 0; i < arg_types.size(); i++) {
2927  if (arg_types.get(i) != other.arg_types.get(i)) {
2928  return false;
2929  }
2930  if (arg_types.get(i) == ExtArgumentType.Cursor) {
2931  String paramName = this.arg_names.get(i);
2932  String otherParamName = other.getExtendedParamNames().get(i);
2933  if (!paramName.equals(otherParamName)) {
2934  return false;
2935  }
2936 
2937  List<ExtArgumentType> field_types = this.getCursorFieldTypes().get(paramName);
2938  List<ExtArgumentType> other_field_types =
2939  other.getCursorFieldTypes().get(paramName);
2940  if (field_types.size() != other_field_types.size()) {
2941  return false;
2942  }
2943  for (int j = 0; j < field_types.size(); j++) {
2944  if (field_types.get(j) != other_field_types.get(j)) {
2945  return false;
2946  }
2947  }
2948  }
2949  }
2950  return true;
2951  }
ExtTableFunction(final String name, final ExtensionFunction sig)
List<ExtArgumentType> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getArgTypes ( )
inlinepackage

Definition at line 2967 of file HeavyDBSqlOperatorTable.java.

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

2967  {
2968  return arg_types;
2969  }

+ Here is the caller graph for this function:

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

Definition at line 2794 of file HeavyDBSqlOperatorTable.java.

References Integer.

2794  {
2795  final Boolean debugMode = false;
2796  Set<RelColumnMapping> s = new HashSet<RelColumnMapping>();
2797  debugPrint("getNameAsId() -> " + getNameAsId() + ", arg_names=" + arg_names
2798  + ", out_names=" + out_names,
2799  debugMode);
2800  if (Integer.valueOf(options.getOrDefault("filter_table_function_transpose", "0"))
2801  == 1) {
2802  debugPrint("getNameAsId() -> " + getNameAsId(), debugMode);
2803  int rel_idx = -1;
2804  for (int arg_idx = 0; arg_idx < arg_names.size(); ++arg_idx) {
2805  String arg_name = arg_names.get(arg_idx);
2806  String[] fields;
2807  int start = arg_name.indexOf("[");
2808  if (start != -1) {
2809  rel_idx += 1;
2810  int end = arg_name.lastIndexOf("]");
2811  fields = arg_name.substring(start + 1, end)
2812  .replaceAll("\\s+", "")
2813  .split(",", 0);
2814  } else {
2815  fields = new String[] {arg_name};
2816  }
2817  debugPrint("fields=" + Arrays.toString(fields), debugMode);
2818  for (int field_idx = 0; field_idx < fields.length; ++field_idx) {
2819  int out_idx = out_names.indexOf(fields[field_idx]);
2820  if (out_idx >= 0) {
2821  s.add(new RelColumnMapping(out_idx, rel_idx, field_idx, false));
2822  debugPrint("out_idx, arg_idx/rel_idx, field_idx=" + out_idx + ", " + arg_idx
2823  + "/" + rel_idx + ", " + field_idx,
2824  debugMode);
2825  }
2826  }
2827  }
2828  }
2829  return s;
2830  }
Map<String, List<ExtArgumentType> > com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getCursorFieldTypes ( )
inlinepackage

Definition at line 2963 of file HeavyDBSqlOperatorTable.java.

2963  {
2964  return cursor_field_types;
2965  }
List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getExtendedParamNames ( )
inline

Definition at line 2891 of file HeavyDBSqlOperatorTable.java.

2891  {
2892  return this.arg_names;
2893  }
String com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getExtendedSignature ( )
inline

Definition at line 2841 of file HeavyDBSqlOperatorTable.java.

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

2841  {
2842  StringBuilder ret = new StringBuilder();
2843  ret.append("'");
2844  ret.append(this.getName());
2845  ret.append("(");
2846 
2847  for (int i = 0; i < this.arg_types.size(); i++) {
2848  if (i > 0) {
2849  ret.append(", ");
2850  }
2851 
2852  ExtArgumentType type = arg_types.get(i);
2853  String paramName = arg_names.get(i);
2854  ret.append(paramName).append(" => ");
2855 
2856  final String t = type.toString().toUpperCase(Locale.ROOT);
2857  ret.append("<").append(t);
2858  if (type == ExtArgumentType.Cursor) {
2859  List<ExtensionFunction.ExtArgumentType> field_types =
2860  cursor_field_types.get(paramName);
2861  ret.append("[");
2862  for (int j = 0; j < field_types.size(); j++) {
2863  if (j > 0) {
2864  ret.append(",");
2865  }
2866  ExtArgumentType field_type = field_types.get(j);
2867  ret.append(toSqlTypeName(field_type));
2868  if (isColumnListType(field_type)) {
2869  ExtArgumentType subtype = getValueType(field_type);
2870  ret.append("[");
2871  ret.append(toSqlTypeName(subtype));
2872  ret.append("]");
2873  } else if (isColumnArrayType(field_type) || isArrayType(field_type)) {
2874  ExtArgumentType subtype = getValueType(getValueType(field_type));
2875  ret.append("[");
2876  ret.append(toSqlTypeName(subtype));
2877  ret.append("]");
2878  }
2879  }
2880  ret.append("]");
2881  }
2882  ret.append(">");
2883  }
2884  ret.append(")'");
2885 
2886  return ret.toString();
2887  }
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:168

+ Here is the call graph for this function:

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

Definition at line 2733 of file HeavyDBSqlOperatorTable.java.

References run_benchmark_import.type.

2733  {
2734  final Boolean has_names = this.pretty_arg_names != null
2735  && this.pretty_arg_names.size() == this.arg_types.size();
2736  final List<FunctionParameter> parameters = new java.util.ArrayList<>();
2737  for (int i = 0; i < this.arg_types.size(); i++) {
2738  final int arg_idx = i;
2739  parameters.add(new FunctionParameter() {
2740  public int getOrdinal() {
2741  return arg_idx;
2742  }
2743 
2744  public String getName() {
2745  if (has_names) {
2746  return pretty_arg_names.get(arg_idx);
2747  }
2748  return "arg" + arg_idx;
2749  }
2750 
2751  public RelDataType getType(RelDataTypeFactory typeFactory) {
2752  SqlTypeFamily type = toSqlTypeName(arg_types.get(arg_idx)).getFamily();
2753  return type.getDefaultConcreteType(typeFactory);
2754  }
2755 
2756  public boolean isOptional() {
2757  return false;
2758  }
2759  });
2760  }
2761  return parameters;
2762  }
List<String> com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getParamNames ( )
inline

Definition at line 2719 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2765 of file HeavyDBSqlOperatorTable.java.

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

2765  {
2766  return opBinding -> {
2767  RelDataTypeFactory fact = opBinding.getTypeFactory();
2768  FieldInfoBuilder ret = fact.builder();
2769  for (int out_idx = 0; out_idx < outs.size(); ++out_idx) {
2770  RelDataType type;
2771  if (toSqlTypeName(outs.get(out_idx)) == SqlTypeName.ARRAY) {
2772  ExtArgumentType extSubType = getValueType(outs.get(out_idx));
2773  if (ExtensionFunction.isColumnArrayType(outs.get(out_idx))) {
2774  extSubType = getValueType(extSubType);
2775  }
2776  RelDataType subtype = fact.createSqlType(toSqlTypeName(extSubType));
2777  type = fact.createArrayType(subtype, -1);
2778  } else {
2779  type = fact.createSqlType(toSqlTypeName(outs.get(out_idx)));
2780  }
2781  ret = ret.add(out_names.get(out_idx), type);
2782  ret = ret.nullable(true);
2783  }
2784  return ret.build();
2785  };
2786  }

+ Here is the call graph for this function:

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

Definition at line 2897 of file HeavyDBSqlOperatorTable.java.

2897  {
2898  return this.getExtendedSignature().hashCode();
2899  }
String com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.toString ( )
inline

Definition at line 2954 of file HeavyDBSqlOperatorTable.java.

2954  {
2955  return new String(getName() + "("
2956  + String.join(",",
2957  this.arg_types.stream()
2958  .map(s -> s.toString())
2959  .collect(Collectors.toList()))
2960  + ")");
2961  }

Member Data Documentation

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

Definition at line 2973 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2971 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2977 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2976 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2975 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2972 of file HeavyDBSqlOperatorTable.java.

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

Definition at line 2974 of file HeavyDBSqlOperatorTable.java.


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