public static LongsSketch getInstance ( final String string ) { final String [ ] tokens = string . split ( "," ) ; if ( tokens . length < ( STR_PREAMBLE_TOKENS + 2 ) ) { throw new SketchesArgumentException ( "String not long enough: " + tokens . length ) ; } final int serVer = Integer . parseInt ( tokens [ 0 ] ) ; final int famID = Integer . parseInt ( tokens [ 1 ] ) ; final int lgMax = Integer . parseInt ( tokens [ 2 ] ) ; final int flags = Integer . parseInt ( tokens [ 3 ] ) ; final long streamWt = Long . parseLong ( tokens [ 4 ] ) ; final long offset = Long . parseLong ( tokens [ 5 ] ) ; //error offset //should always get at least the next 2 from the map final int numActive = Integer . parseInt ( tokens [ 6 ] ) ; final int lgCur = Integer . numberOfTrailingZeros ( Integer . parseInt ( tokens [ 7 ] ) ) ; //checks if ( serVer != SER_VER ) { throw new SketchesArgumentException ( "Possible Corruption: Bad SerVer: " + serVer ) ; } Family . FREQUENCY . checkFamilyID ( famID ) ; final boolean empty = flags > 0 ; if ( ! empty && ( numActive == 0 ) ) { throw new SketchesArgumentException ( "Possible Corruption: !Empty && NumActive=0; strLen: " + numActive ) ; } final int numTokens = tokens . length ; if ( ( 2 * numActive ) != ( numTokens - STR_PREAMBLE_TOKENS - 2 ) ) { throw new SketchesArgumentException ( "Possible Corruption: Incorrect # of tokens: " + numTokens + ", numActive: " + numActive ) ; } final LongsSketch sketch = new LongsSketch ( lgMax , lgCur ) ; sketch . streamWeight = streamWt ; sketch . offset = offset ; sketch . hashMap = deserializeFromStringArray ( tokens ) ; return sketch ; }
Returns a sketch instance of this class from the given String which must be a String representation of this sketch class .