protected WritableDataStore < Meta > initializeMeta ( Relation < V > relation , double [ ] [ ] means ) { NumberVectorDistanceFunction < ? super V > df = getDistanceFunction ( ) ; // The actual storage final WritableDataStore < Meta > metas = DataStoreUtil . makeStorage ( relation . getDBIDs ( ) , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP , Meta . class ) ; // Build the metadata, track the two nearest cluster centers. for ( DBIDIter id = relation . iterDBIDs ( ) ; id . valid ( ) ; id . advance ( ) ) { Meta c = new Meta ( k ) ; V fv = relation . get ( id ) ; for ( int i = 0 ; i < k ; i ++ ) { final double d = c . dists [ i ] = df . distance ( fv , DoubleVector . wrap ( means [ i ] ) ) ; if ( i > 0 ) { if ( d < c . dists [ c . primary ] ) { c . primary = i ; } else if ( d > c . dists [ c . secondary ] ) { c . secondary = i ; } } } metas . put ( id , c ) ; } return metas ; }
Initialize the metadata storage .