OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
heavydb._utils Namespace Reference

Functions

def seconds_to_time
 
def time_to_seconds
 
def datetime_in_precisions
 
def date_to_seconds
 

Variables

dictionary mapd_to_slot
 
dictionary mapd_to_na
 

Function Documentation

def heavydb._utils.date_to_seconds (   arr)
Converts date into seconds

Definition at line 36 of file _utils.py.

36 
37 def date_to_seconds(arr):
38  """Converts date into seconds"""
39 
40  return arr.apply(lambda x: np.datetime64(x, "s").astype(int))
41 
def date_to_seconds
Definition: _utils.py:36
def heavydb._utils.datetime_in_precisions (   epoch,
  precision 
)
Convert epoch time value into s, ms, us, ns

Definition at line 19 of file _utils.py.

Referenced by heavydb._parsers._format_result_timestamp().

19 
20 def datetime_in_precisions(epoch, precision):
21  """Convert epoch time value into s, ms, us, ns"""
22  base = datetime.datetime(1970, 1, 1)
23  if precision == 0:
24  return base + datetime.timedelta(seconds=epoch)
25  elif precision == 3:
26  seconds, modulus = divmod(epoch, 1000)
27  return base + datetime.timedelta(seconds=seconds, milliseconds=modulus)
28  elif precision == 6:
29  seconds, modulus = divmod(epoch, 1000000)
30  return base + datetime.timedelta(seconds=seconds, microseconds=modulus)
31  elif precision == 9:
32  return np.datetime64(epoch, 'ns')
33  else:
34  raise TypeError("Invalid timestamp precision: {}".format(precision))
35 
def datetime_in_precisions
Definition: _utils.py:19

+ Here is the caller graph for this function:

def heavydb._utils.seconds_to_time (   seconds)
Convert seconds since midnight to a datetime.time

Definition at line 5 of file _utils.py.

Referenced by heavydb._parsers._format_result_time().

5 
6 def seconds_to_time(seconds):
7  """Convert seconds since midnight to a datetime.time"""
8  m, s = divmod(seconds, 60)
9  h, m = divmod(m, 60)
10  return datetime.time(h, m, s)
11 
def seconds_to_time
Definition: _utils.py:5

+ Here is the caller graph for this function:

def heavydb._utils.time_to_seconds (   time)
Convert a datetime.time to seconds since midnight

Definition at line 12 of file _utils.py.

12 
13 def time_to_seconds(time):
14  """Convert a datetime.time to seconds since midnight"""
15  if time is None:
16  return None
17  return 3600 * time.hour + 60 * time.minute + time.second
18 
def time_to_seconds
Definition: _utils.py:12

Variable Documentation

dictionary heavydb._utils.mapd_to_na
Initial value:
1 = {
2  'BOOL': -128,
3  'BOOLEAN': -128,
4  'SMALLINT': -32768,
5  'INT': -2147483648,
6  'INTEGER': -2147483648,
7  'BIGINT': -9223372036854775808,
8  'FLOAT': 0,
9  'DECIMAL': 0,
10  'DOUBLE': 0,
11  'TIMESTAMP': -9223372036854775808,
12  'DATE': -9223372036854775808,
13  'TIME': -9223372036854775808,
14  'STR': '',
15  'POINT': '',
16  'MULTIPOINT': '',
17  'LINESTRING': '',
18  'MULTILINESTRING': '',
19  'POLYGON': '',
20  'MULTIPOLYGON': '',
21  'TINYINT': -128,
22  'GEOMETRY': '',
23  'GEOGRAPHY': '',
24 }

Definition at line 68 of file _utils.py.

dictionary heavydb._utils.mapd_to_slot
Initial value:
1 = {
2  'BOOL': 'int_col',
3  'BOOLEAN': 'int_col',
4  'SMALLINT': 'int_col',
5  'INT': 'int_col',
6  'INTEGER': 'int_col',
7  'BIGINT': 'int_col',
8  'FLOAT': 'real_col',
9  'DECIMAL': 'int_col',
10  'DOUBLE': 'real_col',
11  'TIMESTAMP': 'int_col',
12  'DATE': 'int_col',
13  'TIME': 'int_col',
14  'STR': 'str_col',
15  'POINT': 'str_col',
16  'MULTIPOINT': 'str_col',
17  'LINESTRING': 'str_col',
18  'MULTILINESTRING': 'str_col',
19  'POLYGON': 'str_col',
20  'MULTIPOLYGON': 'str_col',
21  'TINYINT': 'int_col',
22  'GEOMETRY': 'str_col',
23  'GEOGRAPHY': 'str_col',
24 }

Definition at line 42 of file _utils.py.