@Override
  public Map<String, String> detect() {
    LOGGER.info("Calculating the most probable attribute/value ...");
    Map<String, String> detectedMap = Maps.newHashMap();

    Map.Entry<String, Integer> selectedEntry = null;

    for (Map.Entry<String, Integer> entry : occurrenceMap().entrySet()) {
      if (selectedEntry == null) {

        selectedEntry = entry;
        LOGGER.debug("Initial attribute / value entry: {}", selectedEntry);
        continue;

      }

      if (selectedEntry.getValue() < entry.getValue()) {

        LOGGER.info("Changing potential attribute / value entry from : [{}] to: [{}]", selectedEntry, entry);
        selectedEntry = entry;

      }
    }

    // check whether the selected entry is valid (has occured in the sample result set)
    String detectedVal = "N/A";

    if (selectedEntry.getValue() > 0) {
      detectedVal = selectedEntry.getKey();
    } else {
      LOGGER.warn("Unable to detect attribute or attribute value");
    }

    LOGGER.info("Detected attribute or value: [{}]", detectedVal);
    detectedMap.put(detectedProperty(), detectedVal);
    return detectedMap;
  }
Calculates the attribute value based on the two maps.

@return a map with a single element, the key is the configuration key, the value is the detected attribute value
ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java