idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
133,200
protected static void buildTree ( EndpointPart parent , String [ ] parts , int index , String endpointType ) { String name = parts [ index ] ; String qualifier = null ; if ( index == parts . length - 1 ) { qualifier = EndpointUtil . decodeEndpointOperation ( parts [ index ] , false ) ; name = EndpointUtil . decodeEndpo...
This method builds a tree .
133,201
protected static List < EndpointInfo > extractEndpointInfo ( EndpointPart root ) { List < EndpointInfo > endpoints = new ArrayList < EndpointInfo > ( ) ; root . extractEndpointInfo ( endpoints , "" ) ; return endpoints ; }
This method expands a tree into the collapsed set of endpoints .
133,202
protected static void initEndpointInfo ( List < EndpointInfo > endpoints ) { for ( int i = 0 ; i < endpoints . size ( ) ; i ++ ) { initEndpointInfo ( endpoints . get ( i ) ) ; } }
This method initialises the list of endpoint information .
133,203
protected static void initEndpointInfo ( EndpointInfo endpoint ) { endpoint . setRegex ( createRegex ( endpoint . getEndpoint ( ) , endpoint . metaURI ( ) ) ) ; String uri = EndpointUtil . decodeEndpointURI ( endpoint . getEndpoint ( ) ) ; if ( uri != null ) { endpoint . setUriRegex ( createRegex ( uri , endpoint . met...
This method initialises the endpoint information .
133,204
protected static boolean hasMetrics ( CommunicationSummaryStatistics css ) { if ( css . getCount ( ) > 0 ) { return true ; } for ( ConnectionStatistics cs : css . getOutbound ( ) . values ( ) ) { if ( cs . getCount ( ) > 0 ) { return true ; } if ( cs . getNode ( ) != null ) { if ( hasMetrics ( cs . getNode ( ) ) ) { re...
This method determines whether the communication summary statistics have defined metrics .
133,205
protected List < EndpointInfo > doGetUnboundEndpoints ( String tenantId , List < Trace > fragments , boolean compress ) { List < EndpointInfo > ret = new ArrayList < EndpointInfo > ( ) ; Map < String , EndpointInfo > map = new HashMap < String , EndpointInfo > ( ) ; for ( int i = 0 ; i < fragments . size ( ) ; i ++ ) {...
This method obtains the unbound endpoints from a list of trace fragments .
133,206
protected void obtainEndpoints ( List < Node > nodes , List < EndpointInfo > endpoints ) { for ( int i = 0 ; i < nodes . size ( ) ; i ++ ) { Node node = nodes . get ( i ) ; if ( node . getUri ( ) != null ) { EndpointInfo ei = new EndpointInfo ( ) ; ei . setEndpoint ( EndpointUtil . encodeEndpoint ( node . getUri ( ) , ...
This method collects the information regarding endpoints .
133,207
protected void obtainProducerEndpoints ( List < Node > nodes , List < EndpointInfo > endpoints , Map < String , EndpointInfo > map ) { for ( int i = 0 ; i < nodes . size ( ) ; i ++ ) { Node node = nodes . get ( i ) ; if ( node instanceof Producer ) { String endpoint = EndpointUtil . encodeEndpoint ( node . getUri ( ) ,...
This method collects the information regarding endpoints for contained producers .
133,208
protected static String createRegex ( String endpoint , boolean meta ) { StringBuilder regex = new StringBuilder ( ) ; regex . append ( '^' ) ; for ( int i = 0 ; i < endpoint . length ( ) ; i ++ ) { char ch = endpoint . charAt ( i ) ; if ( "*" . indexOf ( ch ) != - 1 ) { regex . append ( '.' ) ; } else if ( "\\.^$|?+[]...
This method derives the regular expression from the supplied URI .
133,209
protected boolean processQueryParameters ( Trace trace , Node node ) { boolean ret = false ; Set < Property > queryString = node . getProperties ( Constants . PROP_HTTP_QUERY ) ; if ( ! queryString . isEmpty ( ) ) { StringTokenizer st = new StringTokenizer ( queryString . iterator ( ) . next ( ) . getValue ( ) , "&" ) ...
This method processes the query parameters associated with the supplied node to extract templated named values as properties on the trace node .
133,210
public boolean multipleConsumers ( ) { Set < Property > props = getProperties ( Producer . PROPERTY_PUBLISH ) ; return ! props . isEmpty ( ) && props . iterator ( ) . next ( ) . getValue ( ) . equalsIgnoreCase ( Boolean . TRUE . toString ( ) ) ; }
This method determines whether the interaction node is associated with a multi - consumer communication .
133,211
protected String getValue ( Trace trace , Node node , Direction direction , Map < String , ? > headers , Object [ ] values ) { if ( expression != null ) { return expression . evaluate ( trace , node , direction , headers , values ) ; } return null ; }
This method returns the value associated with the expression for the supplied data .
133,212
public void startSpanWithParent ( SpanBuilder spanBuilder , Span parent , String id ) { if ( parent != null ) { spanBuilder . asChildOf ( parent . context ( ) ) ; } doStartSpan ( spanBuilder , id ) ; }
This is a convenience method for situations where we don t know if a parent span is available . If we try to add a childOf relationship to a null parent it would cause a null pointer exception .
133,213
public void startSpanWithContext ( SpanBuilder spanBuilder , SpanContext context , String id ) { if ( context != null ) { spanBuilder . asChildOf ( context ) ; } doStartSpan ( spanBuilder , id ) ; }
This is a convenience method for situations where we don t know if a parent span is available . If we try to add a childOf relationship to a null context it would cause a null pointer exception .
133,214
public boolean hasSpanWithId ( String id ) { TraceState ts = traceState . get ( ) ; if ( id != null && ts != null ) { boolean spanFound = ts . getSpanForId ( id ) != null ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Has span with id = " + id + "? " + spanFound ) ; } return spanFound ; } return false ;...
This method determines whether there is a span available associated with the supplied id .
133,215
public boolean isCurrentSpan ( String id ) { TraceState ts = traceState . get ( ) ; if ( id != null && ts != null ) { boolean spanFound = ts . peekId ( ) . equals ( id ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Is current span id = " + id + "? " + spanFound ) ; } return spanFound ; } return false ...
This method determines whether the current span is associated with the supplied id .
133,216
public Span getSpan ( ) { TraceState ts = traceState . get ( ) ; if ( ts != null ) { Span span = ts . peekSpan ( ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Get span = " + span + " trace state = " + ts ) ; } return span ; } if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Get span reque...
This method retrieves the current span if available .
133,217
public void suspend ( String id ) { TraceState ts = traceState . get ( ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Suspend trace state = " + ts + " id = " + id ) ; } if ( ts != null ) { setExpire ( ts ) ; try { suspendedStateLock . lock ( ) ; if ( suspendedState . containsKey ( id ) && log . isLogg...
This method suspends any current trace state associated with this thread and associates it with the supplied id . This state can then be re - activated using the resume method .
133,218
public void resume ( String id ) { try { suspendedStateLock . lock ( ) ; TraceState ts = suspendedState . get ( id ) ; if ( ts != null ) { clearExpire ( ts ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Resume trace state = " + ts + " id = " + id ) ; } if ( traceState . get ( ) != null && log . isLogg...
This method attempts to resume a previously suspended trace state associated with the supplied id . When resumed the trace state is associated with the current thread .
133,219
public boolean includePath ( String path ) { if ( path . startsWith ( "/hawkular/apm" ) ) { return false ; } int dotPos = path . lastIndexOf ( '.' ) ; int slashPos = path . lastIndexOf ( '/' ) ; if ( dotPos <= slashPos ) { return true ; } if ( ! fileExtensionWhitelist . isEmpty ( ) ) { String extension = path . substri...
This method determines if the supplied path should be monitored .
133,220
public String sanitizePaths ( String baseUri , String resourcePath ) { if ( baseUri . endsWith ( "/" ) && resourcePath . startsWith ( "/" ) ) { return baseUri . substring ( 0 , baseUri . length ( ) - 1 ) + resourcePath ; } if ( ( ! baseUri . endsWith ( "/" ) ) && ( ! resourcePath . startsWith ( "/" ) ) ) { return baseU...
Helper to remove duplicate slashes
133,221
public static String serialize ( Object data ) { String ret = null ; if ( data != null ) { if ( data . getClass ( ) == String . class ) { ret = ( String ) data ; } else if ( data instanceof byte [ ] ) { ret = new String ( ( byte [ ] ) data ) ; } else { try { ret = mapper . writeValueAsString ( data ) ; } catch ( JsonPr...
This method serializes the supplied object to a JSON document .
133,222
public static void initialiseLinks ( TraceCompletionInformation ci , long fragmentBaseTime , Node n , StringBuilder nodeId ) { TraceCompletionInformation . Communication c = new TraceCompletionInformation . Communication ( ) ; c . getIds ( ) . add ( nodeId . toString ( ) ) ; c . setMultipleConsumers ( true ) ; c . setB...
This method initialises the completion time information for a trace instance .
133,223
public static synchronized ElasticsearchClient getSingleton ( ) { if ( singleton == null ) { singleton = new ElasticsearchClient ( ) ; try { singleton . init ( ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , "Failed to initialise Elasticsearch client" , e ) ; } } return singleton ; }
This method explicit instantiates the singleton . For use outside a CDI environment .
133,224
@ SuppressWarnings ( "unchecked" ) private boolean prepareMapping ( String index , Map < String , Object > defaultMappings ) { boolean success = true ; for ( Map . Entry < String , Object > stringObjectEntry : defaultMappings . entrySet ( ) ) { Map < String , Object > mapping = ( Map < String , Object > ) stringObjectE...
This method applies the supplied mapping to the index .
133,225
private boolean createIndex ( String index , Map < String , Object > defaultSettings ) { IndicesExistsResponse res = client . admin ( ) . indices ( ) . prepareExists ( index ) . execute ( ) . actionGet ( ) ; boolean created = false ; if ( ! res . isExists ( ) ) { CreateIndexRequestBuilder req = client . admin ( ) . ind...
Check if index is created . if not it will created it
133,226
private void determineHostsAsProperty ( ) { if ( hosts . startsWith ( "${" ) && hosts . endsWith ( "}" ) ) { String hostsProperty = hosts . substring ( 2 , hosts . length ( ) - 1 ) ; hosts = PropertyUtil . getProperty ( hostsProperty ) ; if ( hosts == null ) { throw new IllegalArgumentException ( "Could not find proper...
sets hosts if the _hosts propertey is determined to be a property placeholder Throws IllegalArgumentException argument exception when nothing found
133,227
public void clearTenant ( String tenantId ) { String index = getIndex ( tenantId ) ; synchronized ( knownIndices ) { IndicesAdminClient indices = client . admin ( ) . indices ( ) ; boolean indexExists = indices . prepareExists ( index ) . execute ( ) . actionGet ( ) . isExists ( ) ; if ( indexExists ) { indices . prepa...
Removes all data associated with tenant .
133,228
public void close ( ) { if ( node != null ) { node . close ( ) ; } if ( client != null ) { client . close ( ) ; client = null ; } }
This method closes the Elasticsearch client .
133,229
public static CompletionTime spanToCompletionTime ( SpanCache spanCache , Span span ) { CompletionTime completionTime = new CompletionTime ( ) ; completionTime . setId ( span . getId ( ) ) ; if ( span . getTimestamp ( ) != null ) { completionTime . setTimestamp ( span . getTimestamp ( ) ) ; } if ( span . getDuration ( ...
Convert span to CompletionTime object
133,230
protected static void initialiseOutbound ( Node n , long baseTime , CommunicationDetails cd , StringBuilder nodeId ) { CommunicationDetails . Outbound ob = new CommunicationDetails . Outbound ( ) ; ob . getLinkIds ( ) . add ( nodeId . toString ( ) ) ; ob . setMultiConsumer ( true ) ; ob . setProducerOffset ( n . getTim...
This method initialises the outbound information from the consumer s nodes in the supplied communication details .
133,231
public static FilterBuilder buildFilter ( Criteria criteria ) { if ( criteria . getTransaction ( ) != null && criteria . getTransaction ( ) . trim ( ) . isEmpty ( ) ) { return FilterBuilders . missingFilter ( TRANSACTION_FIELD ) ; } return null ; }
This method returns a filter associated with the supplied criteria .
133,232
public static long toMicros ( Instant instant ) { return TimeUnit . SECONDS . toMicros ( instant . getEpochSecond ( ) ) + TimeUnit . NANOSECONDS . toMicros ( instant . getNano ( ) ) ; }
This method returns the timestamp associated with the supplied instant in microseconds .
133,233
public String getProperty ( String name , String def ) { String ret = PropertyUtil . getProperty ( name , null ) ; if ( ret == null ) { if ( getProperties ( ) . containsKey ( name ) ) { ret = getProperties ( ) . get ( name ) ; } else { ret = def ; } } if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Get pro...
This method returns the property associated with the supplied name . The system properties will be checked first and if not available then the collector configuration properties .
133,234
public void merge ( CollectorConfiguration config , boolean overwrite ) throws IllegalArgumentException { for ( String key : config . getInstrumentation ( ) . keySet ( ) ) { if ( getInstrumentation ( ) . containsKey ( key ) && ! overwrite ) { throw new IllegalArgumentException ( "Instrumentation for '" + key + "' alrea...
This method merges the supplied configuration into this configuration . If a conflict is found if overwrite is true then the supplied config element will be used otherwise an exception will be raised .
133,235
public static ExpressionHandler getHandler ( Expression expression ) { ExpressionHandler ret = null ; Class < ? extends ExpressionHandler > cls = handlers . get ( expression . getClass ( ) ) ; if ( cls != null ) { try { Constructor < ? extends ExpressionHandler > con = cls . getConstructor ( Expression . class ) ; ret ...
This method returns an expression handler for the supplied expression .
133,236
public static Collection < CommunicationSummaryStatistics > buildCommunicationSummaryTree ( Collection < CommunicationSummaryStatistics > nodes , Set < String > endpoints ) { Map < String , CommunicationSummaryStatistics > nodeMap = new HashMap < String , CommunicationSummaryStatistics > ( ) ; for ( CommunicationSummar...
This method returns the supplied list of flat nodes as a set of tree structures with related nodes .
133,237
protected void setConfigurationService ( ConfigurationService configService ) { if ( log . isLoggable ( Level . FINER ) ) { log . finer ( "Set configuration service = " + configService ) ; } configurationService = configService ; if ( configurationService != null ) { initConfig ( ) ; } }
This method sets the configuration service .
133,238
protected void initConfig ( ) { CollectorConfiguration config = configurationService . getCollector ( null , null , null , null ) ; if ( config != null ) { configLastUpdated = System . currentTimeMillis ( ) ; filterManager = new FilterManager ( config ) ; try { processorManager = new ProcessorManager ( config ) ; } cat...
This method initialises the configuration .
133,239
protected void initRefreshCycle ( ) { Integer refresh = PropertyUtil . getPropertyAsInteger ( PropertyUtil . HAWKULAR_APM_CONFIG_REFRESH ) ; if ( log . isLoggable ( Level . FINER ) ) { log . finer ( "Configuration refresh cycle (in seconds) = " + refresh ) ; } if ( refresh != null ) { Executors . newSingleThreadSchedul...
This method initialises the refresh cycle .
133,240
protected void mergeProducer ( Producer inner , Producer outer ) { if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Merging Producer = " + inner + " into Producer = " + outer ) ; } if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Merging Producers: replacing correlation ids (" + outer . getCorre...
This method merges an inner Producer node information into its containing Producer node before removing the inner node .
133,241
protected void processInContent ( String location , FragmentBuilder builder , int hashCode ) { if ( builder . isInBufferActive ( hashCode ) ) { processIn ( location , null , builder . getInData ( hashCode ) ) ; } else if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "processInContent: location=[" + location ...
This method processes the in content if available .
133,242
protected void processOutContent ( String location , FragmentBuilder builder , int hashCode ) { if ( builder . isOutBufferActive ( hashCode ) ) { processOut ( location , null , builder . getOutData ( hashCode ) ) ; } else if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "processOutContent: location=[" + loca...
This method processes the out content if available .
133,243
protected void push ( String location , FragmentBuilder builder , Node node ) { processInContent ( location , builder , - 1 ) ; builder . pushNode ( node ) ; }
This method pushes a new node into the trace fragment .
133,244
protected < T extends Node > T pop ( String location , FragmentBuilder builder , Class < T > cls , String uri ) { if ( builder == null ) { if ( log . isLoggable ( Level . WARNING ) ) { log . warning ( "No fragment builder for this thread (" + Thread . currentThread ( ) + ") - trying to pop node of type: " + cls ) ; } r...
This method pops an existing node from the trace fragment .
133,245
protected void processValues ( Trace trace , Node node , Direction direction , Map < String , ? > headers , Object [ ] values ) { if ( node . interactionNode ( ) ) { Message m = null ; if ( direction == Direction . In ) { m = ( ( InteractionNode ) node ) . getIn ( ) ; if ( m == null ) { m = new Message ( ) ; ( ( Intera...
This method processes the values associated with the start or end of a scoped activity .
133,246
protected String getHeaderValueText ( Object value ) { if ( value == null ) { return null ; } if ( value . getClass ( ) == String . class ) { return ( String ) value ; } else if ( value instanceof List ) { List < ? > list = ( List < ? > ) value ; if ( list . size ( ) == 1 ) { return getHeaderValueText ( list . get ( 0 ...
This method returns a textual representation of the supplied header value .
133,247
protected void checkForCompletion ( FragmentBuilder builder , Node node ) { if ( builder . isComplete ( ) ) { if ( node != null ) { Trace trace = builder . getTrace ( ) ; if ( builder . getLevel ( ) . ordinal ( ) <= ReportingLevel . None . ordinal ( ) ) { if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( "Not...
This method checks whether the supplied fragment has been completed and therefore should be processed .
133,248
protected void spawnFragment ( FragmentBuilder parentBuilder , Node node , int position , FragmentBuilder spawnedBuilder ) { Trace trace = parentBuilder . getTrace ( ) ; String id = UUID . randomUUID ( ) . toString ( ) ; String location = null ; String uri = null ; String operation = null ; String type = null ; if ( ! ...
This method creates a new linked fragment to handle some asynchronous activities .
133,249
public static synchronized < K , V > Cache < K , V > getDefaultCache ( String cacheName ) { if ( defaultCacheManager == null ) { defaultCacheManager = new DefaultCacheManager ( ) ; } return defaultCacheManager . getCache ( cacheName ) ; }
This method returns a default cache .
133,250
@ SuppressWarnings ( "unchecked" ) public static < T > T getSingletonService ( Class < T > intf ) { T ret = null ; synchronized ( singletons ) { if ( singletons . containsKey ( intf ) ) { ret = ( T ) singletons . get ( intf ) ; } else { List < T > services = getServices ( intf ) ; if ( ! services . isEmpty ( ) ) { ret ...
This method identifies a service implementation that implements the supplied interface and returns it as a singleton so that subsequent calls for the same service will get the same instance .
133,251
public static < T > List < T > getServices ( Class < T > intf ) { List < T > ret = new ArrayList < T > ( ) ; for ( T service : ServiceLoader . load ( intf ) ) { if ( ! ( service instanceof ServiceStatus ) || ( ( ServiceStatus ) service ) . isAvailable ( ) ) { if ( service instanceof ServiceLifecycle ) { ( ( ServiceLife...
This method returns the list of service implementations that implement the supplied interface .
133,252
public void init ( String txn , TransactionConfig btc ) { FilterProcessor fp = null ; if ( btc . getFilter ( ) != null ) { fp = new FilterProcessor ( txn , btc ) ; } synchronized ( filterMap ) { FilterProcessor oldfp = filterMap . get ( txn ) ; if ( oldfp != null ) { globalExclusionFilters . remove ( oldfp ) ; btxnFilt...
This method initialises the filter manager with the supplied transaction configuration .
133,253
public void remove ( String txn ) { synchronized ( filterMap ) { FilterProcessor oldfp = filterMap . get ( txn ) ; if ( oldfp != null ) { globalExclusionFilters . remove ( oldfp ) ; btxnFilters . remove ( oldfp ) ; } } }
This method removes the transaction .
133,254
public FilterProcessor getFilterProcessor ( String endpoint ) { FilterProcessor ret = ( onlyNamedTransactions ? null : unnamedBTxn ) ; synchronized ( filterMap ) { for ( int i = 0 ; i < globalExclusionFilters . size ( ) ; i ++ ) { if ( globalExclusionFilters . get ( i ) . isExcluded ( endpoint ) ) { if ( log . isLoggab...
This method determines whether the supplied endpoint is associated with a defined transaction or valid due to global inclusion criteria .
133,255
public static List < EmojiChar > search ( String ... annotations ) { return Emoji . findByAnnotations ( SPACE_JOINER . join ( annotations ) ) ; }
Finds matching Emoji character by its annotated metadata .
133,256
public final void applyPattern ( String pattern ) { if ( hasRegistry ( ) ) { super . applyPattern ( pattern ) ; toPattern = super . toPattern ( ) ; return ; } ArrayList < Format > foundFormats = new ArrayList < Format > ( ) ; ArrayList < String > foundDescriptions = new ArrayList < String > ( ) ; StringBuilder stripCus...
Apply the specified pattern .
133,257
private Format getFormat ( String desc ) { if ( registry != null ) { String name = desc ; String args = "" ; int i = desc . indexOf ( START_FMT ) ; if ( i > 0 ) { name = desc . substring ( 0 , i ) . trim ( ) ; args = desc . substring ( i + 1 ) . trim ( ) ; } FormatFactory factory = registry . get ( name ) ; if ( factor...
Get a custom format from a format description .
133,258
private void getQuotedString ( String pattern , ParsePosition pos , boolean escapingOn ) { appendQuotedString ( pattern , pos , null , escapingOn ) ; }
Consume quoted string only
133,259
public int doEndTag ( ) throws JspException { String key = null ; LocalizationContext locCtxt = null ; if ( keySpecified ) { key = keyAttrValue ; } else { if ( bodyContent != null && bodyContent . getString ( ) != null ) key = bodyContent . getString ( ) . trim ( ) ; } if ( ( key == null ) || key . equals ( "" ) ) { tr...
Tag attributes known at translation time
133,260
public static String codePointsToString ( String ... points ) { StringBuilder ret = new StringBuilder ( ) ; for ( String hexPoint : points ) { ret . append ( codePointToString ( hexPoint ) ) ; } return ret . toString ( ) ; }
Transforms a list of Unicode code points as hex strings into a proper encoded string .
133,261
public static String codePointToString ( String point ) { String ret ; if ( Strings . isNullOrEmpty ( point ) ) { return point ; } int unicodeScalar = Integer . parseInt ( point , 16 ) ; if ( Character . isSupplementaryCodePoint ( unicodeScalar ) ) { ret = String . valueOf ( Character . toChars ( unicodeScalar ) ) ; } ...
Transforms an Unicode code point given as a hex string into a proper encoded string . Supplementary code points are encoded in UTF - 16 as required by Java .
133,262
public static EmojiChar findByVendorCodePoint ( Vendor vendor , String point ) { Emoji emoji = Emoji . getInstance ( ) ; return emoji . _findByVendorCodePoint ( vendor , point ) ; }
Finds an emoji character by vendor code point .
133,263
public StringBuffer render ( StringBuffer buffer , Object ... arguments ) { return format ( arguments , buffer , null ) ; }
Formats the current pattern with the given arguments .
133,264
public String mapTo ( Vendor vendor ) { String [ ] m = getMapping ( vendor ) ; return m == null ? null : m [ VENDOR_MAP_RAW ] ; }
Gets the raw character value of this emoji character for a given vendor .
133,265
public static Map < String , Format > get ( String name ) { return instance ( ) . methods . get ( name ) ; }
Retrieves a variants map for a given format name .
133,266
public String format ( Date ref , Date then ) { return prettyTime . format ( DurationHelper . calculateDuration ( ref , then , prettyTime . getUnits ( ) ) ) ; }
Convenience format method .
133,267
public String format ( Date ref , Date then , long precision ) { List < Duration > durations = DurationHelper . calculatePreciseDuration ( ref , then , prettyTime . getUnits ( ) ) ; List < Duration > retained = retainPrecision ( durations , precision ) ; return retained . isEmpty ( ) ? "" : prettyTime . format ( retain...
Convenience format method for precise durations .
133,268
public static String transliterate ( final String text , final String id ) { Transliterator transliterator = Transliterator . getInstance ( id ) ; return transliterator . transform ( text ) ; }
Converts the characters of the given text to the specified script .
133,269
public static FormatFactory factory ( ) { return new FormatFactory ( ) { public Format getFormat ( String name , String args , Locale locale ) { Map < String , Format > mt = FormatTables . get ( name ) ; Preconditions . checkArgument ( mt != null , "There's no format instance for [%s]" , name ) ; Format m = mt . get ( ...
Creates a factory for the specified format .
133,270
public static String naturalDay ( int style , Date then ) { Date today = new Date ( ) ; long delta = then . getTime ( ) - today . getTime ( ) ; long days = delta / ND_FACTOR ; if ( days == 0 ) return context . get ( ) . getMessage ( "today" ) ; else if ( days == 1 ) return context . get ( ) . getMessage ( "tomorrow" ) ...
For dates that are the current day or within one day return today tomorrow or yesterday as appropriate . Otherwise returns a string formatted according to a locale sensitive DateFormat .
133,271
public static String naturalTime ( Date reference , Date duration ) { return context . get ( ) . formatRelativeDate ( reference , duration ) ; }
Computes both past and future relative dates .
133,272
public static String ordinal ( Number value ) { int v = value . intValue ( ) ; int vc = v % 100 ; if ( vc > 10 && vc < 14 ) return String . format ( ORDINAL_FMT , v , context . get ( ) . ordinalSuffix ( 0 ) ) ; return String . format ( ORDINAL_FMT , v , context . get ( ) . ordinalSuffix ( v % 10 ) ) ; }
Converts a number to its ordinal as a string .
133,273
public static String times ( final Number num ) { java . text . MessageFormat f = new java . text . MessageFormat ( context . get ( ) . getBundle ( ) . getString ( "times.choice" ) , currentLocale ( ) ) ; return f . format ( new Object [ ] { Math . abs ( num . intValue ( ) ) } ) ; }
Interprets numbers as occurrences .
133,274
public double [ ] getCentralCuts ( Integer size ) throws SAXException { switch ( size ) { case 2 : return center_case2 ; case 3 : return center_case3 ; case 4 : return center_case4 ; case 5 : return center_case5 ; case 6 : return center_case6 ; case 7 : return center_case7 ; case 8 : return center_case8 ; case 9 : retu...
Produces central cut intervals lines for the normal distribution .
133,275
public void addElement ( T data ) { Node < T > newNode = new Node < T > ( data ) ; if ( isEmpty ( ) ) { first = newNode ; size = 1 ; } else { if ( this . comparator . compare ( newNode . data , first . data ) > 0 ) { Node < T > tmp = first ; first = newNode ; first . next = tmp ; tmp . prev = first ; size ++ ; } else {...
Adds a data instance .
133,276
public void insertSorted ( T value ) { add ( value ) ; @ SuppressWarnings ( "unchecked" ) Comparable < T > cmp = ( Comparable < T > ) value ; for ( int i = size ( ) - 1 ; i > 0 && cmp . compareTo ( get ( i - 1 ) ) < 0 ; i -- ) { Collections . swap ( this , i , i - 1 ) ; } }
Inserts an element and sorts the array .
133,277
public double distance2 ( double [ ] point1 , double [ ] point2 ) throws Exception { if ( point1 . length == point2 . length ) { Double sum = 0D ; for ( int i = 0 ; i < point1 . length ; i ++ ) { double tmp = point2 [ i ] - point1 [ i ] ; sum = sum + tmp * tmp ; } return sum ; } else { throw new Exception ( "Exception ...
Calculates the square of the Euclidean distance between two multidimensional points represented by the rational vectors .
133,278
public long distance2 ( int [ ] point1 , int [ ] point2 ) throws Exception { if ( point1 . length == point2 . length ) { long sum = 0 ; for ( int i = 0 ; i < point1 . length ; i ++ ) { sum = sum + ( point2 [ i ] - point1 [ i ] ) * ( point2 [ i ] - point1 [ i ] ) ; } return sum ; } else { throw new Exception ( "Exceptio...
Calculates the square of the Euclidean distance between two multidimensional points represented by integer vectors .
133,279
public double seriesDistance ( double [ ] [ ] series1 , double [ ] [ ] series2 ) throws Exception { if ( series1 . length == series2 . length ) { Double res = 0D ; for ( int i = 0 ; i < series1 . length ; i ++ ) { res = res + distance2 ( series1 [ i ] , series2 [ i ] ) ; } return Math . sqrt ( res ) ; } else { throw ne...
Calculates Euclidean distance between two multi - dimensional time - series of equal length .
133,280
public double normalizedDistance ( double [ ] point1 , double [ ] point2 ) throws Exception { return Math . sqrt ( distance2 ( point1 , point2 ) ) / point1 . length ; }
Calculates the Normalized Euclidean distance between two points .
133,281
public Double earlyAbandonedDistance ( double [ ] series1 , double [ ] series2 , double cutoff ) throws Exception { if ( series1 . length == series2 . length ) { double cutOff2 = cutoff ; if ( Double . MAX_VALUE != cutoff ) { cutOff2 = cutoff * cutoff ; } Double res = 0D ; for ( int i = 0 ; i < series1 . length ; i ++ ...
Implements Euclidean distance with early abandoning .
133,282
public char [ ] getStr ( ) { char [ ] res = new char [ this . payload . length ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = this . payload [ i ] ; } return res ; }
Get a string payload .
133,283
public boolean isTrivial ( Integer complexity ) { int len = payload . length ; if ( ( null == complexity ) || ( len < 2 ) ) { return true ; } else if ( ( complexity . intValue ( ) > 0 ) && ( len > 2 ) ) { Set < Character > seen = new TreeSet < Character > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { Character c = Charact...
Check the complexity of the string .
133,284
private static MotifRecord ADM ( double [ ] series , ArrayList < Integer > neighborhood , int motifSize , double range , double znormThreshold ) throws Exception { MotifRecord res = new MotifRecord ( - 1 , new ArrayList < Integer > ( ) ) ; ArrayList < BitSet > admDistances = new ArrayList < BitSet > ( neighborhood . si...
This is not a real ADM implementation .
133,285
private static boolean isNonTrivialMatch ( double [ ] series , int i , int j , Integer motifSize , double range , double znormThreshold ) { if ( Math . abs ( i - j ) < motifSize ) { return false ; } Double dd = eaDistance ( series , i , j , motifSize , range , znormThreshold ) ; if ( Double . isFinite ( dd ) ) { return...
Checks for the overlap and the range - configured distance .
133,286
private static Double eaDistance ( double [ ] series , int a , int b , Integer motifSize , double range , double znormThreshold ) { distCounter ++ ; double cutOff2 = range * range ; double [ ] seriesA = tp . znorm ( tp . subseriesByCopy ( series , a , a + motifSize ) , znormThreshold ) ; double [ ] seriesB = tp . znorm...
Early abandoning distance configure by range .
133,287
public int compareTo ( SAXRecord o ) { int a = this . occurrences . size ( ) ; int b = o . getIndexes ( ) . size ( ) ; if ( a == b ) { return 0 ; } else if ( a > b ) { return 1 ; } return - 1 ; }
This comparator compares entries by the length of the entries array - i . e . by the total frequency of entry occurrence .
133,288
public static DiscordRecords series2BruteForceDiscords ( double [ ] series , Integer windowSize , int discordCollectionSize , SlidingWindowMarkerAlgorithm marker , double nThreshold ) throws Exception { DiscordRecords discords = new DiscordRecords ( ) ; VisitRegistry globalTrackVisitRegistry = new VisitRegistry ( serie...
Brute force discord search implementation . BRUTE FORCE algorithm .
133,289
private static DiscordRecord findBestDiscordBruteForce ( double [ ] series , Integer windowSize , VisitRegistry globalRegistry , double nThreshold ) throws Exception { Date start = new Date ( ) ; long distanceCallsCounter = 0 ; double bestSoFarDistance = - 1.0 ; int bestSoFarPosition = - 1 ; VisitRegistry outerRegistry...
Finds the best discord . BRUTE FORCE algorithm .
133,290
public char [ ] ts2string ( double [ ] ts , int paaSize , double [ ] cuts , double nThreshold ) throws SAXException { if ( paaSize == ts . length ) { return tsProcessor . ts2String ( tsProcessor . znorm ( ts , nThreshold ) , cuts ) ; } else { double [ ] paa = tsProcessor . paa ( tsProcessor . znorm ( ts , nThreshold ) ...
Convert the timeseries into SAX string representation .
133,291
public SAXRecords ts2saxByChunking ( double [ ] ts , int paaSize , double [ ] cuts , double nThreshold ) throws SAXException { SAXRecords saxFrequencyData = new SAXRecords ( ) ; double [ ] normalizedTS = tsProcessor . znorm ( ts , nThreshold ) ; double [ ] paa = tsProcessor . paa ( normalizedTS , paaSize ) ; char [ ] c...
Converts the input time series into a SAX data structure via chunking and Z normalization .
133,292
public int charDistance ( char a , char b ) { return Math . abs ( Character . getNumericValue ( a ) - Character . getNumericValue ( b ) ) ; }
Compute the distance between the two chars based on the ASCII symbol codes .
133,293
public int strDistance ( char [ ] a , char [ ] b ) throws SAXException { if ( a . length == b . length ) { int distance = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { int tDist = Math . abs ( Character . getNumericValue ( a [ i ] ) - Character . getNumericValue ( b [ i ] ) ) ; distance += tDist ; } return distance ;...
Compute the distance between the two strings this function use the numbers associated with ASCII codes i . e . distance between a and b would be 1 .
133,294
public double saxMinDist ( char [ ] a , char [ ] b , double [ ] [ ] distanceMatrix , int n , int w ) throws SAXException { if ( a . length == b . length ) { double dist = 0.0D ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( Character . isLetter ( a [ i ] ) && Character . isLetter ( b [ i ] ) ) { int numA = Character...
This function implements SAX MINDIST function which uses alphabet based distance matrix .
133,295
public boolean checkMinDistIsZero ( char [ ] a , char [ ] b ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( charDistance ( a [ i ] , b [ i ] ) > 1 ) { return false ; } } return true ; }
Check for trivial mindist case .
133,296
public Map < String , Integer > ts2Shingles ( double [ ] series , int windowSize , int paaSize , int alphabetSize , NumerosityReductionStrategy strategy , double nrThreshold , int shingleSize ) throws SAXException { String [ ] alphabet = new String [ alphabetSize ] ; for ( int i = 0 ; i < alphabetSize ; i ++ ) { alphab...
Converts a single time - series into map of shingle frequencies .
133,297
public static String [ ] getAllPermutations ( String [ ] alphabet , int wordLength ) { String [ ] allLists = new String [ ( int ) Math . pow ( alphabet . length , wordLength ) ] ; if ( wordLength == 1 ) return alphabet ; else { String [ ] allSublists = getAllPermutations ( alphabet , wordLength - 1 ) ; int arrayIndex =...
Get all permutations of the given alphabet of given length .
133,298
public static String timeToString ( long start , long finish ) { Duration duration = new Duration ( finish - start ) ; PeriodFormatter formatter = new PeriodFormatterBuilder ( ) . appendDays ( ) . appendSuffix ( "d" ) . appendHours ( ) . appendSuffix ( "h" ) . appendMinutes ( ) . appendSuffix ( "m" ) . appendSeconds ( ...
Generic method to convert the milliseconds into the elapsed time string .
133,299
public static DiscordRecords series2DiscordsDeprecated ( double [ ] series , int discordsNumToReport , int windowSize , int paaSize , int alphabetSize , SlidingWindowMarkerAlgorithm markerAlgorithm , NumerosityReductionStrategy strategy , double nThreshold ) throws Exception { Date start = new Date ( ) ; NormalAlphabet...
Old implementation . Nearest neighbot for a candidate subsequence is searched among all other time - series subsequences regardless of their exclusion by EXACT or MINDIST . This also accepts a marker implementation which is responsible for marking a segment as visited .