OmniSciDB  2e3a973ef4
com.omnisci.jdbc.OmniSciEscapeFunctions Class Reference
+ Collaboration diagram for com.omnisci.jdbc.OmniSciEscapeFunctions:

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 OmniSciEscapeFunctions.java.

Member Function Documentation

◆ appendCall()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

Referenced by com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ createFunctionMap()

static ConcurrentMap<String, Method> com.omnisci.jdbc.OmniSciEscapeFunctions.createFunctionMap ( String  prefix)
inlinestaticprivate

Definition at line 17 of file OmniSciEscapeFunctions.java.

References run_benchmark_import.method.

17  {
18  Method[] methods = OmniSciEscapeFunctions.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  }

◆ getFunction()

static Method com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References run_benchmark_import.method.

Referenced by com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.makeMatch().

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
+ Here is the caller graph for this function:

◆ singleArgumentFunctionCall()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.singleArgumentFunctionCall ( StringBuilder  buf,
String  call,
String  functionName,
List<? extends CharSequence >  parsedArgs 
)
inlinestaticprivate

Definition at line 197 of file OmniSciEscapeFunctions.java.

Referenced by com.omnisci.jdbc.OmniSciEscapeFunctions.sqlceiling(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqldayofmonth(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqldayofyear(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlhour(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlminute(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlmonth(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlquarter(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlsecond(), com.omnisci.jdbc.OmniSciEscapeFunctions.sqlweek(), and com.omnisci.jdbc.OmniSciEscapeFunctions.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  }
+ Here is the caller graph for this function:

◆ sqlceiling()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqldayofmonth()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqldayofweek()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqldayofyear()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlhour()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlminute()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlmonth()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlquarter()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlsecond()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlweek()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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:

◆ sqlyear()

static void com.omnisci.jdbc.OmniSciEscapeFunctions.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 OmniSciEscapeFunctions.java.

References com.omnisci.jdbc.OmniSciEscapeFunctions.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

◆ FUNCTION_MAP

final ConcurrentMap<String, Method> com.omnisci.jdbc.OmniSciEscapeFunctions.FUNCTION_MAP
staticprivate
Initial value:

storage for functions implementations

Definition at line 14 of file OmniSciEscapeFunctions.java.


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