devicemap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reza Naghibi <reza.nagh...@yahoo.com.INVALID>
Subject RE: Comments needed for DeviceMapClient.createIndex()
Date Mon, 29 Dec 2014 15:03:42 GMT
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 <volkan.yazici@gmail.com>
</div><div>Date:12/29/2014  7:53 AM  (GMT-05:00) </div><div>To: dev@devicemap.apache.org
</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.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message