public void run ( final R row , final String value , final int distinctCount ) { final List < Token > tokens ; try { tokens = _tokenizer . tokenize ( value ) ; } catch ( final RuntimeException e ) { throw new IllegalStateException ( "Error occurred while tokenizing value: " + value , e ) ; } final String patternCode = getPatternCode ( tokens ) ; final Collection < TokenPattern > patterns = getOrCreatePatterns ( patternCode ) ; // lock on "patterns" since it is going to be the same collection for // all matching pattern codes. synchronized ( patterns ) { boolean match = false ; for ( final TokenPattern pattern : patterns ) { if ( pattern . match ( tokens ) ) { storeMatch ( pattern , row , value , distinctCount ) ; match = true ; break ; } } if ( ! match ) { final TokenPattern pattern ; try { pattern = new TokenPatternImpl ( value , tokens , _configuration ) ; } catch ( final RuntimeException e ) { throw new IllegalStateException ( "Error occurred while creating pattern for: " + tokens , e ) ; } storeNewPattern ( pattern , row , value , distinctCount ) ; patterns . add ( pattern ) ; } } }
This method should be invoked by the user of the PatternFinder . Invoke it for each value in your dataset . Repeated values are handled correctly but if available it is more efficient to handle only the distinct values and their corresponding distinct counts .