OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ai.heavy.jdbc.HeavyAIEscapeFunctions Class Reference
+ Collaboration diagram for ai.heavy.jdbc.HeavyAIEscapeFunctions:

Static Public Member Functions

static Method getFunction (String functionName)
 
static void sqlceiling (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqldayofmonth (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqldayofweek (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqldayofyear (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlhour (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlminute (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlmonth (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlquarter (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlsecond (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlweek (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void sqlyear (StringBuilder buf, List<?extends CharSequence > parsedArgs) throws SQLException
 
static void appendCall (StringBuilder sb, String begin, String separator, String end, List<?extends CharSequence > args)
 

Static Private Member Functions

static ConcurrentMap< String,
Method > 
createFunctionMap (String prefix)
 
static void singleArgumentFunctionCall (StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)
 

Static Private Attributes

static final ConcurrentMap
< String, Method > 
FUNCTION_MAP
 

Detailed Description

Definition at line 10 of file HeavyAIEscapeFunctions.java.

Member Function Documentation

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.appendCall ( StringBuilder  sb,
String  begin,
String  separator,
String  end,
List<?extends CharSequence >  args 
)
inlinestatic

Appends

begin arg0 separator arg1 separator end

sequence to the input StringBuilder

Parameters
sbdestination StringBuilder
beginbegin string
separatorseparator string
endend string
argsarguments

Definition at line 220 of file HeavyAIEscapeFunctions.java.

References generate_TableFunctionsFactory_init.separator.

Referenced by ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofweek().

224  {
225  int size = begin.length();
226  // Typically just-in-time compiler would eliminate Iterator in case foreach is used,
227  // however the code below uses indexed iteration to keep the conde independent from
228  // various JIT implementations (== avoid Iterator allocations even for not-so-smart
229  // JITs) see https://bugs.openjdk.java.net/browse/JDK-8166840 see
230  // http://2016.jpoint.ru/talks/cheremin/ (video and slides)
231  int numberOfArguments = args.size();
232  for (int i = 0; i < numberOfArguments; i++) {
233  size += args.get(i).length();
234  }
235  size += separator.length() * (numberOfArguments - 1);
236  sb.ensureCapacity(sb.length() + size + 1);
237  sb.append(begin);
238  for (int i = 0; i < numberOfArguments; i++) {
239  if (i > 0) {
240  sb.append(separator);
241  }
242  sb.append(args.get(i));
243  }
244  sb.append(end);
245  }

+ Here is the caller graph for this function:

static ConcurrentMap<String, Method> ai.heavy.jdbc.HeavyAIEscapeFunctions.createFunctionMap ( String  prefix)
inlinestaticprivate

Definition at line 17 of file HeavyAIEscapeFunctions.java.

References substring().

17  {
18  Method[] methods = HeavyAIEscapeFunctions.class.getMethods();
19  ConcurrentMap<String, Method> functionMap =
20  new ConcurrentHashMap<String, Method>(methods.length * 2);
21  for (Method method : methods) {
22  if (method.getName().startsWith(prefix)) {
23  functionMap.put(
24  method.getName().substring(prefix.length()).toLowerCase(Locale.US),
25  method);
26  }
27  }
28  return functionMap;
29  }
std::pair< std::string_view, const char * > substring(const std::string &str, size_t substr_length)
return substring of str with postfix if str.size() &gt; substr_length

+ Here is the call graph for this function:

static Method ai.heavy.jdbc.HeavyAIEscapeFunctions.getFunction ( String  functionName)
inlinestatic

get Method object implementing the given function

Parameters
functionNamename of the searched function
Returns
a Method object or null if not found

Definition at line 37 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.FUNCTION_MAP.

37  {
38  Method method = FUNCTION_MAP.get(functionName);
39  if (method != null) {
40  return method;
41  }
42  // FIXME: this probably should not use the US locale
43  String nameLower = functionName.toLowerCase(Locale.US);
44  if (nameLower.equals(functionName)) {
45  // Input name was in lower case, the function is not there
46  return null;
47  }
48  method = FUNCTION_MAP.get(nameLower);
49  if (method != null && FUNCTION_MAP.size() < 1000) {
50  // Avoid OutOfMemoryError in case input function names are randomized
51  // The number of methods is finite, however the number of upper-lower case
52  // combinations is quite a few (e.g. substr, Substr, sUbstr, SUbstr, etc).
53  FUNCTION_MAP.putIfAbsent(functionName, method);
54  }
55  return method;
56  }
static final ConcurrentMap< String, Method > FUNCTION_MAP
static void ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall ( StringBuilder  buf,
String  call,
String  functionName,
List<?extends CharSequence >  parsedArgs 
)
inlinestaticprivate

Definition at line 197 of file HeavyAIEscapeFunctions.java.

References File_Namespace.append().

Referenced by ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlceiling(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofmonth(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofyear(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlhour(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlminute(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlmonth(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlquarter(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlsecond(), ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlweek(), and ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlyear().

200  {
201  if (parsedArgs.size() != 1) {
202  throw new RuntimeException(
203  "Syntax error " + functionName + " takes one and only one argument.");
204  }
205  CharSequence arg0 = parsedArgs.get(0);
206  buf.ensureCapacity(buf.length() + call.length() + arg0.length() + 1);
207  buf.append(call).append(arg0).append(')');
208  }
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:158

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlceiling ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

ceiling to ceil translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 67 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

68  {
69  singleArgumentFunctionCall(buf, "ceil(", "ceiling", parsedArgs);
70  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofmonth ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

dayofmonth translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 79 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

80  {
81  singleArgumentFunctionCall(buf, "extract(day from ", "dayofmonth", parsedArgs);
82  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofweek ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

dayofweek translation adding 1 to postgresql function since we expect values from 1 to 7

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 92 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.appendCall().

93  {
94  if (parsedArgs.size() != 1) {
95  throw new RuntimeException(
96  "Syntax error function 'dayofweek' takes one and only one argument.");
97  }
98  appendCall(buf, "extract(dow from ", ",", ")+1", parsedArgs);
99  }
static void appendCall(StringBuilder sb, String begin, String separator, String end, List<?extends CharSequence > args)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqldayofyear ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

dayofyear translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 108 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

109  {
110  singleArgumentFunctionCall(buf, "extract(doy from ", "dayofyear", parsedArgs);
111  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlhour ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

hour translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 120 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

121  {
122  singleArgumentFunctionCall(buf, "extract(hour from ", "hour", parsedArgs);
123  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlminute ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

minute translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 132 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

133  {
134  singleArgumentFunctionCall(buf, "extract(minute from ", "minute", parsedArgs);
135  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlmonth ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

month translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 144 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

145  {
146  singleArgumentFunctionCall(buf, "extract(month from ", "month", parsedArgs);
147  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlquarter ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

quarter translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 156 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

157  {
158  singleArgumentFunctionCall(buf, "extract(quarter from ", "quarter", parsedArgs);
159  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlsecond ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

second translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 168 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

169  {
170  singleArgumentFunctionCall(buf, "extract(second from ", "second", parsedArgs);
171  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlweek ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

week translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 180 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

181  {
182  singleArgumentFunctionCall(buf, "extract(week from ", "week", parsedArgs);
183  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

static void ai.heavy.jdbc.HeavyAIEscapeFunctions.sqlyear ( StringBuilder  buf,
List<?extends CharSequence >  parsedArgs 
) throws SQLException
inlinestatic

year translation

Parameters
bufThe buffer to append into
parsedArgsarguments
Exceptions
SQLExceptionif something wrong happens

Definition at line 192 of file HeavyAIEscapeFunctions.java.

References ai.heavy.jdbc.HeavyAIEscapeFunctions.singleArgumentFunctionCall().

193  {
194  singleArgumentFunctionCall(buf, "extract(year from ", "year", parsedArgs);
195  }
static void singleArgumentFunctionCall(StringBuilder buf, String call, String functionName, List<?extends CharSequence > parsedArgs)

+ Here is the call graph for this function:

Member Data Documentation

final ConcurrentMap<String, Method> ai.heavy.jdbc.HeavyAIEscapeFunctions.FUNCTION_MAP
staticprivate
Initial value:

storage for functions implementations

Definition at line 14 of file HeavyAIEscapeFunctions.java.

Referenced by ai.heavy.jdbc.HeavyAIEscapeFunctions.getFunction().


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