Menu

#1372 AtomContainer properties are returned as unmodifiable collection in 1.5.11

cdk-1.6.x
closed
John May
None
1
2015-09-09
2015-09-09
No

Since 1.5.11 the atomcontainer properties collection returns unmodifiable map.

@Override
public Map<Object, Object> getProperties() {
    return properties == null ? Collections.emptyMap()
                              : Collections.unmodifiableMap(properties);
}

I've probably missed when this change was discussed.
I can see the reason (and the inefficient workaround through cloning), but this change is likely to break a lot of code, e.g. in the simple scenario of reading the structure and properties form SDF file, calculating something and putting back into properties.

Related

Bugs: #1372

Discussion

  • Nina Jeliazkova

    Nina Jeliazkova - 2015-09-09

    OK, there is setProperty() which should be used instead, still existing code needs to be modified.

     
    • John May

      John May - 2015-09-09

      For encapsulation the caller shouldn't have direct access to the underlying
      array/collection. I understand existing code that makes than assumption
      will break but the benefit is we can show an empty map without allocating
      the maps. If we looped over an molecule with 20 atoms and called
      getProperties() on each atom just to see if there were any this silently
      allocates 1KB of arrays let alone the object overhead.

      Regards,
      John W May
      john.wilkinsonmay@gmail.com

      On 9 September 2015 at 07:39, Nina Jeliazkova vedina@users.sf.net wrote:

      OK, there is setProperty() which should be used instead, still existing
      code needs to be modified.


      Status: open
      Group: cdk-1.6.x
      Created: Wed Sep 09, 2015 06:35 AM UTC by Nina Jeliazkova
      Last Updated: Wed Sep 09, 2015 06:35 AM UTC
      Owner: John May

      Since 1.5.11 the atomcontainer properties collection returns unmodifiable
      map.

      @Override
      public Map<Object, Object=""> getProperties() {
      return properties == null ? Collections.emptyMap()
      : Collections.unmodifiableMap(properties);
      }

      I've probably missed when this change was discussed.
      I can see the reason (and the inefficient workaround through cloning), but
      this change is likely to break a lot of code, e.g. in the simple scenario
      of reading the structure and properties form SDF file, calculating
      something and putting back into properties.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cdk/bugs/1372/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1372

  • Nina Jeliazkova

    Nina Jeliazkova - 2015-09-09

    Thanks, this is fine, consider this closed.

     
  • John May

    John May - 2015-09-09

    Would you consider moving AMBIT to github Nina? I'd be more than happy to test and patch changes like this if it was easy.

     
    • Nina Jeliazkova

      Nina Jeliazkova - 2015-09-09

      Not impossible :)

      On 9 September 2015 at 12:26, John May jwmay@users.sf.net wrote:

      Would you consider moving AMBIT to github Nina? I'd be more than happy to
      test and patch changes like this if it was easy.


      Status: open
      Group: cdk-1.6.x
      Created: Wed Sep 09, 2015 06:35 AM UTC by Nina Jeliazkova
      Last Updated: Wed Sep 09, 2015 07:55 AM UTC
      Owner: John May

      Since 1.5.11 the atomcontainer properties collection returns unmodifiable
      map.

      @Override
      public Map<Object, Object=""> getProperties() {
      return properties == null ? Collections.emptyMap()
      : Collections.unmodifiableMap(properties);
      }

      I've probably missed when this change was discussed.
      I can see the reason (and the inefficient workaround through cloning), but
      this change is likely to break a lot of code, e.g. in the simple scenario
      of reading the structure and properties form SDF file, calculating
      something and putting back into properties.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cdk/bugs/1372/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1372

  • John May

    John May - 2015-09-09
    • status: open --> closed
     
  • Nina Jeliazkova

    Nina Jeliazkova - 2015-09-09

    John, is there a replacement of mol.getProperties().clear() in 1.5.11 ?

     
    • John May

      John May - 2015-09-09

      Nope, but we should add a clearProperties() method.

      mol.setProperties(new LinkedHashMap<>());

      ?

      Regards,
      John W May
      john.wilkinsonmay@gmail.com

      On 9 September 2015 at 14:17, Nina Jeliazkova vedina@users.sf.net wrote:

      John, is there a replacement of mol.getProperties().clear() in 1.5.11 ?

      Status: closed
      Group: cdk-1.6.x
      Created: Wed Sep 09, 2015 06:35 AM UTC by Nina Jeliazkova
      Last Updated: Wed Sep 09, 2015 09:43 AM UTC
      Owner: John May

      Since 1.5.11 the atomcontainer properties collection returns unmodifiable
      map.

      @Override
      public Map<Object, Object=""> getProperties() {
      return properties == null ? Collections.emptyMap()
      : Collections.unmodifiableMap(properties);
      }

      I've probably missed when this change was discussed.
      I can see the reason (and the inefficient workaround through cloning), but
      this change is likely to break a lot of code, e.g. in the simple scenario
      of reading the structure and properties form SDF file, calculating
      something and putting back into properties.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cdk/bugs/1372/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1372

  • Nina Jeliazkova

    Nina Jeliazkova - 2015-09-09

    +1