MatchUp Object:Read-Write:Order of Operations

From Melissa Data Wiki
Revision as of 20:38, 28 July 2015 by Admin (talk | contribs)
Jump to navigation Jump to search

← MatchUp Object Reference

MatchUp Object Read-Write Interface Navigation
Overview
Order of Operations
Functions
Initialization
Mapping
Match Key
Processing
Retrieval



Basic Steps

These are the basic steps of a typical implementation of the Read-Write Interface.

  1. Initialize the Read-Write Interface.
    After creating an instance of the Read-Write Interface, point the object toward its supporting data file, select a matchcode and key file to use, and initialize these files.
  2. Create field mappings.
    In order to build a key to be written to the key file, the Read-Write Interface needs to know which types of data the application will be passing to the Interface and in what order.
  3. Read the records from the database.
    Loop through the master database and get the data fields needed to build a key, according to the mappings defined in step 2.
  4. Build a match key for each record.
    This consists of passing the actual data to the Interface in the same order used when creating the field mapping. After passing the necessary fields (usually a small subset of the fields from each record) via the AddField function, the Interface uses this information to generate a match key.
  5. Write each match key to the key file.
    The WriteRecord function stores each match key in a temporary key file.
  6. Process the keys.
    After building the keys, calling the Process function loops through the keys and compares them to each other.
  7. Loop through the records and read the deduping data for each one.
    The ReadRecord function loops through the entire set of deduped records and allows the application to read information on the record’s duplicate/unique status, the number of duplicates for each record and the record dupe group.

Pseudocode Implementation

This is a common implementation of the Read-Write Interface using pseudocode for maximum clarity. Working sample programs in several programming languages can be found on the MatchUp Object install disc.

Initialize the Read-Write Interface

After creating an instance of the Read-Write Interface, point the object toward its supporting data file, select a matchcode and key file to use, and initialize these files.

First, create a new instance of the Read-Write Interface.

SET mu = NEW mdMUReadWrite

In order to successfully initialize this new instance, the application must point it toward its data files and supply a valid license string.

CALL mu.SetLicenseString with LicenseString
CALL mu.SetPathToMatchUpFiles with PathToMatchUpFiles

Before initialization, the application must specify which matchcode and key file will be used for the current deduping operation.

CALL mu.SetMatchcodeName with MatchCodeName
CALL mu.SetKeyFile with PathToKeyFile

If all of the above have been set correctly, calling the InitializeDataFiles function should return a value of ErrorNone. If it does not, call the GetInitializeErrorString function to determine the reason for the failure to initialize.

CALL mu.InitializeDataFiles RETURNING ProgramStatusResult
IF ProgramStatusResult is not 0 THEN
  PRINT "Initialization Error: " + mu.GetInitializeErrorString
  EXIT ROUTINE
END IF

If the initialization was successful, the application can call the following functions to display version and expiration information about the instance of MatchUp Object currently in use on the local computer.

PRINT "Confirming Initialization: " + mu.GetInitializeErrorString
PRINT "Build Number: " + mu.GetBuildNumber
PRINT "Database Date: " + mu.GetDatabaseDate
PRINT "Database Expiration Date: " + mu.GetDatabaseExpirationDate
PRINT "License Expiration Date: " + mu.GetLicenseExpirationDate

Create field mappings

Field mappings define which types of data the Read-Write Interface is expecting. In this case, the selected matchcode looks for a five-digit ZIP Code, a first name, a last name and a street address.

CALL mu.ClearMappings

After clearing any mappings from a previous use of the Read-Write Interface, call the AddMapping function once for each field being considered.

CALL mu.AddMapping with mu.Zip5 RETURNING mapOK
CALL mu.AddMapping with mu.First RETURNING mapOK
CALL mu.AddMapping with mu.Last RETURNING mapOK
CALL mu.AddMapping with mu.Address RETURNING mapOK

Loop through database records and build keys

The Read-Write Interface builds a temporary key file out of the data from the database. To do this, the application loops through each record and pulls the data from the fields that match the mappings made above.

FOR EACH Record in database
  Read Zip5, FirstName, LastName, StreetAddress, userInfo fields from database

After pulling the data from the database, pass it to the Read-Write Interface with the AddField function. The application must do this in the same order that it mapped the data types in the step above.

Even if the fields in a database do not exactly match the components required by the matchcode, MatchUp Object is able to extract only the information it needs. For example, if the database only contained a full name field, that field could be passed twice and MatchUp Object would recognize the first names and last names and only use the parts it needed.

After passing each set of fields, call the BuildKey function to create the match key according to the mappings and the current matchcode.

CALL mu.ClearFields
CALL mu.AddField with Zip5
CALL mu.AddField with FirstName
CALL mu.AddField with LastName
CALL mu.AddField with StreetAddress
CALL mu.BuildKey

The UserInfo is a unique identifier for each record. The application will need this to later match the deduping information to the original records.

CALL mu.SetUserInfo with userInfo

The WriteRecord function adds the current key and UserInfo to the key field.

CALL mu.WriteRecord

Repeat for every record in the current data set.

NEXT Record

Begin processing the records

The Process function switches the Read-Write Interface from writing new keys to comparing the stored keys to each other.

CALL mu.Process

Examine the processed records

At this point, loop through the processed records, and get information on each record’s unique/duplicate status and how many duplicates of each record exist in the data set.

WHILE mu.ReadRecord does not return 0

Each call to the ReadRecord function advances the Interface to the next record and populates the fields returned by the functions below.

PRINT "Record: " + mu.GetUserInfo
PRINT "Key: " + mu.GetKey
PRINT "Dupe Group: " + mu.GetDupeGroup
PRINT mu.GetCount + " records in this dupe group."
PRINT "This is record #" + mu.GetEntry + " in this dupe group."

The Results property indicates whether the record is unique, a record with duplicates, or a duplicate of another record.

CASE mu.GetResults Contains
  MS03 :PRINT "This record is a duplicate."
  MS02 :PRINT "This record has duplicates."
  MS01 :PRINT "This record is unique."
ENDCASE

The result codes returned by the GetResults function also indicate which combination or combinations defined by the matchcode produced the hit. In addition to the status code, other potential result codes correspond to a specific combination number, so the application needs to use logical AND operation for each bit to actually make use of this information.

CALL mu.GetResults Contains
MS06 Match: Rule 1 Matched another record by matchcode combination 1
MS07 Match: Rule 2 Matched another record by matchcode combination 2
MS08 Match: Rule 3 Matched another record by matchcode combination 3
MS09 Match: Rule 4 Matched another record by matchcode combination 4
MS10 Match: Rule 5 Matched another record by matchcode combination 5
MS11 Match: Rule 6 Matched another record by matchcode combination 6
MS12 Match: Rule 7 Matched another record by matchcode combination 7
MS13 Match: Rule 8 Matched another record by matchcode combination 8
MS14 Match: Rule 9 Matched another record by matchcode combination 9
MS15 Match: Rule 10 Matched another record by matchcode combination 10
MS16 Match: Rule 11 Matched another record by matchcode combination 11
MS17 Match: Rule 12 Matched another record by matchcode combination 12
MS18 Match: Rule 13 Matched another record by matchcode combination 13
MS19 Match: Rule 14 Matched another record by matchcode combination 14
MS20 Match: Rule 15 Matched another record by matchcode combination 15
MS21 Match: Rule 16 Matched another record by matchcode combination 16