idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
13,700 | protected Configurations merge ( Configurations other ) { Set < Class < ? > > mergedClasses = new LinkedHashSet < > ( getClasses ( ) ) ; mergedClasses . addAll ( other . getClasses ( ) ) ; return merge ( mergedClasses ) ; } | Merge configurations from another source of the same type . |
13,701 | public static Class < ? > [ ] getClasses ( Collection < Configurations > configurations ) { List < Configurations > ordered = new ArrayList < > ( configurations ) ; ordered . sort ( COMPARATOR ) ; List < Configurations > collated = collate ( ordered ) ; LinkedHashSet < Class < ? > > classes = collated . stream ( ) . flatMap ( Configurations :: streamClasses ) . collect ( Collectors . toCollection ( LinkedHashSet :: new ) ) ; return ClassUtils . toClassArray ( classes ) ; } | Return the classes from all the specified configurations in the order that they would be registered . |
13,702 | private static String coerceToEpoch ( String s ) { Long epoch = parseEpochSecond ( s ) ; if ( epoch != null ) { return String . valueOf ( epoch ) ; } SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssZ" ) ; try { return String . valueOf ( format . parse ( s ) . getTime ( ) ) ; } catch ( ParseException ex ) { return s ; } } | Attempt to convert the specified value to epoch time . Git properties information are known to be specified either as epoch time in seconds or using a specific date format . |
13,703 | public void write ( File file ) throws IOException { Assert . state ( this . pid != null , "No PID available" ) ; createParentFolder ( file ) ; if ( file . exists ( ) ) { assertCanOverwrite ( file ) ; } try ( FileWriter writer = new FileWriter ( file ) ) { writer . append ( this . pid ) ; } } | Write the PID to the specified file . |
13,704 | private void preInitializeLeakyClasses ( ) { try { Class < ? > readerClass = ClassNameReader . class ; Field field = readerClass . getDeclaredField ( "EARLY_EXIT" ) ; field . setAccessible ( true ) ; ( ( Throwable ) field . get ( null ) ) . fillInStackTrace ( ) ; } catch ( Exception ex ) { this . logger . warn ( "Unable to pre-initialize classes" , ex ) ; } } | CGLIB has a private exception field which needs to initialized early to ensure that the stacktrace doesn t retain a reference to the RestartClassLoader . |
13,705 | public void addUrls ( Collection < URL > urls ) { Assert . notNull ( urls , "Urls must not be null" ) ; this . urls . addAll ( urls ) ; } | Add additional URLs to be includes in the next restart . |
13,706 | public void restart ( FailureHandler failureHandler ) { if ( ! this . enabled ) { this . logger . debug ( "Application restart is disabled" ) ; return ; } this . logger . debug ( "Restarting application" ) ; getLeakSafeThread ( ) . call ( ( ) -> { Restarter . this . stop ( ) ; Restarter . this . start ( failureHandler ) ; return null ; } ) ; } | Restart the running application . |
13,707 | protected void start ( FailureHandler failureHandler ) throws Exception { do { Throwable error = doStart ( ) ; if ( error == null ) { return ; } if ( failureHandler . handle ( error ) == Outcome . ABORT ) { return ; } } while ( true ) ; } | Start the application . |
13,708 | protected Throwable relaunch ( ClassLoader classLoader ) throws Exception { RestartLauncher launcher = new RestartLauncher ( classLoader , this . mainClassName , this . args , this . exceptionHandler ) ; launcher . start ( ) ; launcher . join ( ) ; return launcher . getError ( ) ; } | Relaunch the application using the specified classloader . |
13,709 | protected void stop ( ) throws Exception { this . logger . debug ( "Stopping application" ) ; this . stopLock . lock ( ) ; try { for ( ConfigurableApplicationContext context : this . rootContexts ) { context . close ( ) ; this . rootContexts . remove ( context ) ; } cleanupCaches ( ) ; if ( this . forceReferenceCleanup ) { forceReferenceCleanup ( ) ; } } finally { this . stopLock . unlock ( ) ; } System . gc ( ) ; System . runFinalization ( ) ; } | Stop the application . |
13,710 | public String getLastElement ( Form form ) { int size = getNumberOfElements ( ) ; return ( size != 0 ) ? getElement ( size - 1 , form ) : EMPTY_STRING ; } | Return the last element in the name in the given form . |
13,711 | public String getElement ( int elementIndex , Form form ) { CharSequence element = this . elements . get ( elementIndex ) ; ElementType type = this . elements . getType ( elementIndex ) ; if ( type . isIndexed ( ) ) { return element . toString ( ) ; } if ( form == Form . ORIGINAL ) { if ( type != ElementType . NON_UNIFORM ) { return element . toString ( ) ; } return convertToOriginalForm ( element ) . toString ( ) ; } if ( form == Form . DASHED ) { if ( type == ElementType . UNIFORM || type == ElementType . DASHED ) { return element . toString ( ) ; } return convertToDashedElement ( element ) . toString ( ) ; } CharSequence uniformElement = this . uniformElements [ elementIndex ] ; if ( uniformElement == null ) { uniformElement = ( type != ElementType . UNIFORM ) ? convertToUniformElement ( element ) : element ; this . uniformElements [ elementIndex ] = uniformElement . toString ( ) ; } return uniformElement . toString ( ) ; } | Return an element in the name in the given form . |
13,712 | public void addCommands ( Iterable < Command > commands ) { Assert . notNull ( commands , "Commands must not be null" ) ; for ( Command command : commands ) { addCommand ( command ) ; } } | Add the specified commands . |
13,713 | public Command findCommand ( String name ) { for ( Command candidate : this . commands ) { String candidateName = candidate . getName ( ) ; if ( candidateName . equals ( name ) || ( isOptionCommand ( candidate ) && ( "--" + candidateName ) . equals ( name ) ) ) { return candidate ; } } return null ; } | Find a command by name . |
13,714 | public int runAndHandleErrors ( String ... args ) { String [ ] argsWithoutDebugFlags = removeDebugFlags ( args ) ; boolean debug = argsWithoutDebugFlags . length != args . length ; if ( debug ) { System . setProperty ( "debug" , "true" ) ; } try { ExitStatus result = run ( argsWithoutDebugFlags ) ; if ( result != null && result . isHangup ( ) ) { return ( result . getCode ( ) > 0 ) ? result . getCode ( ) : 0 ; } return 0 ; } catch ( NoArgumentsException ex ) { showUsage ( ) ; return 1 ; } catch ( Exception ex ) { return handleError ( debug , ex ) ; } } | Run the appropriate and handle and errors . |
13,715 | protected ExitStatus run ( String ... args ) throws Exception { if ( args . length == 0 ) { throw new NoArgumentsException ( ) ; } String commandName = args [ 0 ] ; String [ ] commandArguments = Arrays . copyOfRange ( args , 1 , args . length ) ; Command command = findCommand ( commandName ) ; if ( command == null ) { throw new NoSuchCommandException ( commandName ) ; } beforeRun ( command ) ; try { return command . run ( commandArguments ) ; } finally { afterRun ( command ) ; } } | Parse the arguments and run a suitable command . |
13,716 | private void applySerializationModifier ( ObjectMapper mapper ) { SerializerFactory factory = BeanSerializerFactory . instance . withSerializerModifier ( new GenericSerializerModifier ( ) ) ; mapper . setSerializerFactory ( factory ) ; } | Ensure only bindable and non - cyclic bean properties are reported . |
13,717 | @ SuppressWarnings ( "unchecked" ) private Map < String , Object > sanitize ( String prefix , Map < String , Object > map ) { map . forEach ( ( key , value ) -> { String qualifiedKey = ( prefix . isEmpty ( ) ? prefix : prefix + "." ) + key ; if ( value instanceof Map ) { map . put ( key , sanitize ( qualifiedKey , ( Map < String , Object > ) value ) ) ; } else if ( value instanceof List ) { map . put ( key , sanitize ( qualifiedKey , ( List < Object > ) value ) ) ; } else { value = this . sanitizer . sanitize ( key , value ) ; value = this . sanitizer . sanitize ( qualifiedKey , value ) ; map . put ( key , value ) ; } } ) ; return map ; } | Sanitize all unwanted configuration properties to avoid leaking of sensitive information . |
13,718 | public void setKeysToSanitize ( String ... keysToSanitize ) { Assert . notNull ( keysToSanitize , "KeysToSanitize must not be null" ) ; this . keysToSanitize = new Pattern [ keysToSanitize . length ] ; for ( int i = 0 ; i < keysToSanitize . length ; i ++ ) { this . keysToSanitize [ i ] = getPattern ( keysToSanitize [ i ] ) ; } } | Keys that should be sanitized . Keys can be simple strings that the property ends with or regular expressions . |
13,719 | public Object sanitize ( String key , Object value ) { if ( value == null ) { return null ; } for ( Pattern pattern : this . keysToSanitize ) { if ( pattern . matcher ( key ) . matches ( ) ) { return "******" ; } } return value ; } | Sanitize the given value if necessary . |
13,720 | public static String numberToString ( Number number ) throws JSONException { if ( number == null ) { throw new JSONException ( "Number must be non-null" ) ; } double doubleValue = number . doubleValue ( ) ; JSON . checkDouble ( doubleValue ) ; if ( number . equals ( NEGATIVE_ZERO ) ) { return "-0" ; } long longValue = number . longValue ( ) ; if ( doubleValue == longValue ) { return Long . toString ( longValue ) ; } return number . toString ( ) ; } | Encodes the number as a JSON string . |
13,721 | public void configure ( DefaultJmsListenerContainerFactory factory , ConnectionFactory connectionFactory ) { Assert . notNull ( factory , "Factory must not be null" ) ; Assert . notNull ( connectionFactory , "ConnectionFactory must not be null" ) ; factory . setConnectionFactory ( connectionFactory ) ; factory . setPubSubDomain ( this . jmsProperties . isPubSubDomain ( ) ) ; if ( this . transactionManager != null ) { factory . setTransactionManager ( this . transactionManager ) ; } else { factory . setSessionTransacted ( true ) ; } if ( this . destinationResolver != null ) { factory . setDestinationResolver ( this . destinationResolver ) ; } if ( this . messageConverter != null ) { factory . setMessageConverter ( this . messageConverter ) ; } JmsProperties . Listener listener = this . jmsProperties . getListener ( ) ; factory . setAutoStartup ( listener . isAutoStartup ( ) ) ; if ( listener . getAcknowledgeMode ( ) != null ) { factory . setSessionAcknowledgeMode ( listener . getAcknowledgeMode ( ) . getMode ( ) ) ; } String concurrency = listener . formatConcurrency ( ) ; if ( concurrency != null ) { factory . setConcurrency ( concurrency ) ; } } | Configure the specified jms listener container factory . The factory can be further tuned and default settings can be overridden . |
13,722 | public void include ( ConfigurationMetadataRepository repository ) { for ( ConfigurationMetadataGroup group : repository . getAllGroups ( ) . values ( ) ) { ConfigurationMetadataGroup existingGroup = this . allGroups . get ( group . getId ( ) ) ; if ( existingGroup == null ) { this . allGroups . put ( group . getId ( ) , group ) ; } else { group . getProperties ( ) . forEach ( ( name , value ) -> putIfAbsent ( existingGroup . getProperties ( ) , name , value ) ) ; group . getSources ( ) . forEach ( ( name , value ) -> putIfAbsent ( existingGroup . getSources ( ) , name , value ) ) ; } } } | Merge the content of the specified repository to this repository . |
13,723 | protected void configureSsl ( SslContextFactory factory , Ssl ssl , SslStoreProvider sslStoreProvider ) { factory . setProtocol ( ssl . getProtocol ( ) ) ; configureSslClientAuth ( factory , ssl ) ; configureSslPasswords ( factory , ssl ) ; factory . setCertAlias ( ssl . getKeyAlias ( ) ) ; if ( ! ObjectUtils . isEmpty ( ssl . getCiphers ( ) ) ) { factory . setIncludeCipherSuites ( ssl . getCiphers ( ) ) ; factory . setExcludeCipherSuites ( ) ; } if ( ssl . getEnabledProtocols ( ) != null ) { factory . setIncludeProtocols ( ssl . getEnabledProtocols ( ) ) ; } if ( sslStoreProvider != null ) { try { factory . setKeyStore ( sslStoreProvider . getKeyStore ( ) ) ; factory . setTrustStore ( sslStoreProvider . getTrustStore ( ) ) ; } catch ( Exception ex ) { throw new IllegalStateException ( "Unable to set SSL store" , ex ) ; } } else { configureSslKeyStore ( factory , ssl ) ; configureSslTrustStore ( factory , ssl ) ; } } | Configure the SSL connection . |
13,724 | public void configure ( ConcurrentKafkaListenerContainerFactory < Object , Object > listenerFactory , ConsumerFactory < Object , Object > consumerFactory ) { listenerFactory . setConsumerFactory ( consumerFactory ) ; configureListenerFactory ( listenerFactory ) ; configureContainer ( listenerFactory . getContainerProperties ( ) ) ; } | Configure the specified Kafka listener container factory . The factory can be further tuned and default settings can be overridden . |
13,725 | public Resource resolveConfigLocation ( ) { if ( this . config == null ) { return null ; } Assert . isTrue ( this . config . exists ( ) , ( ) -> "Hazelcast configuration does not " + "exist '" + this . config . getDescription ( ) + "'" ) ; return this . config ; } | Resolve the config location if set . |
13,726 | public < T > T execute ( long wait , int maxAttempts , Callable < T > callback ) throws Exception { getLog ( ) . debug ( "Waiting for spring application to start..." ) ; for ( int i = 0 ; i < maxAttempts ; i ++ ) { T result = callback . call ( ) ; if ( result != null ) { return result ; } String message = "Spring application is not ready yet, waiting " + wait + "ms (attempt " + ( i + 1 ) + ")" ; getLog ( ) . debug ( message ) ; synchronized ( this . lock ) { try { this . lock . wait ( wait ) ; } catch ( InterruptedException ex ) { Thread . currentThread ( ) . interrupt ( ) ; throw new IllegalStateException ( "Interrupted while waiting for Spring Boot app to start." ) ; } } } throw new MojoExecutionException ( "Spring application did not start before the configured " + "timeout (" + ( wait * maxAttempts ) + "ms" ) ; } | Execute a task retrying it on failure . |
13,727 | public void setInitParameters ( Map < String , String > initParameters ) { Assert . notNull ( initParameters , "InitParameters must not be null" ) ; this . initParameters = new LinkedHashMap < > ( initParameters ) ; } | Set init - parameters for this registration . Calling this method will replace any existing init - parameters . |
13,728 | public void addInitParameter ( String name , String value ) { Assert . notNull ( name , "Name must not be null" ) ; this . initParameters . put ( name , value ) ; } | Add a single init - parameter replacing any existing parameter with the same name . |
13,729 | protected final String getOrDeduceName ( Object value ) { return ( this . name != null ) ? this . name : Conventions . getVariableName ( value ) ; } | Deduces the name for this registration . Will return user specified name or fallback to convention based naming . |
13,730 | @ SuppressWarnings ( "unchecked" ) public < A extends Annotation > A getAnnotation ( Class < A > type ) { for ( Annotation annotation : this . annotations ) { if ( type . isInstance ( annotation ) ) { return ( A ) annotation ; } } return null ; } | Return a single associated annotations that could affect binding . |
13,731 | @ SuppressWarnings ( "unchecked" ) protected Class < ? extends T > getCauseType ( ) { return ( Class < ? extends T > ) ResolvableType . forClass ( AbstractFailureAnalyzer . class , getClass ( ) ) . resolveGeneric ( ) ; } | Return the cause type being handled by the analyzer . By default the class generic is used . |
13,732 | private Map < String , Object > flatten ( Map < String , Object > map ) { Map < String , Object > result = new LinkedHashMap < > ( ) ; flatten ( null , result , map ) ; return result ; } | Flatten the map keys using period separator . |
13,733 | public void recordConditionEvaluation ( String source , Condition condition , ConditionOutcome outcome ) { Assert . notNull ( source , "Source must not be null" ) ; Assert . notNull ( condition , "Condition must not be null" ) ; Assert . notNull ( outcome , "Outcome must not be null" ) ; this . unconditionalClasses . remove ( source ) ; if ( ! this . outcomes . containsKey ( source ) ) { this . outcomes . put ( source , new ConditionAndOutcomes ( ) ) ; } this . outcomes . get ( source ) . add ( condition , outcome ) ; this . addedAncestorOutcomes = false ; } | Record the occurrence of condition evaluation . |
13,734 | public void recordExclusions ( Collection < String > exclusions ) { Assert . notNull ( exclusions , "exclusions must not be null" ) ; this . exclusions . addAll ( exclusions ) ; } | Records the names of the classes that have been excluded from condition evaluation . |
13,735 | public void recordEvaluationCandidates ( List < String > evaluationCandidates ) { Assert . notNull ( evaluationCandidates , "evaluationCandidates must not be null" ) ; this . unconditionalClasses . addAll ( evaluationCandidates ) ; } | Records the names of the classes that are candidates for condition evaluation . |
13,736 | public Map < String , ConditionAndOutcomes > getConditionAndOutcomesBySource ( ) { if ( ! this . addedAncestorOutcomes ) { this . outcomes . forEach ( ( source , sourceOutcomes ) -> { if ( ! sourceOutcomes . isFullMatch ( ) ) { addNoMatchOutcomeToAncestors ( source ) ; } } ) ; this . addedAncestorOutcomes = true ; } return Collections . unmodifiableMap ( this . outcomes ) ; } | Returns condition outcomes from this report grouped by the source . |
13,737 | public Set < String > getUnconditionalClasses ( ) { Set < String > filtered = new HashSet < > ( this . unconditionalClasses ) ; filtered . removeAll ( this . exclusions ) ; return Collections . unmodifiableSet ( filtered ) ; } | Returns the names of the classes that were evaluated but were not conditional . |
13,738 | public boolean createSchema ( ) { List < Resource > scripts = getScripts ( "spring.datasource.schema" , this . properties . getSchema ( ) , "schema" ) ; if ( ! scripts . isEmpty ( ) ) { if ( ! isEnabled ( ) ) { logger . debug ( "Initialization disabled (not running DDL scripts)" ) ; return false ; } String username = this . properties . getSchemaUsername ( ) ; String password = this . properties . getSchemaPassword ( ) ; runScripts ( scripts , username , password ) ; } return ! scripts . isEmpty ( ) ; } | Create the schema if necessary . |
13,739 | public void initSchema ( ) { List < Resource > scripts = getScripts ( "spring.datasource.data" , this . properties . getData ( ) , "data" ) ; if ( ! scripts . isEmpty ( ) ) { if ( ! isEnabled ( ) ) { logger . debug ( "Initialization disabled (not running data scripts)" ) ; return ; } String username = this . properties . getDataUsername ( ) ; String password = this . properties . getDataPassword ( ) ; runScripts ( scripts , username , password ) ; } } | Initialize the schema if necessary . |
13,740 | public void setTldSkipPatterns ( Collection < String > patterns ) { Assert . notNull ( patterns , "Patterns must not be null" ) ; this . tldSkipPatterns = new LinkedHashSet < > ( patterns ) ; } | Set the patterns that match jars to ignore for TLD scanning . See Tomcat s catalina . properties for typical values . Defaults to a list drawn from that source . |
13,741 | public void addTldSkipPatterns ( String ... patterns ) { Assert . notNull ( patterns , "Patterns must not be null" ) ; this . tldSkipPatterns . addAll ( Arrays . asList ( patterns ) ) ; } | Add patterns that match jars to ignore for TLD scanning . See Tomcat s catalina . properties for typical values . |
13,742 | public static boolean isTerminal ( ArrayList < Configuration > beam ) { for ( Configuration configuration : beam ) if ( ! configuration . state . isTerminalState ( ) ) return false ; return true ; } | Shows true if all of the configurations in the beam are in the terminal state |
13,743 | public String [ ] [ ] toWordTagNerArray ( NERTagSet tagSet ) { List < String [ ] > tupleList = Utility . convertSentenceToNER ( this , tagSet ) ; String [ ] [ ] result = new String [ 3 ] [ tupleList . size ( ) ] ; Iterator < String [ ] > iterator = tupleList . iterator ( ) ; for ( int i = 0 ; i < result [ 0 ] . length ; i ++ ) { String [ ] tuple = iterator . next ( ) ; for ( int j = 0 ; j < 3 ; ++ j ) { result [ j ] [ i ] = tuple [ j ] ; } } return result ; } | word pos ner |
13,744 | protected int addWordToVocab ( String word ) { vocab [ vocabSize ] = new VocabWord ( word ) ; vocabSize ++ ; if ( vocabSize + 2 >= vocabMaxSize ) { vocabMaxSize += 1000 ; VocabWord [ ] temp = new VocabWord [ vocabMaxSize ] ; System . arraycopy ( vocab , 0 , temp , 0 , vocabSize ) ; vocab = temp ; } vocabIndexMap . put ( word , vocabSize - 1 ) ; return vocabSize - 1 ; } | Adds a word to the vocabulary |
13,745 | int searchVocab ( String word ) { if ( word == null ) return - 1 ; Integer pos = vocabIndexMap . get ( word ) ; return pos == null ? - 1 : pos . intValue ( ) ; } | Returns position of a word in the vocabulary ; if the word is not found returns - 1 |
13,746 | void sortVocab ( ) { Arrays . sort ( vocab , 0 , vocabSize ) ; final int size = vocabSize ; trainWords = 0 ; table = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { VocabWord word = vocab [ i ] ; if ( word . cn < config . getMinCount ( ) ) { table [ vocabIndexMap . get ( word . word ) ] = - 4 ; vocabSize -- ; } else { table [ vocabIndexMap . get ( word . word ) ] = i ; setVocabIndexMap ( word , i ) ; } } vocabIndexMap = null ; VocabWord [ ] nvocab = new VocabWord [ vocabSize ] ; System . arraycopy ( vocab , 0 , nvocab , 0 , vocabSize ) ; } | Sorts the vocabulary by frequency using word counts |
13,747 | void createBinaryTree ( ) { int [ ] point = new int [ VocabWord . MAX_CODE_LENGTH ] ; char [ ] code = new char [ VocabWord . MAX_CODE_LENGTH ] ; int [ ] count = new int [ vocabSize * 2 + 1 ] ; char [ ] binary = new char [ vocabSize * 2 + 1 ] ; int [ ] parentNode = new int [ vocabSize * 2 + 1 ] ; for ( int i = 0 ; i < vocabSize ; i ++ ) count [ i ] = vocab [ i ] . cn ; for ( int i = vocabSize ; i < vocabSize * 2 ; i ++ ) count [ i ] = Integer . MAX_VALUE ; int pos1 = vocabSize - 1 ; int pos2 = vocabSize ; int min1i , min2i ; for ( int i = 0 ; i < vocabSize - 1 ; i ++ ) { if ( pos1 >= 0 ) { if ( count [ pos1 ] < count [ pos2 ] ) { min1i = pos1 ; pos1 -- ; } else { min1i = pos2 ; pos2 ++ ; } } else { min1i = pos2 ; pos2 ++ ; } if ( pos1 >= 0 ) { if ( count [ pos1 ] < count [ pos2 ] ) { min2i = pos1 ; pos1 -- ; } else { min2i = pos2 ; pos2 ++ ; } } else { min2i = pos2 ; pos2 ++ ; } count [ vocabSize + i ] = count [ min1i ] + count [ min2i ] ; parentNode [ min1i ] = vocabSize + i ; parentNode [ min2i ] = vocabSize + i ; binary [ min2i ] = 1 ; } for ( int j = 0 ; j < vocabSize ; j ++ ) { int k = j ; int i = 0 ; while ( true ) { code [ i ] = binary [ k ] ; point [ i ] = k ; i ++ ; k = parentNode [ k ] ; if ( k == vocabSize * 2 - 2 ) break ; } vocab [ j ] . codelen = i ; vocab [ j ] . point [ 0 ] = vocabSize - 2 ; for ( k = 0 ; k < i ; k ++ ) { vocab [ j ] . code [ i - k - 1 ] = code [ k ] ; vocab [ j ] . point [ i - k ] = point [ k ] - vocabSize ; } } } | Create binary Huffman tree using the word counts . Frequent words will have short uniqe binary codes |
13,748 | public int [ ] toIdList ( int codePoint ) { int count ; if ( codePoint < 0x80 ) count = 1 ; else if ( codePoint < 0x800 ) count = 2 ; else if ( codePoint < 0x10000 ) count = 3 ; else if ( codePoint < 0x200000 ) count = 4 ; else if ( codePoint < 0x4000000 ) count = 5 ; else if ( codePoint <= 0x7fffffff ) count = 6 ; else return EMPTYLIST ; int [ ] r = new int [ count ] ; switch ( count ) { case 6 : r [ 5 ] = ( char ) ( 0x80 | ( codePoint & 0x3f ) ) ; codePoint = codePoint >> 6 ; codePoint |= 0x4000000 ; case 5 : r [ 4 ] = ( char ) ( 0x80 | ( codePoint & 0x3f ) ) ; codePoint = codePoint >> 6 ; codePoint |= 0x200000 ; case 4 : r [ 3 ] = ( char ) ( 0x80 | ( codePoint & 0x3f ) ) ; codePoint = codePoint >> 6 ; codePoint |= 0x10000 ; case 3 : r [ 2 ] = ( char ) ( 0x80 | ( codePoint & 0x3f ) ) ; codePoint = codePoint >> 6 ; codePoint |= 0x800 ; case 2 : r [ 1 ] = ( char ) ( 0x80 | ( codePoint & 0x3f ) ) ; codePoint = codePoint >> 6 ; codePoint |= 0xc0 ; case 1 : r [ 0 ] = ( char ) codePoint ; } return r ; } | codes ported from iconv lib in utf8 . h utf8_codepointtomb |
13,749 | void normalize ( ) { double nrm = norm ( ) ; for ( Map . Entry < Integer , Double > d : entrySet ( ) ) { d . setValue ( d . getValue ( ) / nrm ) ; } } | Normalize a vector . |
13,750 | void multiply_constant ( double x ) { for ( Map . Entry < Integer , Double > entry : entrySet ( ) ) { entry . setValue ( entry . getValue ( ) * x ) ; } } | Multiply each value of avector by a constant value . |
13,751 | void add_vector ( SparseVector vec ) { for ( Map . Entry < Integer , Double > entry : vec . entrySet ( ) ) { Double v = get ( entry . getKey ( ) ) ; if ( v == null ) v = 0. ; put ( entry . getKey ( ) , v + entry . getValue ( ) ) ; } } | Add other vector . |
13,752 | static double inner_product ( SparseVector vec1 , SparseVector vec2 ) { Iterator < Map . Entry < Integer , Double > > it ; SparseVector other ; if ( vec1 . size ( ) < vec2 . size ( ) ) { it = vec1 . entrySet ( ) . iterator ( ) ; other = vec2 ; } else { it = vec2 . entrySet ( ) . iterator ( ) ; other = vec1 ; } double prod = 0 ; while ( it . hasNext ( ) ) { Map . Entry < Integer , Double > entry = it . next ( ) ; prod += entry . getValue ( ) * other . get ( entry . getKey ( ) ) ; } return prod ; } | Calculate the inner product value between vectors . |
13,753 | double cosine ( SparseVector vec1 , SparseVector vec2 ) { double norm1 = vec1 . norm ( ) ; double norm2 = vec2 . norm ( ) ; double result = 0.0f ; if ( norm1 == 0 && norm2 == 0 ) { return result ; } else { double prod = inner_product ( vec1 , vec2 ) ; result = prod / ( norm1 * norm2 ) ; return Double . isNaN ( result ) ? 0.0f : result ; } } | Calculate the cosine value between vectors . |
13,754 | void reduceVocab ( ) { table = new int [ vocabSize ] ; int j = 0 ; for ( int i = 0 ; i < vocabSize ; i ++ ) { if ( vocab [ i ] . cn > minReduce ) { vocab [ j ] . cn = vocab [ i ] . cn ; vocab [ j ] . word = vocab [ i ] . word ; table [ vocabIndexMap . get ( vocab [ j ] . word ) ] = j ; j ++ ; } else { table [ vocabIndexMap . get ( vocab [ j ] . word ) ] = - 4 ; } } try { cache . close ( ) ; File fixingFile = new File ( cacheFile . getAbsolutePath ( ) + ".fixing" ) ; cache = new DataOutputStream ( new FileOutputStream ( fixingFile ) ) ; DataInputStream oldCache = new DataInputStream ( new FileInputStream ( cacheFile ) ) ; while ( oldCache . available ( ) >= 4 ) { int oldId = oldCache . readInt ( ) ; if ( oldId < 0 ) { cache . writeInt ( oldId ) ; continue ; } int id = table [ oldId ] ; if ( id == - 4 ) continue ; cache . writeInt ( id ) ; } oldCache . close ( ) ; cache . close ( ) ; if ( ! fixingFile . renameTo ( cacheFile ) ) { throw new RuntimeException ( String . format ( "moving %s to %s failed" , fixingFile . getAbsolutePath ( ) , cacheFile . getName ( ) ) ) ; } cache = new DataOutputStream ( new FileOutputStream ( cacheFile ) ) ; } catch ( IOException e ) { throw new RuntimeException ( String . format ( "failed to adjust cache file" , e ) ) ; } table = null ; vocabSize = j ; vocabIndexMap . clear ( ) ; for ( int i = 0 ; i < vocabSize ; i ++ ) { vocabIndexMap . put ( vocab [ i ] . word , i ) ; } minReduce ++ ; } | Reduces the vocabulary by removing infrequent tokens |
13,755 | String readWord ( BufferedReader raf ) throws IOException { while ( true ) { if ( wbp < wordsBuffer . length ) { return wordsBuffer [ wbp ++ ] ; } String line = raf . readLine ( ) ; if ( line == null ) { eoc = true ; return null ; } line = line . trim ( ) ; if ( line . length ( ) == 0 ) { continue ; } cache . writeInt ( - 3 ) ; wordsBuffer = line . split ( "\\s+" ) ; wbp = 0 ; eoc = false ; } } | Reads a single word from a file assuming space + tab + EOL to be word boundaries |
13,756 | void set_composite_vector ( ) { composite_ . clear ( ) ; for ( Document < K > document : documents_ ) { composite_ . add_vector ( document . feature ( ) ) ; } } | Add the vectors of all documents to a composite vector . |
13,757 | void clear ( ) { documents_ . clear ( ) ; composite_ . clear ( ) ; if ( centroid_ != null ) centroid_ . clear ( ) ; if ( sectioned_clusters_ != null ) sectioned_clusters_ . clear ( ) ; sectioned_gain_ = 0.0 ; } | Clear status . |
13,758 | SparseVector centroid_vector ( ) { if ( documents_ . size ( ) > 0 && composite_ . size ( ) == 0 ) set_composite_vector ( ) ; centroid_ = ( SparseVector ) composite_vector ( ) . clone ( ) ; centroid_ . normalize ( ) ; return centroid_ ; } | Get the pointer of a centroid vector . |
13,759 | void refresh ( ) { ListIterator < Document < K > > listIterator = documents_ . listIterator ( ) ; while ( listIterator . hasNext ( ) ) { if ( listIterator . next ( ) == null ) listIterator . remove ( ) ; } } | Delete removed documents from the internal container . |
13,760 | void set_sectioned_gain ( ) { double gain = 0.0f ; if ( sectioned_gain_ == 0 && sectioned_clusters_ . size ( ) > 1 ) { for ( Cluster < K > cluster : sectioned_clusters_ ) { gain += cluster . composite_vector ( ) . norm ( ) ; } gain -= composite_ . norm ( ) ; } sectioned_gain_ = gain ; } | Set a gain when the cluster sectioned . |
13,761 | public static List < String > parseOrExit ( Object target , String [ ] args ) { try { return parse ( target , args ) ; } catch ( IllegalArgumentException e ) { System . err . println ( e . getMessage ( ) ) ; Args . usage ( target ) ; System . exit ( 1 ) ; throw e ; } } | A convenience method for parsing and automatically producing error messages . |
13,762 | public static Matrix constructWithCopy ( double [ ] [ ] A ) { int m = A . length ; int n = A [ 0 ] . length ; Matrix X = new Matrix ( m , n ) ; double [ ] [ ] C = X . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( A [ i ] . length != n ) { throw new IllegalArgumentException ( "All rows must have the same length." ) ; } for ( int j = 0 ; j < n ; j ++ ) { C [ i ] [ j ] = A [ i ] [ j ] ; } } return X ; } | Construct a matrix from a copy of a 2 - D array . |
13,763 | public Matrix copy ( ) { Matrix X = new Matrix ( m , n ) ; double [ ] [ ] C = X . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { C [ i ] [ j ] = A [ i ] [ j ] ; } } return X ; } | Make a deep copy of a matrix |
13,764 | public double [ ] [ ] getArrayCopy ( ) { double [ ] [ ] C = new double [ m ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { C [ i ] [ j ] = A [ i ] [ j ] ; } } return C ; } | Copy the internal two - dimensional array . |
13,765 | public Matrix plus ( Matrix B ) { checkMatrixDimensions ( B ) ; Matrix X = new Matrix ( m , n ) ; double [ ] [ ] C = X . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { C [ i ] [ j ] = A [ i ] [ j ] + B . A [ i ] [ j ] ; } } return X ; } | C = A + B |
13,766 | public Matrix plusEquals ( Matrix B ) { checkMatrixDimensions ( B ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { A [ i ] [ j ] = A [ i ] [ j ] + B . A [ i ] [ j ] ; } } return this ; } | A = A + B |
13,767 | public double trace ( ) { double t = 0 ; for ( int i = 0 ; i < Math . min ( m , n ) ; i ++ ) { t += A [ i ] [ i ] ; } return t ; } | Matrix trace . |
13,768 | public static Matrix random ( int m , int n ) { Matrix A = new Matrix ( m , n ) ; double [ ] [ ] X = A . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { X [ i ] [ j ] = Math . random ( ) ; } } return A ; } | Generate matrix with random elements |
13,769 | public static Matrix identity ( int m , int n ) { Matrix A = new Matrix ( m , n ) ; double [ ] [ ] X = A . getArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { X [ i ] [ j ] = ( i == j ? 1.0 : 0.0 ) ; } } return A ; } | Generate identity matrix |
13,770 | public void print ( int w , int d ) { print ( new PrintWriter ( System . out , true ) , w , d ) ; } | Print the matrix to stdout . Line the elements up in columns with a Fortran - like Fw . d style format . |
13,771 | public void print ( PrintWriter output , int w , int d ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; format . setMinimumFractionDigits ( d ) ; format . setGroupingUsed ( false ) ; print ( output , format , w + 2 ) ; } | Print the matrix to the output stream . Line the elements up in columns with a Fortran - like Fw . d style format . |
13,772 | public void print ( NumberFormat format , int width ) { print ( new PrintWriter ( System . out , true ) , format , width ) ; } | Print the matrix to stdout . Line the elements up in columns . Use the format object and right justify within columns of width characters . Note that is the matrix is to be read back in you probably will want to use a NumberFormat that is set to US Locale . |
13,773 | public final void addStrings ( Collection < String > strCollection ) { if ( sourceNode != null ) { String previousString = "" ; for ( String currentString : strCollection ) { int mpsIndex = calculateMinimizationProcessingStartIndex ( previousString , currentString ) ; if ( mpsIndex != - 1 ) { String transitionSubstring = previousString . substring ( 0 , mpsIndex ) ; String minimizationProcessingSubString = previousString . substring ( mpsIndex ) ; replaceOrRegister ( sourceNode . transition ( transitionSubstring ) , minimizationProcessingSubString ) ; } addStringInternal ( currentString ) ; previousString = currentString ; } replaceOrRegister ( sourceNode , previousString ) ; } else { unSimplify ( ) ; addStrings ( strCollection ) ; } } | Adds a Collection of Strings to the MDAG . |
13,774 | public void addString ( String str ) { if ( sourceNode != null ) { addStringInternal ( str ) ; replaceOrRegister ( sourceNode , str ) ; } else { unSimplify ( ) ; addString ( str ) ; } } | Adds a string to the MDAG . |
13,775 | private int calculateSoleTransitionPathLength ( String str ) { Stack < MDAGNode > transitionPathNodeStack = sourceNode . getTransitionPathNodes ( str ) ; transitionPathNodeStack . pop ( ) ; transitionPathNodeStack . trimToSize ( ) ; while ( ! transitionPathNodeStack . isEmpty ( ) ) { MDAGNode currentNode = transitionPathNodeStack . peek ( ) ; if ( currentNode . getOutgoingTransitions ( ) . size ( ) <= 1 && ! currentNode . isAcceptNode ( ) ) transitionPathNodeStack . pop ( ) ; else break ; } return ( transitionPathNodeStack . capacity ( ) - transitionPathNodeStack . size ( ) ) ; } | Calculates the length of the the sub - path in a _transition path that is used only by a given string . |
13,776 | public void removeString ( String str ) { if ( sourceNode != null ) { splitTransitionPath ( sourceNode , str ) ; removeTransitionPathRegisterEntries ( str ) ; MDAGNode strEndNode = sourceNode . transition ( str ) ; if ( strEndNode == null ) return ; if ( ! strEndNode . hasTransitions ( ) ) { int soleInternalTransitionPathLength = calculateSoleTransitionPathLength ( str ) ; int internalTransitionPathLength = str . length ( ) - 1 ; if ( soleInternalTransitionPathLength == internalTransitionPathLength ) { sourceNode . removeOutgoingTransition ( str . charAt ( 0 ) ) ; transitionCount -= str . length ( ) ; } else { int toBeRemovedTransitionLabelCharIndex = ( internalTransitionPathLength - soleInternalTransitionPathLength ) ; MDAGNode latestNonSoloTransitionPathNode = sourceNode . transition ( str . substring ( 0 , toBeRemovedTransitionLabelCharIndex ) ) ; latestNonSoloTransitionPathNode . removeOutgoingTransition ( str . charAt ( toBeRemovedTransitionLabelCharIndex ) ) ; transitionCount -= str . substring ( toBeRemovedTransitionLabelCharIndex ) . length ( ) ; replaceOrRegister ( sourceNode , str . substring ( 0 , toBeRemovedTransitionLabelCharIndex ) ) ; } } else { strEndNode . setAcceptStateStatus ( false ) ; replaceOrRegister ( sourceNode , str ) ; } } else { unSimplify ( ) ; } } | Removes a String from the MDAG . |
13,777 | private String determineLongestPrefixInMDAG ( String str ) { MDAGNode currentNode = sourceNode ; int numberOfChars = str . length ( ) ; int onePastPrefixEndIndex = 0 ; for ( int i = 0 ; i < numberOfChars ; i ++ , onePastPrefixEndIndex ++ ) { char currentChar = str . charAt ( i ) ; if ( currentNode . hasOutgoingTransition ( currentChar ) ) currentNode = currentNode . transition ( currentChar ) ; else break ; } return str . substring ( 0 , onePastPrefixEndIndex ) ; } | Determines the longest prefix of a given String that is the prefix of another String previously added to the MDAG . |
13,778 | private int createSimpleMDAGTransitionSet ( MDAGNode node , SimpleMDAGNode [ ] mdagDataArray , int onePastLastCreatedTransitionSetIndex ) { int pivotIndex = onePastLastCreatedTransitionSetIndex ; node . setTransitionSetBeginIndex ( pivotIndex ) ; onePastLastCreatedTransitionSetIndex += node . getOutgoingTransitionCount ( ) ; TreeMap < Character , MDAGNode > transitionTreeMap = node . getOutgoingTransitions ( ) ; for ( Entry < Character , MDAGNode > transitionKeyValuePair : transitionTreeMap . entrySet ( ) ) { char transitionLabelChar = transitionKeyValuePair . getKey ( ) ; MDAGNode transitionTargetNode = transitionKeyValuePair . getValue ( ) ; mdagDataArray [ pivotIndex ] = new SimpleMDAGNode ( transitionLabelChar , transitionTargetNode . isAcceptNode ( ) , transitionTargetNode . getOutgoingTransitionCount ( ) ) ; if ( transitionTargetNode . getTransitionSetBeginIndex ( ) == - 1 ) onePastLastCreatedTransitionSetIndex = createSimpleMDAGTransitionSet ( transitionTargetNode , mdagDataArray , onePastLastCreatedTransitionSetIndex ) ; mdagDataArray [ pivotIndex ++ ] . setTransitionSetBeginIndex ( transitionTargetNode . getTransitionSetBeginIndex ( ) ) ; } return onePastLastCreatedTransitionSetIndex ; } | Creates a SimpleMDAGNode version of an MDAGNode s outgoing _transition set in mdagDataArray . |
13,779 | private static boolean isAcceptNode ( Object nodeObj ) { if ( nodeObj != null ) { Class nodeObjClass = nodeObj . getClass ( ) ; if ( nodeObjClass . equals ( MDAGNode . class ) ) return ( ( MDAGNode ) nodeObj ) . isAcceptNode ( ) ; else if ( nodeObjClass . equals ( SimpleMDAGNode . class ) ) return ( ( SimpleMDAGNode ) nodeObj ) . isAcceptNode ( ) ; } throw new IllegalArgumentException ( "Argument is not an MDAGNode or SimpleMDAGNode" ) ; } | Determines if a child node object is accepting . |
13,780 | public SimpleMDAGNode transition ( SimpleMDAGNode [ ] mdagDataArray , char letter ) { SimpleMDAGNode targetNode = null ; int offset = binarySearch ( mdagDataArray , letter ) ; if ( offset >= 0 ) { targetNode = mdagDataArray [ offset ] ; } return targetNode ; } | Follows an outgoing _transition from this node . |
13,781 | public static SimpleMDAGNode traverseMDAG ( SimpleMDAGNode [ ] mdagDataArray , SimpleMDAGNode sourceNode , String str ) { return sourceNode . transition ( mdagDataArray , str . toCharArray ( ) ) ; } | Follows a _transition path starting from the source node of a MDAG . |
13,782 | public boolean isNonprojective ( ) { for ( int dep1 : goldDependencies . keySet ( ) ) { int head1 = goldDependencies . get ( dep1 ) . headIndex ; for ( int dep2 : goldDependencies . keySet ( ) ) { int head2 = goldDependencies . get ( dep2 ) . headIndex ; if ( head1 < 0 || head2 < 0 ) continue ; if ( dep1 > head1 && head1 != head2 ) if ( ( dep1 > head2 && dep1 < dep2 && head1 < head2 ) || ( dep1 < head2 && dep1 > dep2 && head1 < dep2 ) ) return true ; if ( dep1 < head1 && head1 != head2 ) if ( ( head1 > head2 && head1 < dep2 && dep1 < head2 ) || ( head1 < head2 && head1 > dep2 && dep1 < dep2 ) ) return true ; } } return false ; } | Shows whether the tree to train is projective or not |
13,783 | public void save ( OutputStream stream ) throws IOException { DataOutputStream out = null ; try { out = new DataOutputStream ( new BufferedOutputStream ( stream ) ) ; for ( int i = 0 ; i < _array . length ; ++ i ) { out . writeInt ( _array [ i ] ) ; } } finally { if ( out != null ) { out . close ( ) ; } } } | Saves the trie data into a stream . |
13,784 | public int exactMatchSearch ( byte [ ] key ) { int unit = _array [ 0 ] ; int nodePos = 0 ; for ( byte b : key ) { nodePos ^= ( ( unit >>> 10 ) << ( ( unit & ( 1 << 9 ) ) >>> 6 ) ) ^ ( b & 0xFF ) ; unit = _array [ nodePos ] ; if ( ( unit & ( ( 1 << 31 ) | 0xFF ) ) != ( b & 0xff ) ) { return - 1 ; } } if ( ( ( unit >>> 8 ) & 1 ) != 1 ) { return - 1 ; } unit = _array [ nodePos ^ ( ( unit >>> 10 ) << ( ( unit & ( 1 << 9 ) ) >>> 6 ) ) ] ; return unit & ( ( 1 << 31 ) - 1 ) ; } | Returns the corresponding value if the key is found . Otherwise returns - 1 . |
13,785 | public List < Pair < Integer , Integer > > commonPrefixSearch ( byte [ ] key , int offset , int maxResults ) { ArrayList < Pair < Integer , Integer > > result = new ArrayList < Pair < Integer , Integer > > ( ) ; int unit = _array [ 0 ] ; int nodePos = 0 ; nodePos ^= ( ( unit >>> 10 ) << ( ( unit & ( 1 << 9 ) ) >>> 6 ) ) ; for ( int i = offset ; i < key . length ; ++ i ) { byte b = key [ i ] ; nodePos ^= ( b & 0xff ) ; unit = _array [ nodePos ] ; if ( ( unit & ( ( 1 << 31 ) | 0xFF ) ) != ( b & 0xff ) ) { return result ; } nodePos ^= ( ( unit >>> 10 ) << ( ( unit & ( 1 << 9 ) ) >>> 6 ) ) ; if ( ( ( unit >>> 8 ) & 1 ) == 1 ) { if ( result . size ( ) < maxResults ) { result . add ( new Pair < Integer , Integer > ( i + 1 , _array [ nodePos ] & ( ( 1 << 31 ) - 1 ) ) ) ; } } } return result ; } | Returns the keys that begins with the given key and its corresponding values . The first of the returned pair represents the length of the found key . |
13,786 | private void writeArrayHeader ( ByteBufAllocator allocator , ArrayHeaderRedisMessage msg , List < Object > out ) { writeArrayHeader ( allocator , msg . isNull ( ) , msg . length ( ) , out ) ; } | Write array header only without body . Use this if you want to write arrays as streaming . |
13,787 | private void writeArrayMessage ( ByteBufAllocator allocator , ArrayRedisMessage msg , List < Object > out ) { if ( msg . isNull ( ) ) { writeArrayHeader ( allocator , msg . isNull ( ) , RedisConstants . NULL_VALUE , out ) ; } else { writeArrayHeader ( allocator , msg . isNull ( ) , msg . children ( ) . size ( ) , out ) ; for ( RedisMessage child : msg . children ( ) ) { writeRedisMessage ( allocator , child , out ) ; } } } | Write full constructed array message . |
13,788 | public static ByteBuf wrappedBuffer ( ByteBuffer buffer ) { if ( ! buffer . hasRemaining ( ) ) { return EMPTY_BUFFER ; } if ( ! buffer . isDirect ( ) && buffer . hasArray ( ) ) { return wrappedBuffer ( buffer . array ( ) , buffer . arrayOffset ( ) + buffer . position ( ) , buffer . remaining ( ) ) . order ( buffer . order ( ) ) ; } else if ( PlatformDependent . hasUnsafe ( ) ) { if ( buffer . isReadOnly ( ) ) { if ( buffer . isDirect ( ) ) { return new ReadOnlyUnsafeDirectByteBuf ( ALLOC , buffer ) ; } else { return new ReadOnlyByteBufferBuf ( ALLOC , buffer ) ; } } else { return new UnpooledUnsafeDirectByteBuf ( ALLOC , buffer , buffer . remaining ( ) ) ; } } else { if ( buffer . isReadOnly ( ) ) { return new ReadOnlyByteBufferBuf ( ALLOC , buffer ) ; } else { return new UnpooledDirectByteBuf ( ALLOC , buffer , buffer . remaining ( ) ) ; } } } | Creates a new buffer which wraps the specified NIO buffer s current slice . A modification on the specified buffer s content will be visible to the returned buffer . |
13,789 | public static ByteBuf wrappedBuffer ( ByteBuf buffer ) { if ( buffer . isReadable ( ) ) { return buffer . slice ( ) ; } else { buffer . release ( ) ; return EMPTY_BUFFER ; } } | Creates a new buffer which wraps the specified buffer s readable bytes . A modification on the specified buffer s content will be visible to the returned buffer . |
13,790 | public static ByteBuf wrappedBuffer ( int maxNumComponents , ByteBuf ... buffers ) { switch ( buffers . length ) { case 0 : break ; case 1 : ByteBuf buffer = buffers [ 0 ] ; if ( buffer . isReadable ( ) ) { return wrappedBuffer ( buffer . order ( BIG_ENDIAN ) ) ; } else { buffer . release ( ) ; } break ; default : for ( int i = 0 ; i < buffers . length ; i ++ ) { ByteBuf buf = buffers [ i ] ; if ( buf . isReadable ( ) ) { return new CompositeByteBuf ( ALLOC , false , maxNumComponents , buffers , i ) ; } buf . release ( ) ; } break ; } return EMPTY_BUFFER ; } | Creates a new big - endian composite buffer which wraps the readable bytes of the specified buffers without copying them . A modification on the content of the specified buffers will be visible to the returned buffer . |
13,791 | public static ByteBuf wrappedBuffer ( int maxNumComponents , ByteBuffer ... buffers ) { return wrappedBuffer ( maxNumComponents , CompositeByteBuf . BYTE_BUFFER_WRAPPER , buffers ) ; } | Creates a new big - endian composite buffer which wraps the slices of the specified NIO buffers without copying them . A modification on the content of the specified buffers will be visible to the returned buffer . |
13,792 | public static ByteBuf copyInt ( int value ) { ByteBuf buf = buffer ( 4 ) ; buf . writeInt ( value ) ; return buf ; } | Creates a new 4 - byte big - endian buffer that holds the specified 32 - bit integer . |
13,793 | public static ByteBuf copyInt ( int ... values ) { if ( values == null || values . length == 0 ) { return EMPTY_BUFFER ; } ByteBuf buffer = buffer ( values . length * 4 ) ; for ( int v : values ) { buffer . writeInt ( v ) ; } return buffer ; } | Create a big - endian buffer that holds a sequence of the specified 32 - bit integers . |
13,794 | public static ByteBuf copyShort ( int value ) { ByteBuf buf = buffer ( 2 ) ; buf . writeShort ( value ) ; return buf ; } | Creates a new 2 - byte big - endian buffer that holds the specified 16 - bit integer . |
13,795 | public static ByteBuf copyShort ( short ... values ) { if ( values == null || values . length == 0 ) { return EMPTY_BUFFER ; } ByteBuf buffer = buffer ( values . length * 2 ) ; for ( int v : values ) { buffer . writeShort ( v ) ; } return buffer ; } | Create a new big - endian buffer that holds a sequence of the specified 16 - bit integers . |
13,796 | public static ByteBuf copyMedium ( int value ) { ByteBuf buf = buffer ( 3 ) ; buf . writeMedium ( value ) ; return buf ; } | Creates a new 3 - byte big - endian buffer that holds the specified 24 - bit integer . |
13,797 | public static ByteBuf copyMedium ( int ... values ) { if ( values == null || values . length == 0 ) { return EMPTY_BUFFER ; } ByteBuf buffer = buffer ( values . length * 3 ) ; for ( int v : values ) { buffer . writeMedium ( v ) ; } return buffer ; } | Create a new big - endian buffer that holds a sequence of the specified 24 - bit integers . |
13,798 | public static ByteBuf copyLong ( long value ) { ByteBuf buf = buffer ( 8 ) ; buf . writeLong ( value ) ; return buf ; } | Creates a new 8 - byte big - endian buffer that holds the specified 64 - bit integer . |
13,799 | public static ByteBuf copyLong ( long ... values ) { if ( values == null || values . length == 0 ) { return EMPTY_BUFFER ; } ByteBuf buffer = buffer ( values . length * 8 ) ; for ( long v : values ) { buffer . writeLong ( v ) ; } return buffer ; } | Create a new big - endian buffer that holds a sequence of the specified 64 - bit integers . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.