No, the line in question is very important. I recommend you try your suggestion and look at the resulting index and see how it changes.
<div>-------- Original message --------</div><div>From: Volkan YAZICI <[email protected]> </div><div>Date:12/29/2014 7:53 AM (GMT-05:00) </div><div>To: [email protected] </div><div>Cc: </div><div>Subject: Comments needed for DeviceMapClient.createIndex() </div><div> </div>Hi, I am working on a mechanism to enable the concurrent devicemap data initialization for DeviceMap Java client. In createIndex() method, what is the purpose of the *i == (pattern.getPatternParts().size() - 1)* check? That is, private void createIndex() { patterns = new HashMap<String, List<DeviceType>>(8000); for (DeviceType device : devices.values()) { for (Pattern pattern : device.getPatternSet().getPatterns()) { for (int i = 0; i < pattern.getPatternParts().size(); i++) { String part = pattern.getPatternParts().get(i); //duplicate if (patterns.get(part) != null) { if (i == (pattern.getPatternParts().size() - 1) && !patterns.get(part).contains(device)) { patterns.get(part).add(device); } } else { List<DeviceType> single = new ArrayList<DeviceType>(); single.add(device); patterns.put(part, single); } } } } } Can't we just go with a *!patterns.get(part).contains(device)* check? Additionally, wouldn't it be better to rather use a Set instead of a List? Best.
