Use a simple list for string code table 89/80889/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 15 Mar 2019 11:33:05 +0000 (12:33 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 15 Mar 2019 11:33:05 +0000 (12:33 +0100)
commit02a9d36756493691fda2bdd36a1c243ebc5e7cca
treeea34123e97d1f65ca7e7013f06e6e795418ea480
parentbfed3c0a9e208b7fd45d6a853f9c63ef95fde00e
Use a simple list for string code table

Since the codes are assigned in a linear fashion, we can use
a simple ArrayList to track assignes codes, preventing the need
for boxing integer during population and lookups. Lookups also
end up requiring an array offset lookup rather than needing
to go through multiple indirections.

While this can in theory lead to a large array being allocated,
the set of strings we keep in the table is limited by the
SchemaContext and thus will be typically capped ad couple of
thousand.

The cost of growing the lookup should not be significantly
higher, even if ArrayList grows slower:
- 10, 16, 25, 38,  58,  88
versus HashMap (with .75 load factor)
- 12, 24, 48, 96, 192, 384

each resize operation is significantly faster.

Change-Id: I00c7a2e0985dbf901b6857a16424bf157e5af39d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.