idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
3,400
public static tunnelglobal_tunneltrafficpolicy_binding [ ] get ( nitro_service service ) throws Exception { tunnelglobal_tunneltrafficpolicy_binding obj = new tunnelglobal_tunneltrafficpolicy_binding ( ) ; tunnelglobal_tunneltrafficpolicy_binding response [ ] = ( tunnelglobal_tunneltrafficpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch a tunnelglobal_tunneltrafficpolicy_binding resources .
3,401
public static pq_stats get ( nitro_service service ) throws Exception { pq_stats obj = new pq_stats ( ) ; pq_stats [ ] response = ( pq_stats [ ] ) obj . stat_resources ( service ) ; return response [ 0 ] ; }
Use this API to fetch the statistics of all pq_stats resources that are configured on netscaler .
3,402
public static csvserver_authorizationpolicy_binding [ ] get ( nitro_service service , String name ) throws Exception { csvserver_authorizationpolicy_binding obj = new csvserver_authorizationpolicy_binding ( ) ; obj . set_name ( name ) ; csvserver_authorizationpolicy_binding response [ ] = ( csvserver_authorizationpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch csvserver_authorizationpolicy_binding resources of given name .
3,403
public Tree newTreeNode ( Label parentLabel , List < Tree > children ) { return new LabeledScoredTreeNode ( lf . newLabel ( parentLabel ) , children ) ; }
Create a new non - leaf tree node with the given label
3,404
public static policystringmap_binding get ( nitro_service service , String name ) throws Exception { policystringmap_binding obj = new policystringmap_binding ( ) ; obj . set_name ( name ) ; policystringmap_binding response = ( policystringmap_binding ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch policystringmap_binding resource of given name .
3,405
public static long count ( nitro_service service , clusternodegroup_crvserver_binding obj ) throws Exception { options option = new options ( ) ; option . set_count ( true ) ; option . set_args ( nitro_util . object_to_string_withoutquotes ( obj ) ) ; clusternodegroup_crvserver_binding response [ ] = ( clusternodegroup_crvserver_binding [ ] ) obj . get_resources ( service , option ) ; if ( response != null ) { return response [ 0 ] . __count ; } return 0 ; }
Use this API to count clusternodegroup_crvserver_binding resources configued on NetScaler .
3,406
public static < T > Set < T > asSet ( T [ ] a ) { return new HashSet < T > ( Arrays . asList ( a ) ) ; }
Return a set containing the same elements as the specified array .
3,407
public static double [ ] toDouble ( float [ ] a ) { double [ ] d = new double [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { d [ i ] = a [ i ] ; } return d ; }
Casts to a double array
3,408
public static double [ ] toDouble ( int [ ] array ) { double [ ] rv = new double [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { rv [ i ] = array [ i ] ; } return rv ; }
Casts to a double array .
3,409
public static base_response add ( nitro_service client , vpnsessionpolicy resource ) throws Exception { vpnsessionpolicy addresource = new vpnsessionpolicy ( ) ; addresource . name = resource . name ; addresource . rule = resource . rule ; addresource . action = resource . action ; return addresource . add_resource ( client ) ; }
Use this API to add vpnsessionpolicy .
3,410
public static base_response update ( nitro_service client , vpnsessionpolicy resource ) throws Exception { vpnsessionpolicy updateresource = new vpnsessionpolicy ( ) ; updateresource . name = resource . name ; updateresource . rule = resource . rule ; updateresource . action = resource . action ; return updateresource . update_resource ( client ) ; }
Use this API to update vpnsessionpolicy .
3,411
public static vpnsessionpolicy [ ] get ( nitro_service service ) throws Exception { vpnsessionpolicy obj = new vpnsessionpolicy ( ) ; vpnsessionpolicy [ ] response = ( vpnsessionpolicy [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch all the vpnsessionpolicy resources that are configured on netscaler .
3,412
public static vpnsessionpolicy get ( nitro_service service , String name ) throws Exception { vpnsessionpolicy obj = new vpnsessionpolicy ( ) ; obj . set_name ( name ) ; vpnsessionpolicy response = ( vpnsessionpolicy ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch vpnsessionpolicy resource of given name .
3,413
private static Pair < Double , ClassicCounter < Integer > > readModel ( File modelFile , boolean multiclass ) { int modelLineCount = 0 ; try { int numLinesToSkip = multiclass ? 13 : 10 ; String stopToken = "#" ; BufferedReader in = new BufferedReader ( new FileReader ( modelFile ) ) ; for ( int i = 0 ; i < numLinesToSkip ; i ++ ) { in . readLine ( ) ; modelLineCount ++ ; } List < Pair < Double , ClassicCounter < Integer > > > supportVectors = new ArrayList < Pair < Double , ClassicCounter < Integer > > > ( ) ; String thresholdLine = in . readLine ( ) ; modelLineCount ++ ; String [ ] pieces = thresholdLine . split ( "\\s+" ) ; double threshold = Double . parseDouble ( pieces [ 0 ] ) ; while ( in . ready ( ) ) { String svLine = in . readLine ( ) ; modelLineCount ++ ; pieces = svLine . split ( "\\s+" ) ; double alpha = Double . parseDouble ( pieces [ 0 ] ) ; ClassicCounter < Integer > supportVector = new ClassicCounter < Integer > ( ) ; for ( int i = 1 ; i < pieces . length ; ++ i ) { String piece = pieces [ i ] ; if ( piece . equals ( stopToken ) ) break ; String [ ] indexNum = piece . split ( ":" ) ; String featureIndex = indexNum [ 0 ] ; if ( ! featureIndex . equals ( "qid" ) ) { double count = Double . parseDouble ( indexNum [ 1 ] ) ; supportVector . incrementCount ( Integer . valueOf ( featureIndex ) , count ) ; } } supportVectors . add ( new Pair < Double , ClassicCounter < Integer > > ( alpha , supportVector ) ) ; } in . close ( ) ; return new Pair < Double , ClassicCounter < Integer > > ( threshold , getWeights ( supportVectors ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new RuntimeException ( "Error reading SVM model (line " + modelLineCount + " in file " + modelFile . getAbsolutePath ( ) + ")" ) ; } }
Reads in a model file in svm light format . It needs to know if its multiclass or not because it affects the number of header lines . Maybe there is another way to tell and we can remove this flag?
3,414
private ClassicCounter < Pair < F , L > > convertWeights ( ClassicCounter < Integer > weights , Index < F > featureIndex , Index < L > labelIndex , boolean multiclass ) { return multiclass ? convertSVMStructWeights ( weights , featureIndex , labelIndex ) : convertSVMLightWeights ( weights , featureIndex , labelIndex ) ; }
Converts the weight Counter to be from indexed svm_light format to a format we can use in our LinearClassifier .
3,415
private LinearClassifier < L , L > fitSigmoid ( SVMLightClassifier < L , F > classifier , GeneralDataset < L , F > dataset ) { RVFDataset < L , L > plattDataset = new RVFDataset < L , L > ( ) ; for ( int i = 0 ; i < dataset . size ( ) ; i ++ ) { RVFDatum < L , F > d = dataset . getRVFDatum ( i ) ; Counter < L > scores = classifier . scoresOf ( ( Datum < L , F > ) d ) ; scores . incrementCount ( null ) ; plattDataset . add ( new RVFDatum < L , L > ( scores , d . label ( ) ) ) ; } LinearClassifierFactory < L , L > factory = new LinearClassifierFactory < L , L > ( ) ; factory . setPrior ( new LogPrior ( LogPrior . LogPriorType . NULL ) ) ; return factory . trainClassifier ( plattDataset ) ; }
Builds a sigmoid model to turn the classifier outputs into probabilities .
3,416
public static gslbservice_binding get ( nitro_service service , String servicename ) throws Exception { gslbservice_binding obj = new gslbservice_binding ( ) ; obj . set_servicename ( servicename ) ; gslbservice_binding response = ( gslbservice_binding ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch gslbservice_binding resource of given name .
3,417
public Reader getUrl ( String prefix , String postfix ) throws MtasParserException { String url = getString ( ) ; if ( ( url != null ) && ! url . equals ( "" ) ) { if ( prefix != null ) { url = prefix + url ; } if ( postfix != null ) { url = url + postfix ; } if ( url . startsWith ( "http://" ) || url . startsWith ( "https://" ) ) { BufferedReader in = null ; try { URLConnection connection = new URL ( url ) . openConnection ( ) ; connection . setRequestProperty ( "Accept-Encoding" , "gzip" ) ; connection . setReadTimeout ( 10000 ) ; if ( connection . getHeaderField ( "Content-Encoding" ) != null && connection . getHeaderField ( "Content-Encoding" ) . equals ( "gzip" ) ) { in = new BufferedReader ( new InputStreamReader ( new GZIPInputStream ( connection . getInputStream ( ) ) , StandardCharsets . UTF_8 ) ) ; } else { in = new BufferedReader ( new InputStreamReader ( connection . getInputStream ( ) , StandardCharsets . UTF_8 ) ) ; } return in ; } catch ( IOException ex ) { log . debug ( ex ) ; throw new MtasParserException ( "couldn't get " + url ) ; } } else { throw new MtasParserException ( "no valid url: " + url ) ; } } else { throw new MtasParserException ( "no valid url: " + url ) ; } }
Gets the url .
3,418
public Reader getFile ( String prefix , String postfix ) throws MtasParserException { String file = getString ( ) ; if ( ( file != null ) && ! file . equals ( "" ) ) { if ( prefix != null ) { file = prefix + file ; } if ( postfix != null ) { file = file + postfix ; } Path path = ( new File ( file ) ) . toPath ( ) ; if ( Files . isReadable ( path ) ) { try { return new InputStreamReader ( new GZIPInputStream ( new FileInputStream ( file ) ) , StandardCharsets . UTF_8 ) ; } catch ( IOException e1 ) { log . debug ( e1 ) ; try { String text = new String ( Files . readAllBytes ( Paths . get ( file ) ) , StandardCharsets . UTF_8 ) ; return new StringReader ( text ) ; } catch ( IOException e2 ) { log . debug ( e2 ) ; throw new MtasParserException ( e2 . getMessage ( ) ) ; } } } else { throw new MtasParserException ( "file '" + file + "' does not exists or not readable" ) ; } } else { throw new MtasParserException ( "no valid file: " + file ) ; } }
Gets the file .
3,419
public static service_binding get ( nitro_service service , String name ) throws Exception { service_binding obj = new service_binding ( ) ; obj . set_name ( name ) ; service_binding response = ( service_binding ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch service_binding resource of given name .
3,420
public static systemglobal_authenticationlocalpolicy_binding [ ] get ( nitro_service service ) throws Exception { systemglobal_authenticationlocalpolicy_binding obj = new systemglobal_authenticationlocalpolicy_binding ( ) ; systemglobal_authenticationlocalpolicy_binding response [ ] = ( systemglobal_authenticationlocalpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch a systemglobal_authenticationlocalpolicy_binding resources .
3,421
public static auditsyslogpolicy_tmglobal_binding [ ] get ( nitro_service service , String name ) throws Exception { auditsyslogpolicy_tmglobal_binding obj = new auditsyslogpolicy_tmglobal_binding ( ) ; obj . set_name ( name ) ; auditsyslogpolicy_tmglobal_binding response [ ] = ( auditsyslogpolicy_tmglobal_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch auditsyslogpolicy_tmglobal_binding resources of given name .
3,422
String readLine ( boolean ignoreLF ) throws IOException { StringBuffer s = null ; int startChar ; synchronized ( lock ) { ensureOpen ( ) ; boolean omitLF = ignoreLF || skipLF ; for ( ; ; ) { if ( nextChar >= nChars ) fill ( ) ; if ( nextChar >= nChars ) { if ( s != null && s . length ( ) > 0 ) return s . toString ( ) ; else return null ; } boolean eol = false ; char c = 0 ; int i ; if ( omitLF && ( cb [ nextChar ] == '\n' ) ) nextChar ++ ; skipLF = false ; omitLF = false ; charLoop : for ( i = nextChar ; i < nChars ; i ++ ) { c = cb [ i ] ; if ( ( c == '\n' ) || ( c == '\r' ) ) { eol = true ; break charLoop ; } } startChar = nextChar ; nextChar = i ; if ( eol ) { String str ; if ( s == null ) { str = new String ( cb , startChar , i - startChar ) ; } else { s . append ( cb , startChar , i - startChar ) ; str = s . toString ( ) ; } nextChar ++ ; if ( c == '\r' ) { skipLF = true ; } return str ; } if ( s == null ) s = new StringBuffer ( defaultExpectedLineLength ) ; s . append ( cb , startChar , i - startChar ) ; } } }
Read line .
3,423
public static base_response unset ( nitro_service client , vpnparameter resource , String [ ] args ) throws Exception { vpnparameter unsetresource = new vpnparameter ( ) ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of vpnparameter resource . Properties that need to be unset are specified in args array .
3,424
public static vpnparameter get ( nitro_service service , options option ) throws Exception { vpnparameter obj = new vpnparameter ( ) ; vpnparameter [ ] response = ( vpnparameter [ ] ) obj . get_resources ( service , option ) ; return response [ 0 ] ; }
Use this API to fetch all the vpnparameter resources that are configured on netscaler .
3,425
public Iterator < List < IN > > getIterator ( Reader r ) { Tokenizer < IN > tokenizer = tokenizerFactory . getTokenizer ( r ) ; List < IN > words = new ArrayList < IN > ( ) ; IN previous = tokenFactory . makeToken ( ) ; StringBuilder prepend = new StringBuilder ( ) ; while ( tokenizer . hasNext ( ) ) { IN w = tokenizer . next ( ) ; String word = w . get ( CoreAnnotations . TextAnnotation . class ) ; Matcher m = sgml . matcher ( word ) ; if ( m . matches ( ) ) { String before = StringUtils . getNotNullString ( w . get ( CoreAnnotations . BeforeAnnotation . class ) ) ; String after = StringUtils . getNotNullString ( w . get ( CoreAnnotations . AfterAnnotation . class ) ) ; prepend . append ( before ) . append ( word ) ; String previousTokenAfter = StringUtils . getNotNullString ( previous . get ( CoreAnnotations . AfterAnnotation . class ) ) ; previous . set ( AfterAnnotation . class , previousTokenAfter + word + after ) ; } else { String before = StringUtils . getNotNullString ( w . get ( CoreAnnotations . BeforeAnnotation . class ) ) ; if ( prepend . length ( ) > 0 ) { w . set ( BeforeAnnotation . class , prepend . toString ( ) + before ) ; prepend = new StringBuilder ( ) ; } words . add ( w ) ; previous = w ; } } List < List < IN > > sentences = wts . process ( words ) ; String after = "" ; IN last = null ; for ( List < IN > sentence : sentences ) { int pos = 0 ; for ( IN w : sentence ) { w . set ( PositionAnnotation . class , Integer . toString ( pos ) ) ; after = StringUtils . getNotNullString ( w . get ( CoreAnnotations . AfterAnnotation . class ) ) ; w . remove ( AfterAnnotation . class ) ; last = w ; } } if ( last != null ) { last . set ( AfterAnnotation . class , after ) ; } return sentences . iterator ( ) ; }
sentence splitting as now
3,426
public static lbvserver_dospolicy_binding [ ] get ( nitro_service service , String name ) throws Exception { lbvserver_dospolicy_binding obj = new lbvserver_dospolicy_binding ( ) ; obj . set_name ( name ) ; lbvserver_dospolicy_binding response [ ] = ( lbvserver_dospolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch lbvserver_dospolicy_binding resources of given name .
3,427
public static nsrunningconfig get ( nitro_service service ) throws Exception { nsrunningconfig obj = new nsrunningconfig ( ) ; nsrunningconfig [ ] response = ( nsrunningconfig [ ] ) obj . get_resources ( service ) ; return response [ 0 ] ; }
Use this API to fetch all the nsrunningconfig resources that are configured on netscaler .
3,428
public static nsrunningconfig [ ] get ( nitro_service service , nsrunningconfig_args args ) throws Exception { nsrunningconfig obj = new nsrunningconfig ( ) ; options option = new options ( ) ; option . set_args ( nitro_util . object_to_string_withoutquotes ( args ) ) ; nsrunningconfig [ ] response = ( nsrunningconfig [ ] ) obj . get_resources ( service , option ) ; return response ; }
Use this API to fetch all the nsrunningconfig resources that are configured on netscaler . This uses nsrunningconfig_args which is a way to provide additional arguments while fetching the resources .
3,429
public static servicegroup_servicegroupmember_binding [ ] get ( nitro_service service , String servicegroupname ) throws Exception { servicegroup_servicegroupmember_binding obj = new servicegroup_servicegroupmember_binding ( ) ; obj . set_servicegroupname ( servicegroupname ) ; servicegroup_servicegroupmember_binding response [ ] = ( servicegroup_servicegroupmember_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch servicegroup_servicegroupmember_binding resources of given name .
3,430
public static aaagroup_auditnslogpolicy_binding [ ] get ( nitro_service service , String groupname ) throws Exception { aaagroup_auditnslogpolicy_binding obj = new aaagroup_auditnslogpolicy_binding ( ) ; obj . set_groupname ( groupname ) ; aaagroup_auditnslogpolicy_binding response [ ] = ( aaagroup_auditnslogpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch aaagroup_auditnslogpolicy_binding resources of given name .
3,431
public static nd6ravariables_onlinkipv6prefix_binding [ ] get ( nitro_service service , Long vlan ) throws Exception { nd6ravariables_onlinkipv6prefix_binding obj = new nd6ravariables_onlinkipv6prefix_binding ( ) ; obj . set_vlan ( vlan ) ; nd6ravariables_onlinkipv6prefix_binding response [ ] = ( nd6ravariables_onlinkipv6prefix_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch nd6ravariables_onlinkipv6prefix_binding resources of given name .
3,432
public static double [ ] exp ( double [ ] a ) { double [ ] result = new double [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { result [ i ] = Math . exp ( a [ i ] ) ; } return result ; }
OPERATIONS ON AN ARRAY - NONDESTRUCTIVE
3,433
public static void expInPlace ( double [ ] a ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = Math . exp ( a [ i ] ) ; } }
OPERATIONS ON AN ARRAY - DESTRUCTIVE
3,434
public static void addInPlace ( double [ ] a , double b ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = a [ i ] + b ; } }
Increases the values in this array by b . Does it in place .
3,435
public static void addMultInPlace ( double [ ] a , double [ ] b , double c ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] += b [ i ] * c ; } }
Add c times the array b to array a . Does it in place .
3,436
public static void multiplyInPlace ( double [ ] a , double b ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = a [ i ] * b ; } }
Scales the values in this array by b . Does it in place .
3,437
public static double [ ] add ( double [ ] a , double c ) { double [ ] result = new double [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { result [ i ] = a [ i ] + c ; } return result ; }
OPERATIONS WITH SCALAR - NONDESTRUCTIVE
3,438
public static double [ ] pow ( double [ ] a , double c ) { double [ ] result = new double [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { result [ i ] = Math . pow ( a [ i ] , c ) ; } return result ; }
raises each entry in array a by power c
3,439
public static int [ ] pairwiseAdd ( int [ ] a , int [ ] b ) { int [ ] result = new int [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { result [ i ] = a [ i ] + b [ i ] ; } return result ; }
OPERATIONS WITH TWO ARRAYS - NONDESTRUCTIVE
3,440
public static double [ ] pairwiseMultiply ( double [ ] a , double [ ] b ) { if ( a . length != b . length ) { throw new RuntimeException ( "Can't pairwise multiple different lengths: a.length=" + a . length + " b.length=" + b . length ) ; } double [ ] result = new double [ a . length ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = a [ i ] * b [ i ] ; } return result ; }
Assumes that both arrays have same length .
3,441
public static double norm_1 ( double [ ] a ) { double sum = 0 ; for ( double anA : a ) { sum += ( anA < 0 ? - anA : anA ) ; } return sum ; }
Computes 1 - norm of vector
3,442
public static double norm ( double [ ] a ) { double squaredSum = 0 ; for ( double anA : a ) { squaredSum += anA * anA ; } return Math . sqrt ( squaredSum ) ; }
Computes 2 - norm of vector
3,443
public static double innerProduct ( double [ ] a , double [ ] b ) { double result = 0.0 ; int len = Math . min ( a . length , b . length ) ; for ( int i = 0 ; i < len ; i ++ ) { result += a [ i ] * b [ i ] ; } return result ; }
LINEAR ALGEBRAIC FUNCTIONS
3,444
public static void normalize ( double [ ] a ) { double total = sum ( a ) ; if ( total == 0.0 || Double . isNaN ( total ) ) { throw new RuntimeException ( "Can't normalize an array with sum 0.0 or NaN: " + Arrays . toString ( a ) ) ; } multiplyInPlace ( a , 1.0 / total ) ; }
Makes the values in this array sum to 1 . 0 . Does it in place . If the total is 0 . 0 or NaN throws an RuntimeException .
3,445
public static void standardize ( double [ ] a ) { double m = mean ( a ) ; if ( Double . isNaN ( m ) ) throw new RuntimeException ( "Can't standardize array whose mean is NaN" ) ; double s = stdev ( a ) ; if ( s == 0.0 || Double . isNaN ( s ) ) throw new RuntimeException ( "Can't standardize array whose standard deviation is 0.0 or NaN" ) ; addInPlace ( a , - m ) ; multiplyInPlace ( a , 1.0 / s ) ; }
Standardize values in this array i . e . subtract the mean and divide by the standard deviation . If standard deviation is 0 . 0 throws an RuntimeException .
3,446
public static int sampleFromDistribution ( double [ ] d , Random random ) { double r = random . nextDouble ( ) ; double total = 0 ; for ( int i = 0 ; i < d . length - 1 ; i ++ ) { if ( Double . isNaN ( d [ i ] ) ) { throw new RuntimeException ( "Can't sample from NaN" ) ; } total += d [ i ] ; if ( r < total ) { return i ; } } return d . length - 1 ; }
Samples from the distribution over values 0 through d . length given by d . Assumes that the distribution sums to 1 . 0 .
3,447
public static void sampleWithoutReplacement ( int [ ] array , int numArgClasses , Random rand ) { int [ ] temp = new int [ numArgClasses ] ; for ( int i = 0 ; i < temp . length ; i ++ ) { temp [ i ] = i ; } shuffle ( temp , rand ) ; System . arraycopy ( temp , 0 , array , 0 , array . length ) ; }
Fills the array with sample from 0 to numArgClasses - 1 without replacement .
3,448
private static double absDiffOfMeans ( double [ ] A , double [ ] B , boolean randomize ) { Random random = new Random ( ) ; double aTotal = 0.0 ; double bTotal = 0.0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( randomize && random . nextBoolean ( ) ) { aTotal += B [ i ] ; bTotal += A [ i ] ; } else { aTotal += A [ i ] ; bTotal += B [ i ] ; } } double aMean = aTotal / A . length ; double bMean = bTotal / B . length ; return Math . abs ( aMean - bMean ) ; }
Assumes input arrays have equal non - zero length .
3,449
public static appfwpolicy_lbvserver_binding [ ] get ( nitro_service service , String name ) throws Exception { appfwpolicy_lbvserver_binding obj = new appfwpolicy_lbvserver_binding ( ) ; obj . set_name ( name ) ; appfwpolicy_lbvserver_binding response [ ] = ( appfwpolicy_lbvserver_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch appfwpolicy_lbvserver_binding resources of given name .
3,450
public static Session getSession ( String wrapper , Object ... parameters ) { org . riverframework . wrapper . Session < ? > _session = null ; Session session = map . get ( wrapper ) ; if ( session != null && session . isOpen ( ) ) { if ( parameters . length > 0 ) { throw new RiverException ( "There is already an open session for the wrapper " + wrapper + ". You must close the current before opening a new one." ) ; } } else { Class < ? > clazzFactory = null ; try { clazzFactory = Class . forName ( wrapper + ".DefaultFactory" ) ; } catch ( ClassNotFoundException e ) { throw new RiverException ( "The wrapper '" + wrapper + "' can not be loaded. If you are using an non-official wrapper, " + "check the wrapper name and its design. Check the CLASSPATH." ) ; } try { Method method = clazzFactory . getDeclaredMethod ( "getInstance" ) ; method . setAccessible ( true ) ; org . riverframework . wrapper . Factory < ? > _factory = ( org . riverframework . wrapper . Factory < ? > ) method . invoke ( null ) ; if ( _factory == null ) throw new RiverException ( "The factory could not be loaded." ) ; if ( parameters . length > 0 ) { _session = ( org . riverframework . wrapper . Session < ? > ) _factory . getSession ( parameters ) ; } else { _session = null ; } Constructor < ? > constructor = DefaultSession . class . getDeclaredConstructor ( org . riverframework . wrapper . Session . class ) ; constructor . setAccessible ( true ) ; session = ( DefaultSession ) constructor . newInstance ( _session ) ; } catch ( Exception e ) { throw new RiverException ( "There's a problem opening the session. Maybe, you will need to check the parameters." , e ) ; } map . put ( wrapper , session ) ; } return session ; }
Loads a wrapper that wraps libraries as lotus . domino or org . openntf . domino and creates a core Session object . Its behavior will depend on how the wrapper is implemented . Anyway this method creates the session just one time and returns the same every time is called . To free the memory resources etc . it s necessary to call the close method at the end of the program or process .
3,451
public static void closeSession ( String wrapper ) { Session session = map . get ( wrapper ) ; if ( session != null ) { Method method ; try { method = session . getClass ( ) . getDeclaredMethod ( "protectedClose" ) ; method . setAccessible ( true ) ; method . invoke ( session ) ; } catch ( InvocationTargetException e ) { throw new RiverException ( e . getCause ( ) . getMessage ( ) , e ) ; } catch ( Exception e ) { throw new RiverException ( e ) ; } map . remove ( wrapper ) ; } }
Calls the Session close method to free resources memory etc . Also it will remove it from its internal table .
3,452
public static base_response update ( nitro_service client , ntpparam resource ) throws Exception { ntpparam updateresource = new ntpparam ( ) ; updateresource . authentication = resource . authentication ; updateresource . trustedkey = resource . trustedkey ; updateresource . autokeylogsec = resource . autokeylogsec ; updateresource . revokelogsec = resource . revokelogsec ; return updateresource . update_resource ( client ) ; }
Use this API to update ntpparam .
3,453
public static base_response unset ( nitro_service client , ntpparam resource , String [ ] args ) throws Exception { ntpparam unsetresource = new ntpparam ( ) ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of ntpparam resource . Properties that need to be unset are specified in args array .
3,454
public static ntpparam get ( nitro_service service ) throws Exception { ntpparam obj = new ntpparam ( ) ; ntpparam [ ] response = ( ntpparam [ ] ) obj . get_resources ( service ) ; return response [ 0 ] ; }
Use this API to fetch all the ntpparam resources that are configured on netscaler .
3,455
public static base_response update ( nitro_service client , snmpengineid resource ) throws Exception { snmpengineid updateresource = new snmpengineid ( ) ; updateresource . engineid = resource . engineid ; updateresource . ownernode = resource . ownernode ; return updateresource . update_resource ( client ) ; }
Use this API to update snmpengineid .
3,456
public static base_responses update ( nitro_service client , snmpengineid resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { snmpengineid updateresources [ ] = new snmpengineid [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { updateresources [ i ] = new snmpengineid ( ) ; updateresources [ i ] . engineid = resources [ i ] . engineid ; updateresources [ i ] . ownernode = resources [ i ] . ownernode ; } result = update_bulk_request ( client , updateresources ) ; } return result ; }
Use this API to update snmpengineid resources .
3,457
public static base_response unset ( nitro_service client , Long ownernode , String args [ ] ) throws Exception { snmpengineid unsetresource = new snmpengineid ( ) ; unsetresource . ownernode = ownernode ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of snmpengineid resource . Properties that need to be unset are specified in args array .
3,458
public static base_responses unset ( nitro_service client , Long ownernode [ ] , String args [ ] ) throws Exception { base_responses result = null ; if ( ownernode != null && ownernode . length > 0 ) { snmpengineid unsetresources [ ] = new snmpengineid [ ownernode . length ] ; for ( int i = 0 ; i < ownernode . length ; i ++ ) { unsetresources [ i ] = new snmpengineid ( ) ; unsetresources [ i ] . ownernode = ownernode [ i ] ; } result = unset_bulk_request ( client , unsetresources , args ) ; } return result ; }
Use this API to unset the properties of snmpengineid resources . Properties that need to be unset are specified in args array .
3,459
public static snmpengineid [ ] get ( nitro_service service ) throws Exception { snmpengineid obj = new snmpengineid ( ) ; snmpengineid [ ] response = ( snmpengineid [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch all the snmpengineid resources that are configured on netscaler .
3,460
public static snmpengineid get ( nitro_service service , Long ownernode ) throws Exception { snmpengineid obj = new snmpengineid ( ) ; obj . set_ownernode ( ownernode ) ; snmpengineid response = ( snmpengineid ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch snmpengineid resource of given name .
3,461
public static snmpengineid [ ] get ( nitro_service service , Long ownernode [ ] ) throws Exception { if ( ownernode != null && ownernode . length > 0 ) { snmpengineid response [ ] = new snmpengineid [ ownernode . length ] ; snmpengineid obj [ ] = new snmpengineid [ ownernode . length ] ; for ( int i = 0 ; i < ownernode . length ; i ++ ) { obj [ i ] = new snmpengineid ( ) ; obj [ i ] . set_ownernode ( ownernode [ i ] ) ; response [ i ] = ( snmpengineid ) obj [ i ] . get_resource ( service ) ; } return response ; } return null ; }
Use this API to fetch snmpengineid resources of given names .
3,462
public static base_response enable ( nitro_service client , sslfipssimsource resource ) throws Exception { sslfipssimsource enableresource = new sslfipssimsource ( ) ; enableresource . targetsecret = resource . targetsecret ; enableresource . sourcesecret = resource . sourcesecret ; return enableresource . perform_operation ( client , "enable" ) ; }
Use this API to enable sslfipssimsource .
3,463
public static base_response init ( nitro_service client , sslfipssimsource resource ) throws Exception { sslfipssimsource initresource = new sslfipssimsource ( ) ; initresource . certfile = resource . certfile ; return initresource . perform_operation ( client , "init" ) ; }
Use this API to init sslfipssimsource .
3,464
public static base_response renumber ( nitro_service client ) throws Exception { nspbrs renumberresource = new nspbrs ( ) ; return renumberresource . perform_operation ( client , "renumber" ) ; }
Use this API to renumber nspbrs .
3,465
public static base_response clear ( nitro_service client ) throws Exception { nspbrs clearresource = new nspbrs ( ) ; return clearresource . perform_operation ( client , "clear" ) ; }
Use this API to clear nspbrs .
3,466
public static base_response apply ( nitro_service client ) throws Exception { nspbrs applyresource = new nspbrs ( ) ; return applyresource . perform_operation ( client , "apply" ) ; }
Use this API to apply nspbrs .
3,467
public static appflowpolicylabel_appflowpolicy_binding [ ] get ( nitro_service service , String labelname ) throws Exception { appflowpolicylabel_appflowpolicy_binding obj = new appflowpolicylabel_appflowpolicy_binding ( ) ; obj . set_labelname ( labelname ) ; appflowpolicylabel_appflowpolicy_binding response [ ] = ( appflowpolicylabel_appflowpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch appflowpolicylabel_appflowpolicy_binding resources of given name .
3,468
@ SuppressWarnings ( "unchecked" ) private void repairPrefixItems ( NamedList < Object > mtasResponse ) { try { ArrayList < NamedList < ? > > list = ( ArrayList < NamedList < ? > > ) mtasResponse . findRecursive ( NAME ) ; if ( list != null ) { for ( NamedList < ? > item : list ) { SortedSet < String > singlePosition = ( SortedSet < String > ) item . get ( "singlePosition" ) ; SortedSet < String > multiplePosition = ( SortedSet < String > ) item . get ( "multiplePosition" ) ; if ( singlePosition != null && multiplePosition != null ) { for ( String prefix : multiplePosition ) { if ( singlePosition . contains ( prefix ) ) { singlePosition . remove ( prefix ) ; } } } } } } catch ( ClassCastException e ) { log . debug ( e ) ; } }
Repair prefix items .
3,469
private static Set < String > collectKnownPrefixes ( FieldInfo fi ) throws IOException { if ( fi != null ) { HashSet < String > result = new HashSet < > ( ) ; String singlePositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION ) ; String multiplePositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION ) ; String setPositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION ) ; if ( singlePositionPrefixes != null ) { String [ ] prefixes = singlePositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { String item = prefixes [ i ] . trim ( ) ; if ( ! item . equals ( "" ) ) { result . add ( item ) ; } } } if ( multiplePositionPrefixes != null ) { String [ ] prefixes = multiplePositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { String item = prefixes [ i ] . trim ( ) ; if ( ! item . equals ( "" ) ) { result . add ( item ) ; } } } if ( setPositionPrefixes != null ) { String [ ] prefixes = setPositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { String item = prefixes [ i ] . trim ( ) ; if ( ! item . equals ( "" ) ) { result . add ( item ) ; } } } return result ; } else { return Collections . emptySet ( ) ; } }
Collect known prefixes .
3,470
private static Set < String > collectIntersectionPrefixes ( FieldInfo fi ) throws IOException { if ( fi != null ) { Set < String > result = new HashSet < > ( ) ; String intersectingPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION ) ; if ( intersectingPrefixes != null ) { String [ ] prefixes = intersectingPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { String item = prefixes [ i ] . trim ( ) ; if ( ! item . equals ( "" ) ) { result . add ( item ) ; } } } return result ; } else { return Collections . emptySet ( ) ; } }
Collect intersection prefixes .
3,471
private static void collectPrefixes ( FieldInfos fieldInfos , String field , ComponentField fieldInfo , Status status ) throws IOException { if ( fieldInfo . prefix != null ) { FieldInfo fi = fieldInfos . fieldInfo ( field ) ; if ( fi != null ) { String singlePositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SINGLE_POSITION ) ; String multiplePositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_MULTIPLE_POSITION ) ; String setPositionPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_SET_POSITION ) ; String intersectingPrefixes = fi . getAttribute ( MtasCodecPostingsFormat . MTAS_FIELDINFO_ATTRIBUTE_PREFIX_INTERSECTION ) ; if ( singlePositionPrefixes != null ) { String [ ] prefixes = singlePositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { fieldInfo . prefix . addSinglePosition ( prefixes [ i ] ) ; } } if ( multiplePositionPrefixes != null ) { String [ ] prefixes = multiplePositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { fieldInfo . prefix . addMultiplePosition ( prefixes [ i ] ) ; } } if ( setPositionPrefixes != null ) { String [ ] prefixes = setPositionPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { fieldInfo . prefix . addSetPosition ( prefixes [ i ] ) ; } } if ( intersectingPrefixes != null ) { String [ ] prefixes = intersectingPrefixes . split ( Pattern . quote ( MtasToken . DELIMITER ) ) ; for ( int i = 0 ; i < prefixes . length ; i ++ ) { fieldInfo . prefix . addIntersecting ( prefixes [ i ] ) ; } } } } }
Collect prefixes .
3,472
private static Map < GroupHit , Spans > collectSpansForOccurences ( Set < GroupHit > occurences , Set < String > prefixes , String field , IndexSearcher searcher , LeafReaderContext lrc ) throws IOException { Map < GroupHit , Spans > list = new HashMap < > ( ) ; IndexReader reader = searcher . getIndexReader ( ) ; final float boost = 0 ; for ( GroupHit hit : occurences ) { MtasSpanQuery queryHit = createQueryFromGroupHit ( prefixes , field , hit ) ; if ( queryHit != null ) { MtasSpanQuery queryHitRewritten = queryHit . rewrite ( reader ) ; SpanWeight weight = queryHitRewritten . createWeight ( searcher , false , boost ) ; Spans spans = weight . getSpans ( lrc , SpanWeight . Postings . POSITIONS ) ; if ( spans != null ) { list . put ( hit , spans ) ; } } } return list ; }
Collect spans for occurences .
3,473
private static MtasSpanQuery createQueryFromGroupHit ( Set < String > prefixes , String field , GroupHit hit ) { if ( prefixes == null || field == null || hit == null ) { return null ; } else { MtasSpanQuery query = null ; if ( hit . missingLeft != null && hit . missingLeft . length > 0 ) { for ( int i = 0 ; i < hit . missingLeft . length ; i ++ ) { if ( hit . missingLeft [ i ] . size ( ) != hit . unknownLeft [ i ] . size ( ) ) { return null ; } } } if ( hit . missingHit != null && hit . missingHit . length > 0 ) { for ( int i = 0 ; i < hit . missingHit . length ; i ++ ) { if ( hit . missingHit [ i ] . size ( ) != hit . unknownHit [ i ] . size ( ) ) { return null ; } } } if ( hit . missingRight != null && hit . missingRight . length > 0 ) { for ( int i = 0 ; i < hit . missingRight . length ; i ++ ) { if ( hit . missingRight [ i ] . size ( ) != hit . unknownRight [ i ] . size ( ) ) { return null ; } } } MtasSpanQuery hitQuery = createSubQueryFromGroupHit ( hit . dataHit , false , field ) ; if ( hitQuery != null ) { query = hitQuery ; MtasSpanQuery leftHitQuery = createSubQueryFromGroupHit ( hit . dataLeft , true , field ) ; MtasSpanQuery rightHitQuery = createSubQueryFromGroupHit ( hit . dataRight , false , field ) ; if ( leftHitQuery != null ) { query = new MtasSpanPrecededByQuery ( query , leftHitQuery ) ; } if ( rightHitQuery != null ) { query = new MtasSpanFollowedByQuery ( query , rightHitQuery ) ; } } return query ; } }
Creates the query from group hit .
3,474
private static MtasSpanQuery createSubQueryFromGroupHit ( List < String > [ ] subHit , boolean reverse , String field ) { MtasSpanQuery query = null ; if ( subHit != null && subHit . length > 0 ) { List < MtasSpanSequenceItem > items = new ArrayList < > ( ) ; List < String > subHitItem ; for ( int i = 0 ; i < subHit . length ; i ++ ) { MtasSpanQuery item = null ; if ( reverse ) { subHitItem = subHit [ ( subHit . length - i - 1 ) ] ; } else { subHitItem = subHit [ i ] ; } if ( subHitItem . isEmpty ( ) ) { item = new MtasSpanMatchAllQuery ( field ) ; } else if ( subHitItem . size ( ) == 1 ) { Term term = new Term ( field , subHitItem . get ( 0 ) ) ; item = new MtasSpanTermQuery ( term ) ; } else { MtasSpanQuery [ ] subList = new MtasSpanQuery [ subHitItem . size ( ) ] ; for ( int j = 0 ; j < subHitItem . size ( ) ; j ++ ) { Term term = new Term ( field , subHitItem . get ( j ) ) ; subList [ j ] = new MtasSpanTermQuery ( term ) ; } item = new MtasSpanAndQuery ( subList ) ; } items . add ( new MtasSpanSequenceItem ( item , false ) ) ; } query = new MtasSpanSequenceQuery ( items , null , null ) ; } return query ; }
Creates the sub query from group hit .
3,475
private static Map < Integer , Integer > computePositions ( CodecInfo mtasCodecInfo , LeafReader r , LeafReaderContext lrc , String field , List < Integer > docSet ) throws IOException { HashMap < Integer , Integer > positionsData ; if ( mtasCodecInfo != null ) { if ( docSet . size ( ) < Math . log ( r . maxDoc ( ) ) ) { positionsData = new HashMap < > ( ) ; for ( int docId : docSet ) { positionsData . put ( docId , mtasCodecInfo . getNumberOfPositions ( field , ( docId - lrc . docBase ) ) ) ; } } else { positionsData = mtasCodecInfo . getAllNumberOfPositions ( field , lrc . docBase ) ; for ( int docId : docSet ) { if ( ! positionsData . containsKey ( docId ) ) { positionsData . put ( docId , 0 ) ; } } } } else { positionsData = new HashMap < > ( ) ; for ( int docId : docSet ) { positionsData . put ( docId , 0 ) ; } } return positionsData ; }
Compute positions .
3,476
private static Map < Integer , long [ ] > computeArguments ( Map < MtasSpanQuery , Map < Integer , Integer > > spansNumberData , MtasSpanQuery [ ] queries , Integer [ ] docSet ) { Map < Integer , long [ ] > args = new HashMap < > ( ) ; for ( int q = 0 ; q < queries . length ; q ++ ) { Map < Integer , Integer > tmpData = spansNumberData . get ( queries [ q ] ) ; long [ ] tmpList = null ; for ( int docId : docSet ) { if ( tmpData != null && tmpData . containsKey ( docId ) ) { if ( ! args . containsKey ( docId ) ) { tmpList = new long [ queries . length ] ; } else { tmpList = args . get ( docId ) ; } tmpList [ q ] = tmpData . get ( docId ) ; args . put ( docId , tmpList ) ; } else if ( ! args . containsKey ( docId ) ) { tmpList = new long [ queries . length ] ; args . put ( docId , tmpList ) ; } } } return args ; }
Compute arguments .
3,477
private static Integer [ ] intersectedDocList ( int [ ] facetDocList , Integer [ ] docSet ) { if ( facetDocList != null && docSet != null ) { Integer [ ] c = new Integer [ Math . min ( facetDocList . length , docSet . length ) ] ; int ai = 0 ; int bi = 0 ; int ci = 0 ; while ( ai < facetDocList . length && bi < docSet . length ) { if ( facetDocList [ ai ] < docSet [ bi ] ) { ai ++ ; } else if ( facetDocList [ ai ] > docSet [ bi ] ) { bi ++ ; } else { if ( ci == 0 || facetDocList [ ai ] != c [ ci - 1 ] ) { c [ ci ++ ] = facetDocList [ ai ] ; } ai ++ ; bi ++ ; } } return Arrays . copyOfRange ( c , 0 , ci ) ; } return new Integer [ ] { } ; }
Intersected doc list .
3,478
private static void createPositions ( List < ComponentPosition > statsPositionList , Map < Integer , Integer > positionsData , List < Integer > docSet ) throws IOException { if ( statsPositionList != null ) { for ( ComponentPosition position : statsPositionList ) { position . dataCollector . initNewList ( 1 ) ; Integer tmpValue ; long [ ] values = new long [ docSet . size ( ) ] ; int value ; int number = 0 ; for ( int docId : docSet ) { tmpValue = positionsData . get ( docId ) ; value = tmpValue == null ? 0 : tmpValue . intValue ( ) ; if ( ( ( position . minimumLong == null ) || ( value >= position . minimumLong ) ) && ( ( position . maximumLong == null ) || ( value <= position . maximumLong ) ) ) { values [ number ] = value ; number ++ ; } } if ( number > 0 ) { position . dataCollector . add ( values , number ) ; } position . dataCollector . closeNewList ( ) ; } } }
Creates the positions .
3,479
private static void createTokens ( List < ComponentToken > statsTokenList , Map < Integer , Integer > tokensData , List < Integer > docSet ) throws IOException { if ( statsTokenList != null ) { for ( ComponentToken token : statsTokenList ) { token . dataCollector . initNewList ( 1 ) ; Integer tmpValue ; long [ ] values = new long [ docSet . size ( ) ] ; int value ; int number = 0 ; if ( tokensData != null ) { for ( int docId : docSet ) { tmpValue = tokensData . get ( docId ) ; value = tmpValue == null ? 0 : tmpValue . intValue ( ) ; if ( ( ( token . minimumLong == null ) || ( value >= token . minimumLong ) ) && ( ( token . maximumLong == null ) || ( value <= token . maximumLong ) ) ) { values [ number ] = value ; number ++ ; } } } if ( number > 0 ) { token . dataCollector . add ( values , number ) ; } token . dataCollector . closeNewList ( ) ; } } }
Creates the tokens .
3,480
private static boolean availablePrefixes ( ComponentGroup group , Set < String > knownPrefixes ) { if ( knownPrefixes != null ) { for ( String prefix : group . prefixes ) { if ( knownPrefixes . contains ( prefix ) ) { return true ; } } } return false ; }
Available prefixes .
3,481
private static boolean intersectionPrefixes ( ComponentGroup group , Set < String > intersectionPrefixes ) { if ( intersectionPrefixes != null ) { for ( String prefix : group . prefixes ) { if ( intersectionPrefixes . contains ( prefix ) ) { return true ; } } } return false ; }
Intersection prefixes .
3,482
private static IntervalTreeNodeData < String > createPositionHit ( Match m , ComponentGroup group ) { Integer start = null ; Integer end = null ; if ( group . hitInside != null || group . hitInsideLeft != null || group . hitInsideRight != null ) { start = m . startPosition ; end = m . endPosition - 1 ; } else { start = null ; end = null ; } if ( group . hitLeft != null ) { start = m . startPosition ; end = Math . max ( m . startPosition + group . hitLeft . length - 1 , m . endPosition - 1 ) ; } if ( group . hitRight != null ) { start = Math . min ( m . endPosition - group . hitRight . length , m . startPosition ) ; end = end == null ? ( m . endPosition - 1 ) : Math . max ( end , ( m . endPosition - 1 ) ) ; } if ( group . left != null ) { start = start == null ? m . startPosition - group . left . length : Math . min ( m . startPosition - group . left . length , start ) ; end = end == null ? m . startPosition - 1 : Math . max ( m . startPosition - 1 , end ) ; } if ( group . right != null ) { start = start == null ? m . endPosition : Math . min ( m . endPosition , start ) ; end = end == null ? m . endPosition + group . right . length - 1 : Math . max ( m . endPosition + group . right . length - 1 , end ) ; } return new IntervalTreeNodeData < > ( start , end , m . startPosition , m . endPosition - 1 ) ; }
Creates the position hit .
3,483
private static void sortMatchList ( List < Match > list ) { if ( list != null ) { Collections . sort ( list , ( Match m1 , Match m2 ) -> ( Integer . compare ( m1 . startPosition , m2 . startPosition ) ) ) ; } }
Sort match list .
3,484
private static String groupedKeyName ( String key , Double baseRangeSize , Double baseRangeBase ) { final double precision = 0.000001 ; if ( baseRangeSize == null || baseRangeSize <= 0 ) { return key ; } else { Double doubleKey ; Double doubleBase ; Double doubleNumber ; Double doubleStart ; Double doubleEnd ; try { doubleKey = Double . parseDouble ( key ) ; doubleBase = baseRangeBase != null ? baseRangeBase : 0 ; doubleNumber = Math . floor ( ( doubleKey - doubleBase ) / baseRangeSize ) ; doubleStart = doubleBase + doubleNumber * baseRangeSize ; doubleEnd = doubleStart + baseRangeSize ; } catch ( NumberFormatException e ) { return key ; } if ( Math . abs ( baseRangeSize - Math . floor ( baseRangeSize ) ) < precision && Math . abs ( doubleBase - Math . floor ( doubleBase ) ) < precision ) { try { if ( baseRangeSize > 1 ) { return String . format ( "%.0f" , doubleStart ) + "-" + String . format ( "%.0f" , doubleEnd - 1 ) ; } else { return String . format ( "%.0f" , doubleStart ) ; } } catch ( NumberFormatException e ) { return key ; } } else { return "[" + doubleStart + "," + doubleEnd + ")" ; } } }
Grouped key name .
3,485
private static Integer [ ] mergeDocLists ( Integer [ ] a , Integer [ ] b ) { Integer [ ] answer = new Integer [ a . length + b . length ] ; int i = 0 ; int j = 0 ; int k = 0 ; Integer tmp ; while ( i < a . length && j < b . length ) { tmp = a [ i ] < b [ j ] ? a [ i ++ ] : b [ j ++ ] ; for ( ; i < a . length && a [ i ] . equals ( tmp ) ; i ++ ) ; for ( ; j < b . length && b [ j ] . equals ( tmp ) ; j ++ ) ; answer [ k ++ ] = tmp ; } while ( i < a . length ) { tmp = a [ i ++ ] ; for ( ; i < a . length && a [ i ] . equals ( tmp ) ; i ++ ) ; answer [ k ++ ] = tmp ; } while ( j < b . length ) { tmp = b [ j ++ ] ; for ( ; j < b . length && b [ j ] . equals ( tmp ) ; j ++ ) ; answer [ k ++ ] = tmp ; } return Arrays . copyOf ( answer , k ) ; }
Merge doc lists .
3,486
private static void createFacet ( List < ComponentFacet > facetList , Map < Integer , Integer > positionsData , Map < MtasSpanQuery , Map < Integer , Integer > > spansNumberData , Map < String , SortedMap < String , int [ ] > > facetData , List < Integer > docSet ) throws IOException { if ( facetList != null ) { for ( ComponentFacet cf : facetList ) { if ( cf . baseFields . length > 0 ) { createFacetBase ( cf , 0 , cf . dataCollector , positionsData , spansNumberData , facetData , docSet . toArray ( new Integer [ docSet . size ( ) ] ) ) ; } } } }
Creates the facet .
3,487
private static boolean validateTermWithStartValue ( BytesRef term , ComponentTermVector termVector ) { if ( termVector . startValue == null ) { return true ; } else if ( termVector . subComponentFunction . sortType . equals ( CodecUtil . SORT_TERM ) ) { if ( term . length > termVector . startValue . length ) { byte [ ] zeroBytes = ( new BytesRef ( "\u0000" ) ) . bytes ; int n = ( int ) ( Math . ceil ( ( ( double ) ( term . length - termVector . startValue . length ) ) / zeroBytes . length ) ) ; byte [ ] newBytes = new byte [ termVector . startValue . length + n * zeroBytes . length ] ; System . arraycopy ( termVector . startValue . bytes , 0 , newBytes , 0 , termVector . startValue . length ) ; for ( int i = 0 ; i < n ; i ++ ) { System . arraycopy ( zeroBytes , 0 , newBytes , termVector . startValue . length + i * zeroBytes . length , zeroBytes . length ) ; } termVector . startValue = new BytesRef ( newBytes ) ; } if ( ( termVector . subComponentFunction . sortDirection . equals ( CodecUtil . SORT_ASC ) && ( termVector . startValue . compareTo ( term ) < 0 ) ) || ( termVector . subComponentFunction . sortDirection . equals ( CodecUtil . SORT_DESC ) && ( termVector . startValue . compareTo ( term ) > 0 ) ) ) { return true ; } } return false ; }
Validate term with start value .
3,488
private static boolean validateTermWithDistance ( BytesRef term , ComponentTermVector termVector ) throws IOException { if ( termVector . distances == null || termVector . distances . isEmpty ( ) ) { return true ; } else { for ( SubComponentDistance item : termVector . distances ) { if ( item . maximum == null ) { continue ; } else { if ( ! item . getDistance ( ) . validateMaximum ( term ) ) { return false ; } } } for ( SubComponentDistance item : termVector . distances ) { if ( item . minimum == null ) { continue ; } else { if ( ! item . getDistance ( ) . validateMinimum ( term ) ) { return false ; } } } return true ; } }
Validate term with distance .
3,489
private static boolean needSecondRoundTermvector ( List < ComponentTermVector > termVectorList ) throws IOException { boolean needSecondRound = false ; for ( ComponentTermVector termVector : termVectorList ) { if ( ! termVector . full && termVector . list == null ) { boolean doCheck ; doCheck = termVector . subComponentFunction . dataCollector . segmentRegistration != null && ( termVector . subComponentFunction . dataCollector . segmentRegistration . equals ( MtasDataCollector . SEGMENT_SORT_ASC ) || termVector . subComponentFunction . dataCollector . segmentRegistration . equals ( MtasDataCollector . SEGMENT_SORT_DESC ) ) && termVector . number > 0 ; doCheck |= termVector . subComponentFunction . dataCollector . segmentRegistration != null && ( termVector . subComponentFunction . dataCollector . segmentRegistration . equals ( MtasDataCollector . SEGMENT_BOUNDARY_ASC ) || termVector . subComponentFunction . dataCollector . segmentRegistration . equals ( MtasDataCollector . SEGMENT_BOUNDARY_DESC ) ) && termVector . number > 0 ; if ( doCheck ) { termVector . subComponentFunction . dataCollector . recomputeSegmentKeys ( ) ; if ( ! termVector . subComponentFunction . dataCollector . checkExistenceNecessaryKeys ( ) ) { needSecondRound = true ; } termVector . subComponentFunction . dataCollector . reduceToSegmentKeys ( ) ; } } } return needSecondRound ; }
Need second round termvector .
3,490
private static boolean preliminaryRegisterValue ( BytesRef term , ComponentTermVector termVector , TermvectorNumberBasic number , Integer termNumberMaximum , Integer segmentNumber , String [ ] mutableKey ) throws IOException { long sortValue = 0 ; if ( termVector . subComponentFunction . sortDirection . equals ( CodecUtil . SORT_DESC ) && termVector . subComponentFunction . sortType . equals ( CodecUtil . STATS_TYPE_SUM ) ) { sortValue = termVector . subComponentFunction . parserFunction . getValueLong ( number . valueSum , 0 ) ; } else if ( termVector . subComponentFunction . sortDirection . equals ( CodecUtil . SORT_DESC ) && termVector . subComponentFunction . sortType . equals ( CodecUtil . STATS_TYPE_N ) ) { sortValue = number . docNumber ; } else { return true ; } MtasDataCollector < Long , ? > dataCollector = ( MtasDataCollector < Long , ? > ) termVector . subComponentFunction . dataCollector ; if ( termVector . boundaryRegistration ) { return dataCollector . validateSegmentBoundary ( sortValue ) ; } else { String segmentStatus = dataCollector . validateSegmentValue ( sortValue , termNumberMaximum , segmentNumber ) ; if ( segmentStatus != null ) { if ( segmentStatus . equals ( MtasDataCollector . SEGMENT_KEY_OR_NEW ) ) { return true ; } else if ( segmentStatus . equals ( MtasDataCollector . SEGMENT_POSSIBLE_KEY ) ) { mutableKey [ 0 ] = MtasToken . getPostfixFromValue ( term ) ; segmentStatus = dataCollector . validateSegmentValue ( mutableKey [ 0 ] , sortValue , termNumberMaximum , segmentNumber , true ) ; return segmentStatus != null ; } else { return false ; } } else { return false ; } } }
Preliminary register value .
3,491
private static TermvectorNumberFull computeTermvectorNumberFull ( List < Integer > docSet , int termDocId , TermsEnum termsEnum , LeafReaderContext lrc , PostingsEnum postingsEnum , Map < Integer , Integer > positionsData ) throws IOException { TermvectorNumberFull result = new TermvectorNumberFull ( docSet . size ( ) ) ; Iterator < Integer > docIterator = docSet . iterator ( ) ; int localTermDocId = termDocId ; postingsEnum = termsEnum . postings ( postingsEnum , PostingsEnum . FREQS ) ; while ( docIterator . hasNext ( ) ) { int docId = docIterator . next ( ) - lrc . docBase ; if ( docId >= localTermDocId && ( ( docId == localTermDocId ) || ( ( localTermDocId = postingsEnum . advance ( docId ) ) == docId ) ) ) { result . args [ result . docNumber ] = postingsEnum . freq ( ) ; result . positions [ result . docNumber ] = ( positionsData == null ) ? 0 : positionsData . get ( docId + lrc . docBase ) ; result . docNumber ++ ; } } return result ; }
Compute termvector number full .
3,492
public boolean containsKey ( String key ) { key = key . toLowerCase ( ) ; key = key . trim ( ) ; return map . containsKey ( key ) ; }
Does the word exist in the dictionary?
3,493
public Map < String , Set < String > > getReverseMap ( ) { Set < Map . Entry < String , Set < String > > > entries = map . entrySet ( ) ; Map < String , Set < String > > rMap = new HashMap < String , Set < String > > ( entries . size ( ) ) ; for ( Map . Entry < String , Set < String > > me : entries ) { String k = me . getKey ( ) ; Set < String > transList = me . getValue ( ) ; for ( String trans : transList ) { Set < String > entry = rMap . get ( trans ) ; if ( entry == null ) { Set < String > toAdd = new LinkedHashSet < String > ( 6 ) ; toAdd . add ( k ) ; rMap . put ( trans , toAdd ) ; } else { entry . add ( k ) ; } } } return rMap ; }
Returns a reversed map of the current map .
3,494
public int addMap ( Map < String , Set < String > > addM ) { int newTrans = 0 ; for ( Map . Entry < String , Set < String > > me : addM . entrySet ( ) ) { String k = me . getKey ( ) ; Set < String > addList = me . getValue ( ) ; Set < String > origList = map . get ( k ) ; if ( origList == null ) { map . put ( k , new LinkedHashSet < String > ( addList ) ) ; Set < String > newList = map . get ( k ) ; if ( newList != null && newList . size ( ) != 0 ) { newTrans += addList . size ( ) ; } } else { for ( String toAdd : addList ) { if ( ! ( origList . contains ( toAdd ) ) ) { origList . add ( toAdd ) ; newTrans ++ ; } } } } return newTrans ; }
Add all of the mappings from the specified map to the current map .
3,495
public static base_response add ( nitro_service client , dnssoarec resource ) throws Exception { dnssoarec addresource = new dnssoarec ( ) ; addresource . domain = resource . domain ; addresource . originserver = resource . originserver ; addresource . contact = resource . contact ; addresource . serial = resource . serial ; addresource . refresh = resource . refresh ; addresource . retry = resource . retry ; addresource . expire = resource . expire ; addresource . minimum = resource . minimum ; addresource . ttl = resource . ttl ; return addresource . add_resource ( client ) ; }
Use this API to add dnssoarec .
3,496
public static base_responses add ( nitro_service client , dnssoarec resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { dnssoarec addresources [ ] = new dnssoarec [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { addresources [ i ] = new dnssoarec ( ) ; addresources [ i ] . domain = resources [ i ] . domain ; addresources [ i ] . originserver = resources [ i ] . originserver ; addresources [ i ] . contact = resources [ i ] . contact ; addresources [ i ] . serial = resources [ i ] . serial ; addresources [ i ] . refresh = resources [ i ] . refresh ; addresources [ i ] . retry = resources [ i ] . retry ; addresources [ i ] . expire = resources [ i ] . expire ; addresources [ i ] . minimum = resources [ i ] . minimum ; addresources [ i ] . ttl = resources [ i ] . ttl ; } result = add_bulk_request ( client , addresources ) ; } return result ; }
Use this API to add dnssoarec resources .
3,497
public static base_responses delete ( nitro_service client , dnssoarec resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { dnssoarec deleteresources [ ] = new dnssoarec [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { deleteresources [ i ] = new dnssoarec ( ) ; deleteresources [ i ] . domain = resources [ i ] . domain ; } result = delete_bulk_request ( client , deleteresources ) ; } return result ; }
Use this API to delete dnssoarec resources .
3,498
public static base_response update ( nitro_service client , dnssoarec resource ) throws Exception { dnssoarec updateresource = new dnssoarec ( ) ; updateresource . domain = resource . domain ; updateresource . originserver = resource . originserver ; updateresource . contact = resource . contact ; updateresource . serial = resource . serial ; updateresource . refresh = resource . refresh ; updateresource . retry = resource . retry ; updateresource . expire = resource . expire ; updateresource . minimum = resource . minimum ; updateresource . ttl = resource . ttl ; return updateresource . update_resource ( client ) ; }
Use this API to update dnssoarec .
3,499
public static base_responses update ( nitro_service client , dnssoarec resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { dnssoarec updateresources [ ] = new dnssoarec [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { updateresources [ i ] = new dnssoarec ( ) ; updateresources [ i ] . domain = resources [ i ] . domain ; updateresources [ i ] . originserver = resources [ i ] . originserver ; updateresources [ i ] . contact = resources [ i ] . contact ; updateresources [ i ] . serial = resources [ i ] . serial ; updateresources [ i ] . refresh = resources [ i ] . refresh ; updateresources [ i ] . retry = resources [ i ] . retry ; updateresources [ i ] . expire = resources [ i ] . expire ; updateresources [ i ] . minimum = resources [ i ] . minimum ; updateresources [ i ] . ttl = resources [ i ] . ttl ; } result = update_bulk_request ( client , updateresources ) ; } return result ; }
Use this API to update dnssoarec resources .