AbstractRecordGrouping implements IRecordGrouping<TYPE> { @Override public void doGroup(TYPE[] inputRow) throws IOException, InterruptedException { extSize = isOutputDistDetails ? 5 : 4; extSize = extSize + 1; if (multiMatchRules.isEmpty()) { return; } switch (matchAlgo) { case simpleVSRMatcher: if (isLinkToPrevious && inputRow.length <= originalInputColumnSize) { isLinkToPrevious = false; } if (isLinkToPrevious && !isMaster(inputRow[originalInputColumnSize + 2])) { TYPE[] inputRowWithExtColumns = createNewInputRowForMultPass(inputRow, originalInputColumnSize + extSize); outputRow(inputRowWithExtColumns); return; } List<Map<String, String>> matchingRule = multiMatchRules.get(0); String[] lookupDataArray = new String[matchingRule.size()]; for (int idx = 0; idx < lookupDataArray.length; idx++) { Object inputObj = inputRow[Integer.parseInt(matchingRule.get(idx).get(IRecordGrouping.COLUMN_IDX))]; lookupDataArray[idx] = inputObj == null ? null : String.valueOf(inputObj); } vsrMatch(inputRow, matchingRule, lookupDataArray); break; case T_SwooshAlgorithm: swooshGrouping.addToList(inputRow, multiMatchRules, this.getSurvivorShipAlgorithmParams()); break; } }  @Override void setColumnDelimiter(String columnDelimiter); @Override void setIsLinkToPrevious(Boolean isLinkToPrevious); @Deprecated @Override void setAcceptableThreshold(float acceptableThreshold); boolean isOutputDistDetails(); Boolean getIsDisplayAttLabels(); @Override void setIsOutputDistDetails(boolean isOutputDistDetails); void setOrginalInputColumnSize(int originalInputColumnSize); @Deprecated @Override void setIsComputeGrpQuality(Boolean isComputeGrpQuality); int getOriginalInputColumnSize(); @Override void setIsDisplayAttLabels(Boolean isDisplayAttLabels); void setIsGIDStringType(Boolean isGIDStringType); @Override void setRecordLinkAlgorithm(RecordMatcherType algorithm); @Override void doGroup(TYPE[] inputRow); @Override void end(); @Deprecated @Override void add(Map<String, String> matchingColumn); @Override void addMatchRule(List<Map<String, String>> matchRule); @Override void setSurvivorShipAlgorithmParams(SurvivorShipAlgorithmParams survivorShipAlgorithmParams); List<List<Map<String, String>>> getMultiMatchRules(); void outputRichRecord(RichRecord row); @Override void initialize(); CombinedRecordMatcher getCombinedRecordMatcher(); @Override void setIsPassOriginalValue(Boolean isPassOriginal); void setIsStoreOndisk(Boolean isStoreOndisk); void setColumnDatePatternMap(Map<String, String> columnMap); Map<String, String> getColumnDatePatternMap(); TSwooshGrouping<TYPE> getSwooshGrouping(); static final float DEFAULT_THRESHOLD; }
@Test public void testDoGroup() { recordGroup = new AbstractRecordGrouping<String>() { @Override protected void outputRow(String[] row) { groupingRecords.add(row); } @Override protected String incrementGroupSize(String oldGroupSize) { String newGroupSize = String.valueOf(Integer.parseInt(String.valueOf(oldGroupSize)) + 1); return newGroupSize; } @Override protected String castAsType(Object objectValue) { String column = String.valueOf(objectValue); return column; } @Override protected boolean isMaster(String col) { return "true".equals(col); } @Override protected String[] createTYPEArray(int size) { String[] arrays = new String[size]; return arrays; } @Override protected void outputRow(RichRecord row) { } }; recordGroup.setColumnDelimiter(columnDelimiter); recordGroup.setIsLinkToPrevious(Boolean.FALSE); List<Map<String, String>> matchingRule = new ArrayList<Map<String, String>>(); Map<String, String> lnameRecords = new HashMap<String, String>(); lnameRecords.put(IRecordGrouping.COLUMN_IDX, String.valueOf(1)); lnameRecords.put(IRecordGrouping.MATCHING_TYPE, "JARO_WINKLER"); lnameRecords.put(IRecordGrouping.TOKENIZATION_TYPE, TokenizedResolutionMethod.NO.toString()); lnameRecords.put(IRecordGrouping.CONFIDENCE_WEIGHT, String.valueOf(1)); lnameRecords.put(IRecordGrouping.ATTRIBUTE_THRESHOLD, String.valueOf(1)); matchingRule.add(lnameRecords); Map<String, String> accountRecords = new HashMap<String, String>(); accountRecords.put(IRecordGrouping.COLUMN_IDX, String.valueOf(6)); accountRecords.put(IRecordGrouping.MATCHING_TYPE, "LEVENSHTEIN"); accountRecords.put(IRecordGrouping.TOKENIZATION_TYPE, TokenizedResolutionMethod.NO.toString()); accountRecords.put(IRecordGrouping.CONFIDENCE_WEIGHT, String.valueOf(0.8)); accountRecords.put(IRecordGrouping.ATTRIBUTE_THRESHOLD, String.valueOf(1)); matchingRule.add(accountRecords); Map<String, String> customRecords = new HashMap<String, String>(); customRecords.put(IRecordGrouping.COLUMN_IDX, String.valueOf(6)); customRecords.put(IRecordGrouping.MATCHING_TYPE, "CUSTOM"); customRecords.put(IRecordGrouping.TOKENIZATION_TYPE, TokenizedResolutionMethod.NO.toString()); customRecords.put(IRecordGrouping.CUSTOMER_MATCH_CLASS, "testCustomMatcher.myCustomMatcherNullMatchAll"); customRecords.put(IRecordGrouping.JAR_PATH, this.getClass().getResource("custom/CustomMatcherTest1.jar").getPath()); customRecords.put(IRecordGrouping.CONFIDENCE_WEIGHT, String.valueOf(0.9)); customRecords.put(IRecordGrouping.ATTRIBUTE_THRESHOLD, String.valueOf(2)); matchingRule.add(customRecords); recordGroup.addMatchRule(matchingRule); try { recordGroup.initialize(); } catch (InstantiationException e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); Assert.fail(e.getMessage()); } recordGroup.setIsOutputDistDetails(true); recordGroup.setAcceptableThreshold(0.95f); try { for (String[] inputRow : inputList) { recordGroup.doGroup(inputRow); } recordGroup.end(); } catch (IOException e) { log.error(e.getMessage(), e); } catch (InterruptedException e) { log.error(e.getMessage(), e); } for (String[] rds : groupingRecords) { if (rds[0].equals("26997914900")) { Assert.assertEquals(1, Integer.valueOf(rds[rds.length - 5]).intValue()); } if (rds[0].equals("13700177100")) { Assert.assertEquals(1, Integer.valueOf(rds[rds.length - 5]).intValue()); } if (rds[0].equals("12083684802")) { Assert.assertEquals(1, Integer.valueOf(rds[rds.length - 5]).intValue()); } if (rds[0].equals("13758354187")) { Assert.assertEquals(1, Integer.valueOf(rds[rds.length - 5]).intValue()); } if (rds[0].equals("15114446900")) { Assert.assertEquals(1, Integer.valueOf(rds[rds.length - 5]).intValue()); } for (String rd : rds) { log.info(rd + ","); } } testGroupQuality(); testMatchThreshold(); testMatchThreshold_0(); }