MCPcopy Create free account
hub / github.com/Shopify/ghostferry / compareDecompressedData

Function compareDecompressedData

inline_verifier.go:657–720  ·  view source on GitHub ↗
(source, target map[string]map[string][]byte)

Source from the content-addressed store, hash-verified

655}
656
657func compareDecompressedData(source, target map[string]map[string][]byte) map[string]InlineVerifierMismatches {
658 mismatchSet := map[string]InlineVerifierMismatches{}
659
660 for paginationKey, targetDecompressedColumns := range target {
661 sourceDecompressedColumns, exists := source[paginationKey]
662 if !exists {
663 // row missing on source
664 mismatchSet[paginationKey] = InlineVerifierMismatches{
665 Pk: paginationKey,
666 MismatchType: MismatchRowMissingOnSource,
667 }
668 continue
669 }
670
671 for colName, targetData := range targetDecompressedColumns {
672 sourceData, exists := sourceDecompressedColumns[colName]
673 if !exists {
674 mismatchSet[paginationKey] = InlineVerifierMismatches{
675 Pk: paginationKey,
676 MismatchType: MismatchColumnMissingOnSource,
677 MismatchColumn: colName,
678 }
679 break // no need to compare other columns
680 } else if !bytes.Equal(sourceData, targetData) {
681 sourceChecksum := md5.Sum(sourceData)
682 targetChecksum := md5.Sum(targetData)
683
684 mismatchSet[paginationKey] = InlineVerifierMismatches{
685 Pk: paginationKey,
686 MismatchType: MismatchColumnValueDifference,
687 MismatchColumn: colName,
688 SourceChecksum: hex.EncodeToString(sourceChecksum[:]),
689 TargetChecksum: hex.EncodeToString(targetChecksum[:]),
690 }
691 break // no need to compare other columns
692 }
693 }
694 }
695
696 for paginationKey, sourceDecompressedColumns := range source {
697 targetDecompressedColumns, exists := target[paginationKey]
698 if !exists {
699 // row missing on target
700 mismatchSet[paginationKey] = InlineVerifierMismatches{
701 Pk: paginationKey,
702 MismatchType: MismatchRowMissingOnTarget,
703 }
704 continue
705 }
706
707 for colName := range sourceDecompressedColumns {
708 _, exists := targetDecompressedColumns[colName]
709 if !exists {
710 mismatchSet[paginationKey] = InlineVerifierMismatches{
711 Pk: paginationKey,
712 MismatchColumn: colName,
713 MismatchType: MismatchColumnMissingOnTarget,
714 }

Calls

no outgoing calls