def _loadInPg(cls, plpy, filt: dict, tupleSelectorStr: str): tupleSelector = TupleSelector.fromJsonStr(tupleSelectorStr) tuples = cls.loadTuples(plpy, tupleSelector) payloadEnvelope = Payload(filt=filt, tuples=tuples).makePayloadEnvelope() vortexMsg = payloadEnvelope.toVortexMsg() return vortexMsg.decode()
def _loadInPg(cls, plpy, tupleSelectorStr: str): tupleSelector = TupleSelector.fromJsonStr(tupleSelectorStr) columnPropKeys = tupleSelector.selector["columnPropKeys"] modelSetId = EventDBEventTupleProvider \ .getModelSetId(plpy, tupleSelector.selector['modelSetKey']) propByKey = cls._getPropertyByKey(plpy, modelSetId) tuples = EventDBEventTupleProvider \ .loadTuples(plpy, tupleSelector) data = '' # Write the heading cols = ['Date', 'Time', 'Milliseconds', 'UTC Offset'] for columnPropKey in columnPropKeys: cols.append('"%s"' % propByKey[columnPropKey].name) data += ','.join(cols) + '\r\n' # Write the data of the table for row in tuples: value = json.loads(row.value) tz = str(row.dateTime.strftime('%z')) cols = [row.dateTime.strftime('%d-%b-%Y'), row.dateTime.strftime('%H:%M:%S'), str(int(row.dateTime.microsecond / 1000)), '%s:%s' % (tz[:-2], tz[-2:])] for columnPropKey in columnPropKeys: prop = propByKey[columnPropKey] val = value.get(columnPropKey) if val is None: cols.append('') else: # Map the value if it has one. valKey = str(val).replace('null', 'none').lower() val = prop.nameByValueMap.get(valKey, val) if isinstance(val, int): cols.append(str(val)) else: cols.append('"%s"' % val) data += ','.join(cols) + '\r\n' return data
def _tupleSelectors(self) -> typing.List[TupleSelector]: tupleSelectors = [] for key in self.__cache: tupleSelectors.append(TupleSelector.fromJsonStr(key)) return tupleSelectors