(self, src_fn, dst_fn, fix)
Dump + compare single table.
Dump + compare single table.
Dump + compare single table .
def dump_compare(self, src_fn, dst_fn, fix):
        """Dump + compare single table."""
        self.log.info("Comparing dumps: %s" % self.table_name)
        f1 = open(src_fn, "r", 64*1024)
        f2 = open(dst_fn, "r", 64*1024)
        src_ln = f1.readline()
        dst_ln = f2.readline()
        if src_ln: self.total_src += 1
        if dst_ln: self.total_dst += 1

        if os.path.isfile(fix):
            os.unlink(fix)

        while src_ln or dst_ln:
            keep_src = keep_dst = 0
            if src_ln != dst_ln:
                src_row = self.get_row(src_ln)
                dst_row = self.get_row(dst_ln)

                diff = self.cmp_keys(src_row, dst_row)
                if diff > 0:
                    # src > dst
                    self.got_missed_delete(dst_row, fix)
                    keep_src = 1
                elif diff < 0:
                    # src < dst
                    self.got_missed_insert(src_row, fix)
                    keep_dst = 1
                else:
                    if self.cmp_data(src_row, dst_row) != 0:
                        self.got_missed_update(src_row, dst_row, fix)

            if not keep_src:
                src_ln = f1.readline()
                if src_ln: self.total_src += 1
            if not keep_dst:
                dst_ln = f2.readline()
                if dst_ln: self.total_dst += 1

        self.log.info("finished %s: src: %d rows, dst: %d rows,"\
                    " missed: %d inserts, %d updates, %d deletes" % (
                self.table_name, self.total_src, self.total_dst,
                self.cnt_insert, self.cnt_update, self.cnt_delete))
def dump_compare ( self , src_fn , dst_fn , fix ) : self . log . info ( "Comparing dumps: %s" % self . table_name ) f1 = open ( src_fn , "r" , 64 * 1024 ) f2 = open ( dst_fn , "r" , 64 * 1024 ) src_ln = f1 . readline ( ) dst_ln = f2 . readline ( ) if src_ln : self . total_src += 1 if dst_ln : self . total_dst += 1 if os . path . isfile ( fix ) : os . unlink ( fix ) while src_ln or dst_ln : keep_src = keep_dst = 0 if src_ln != dst_ln : src_row = self . get_row ( src_ln ) dst_row = self . get_row ( dst_ln ) diff = self . cmp_keys ( src_row , dst_row ) if diff > 0 : # src > dst self . got_missed_delete ( dst_row , fix ) keep_src = 1 elif diff < 0 : # src < dst self . got_missed_insert ( src_row , fix ) keep_dst = 1 else : if self . cmp_data ( src_row , dst_row ) != 0 : self . got_missed_update ( src_row , dst_row , fix ) if not keep_src : src_ln = f1 . readline ( ) if src_ln : self . total_src += 1 if not keep_dst : dst_ln = f2 . readline ( ) if dst_ln : self . total_dst += 1 self . log . info ( "finished %s: src: %d rows, dst: %d rows," " missed: %d inserts, %d updates, %d deletes" % ( self . table_name , self . total_src , self . total_dst , self . cnt_insert , self . cnt_update , self . cnt_delete ) )