Skip to content

Save RAM With EnumMapProperties

Jon Ivmark edited this page Nov 28, 2013 · 5 revisions

Nodes as well as edges can have arbitrary properties associated with them. The default way of storing properties is in a HashMap. If you know the set of keys that will be used you can store the properties in an EnumMap instead, thereby saving a lot of RAM and possibly gaining some speed as well.

An example:

    public static enum ArtistProperty {
        NAME, URL, PICTURE_URL;
    }

    public static final NodeType ARTIST =
        new NodeTypeImpl("Artist",
                         new EnumMapPropertiesFactory<ArtistProperty>(ArtistProperty.class));

The same can be achieved with EdgeTypeImpl for edges.

Clone this wiki locally