(self)
return ins_list, upd_list, del_list
Got all data, prepare for insertion.
Got all data, prepare for insertion.
Got all data prepare for insertion .
def prepare_data(self):
        """Got all data, prepare for insertion."""

        del_list = []
        ins_list = []
        upd_list = []
        for ev_list in self.pkey_ev_map.itervalues():
            # rewrite list of I/U/D events to
            # optional DELETE and optional INSERT/COPY command
            exists_before = -1
            exists_after = 1
            for ev in ev_list:
                if ev.op == "I":
                    if exists_before < 0:
                        exists_before = 0
                    exists_after = 1
                elif ev.op == "U":
                    if exists_before < 0:
                        exists_before = 1
                    #exists_after = 1 # this shouldnt be needed
                elif ev.op == "D":
                    if exists_before < 0:
                        exists_before = 1
                    exists_after = 0
                else:
                    raise Exception('unknown event type: %s' % ev.op)

            # skip short-lived rows
            if exists_before == 0 and exists_after == 0:
                continue

            # take last event
            ev = ev_list[-1]

            # generate needed commands
            if exists_before and exists_after:
                upd_list.append(ev.data)
            elif exists_before:
                del_list.append(ev.data)
            elif exists_after:
                ins_list.append(ev.data)

        return ins_list, upd_list, del_list
def prepare_data ( self ) : del_list = [ ] ins_list = [ ] upd_list = [ ] for ev_list in self . pkey_ev_map . itervalues ( ) : # rewrite list of I/U/D events to # optional DELETE and optional INSERT/COPY command exists_before = - 1 exists_after = 1 for ev in ev_list : if ev . op == "I" : if exists_before < 0 : exists_before = 0 exists_after = 1 elif ev . op == "U" : if exists_before < 0 : exists_before = 1 #exists_after = 1 # this shouldnt be needed elif ev . op == "D" : if exists_before < 0 : exists_before = 1 exists_after = 0 else : raise Exception ( 'unknown event type: %s' % ev . op ) # skip short-lived rows if exists_before == 0 and exists_after == 0 : continue # take last event ev = ev_list [ - 1 ] # generate needed commands if exists_before and exists_after : upd_list . append ( ev . data ) elif exists_before : del_list . append ( ev . data ) elif exists_after : ins_list . append ( ev . data ) return ins_list , upd_list , del_list