OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctionsFactory_util.py
Go to the documentation of this file.
1 from collections import namedtuple
2 
3 
4 OutputBufferSizeTypes = '''
5 kConstant, kUserSpecifiedConstantParameter, kUserSpecifiedRowMultiplier,
6 kTableFunctionSpecifiedParameter, kPreFlightParameter
7 '''.strip().replace(' ', '').split(',')
8 
9 SupportedAnnotations = '''
10 input_id, name, fields, require, range, default
11 '''.strip().replace(' ', '').split(',')
12 
13 # TODO: support `gpu`, `cpu`, `template` as function annotations
14 SupportedFunctionAnnotations = '''
15 filter_table_function_transpose, uses_manager
16 '''.strip().replace(' ', '').split(',')
17 
18 translate_map = dict(
19  Constant='kConstant',
20  PreFlight='kPreFlightParameter',
21  ConstantParameter='kUserSpecifiedConstantParameter',
22  RowMultiplier='kUserSpecifiedRowMultiplier',
23  UserSpecifiedConstantParameter='kUserSpecifiedConstantParameter',
24  UserSpecifiedRowMultiplier='kUserSpecifiedRowMultiplier',
25  TableFunctionSpecifiedParameter='kTableFunctionSpecifiedParameter',
26  short='Int16',
27  int='Int32',
28  long='Int64',
29 )
30 for t in ['Int8', 'Int16', 'Int32', 'Int64', 'Float', 'Double', 'Bool',
31  'TextEncodingDict', 'TextEncodingNone']:
32  translate_map[t.lower()] = t
33  if t.startswith('Int'):
34  translate_map[t.lower() + '_t'] = t
35 
36 
37 Signature = namedtuple('Signature', ['name', 'inputs', 'outputs',
38  'input_annotations', 'output_annotations',
39  'function_annotations', 'sizer'])
40 
41 
42 def tostring(obj):
43  return obj.tostring()
44 
45 
46 def find_comma(line):
47  d = 0
48  for i, c in enumerate(line):
49  if c in '<([{':
50  d += 1
51  elif c in '>)]{':
52  d -= 1
53  elif d == 0 and c == ',':
54  return i
55  return -1
std::string strip(std::string_view str)
trim any whitespace from the left and right ends of a string
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings