Class LeafsetEntryInterner
- java.lang.Object
-
- org.opendaylight.yangtools.yang.data.util.LeafsetEntryInterner
-
@Beta public final class LeafsetEntryInterner extends Object
Utility class for sharing instances ofLeafSetEntryNode
s which have low cardinality -- e.g. those which hold boolean or enumeration values. Instances containing attributes are not interned.Such objects have cardinality which is capped at the product of QNAMES * TYPE_CARDINALITY, where QNAMES is the total number of different QNames where the type is used and TYPE_CARDINALITY is the number of possible values for the type. Boolean has cardinality of 2, enumerations have cardinality equal to the number of enum statements.
The theory here is that we tend to have a large number (100K+) of entries in a few places, which could end up hogging the heap retained via the DataTree with duplicate objects (same QName, same value, different object). Using this utility, such objects will end up reusing the same object, preventing this overhead.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static @Nullable LeafsetEntryInterner
forSchema(@Nullable LeafListSchemaNode schema)
Return aLeafsetEntryInterner
for a particular schema.<T extends LeafSetEntryNode<?>>
@NonNull Tintern(@NonNull T sample)
-
-
-
Method Detail
-
intern
public <T extends LeafSetEntryNode<?>> @NonNull T intern(@NonNull T sample)
-
forSchema
public static @Nullable LeafsetEntryInterner forSchema(@Nullable LeafListSchemaNode schema)
Return aLeafsetEntryInterner
for a particular schema. Interner instances must be used only for leafset entries for that particular schema, otherwise they may produce unexpected results.- Parameters:
schema
- Schema of the parent leaf set- Returns:
- An interner instance, or null if the leafset's type should not be interned.
-
-