public int ensureFeature ( String featureName ) { int feature = featureToIndex . getOrDefault ( featureName , - 1 ) ; if ( feature == - 1 ) { synchronized ( featureToIndex ) { feature = featureToIndex . getOrDefault ( featureName , - 1 ) ; if ( feature == - 1 ) { feature = featureToIndex . size ( ) ; featureToIndex . put ( featureName , feature ) ; } } } return feature ; }
An optimization this lets clients inform the ConcatVectorNamespace of how many features to expect so that we can avoid resizing ConcatVectors .