idx
int64 0
41.2k
| question
stringlengths 74
4.04k
| target
stringlengths 7
750
|
|---|---|---|
40,400
|
public static < V > Node < V > findNode ( List < Node < V > > parents , Predicate < Node < V > > predicate ) { checkArgNotNull ( predicate , "predicate" ) ; if ( parents != null && ! parents . isEmpty ( ) ) { for ( Node < V > child : parents ) { Node < V > found = findNode ( child , predicate ) ; if ( found != null ) return found ; } } return null ; }
|
Returns the first node underneath the given parents for which the given predicate evaluates to true . If parents is null or empty or no node is found the method returns null .
|
40,401
|
public static < V > Node < V > findNodeByLabel ( Node < V > parent , String labelPrefix ) { return findNode ( parent , new LabelPrefixPredicate < V > ( labelPrefix ) ) ; }
|
Returns the first node underneath the given parent for which matches the given label prefix . If parents is null or empty or no node is found the method returns null .
|
40,402
|
public static < V > Node < V > findNodeByLabel ( List < Node < V > > parents , String labelPrefix ) { return findNode ( parents , new LabelPrefixPredicate < V > ( labelPrefix ) ) ; }
|
Returns the first node underneath the given parents which matches the given label prefix . If parents is null or empty or no node is found the method returns null .
|
40,403
|
public static < V > Node < V > findLastNode ( List < Node < V > > parents , Predicate < Node < V > > predicate ) { checkArgNotNull ( predicate , "predicate" ) ; if ( parents != null && ! parents . isEmpty ( ) ) { int parentsSize = parents . size ( ) ; for ( int i = parentsSize - 1 ; i >= 0 ; i -- ) { Node < V > found = findLastNode ( parents . get ( i ) , predicate ) ; if ( found != null ) return found ; } } return null ; }
|
Returns the last node underneath the given parents for which the given predicate evaluates to true . If parents is null or empty or no node is found the method returns null .
|
40,404
|
public static < V , C extends Collection < Node < V > > > C collectNodes ( Node < V > parent , Predicate < Node < V > > predicate , C collection ) { checkArgNotNull ( predicate , "predicate" ) ; checkArgNotNull ( collection , "collection" ) ; return parent != null && hasChildren ( parent ) ? collectNodes ( parent . getChildren ( ) , predicate , collection ) : collection ; }
|
Collects all nodes underneath the given parent for which the given predicate evaluates to true .
|
40,405
|
public static String getNodeText ( Node < ? > node , InputBuffer inputBuffer ) { checkArgNotNull ( node , "node" ) ; checkArgNotNull ( inputBuffer , "inputBuffer" ) ; if ( node . hasError ( ) ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = node . getStartIndex ( ) ; i < node . getEndIndex ( ) ; i ++ ) { char c = inputBuffer . charAt ( i ) ; switch ( c ) { case Chars . DEL_ERROR : i ++ ; break ; case Chars . INS_ERROR : case Chars . EOI : break ; case Chars . RESYNC_START : i ++ ; while ( inputBuffer . charAt ( i ) != Chars . RESYNC_END ) i ++ ; break ; case Chars . RESYNC_END : case Chars . RESYNC_EOI : case Chars . RESYNC : throw new IllegalStateException ( ) ; default : sb . append ( c ) ; } } return sb . toString ( ) ; } return inputBuffer . extract ( node . getStartIndex ( ) , node . getEndIndex ( ) ) ; }
|
Returns the input text matched by the given node with error correction .
|
40,406
|
public static < V , C extends Collection < Node < V > > > C collectNodes ( List < Node < V > > parents , Predicate < Node < V > > predicate , C collection ) { checkArgNotNull ( predicate , "predicate" ) ; checkArgNotNull ( collection , "collection" ) ; if ( parents != null && ! parents . isEmpty ( ) ) { for ( Node < V > child : parents ) { if ( predicate . apply ( child ) ) { collection . add ( child ) ; } collectNodes ( child , predicate , collection ) ; } } return collection ; }
|
Collects all nodes underneath the given parents for which the given predicate evaluates to true .
|
40,407
|
public static String collectContent ( InputBuffer buf ) { StringBuilder sb = new StringBuilder ( ) ; int ix = 0 ; loop : while ( true ) { char c = buf . charAt ( ix ++ ) ; switch ( c ) { case INDENT : sb . append ( '\u00bb' ) ; break ; case DEDENT : sb . append ( '\u00ab' ) ; break ; case EOI : break loop ; default : sb . append ( c ) ; } } return sb . toString ( ) ; }
|
Collects the actual input text the input buffer provides into a String . This is especially useful for IndentDedentInputBuffers created by transformIndents .
|
40,408
|
public boolean append ( char c ) { return set ( get ( ) == null ? String . valueOf ( c ) : get ( ) + c ) ; }
|
Appends the given char . If this instance is currently uninitialized the given char is used for initialization .
|
40,409
|
public static void ensure ( boolean condition , String errorMessageFormat , Object ... errorMessageArgs ) { if ( ! condition ) { throw new GrammarException ( errorMessageFormat , errorMessageArgs ) ; } }
|
Throws a GrammarException if the given condition is not met .
|
40,410
|
private void sort ( InstructionGroup group ) { final InsnList instructions = method . instructions ; Collections . sort ( group . getNodes ( ) , new Comparator < InstructionGraphNode > ( ) { public int compare ( InstructionGraphNode a , InstructionGraphNode b ) { return Integer . valueOf ( instructions . indexOf ( a . getInstruction ( ) ) ) . compareTo ( instructions . indexOf ( b . getInstruction ( ) ) ) ; } } ) ; }
|
sort the group instructions according to their method index
|
40,411
|
private void markUngroupedEnclosedNodes ( InstructionGroup group ) { while_ : while ( true ) { for ( int i = getIndexOfFirstInsn ( group ) , max = getIndexOfLastInsn ( group ) ; i < max ; i ++ ) { InstructionGraphNode node = method . getGraphNodes ( ) . get ( i ) ; if ( node . getGroup ( ) == null ) { markGroup ( node , group ) ; sort ( group ) ; continue while_ ; } } break ; } }
|
also capture all group nodes hidden behind xLoads
|
40,412
|
public boolean isPrefixOf ( MatcherPath that ) { checkArgNotNull ( that , "that" ) ; return element . level <= that . element . level && ( this == that || ( that . parent != null && isPrefixOf ( that . parent ) ) ) ; }
|
Determines whether this path is a prefix of the given other path .
|
40,413
|
public Element getElementAtLevel ( int level ) { checkArgument ( level >= 0 ) ; if ( level > element . level ) return null ; if ( level < element . level ) return parent . getElementAtLevel ( level ) ; return element ; }
|
Returns the Element at the given level .
|
40,414
|
public MatcherPath commonPrefix ( MatcherPath that ) { checkArgNotNull ( that , "that" ) ; if ( element . level > that . element . level ) return parent . commonPrefix ( that ) ; if ( element . level < that . element . level ) return commonPrefix ( that . parent ) ; if ( this == that ) return this ; return ( parent != null && that . parent != null ) ? parent . commonPrefix ( that . parent ) : null ; }
|
Returns the common prefix of this MatcherPath and the given other one .
|
40,415
|
public boolean contains ( Matcher matcher ) { return element . matcher == matcher || ( parent != null && parent . contains ( matcher ) ) ; }
|
Determines whether the given matcher is contained in this path .
|
40,416
|
public static Predicate < Matcher > preventLoops ( ) { return new Predicate < Matcher > ( ) { private final Set < Matcher > visited = new HashSet < Matcher > ( ) ; public boolean apply ( Matcher node ) { node = unwrap ( node ) ; if ( visited . contains ( node ) ) { return false ; } visited . add ( node ) ; return true ; } } ; }
|
A predicate for rule tree printing . Prevents SOEs by detecting and suppressing loops in the rule tree .
|
40,417
|
private void extractInstructions ( InstructionGroup group ) { for ( InstructionGraphNode node : group . getNodes ( ) ) { if ( node != group . getRoot ( ) ) { AbstractInsnNode insn = node . getInstruction ( ) ; method . instructions . remove ( insn ) ; group . getInstructions ( ) . add ( insn ) ; } } }
|
move all group instructions except for the root from the underlying method into the groups Insnlist
|
40,418
|
private void extractFields ( InstructionGroup group ) { List < FieldNode > fields = group . getFields ( ) ; for ( InstructionGraphNode node : group . getNodes ( ) ) { if ( node . isXLoad ( ) ) { VarInsnNode insn = ( VarInsnNode ) node . getInstruction ( ) ; int index ; for ( index = 0 ; index < fields . size ( ) ; index ++ ) { if ( fields . get ( index ) . access == insn . var ) break ; } if ( index == fields . size ( ) ) { Type type = node . getResultValue ( ) . getType ( ) ; fields . add ( new FieldNode ( insn . var , "field$" + index , type . getDescriptor ( ) , null , type ) ) ; } insn . var = index ; } } }
|
create FieldNodes for all xLoad instructions
|
40,419
|
private synchronized void name ( InstructionGroup group , ParserClassNode classNode ) { MD5Digester digester = new MD5Digester ( classNode . name ) ; group . getInstructions ( ) . accept ( digester ) ; for ( FieldNode field : group . getFields ( ) ) digester . visitField ( field ) ; byte [ ] hash = digester . getMD5Hash ( ) ; byte [ ] hash96 = new byte [ 12 ] ; System . arraycopy ( hash , 0 , hash96 , 0 , 12 ) ; String name = group . getRoot ( ) . isActionRoot ( ) ? "Action$" : "VarInit$" ; name += CUSTOM_BASE64 . encodeToString ( hash96 , false ) ; group . setName ( name ) ; }
|
set a group name base on the hash across all group instructions and fields
|
40,420
|
public Characters add ( Characters other ) { checkArgNotNull ( other , "other" ) ; if ( ! subtractive && ! other . subtractive ) { return addToChars ( other . chars ) ; } if ( subtractive && other . subtractive ) { return retainAllChars ( other . chars ) ; } return subtractive ? removeFromChars ( other . chars ) : other . removeFromChars ( chars ) ; }
|
Returns a new Characters object containing all the characters of this instance plus all characters of the given instance .
|
40,421
|
public Characters remove ( Characters other ) { checkArgNotNull ( other , "other" ) ; if ( ! subtractive && ! other . subtractive ) { return removeFromChars ( other . chars ) ; } if ( subtractive && other . subtractive ) { return new Characters ( false , other . removeFromChars ( chars ) . chars ) ; } return subtractive ? addToChars ( other . chars ) : retainAllChars ( other . chars ) ; }
|
Returns a new Characters object containing all the characters of this instance minus all characters of the given instance .
|
40,422
|
public boolean overlapsWith ( IndexRange other ) { checkArgNotNull ( other , "other" ) ; return end > other . start && other . end > start ; }
|
Determines whether this range overlaps with the given other one .
|
40,423
|
public boolean touches ( IndexRange other ) { checkArgNotNull ( other , "other" ) ; return other . end == start || end == other . start ; }
|
Determines whether this range immediated follows or precedes the given other one .
|
40,424
|
public IndexRange mergedWith ( IndexRange other ) { checkArgNotNull ( other , "other" ) ; return new IndexRange ( Math . min ( start , other . start ) , Math . max ( end , other . end ) ) ; }
|
Created a new IndexRange that spans all characters between the smallest and the highest index of the two ranges .
|
40,425
|
private Paint getPreparedPaint ( ) { getActionButton ( ) . resetPaint ( ) ; Paint paint = getActionButton ( ) . getPaint ( ) ; paint . setStyle ( Paint . Style . FILL ) ; paint . setColor ( getActionButton ( ) . getButtonColorRipple ( ) ) ; return paint ; }
|
Returns the paint which is prepared for Ripple Effect drawing
|
40,426
|
private void initShadowRadius ( TypedArray attrs ) { int index = R . styleable . ActionButton_shadow_radius ; if ( attrs . hasValue ( index ) ) { shadowRadius = attrs . getDimension ( index , shadowRadius ) ; LOGGER . trace ( "Initialized Action Button shadow radius: {}" , getShadowRadius ( ) ) ; } }
|
Initializes the shadow radius
|
40,427
|
private void initShadowXOffset ( TypedArray attrs ) { int index = R . styleable . ActionButton_shadow_xOffset ; if ( attrs . hasValue ( index ) ) { shadowXOffset = attrs . getDimension ( index , shadowXOffset ) ; LOGGER . trace ( "Initialized Action Button X-axis offset: {}" , getShadowXOffset ( ) ) ; } }
|
Initializes the shadow X - axis offset
|
40,428
|
private void initShadowYOffset ( TypedArray attrs ) { int index = R . styleable . ActionButton_shadow_yOffset ; if ( attrs . hasValue ( index ) ) { shadowYOffset = attrs . getDimension ( index , shadowYOffset ) ; LOGGER . trace ( "Initialized Action Button shadow Y-axis offset: {}" , getShadowYOffset ( ) ) ; } }
|
Initializes the shadow Y - axis offset
|
40,429
|
private void initShadowColor ( TypedArray attrs ) { int index = R . styleable . ActionButton_shadow_color ; if ( attrs . hasValue ( index ) ) { shadowColor = attrs . getColor ( index , shadowColor ) ; LOGGER . trace ( "Initialized Action Button shadow color: {}" , getShadowColor ( ) ) ; } }
|
Initializes the shadow color
|
40,430
|
private void initShadowResponsiveEffectEnabled ( TypedArray attrs ) { int index = R . styleable . ActionButton_shadowResponsiveEffect_enabled ; if ( attrs . hasValue ( index ) ) { shadowResponsiveEffectEnabled = attrs . getBoolean ( index , shadowResponsiveEffectEnabled ) ; LOGGER . trace ( "Initialized Action Button Shadow Responsive Effect enabled: {}" , isShadowResponsiveEffectEnabled ( ) ) ; } }
|
Initializes the Shadow Responsive Effect
|
40,431
|
private void initStrokeWidth ( TypedArray attrs ) { int index = R . styleable . ActionButton_stroke_width ; if ( attrs . hasValue ( index ) ) { strokeWidth = attrs . getDimension ( index , strokeWidth ) ; LOGGER . trace ( "Initialized Action Button stroke width: {}" , getStrokeWidth ( ) ) ; } }
|
Initializes the stroke width
|
40,432
|
private void initStrokeColor ( TypedArray attrs ) { int index = R . styleable . ActionButton_stroke_color ; if ( attrs . hasValue ( index ) ) { strokeColor = attrs . getColor ( index , strokeColor ) ; LOGGER . trace ( "Initialized Action Button stroke color: {}" , getStrokeColor ( ) ) ; } }
|
Initializes the stroke color
|
40,433
|
@ SuppressWarnings ( "all" ) public void startAnimation ( Animation animation ) { if ( animation != null && ( getAnimation ( ) == null || getAnimation ( ) . hasEnded ( ) ) ) { super . startAnimation ( animation ) ; } }
|
Adds additional checking whether animation is null before starting to play it
|
40,434
|
@ TargetApi ( Build . VERSION_CODES . LOLLIPOP ) private boolean hasElevation ( ) { return Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP && getElevation ( ) > 0.0f ; }
|
Checks whether view elevation is enabled
|
40,435
|
protected void drawStroke ( Canvas canvas ) { resetPaint ( ) ; getPaint ( ) . setStyle ( Paint . Style . STROKE ) ; getPaint ( ) . setStrokeWidth ( getStrokeWidth ( ) ) ; getPaint ( ) . setColor ( getStrokeColor ( ) ) ; canvas . drawCircle ( calculateCenterX ( ) , calculateCenterY ( ) , calculateCircleRadius ( ) , getPaint ( ) ) ; LOGGER . trace ( "Drawn the Action Button stroke" ) ; }
|
Draws stroke around the main circle
|
40,436
|
protected void drawImage ( Canvas canvas ) { int startPointX = ( int ) ( calculateCenterX ( ) - getImageSize ( ) / 2 ) ; int startPointY = ( int ) ( calculateCenterY ( ) - getImageSize ( ) / 2 ) ; int endPointX = ( int ) ( startPointX + getImageSize ( ) ) ; int endPointY = ( int ) ( startPointY + getImageSize ( ) ) ; getImage ( ) . setBounds ( startPointX , startPointY , endPointX , endPointY ) ; getImage ( ) . draw ( canvas ) ; LOGGER . trace ( "Drawn the Action Button image on canvas with coordinates: X start point = {}, " + "Y start point = {}, X end point = {}, Y end point = {}" , startPointX , startPointY , endPointX , endPointY ) ; }
|
Draws the image centered inside the view
|
40,437
|
protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; LOGGER . trace ( "Called Action Button onMeasure" ) ; setMeasuredDimension ( calculateMeasuredWidth ( ) , calculateMeasuredHeight ( ) ) ; LOGGER . trace ( "Measured the Action Button size: height = {}, width = {}" , getHeight ( ) , getWidth ( ) ) ; }
|
Sets the measured dimension for the entire view
|
40,438
|
private int calculateShadowWidth ( ) { float mShadowRadius = isShadowResponsiveEffectEnabled ( ) ? ( ( ShadowResponsiveDrawer ) shadowResponsiveDrawer ) . getMaxShadowRadius ( ) : getShadowRadius ( ) ; int shadowWidth = hasShadow ( ) ? ( int ) ( ( mShadowRadius + Math . abs ( getShadowXOffset ( ) ) ) * 2 ) : 0 ; LOGGER . trace ( "Calculated Action Button shadow width: {}" , shadowWidth ) ; return shadowWidth ; }
|
Calculates shadow width in actual pixels
|
40,439
|
private int calculateShadowHeight ( ) { float mShadowRadius = isShadowResponsiveEffectEnabled ( ) ? ( ( ShadowResponsiveDrawer ) shadowResponsiveDrawer ) . getMaxShadowRadius ( ) : getShadowRadius ( ) ; int shadowHeight = hasShadow ( ) ? ( int ) ( ( mShadowRadius + Math . abs ( getShadowYOffset ( ) ) ) * 2 ) : 0 ; LOGGER . trace ( "Calculated Action Button shadow height: {}" , shadowHeight ) ; return shadowHeight ; }
|
Calculates shadow height in actual pixels
|
40,440
|
void invalidate ( ) { if ( isInvalidationRequired ( ) ) { view . postInvalidate ( ) ; LOGGER . trace ( "Called view invalidation" ) ; } if ( isInvalidationDelayedRequired ( ) ) { view . postInvalidateDelayed ( getInvalidationDelay ( ) ) ; LOGGER . trace ( "Called view delayed invalidation. Delay time is: {}" , getInvalidationDelay ( ) ) ; } reset ( ) ; }
|
Invalidates the view based on the current invalidator configuration
|
40,441
|
boolean isInsideCircle ( float centerPointX , float centerPointY , float radius ) { double xValue = Math . pow ( ( getX ( ) - centerPointX ) , 2 ) ; double yValue = Math . pow ( ( getY ( ) - centerPointY ) , 2 ) ; double radiusValue = Math . pow ( radius , 2 ) ; boolean touchPointInsideCircle = xValue + yValue <= radiusValue ; LOGGER . trace ( "Detected touch point {} inside the main circle" , touchPointInsideCircle ? "IS" : "IS NOT" ) ; return touchPointInsideCircle ; }
|
Checks whether the touch point is inside the circle or not
|
40,442
|
public List < Classification . RuntimeClassification > getClassifications ( ) { List < Classification . RuntimeClassification > result = new ArrayList < > ( ) ; getClassifications ( result , tree . getRoot ( ) ) ; return result ; }
|
Returns list of bottom level classes
|
40,443
|
public static JSONObject getStepAsJSON ( Machine machine , boolean verbose , boolean showUnvisited ) { JSONObject object = new JSONObject ( ) ; if ( verbose ) { object . put ( "modelName" , FilenameUtils . getBaseName ( machine . getCurrentContext ( ) . getModel ( ) . getName ( ) ) ) ; } if ( machine . getCurrentContext ( ) . getCurrentElement ( ) . hasName ( ) ) { object . put ( "currentElementName" , machine . getCurrentContext ( ) . getCurrentElement ( ) . getName ( ) ) ; } else { object . put ( "currentElementName" , "" ) ; } if ( verbose ) { object . put ( "currentElementID" , machine . getCurrentContext ( ) . getCurrentElement ( ) . getId ( ) ) ; JSONArray jsonKeys = new JSONArray ( ) ; for ( Map . Entry < String , String > key : machine . getCurrentContext ( ) . getKeys ( ) . entrySet ( ) ) { JSONObject jsonKey = new JSONObject ( ) ; jsonKey . put ( key . getKey ( ) , key . getValue ( ) ) ; jsonKeys . put ( jsonKey ) ; } object . put ( "data" , jsonKeys ) ; JSONArray jsonProperties = new JSONArray ( ) ; RuntimeBase runtimeBase = ( RuntimeBase ) machine . getCurrentContext ( ) . getCurrentElement ( ) ; for ( Map . Entry < String , Object > key : runtimeBase . getProperties ( ) . entrySet ( ) ) { JSONObject jsonKey = new JSONObject ( ) ; jsonKey . put ( key . getKey ( ) , key . getValue ( ) ) ; jsonProperties . put ( jsonKey ) ; } object . put ( "properties" , jsonProperties ) ; JSONArray jsonActions = new JSONArray ( ) ; if ( runtimeBase . hasActions ( ) ) { for ( Action action : runtimeBase . getActions ( ) ) { JSONObject jsonAction = new JSONObject ( ) ; jsonAction . put ( "Action" , action . getScript ( ) ) ; jsonActions . put ( jsonAction ) ; } object . put ( "actions" , jsonActions ) ; } } if ( showUnvisited ) { Context context = machine . getCurrentContext ( ) ; object . put ( "numberOfElements" , context . getModel ( ) . getElements ( ) . size ( ) ) ; object . put ( "numberOfUnvisitedElements" , context . getProfiler ( ) . getUnvisitedElements ( context ) . size ( ) ) ; JSONArray jsonElements = new JSONArray ( ) ; for ( Element element : context . getProfiler ( ) . getUnvisitedElements ( context ) ) { JSONObject jsonElement = new JSONObject ( ) ; jsonElement . put ( "elementName" , element . getName ( ) ) ; if ( verbose ) { jsonElement . put ( "elementId" , element . getId ( ) ) ; } jsonElements . put ( jsonElement ) ; } object . put ( "unvisitedElements" , jsonElements ) ; } return object ; }
|
Will create a JSON formatted string representing the current step . The step is the current element which can be either a vertex orn an edge .
|
40,444
|
private static void next ( ) { final short t0 = s0 ; short t1 = s1 ; t1 ^= t0 ; s0 = ( short ) ( rotl ( t0 , 8 ) ^ t1 ^ t1 << 5 ) ; s1 = rotl ( t1 , 13 ) ; }
|
8 - 5 - 13 x^32 + x^19 + x^10 + x^9 + x^8 + x^6 + x^5 + x^4 + x^2 + x + 1
|
40,445
|
private static long [ ] computeParameters ( final LongIterator iterator ) { long v = - 1 , prev = - 1 , c = 0 ; while ( iterator . hasNext ( ) ) { v = iterator . nextLong ( ) ; if ( prev > v ) throw new IllegalArgumentException ( "The list of values is not monotone: " + prev + " > " + v ) ; prev = v ; c ++ ; } return new long [ ] { c , v } ; }
|
Computes the number of elements and the last element returned by the given iterator .
|
40,446
|
public static long [ ] [ ] preprocessJenkins ( final BitVector bv , final long seed ) { final long length = bv . length ( ) ; final int wordLength = ( int ) ( length / ( Long . SIZE * 3 ) ) + 1 ; final long aa [ ] = new long [ wordLength ] , bb [ ] = new long [ wordLength ] , cc [ ] = new long [ wordLength ] ; long a , b , c , from = 0 ; if ( aa . length == 0 ) return new long [ 3 ] [ 0 ] ; int i = 0 ; a = b = seed ; c = ARBITRARY_BITS ; aa [ i ] = a ; bb [ i ] = b ; cc [ i ] = c ; i ++ ; while ( length - from >= Long . SIZE * 3 ) { a += bv . getLong ( from , from + Long . SIZE ) ; b += bv . getLong ( from + Long . SIZE , from + 2 * Long . SIZE ) ; c += bv . getLong ( from + 2 * Long . SIZE , from + 3 * Long . SIZE ) ; a -= b ; a -= c ; a ^= ( c >>> 43 ) ; b -= c ; b -= a ; b ^= ( a << 9 ) ; c -= a ; c -= b ; c ^= ( b >>> 8 ) ; a -= b ; a -= c ; a ^= ( c >>> 38 ) ; b -= c ; b -= a ; b ^= ( a << 23 ) ; c -= a ; c -= b ; c ^= ( b >>> 5 ) ; a -= b ; a -= c ; a ^= ( c >>> 35 ) ; b -= c ; b -= a ; b ^= ( a << 49 ) ; c -= a ; c -= b ; c ^= ( b >>> 11 ) ; a -= b ; a -= c ; a ^= ( c >>> 12 ) ; b -= c ; b -= a ; b ^= ( a << 18 ) ; c -= a ; c -= b ; c ^= ( b >>> 22 ) ; from += 3 * Long . SIZE ; aa [ i ] = a ; bb [ i ] = b ; cc [ i ] = c ; i ++ ; } return new long [ ] [ ] { aa , bb , cc } ; }
|
Preprocesses a bit vector so that Jenkins 64 - bit hashing can be computed in constant time on all prefixes .
|
40,447
|
public static long murmur ( final BitVector bv , final long seed ) { long h = seed , k ; long from = 0 ; final long length = bv . length ( ) ; while ( length - from >= Long . SIZE ) { k = bv . getLong ( from , from += Long . SIZE ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; } if ( length > from ) { k = bv . getLong ( from , length ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; } k = length ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; return h ; }
|
MurmurHash 64 - bit
|
40,448
|
public static long murmur ( final BitVector bv , final long prefixLength , final long [ ] state ) { final long precomputedUpTo = prefixLength - prefixLength % Long . SIZE ; long h = state [ ( int ) ( precomputedUpTo / Long . SIZE ) ] , k ; if ( prefixLength > precomputedUpTo ) { k = bv . getLong ( precomputedUpTo , prefixLength ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; } k = prefixLength ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; return h ; }
|
Constant - time MurmurHash 64 - bit hashing for any prefix .
|
40,449
|
public static long murmur ( final BitVector bv , final long prefixLength , final long [ ] state , final long lcp ) { final int startStateWord = ( int ) ( Math . min ( lcp , prefixLength ) / Long . SIZE ) ; long h = state [ startStateWord ] , k ; long from = startStateWord * Long . SIZE ; while ( prefixLength - from >= Long . SIZE ) { k = bv . getLong ( from , from += Long . SIZE ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; } if ( prefixLength > from ) { k = bv . getLong ( from , prefixLength ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; } k = prefixLength ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; return h ; }
|
Constant - time MurmurHash 64 - bit hashing reusing precomputed state partially .
|
40,450
|
public static long [ ] preprocessMurmur ( final BitVector bv , final long seed ) { long h = seed , k ; long from = 0 ; final long length = bv . length ( ) ; final int wordLength = ( int ) ( length / Long . SIZE ) ; final long state [ ] = new long [ wordLength + 1 ] ; int i = 0 ; state [ i ++ ] = h ; for ( ; length - from >= Long . SIZE ; i ++ ) { k = bv . getLong ( from , from += Long . SIZE ) ; k *= M ; k ^= k >>> R ; k *= M ; h ^= k ; h *= M ; state [ i ] = h ; } return state ; }
|
Preprocesses a bit vector so that MurmurHash 64 - bit can be computed in constant time on all prefixes .
|
40,451
|
public static long murmur3 ( final BitVector bv , final long seed ) { long h1 = 0x9368e53c2f6af274L ^ seed ; long h2 = 0x586dcd208f7cd3fdL ^ seed ; long c1 = 0x87c37b91114253d5L ; long c2 = 0x4cf5ad432745937fL ; long from = 0 ; final long length = bv . length ( ) ; long k1 , k2 ; while ( length - from >= Long . SIZE * 2 ) { k1 = bv . getLong ( from , from + Long . SIZE ) ; k2 = bv . getLong ( from + Long . SIZE , from += 2 * Long . SIZE ) ; k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; } if ( length > from ) { if ( length - from > Long . SIZE ) { k1 = bv . getLong ( from , from + Long . SIZE ) ; k2 = bv . getLong ( from + Long . SIZE , length ) ; } else { k1 = bv . getLong ( from , length ) ; k2 = 0 ; } k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; } h2 ^= length ; h1 += h2 ; h2 += h1 ; h1 = finalizeMurmur3 ( h1 ) ; h2 = finalizeMurmur3 ( h2 ) ; return h1 + h2 ; }
|
MurmurHash3 64 - bit
|
40,452
|
public static void murmur3 ( final BitVector bv , final long prefixLength , final long [ ] hh1 , final long [ ] hh2 , final long [ ] cc1 , final long cc2 [ ] , final long h [ ] ) { final int startStateWord = ( int ) ( prefixLength / ( 2 * Long . SIZE ) ) ; long precomputedUpTo = startStateWord * 2L * Long . SIZE ; long h1 = hh1 [ startStateWord ] ; long h2 = hh2 [ startStateWord ] ; long c1 = cc1 [ startStateWord ] ; long c2 = cc2 [ startStateWord ] ; long k1 , k2 ; if ( prefixLength > precomputedUpTo ) { if ( prefixLength - precomputedUpTo > Long . SIZE ) { k1 = bv . getLong ( precomputedUpTo , precomputedUpTo += Long . SIZE ) ; k2 = bv . getLong ( precomputedUpTo , prefixLength ) ; } else { k1 = bv . getLong ( precomputedUpTo , prefixLength ) ; k2 = 0 ; } k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; } h2 ^= prefixLength ; h1 += h2 ; h2 += h1 ; h1 = finalizeMurmur3 ( h1 ) ; h2 = finalizeMurmur3 ( h2 ) ; h1 += h2 ; h2 += h1 ; h [ 0 ] = h1 ; h [ 1 ] = h2 ; }
|
Constant - time MurmurHash3 128 - bit hashing for any prefix .
|
40,453
|
public static void murmur3 ( final BitVector bv , final long prefixLength , final long [ ] hh1 , final long [ ] hh2 , final long [ ] cc1 , final long cc2 [ ] , final long lcp , final long h [ ] ) { final int startStateWord = ( int ) ( Math . min ( lcp , prefixLength ) / ( 2 * Long . SIZE ) ) ; long from = startStateWord * 2L * Long . SIZE ; long h1 = hh1 [ startStateWord ] ; long h2 = hh2 [ startStateWord ] ; long c1 = cc1 [ startStateWord ] ; long c2 = cc2 [ startStateWord ] ; long k1 , k2 ; while ( prefixLength - from >= Long . SIZE * 2 ) { k1 = bv . getLong ( from , from + Long . SIZE ) ; k2 = bv . getLong ( from + Long . SIZE , from += 2 * Long . SIZE ) ; k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; } if ( prefixLength - from != 0 ) { if ( prefixLength - from > Long . SIZE ) { k1 = bv . getLong ( from , from + Long . SIZE ) ; k2 = bv . getLong ( from + Long . SIZE , prefixLength ) ; } else { k1 = bv . getLong ( from , prefixLength ) ; k2 = 0 ; } k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; } h2 ^= prefixLength ; h1 += h2 ; h2 += h1 ; h1 = finalizeMurmur3 ( h1 ) ; h2 = finalizeMurmur3 ( h2 ) ; h1 += h2 ; h2 += h1 ; h [ 0 ] = h1 ; h [ 1 ] = h2 ; }
|
Constant - time MurmurHash3 128 - bit hashing reusing precomputed state partially .
|
40,454
|
public static long [ ] [ ] preprocessMurmur3 ( final BitVector bv , final long seed ) { long from = 0 ; final long length = bv . length ( ) ; long h1 = 0x9368e53c2f6af274L ^ seed ; long h2 = 0x586dcd208f7cd3fdL ^ seed ; long c1 = 0x87c37b91114253d5L ; long c2 = 0x4cf5ad432745937fL ; final int wordLength = ( int ) ( length / ( 2 * Long . SIZE ) ) ; final long state [ ] [ ] = new long [ 4 ] [ wordLength + 1 ] ; long k1 , k2 ; int i = 0 ; state [ 0 ] [ i ] = h1 ; state [ 1 ] [ i ] = h2 ; state [ 2 ] [ i ] = c1 ; state [ 3 ] [ i ] = c2 ; for ( i ++ ; length - from >= Long . SIZE * 2 ; i ++ ) { k1 = bv . getLong ( from , from + Long . SIZE ) ; k2 = bv . getLong ( from + Long . SIZE , from += 2 * Long . SIZE ) ; k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 23 ) ; k1 *= c2 ; h1 ^= k1 ; h1 += h2 ; h2 = Long . rotateLeft ( h2 , 41 ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 23 ) ; k2 *= c1 ; h2 ^= k2 ; h2 += h1 ; h1 = h1 * 3 + 0x52dce729 ; h2 = h2 * 3 + 0x38495ab5 ; c1 = c1 * 5 + 0x7b7d159c ; c2 = c2 * 5 + 0x6bce6396 ; state [ 0 ] [ i ] = h1 ; state [ 1 ] [ i ] = h2 ; state [ 2 ] [ i ] = c1 ; state [ 3 ] [ i ] = c2 ; } return state ; }
|
Preprocesses a bit vector so that MurmurHash3 can be computed in constant time on all prefixes .
|
40,455
|
public static long [ ] preprocessSpooky4 ( final BitVector bv , final long seed ) { final long length = bv . length ( ) ; if ( length < Long . SIZE * 2 ) return null ; final long [ ] state = new long [ 4 * ( int ) ( length + Long . SIZE * 2 ) / ( 4 * Long . SIZE ) ] ; long h0 , h1 , h2 , h3 ; h0 = seed ; h1 = seed ; h2 = ARBITRARY_BITS ; h3 = ARBITRARY_BITS ; long remaining = length ; long pos = 0 ; int p = 0 ; for ( ; ; ) { h2 += bv . getLong ( pos + 0 * Long . SIZE , pos + 1 * Long . SIZE ) ; h3 += bv . getLong ( pos + 1 * Long . SIZE , pos + 2 * Long . SIZE ) ; h2 = Long . rotateLeft ( h2 , 50 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 52 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 30 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 41 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 54 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 48 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 38 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 37 ) ; h1 += h2 ; h3 ^= h1 ; h2 = Long . rotateLeft ( h2 , 62 ) ; h2 += h3 ; h0 ^= h2 ; h3 = Long . rotateLeft ( h3 , 34 ) ; h3 += h0 ; h1 ^= h3 ; h0 = Long . rotateLeft ( h0 , 5 ) ; h0 += h1 ; h2 ^= h0 ; h1 = Long . rotateLeft ( h1 , 36 ) ; h1 += h2 ; h3 ^= h1 ; state [ p + 0 ] = h0 ; state [ p + 1 ] = h1 ; state [ p + 2 ] = h2 ; state [ p + 3 ] = h3 ; p += 4 ; if ( remaining >= Long . SIZE * 6 ) { h0 += bv . getLong ( pos + 2 * Long . SIZE , pos + 3 * Long . SIZE ) ; h1 += bv . getLong ( pos + 3 * Long . SIZE , pos + 4 * Long . SIZE ) ; remaining -= 4 * Long . SIZE ; pos += 4 * Long . SIZE ; } else return state ; } }
|
Preprocesses a bit vector so that SpookyHash 4 - word - state can be computed in constant time on all prefixes .
|
40,456
|
public long getLongByTriple ( final long [ ] triple ) { if ( n == 0 ) return defRetValue ; final int [ ] e = new int [ 3 ] ; final int chunk = chunkShift == Long . SIZE ? 0 : ( int ) ( triple [ 0 ] >>> chunkShift ) ; final long chunkOffset = offset [ chunk ] ; HypergraphSorter . tripleToEdge ( triple , seed [ chunk ] , ( int ) ( offset [ chunk + 1 ] - chunkOffset ) , e ) ; if ( e [ 0 ] == - 1 ) return defRetValue ; final long result = rank ( chunkOffset + e [ ( int ) ( values . getLong ( e [ 0 ] + chunkOffset ) + values . getLong ( e [ 1 ] + chunkOffset ) + values . getLong ( e [ 2 ] + chunkOffset ) ) % 3 ] ) ; if ( signatureMask != 0 ) return result >= n || signatures . getLong ( result ) != ( triple [ 0 ] & signatureMask ) ? defRetValue : result ; return result < n ? result : defRetValue ; }
|
Low - level access to the output of this minimal perfect hash function .
|
40,457
|
private boolean sort ( ) { final int [ ] d = this . d ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Peeling hypergraph..." ) ; top = 0 ; for ( int i = 0 ; i < numVertices ; i ++ ) if ( d [ i ] == 1 ) peel ( i ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( top == numEdges ? "Peeling completed." : "Visit failed: peeled " + top + " edges out of " + numEdges + "." ) ; return top == numEdges ; }
|
Sorts the edges of a random 3 - hypergraph in &ldquo ; leaf peeling&rdquo ; order .
|
40,458
|
public LcpMonotoneMinimalPerfectHashFunction < T > build ( ) throws IOException { if ( built ) throw new IllegalStateException ( "This builder has been already used" ) ; built = true ; return new LcpMonotoneMinimalPerfectHashFunction < > ( keys , numKeys , transform , signatureWidth , tempDir ) ; }
|
Builds an LCP monotone minimal perfect hash function .
|
40,459
|
public void add ( final T o , final long value ) throws IOException { final long [ ] triple = new long [ 3 ] ; Hashes . spooky4 ( transform . toBitVector ( o ) , seed , triple ) ; add ( triple , value ) ; }
|
Adds an element to this store associating it with a specified value .
|
40,460
|
private void add ( final long [ ] triple , final long value ) throws IOException { final int chunk = ( int ) ( triple [ 0 ] >>> DISK_CHUNKS_SHIFT ) ; count [ chunk ] ++ ; checkedForDuplicates = false ; if ( DEBUG ) System . err . println ( "Adding " + Arrays . toString ( triple ) ) ; writeLong ( triple [ 0 ] , byteBuffer [ chunk ] , writableByteChannel [ chunk ] ) ; writeLong ( triple [ 1 ] , byteBuffer [ chunk ] , writableByteChannel [ chunk ] ) ; writeLong ( triple [ 2 ] , byteBuffer [ chunk ] , writableByteChannel [ chunk ] ) ; if ( hashMask == 0 ) writeLong ( value , byteBuffer [ chunk ] , writableByteChannel [ chunk ] ) ; if ( filteredSize != - 1 && ( filter == null || filter . evaluate ( triple ) ) ) filteredSize ++ ; if ( value2FrequencyMap != null ) value2FrequencyMap . addTo ( value , 1 ) ; size ++ ; }
|
Adds a triple to this store .
|
40,461
|
public void addAll ( final Iterator < ? extends T > elements , final LongIterator values , final boolean requiresValue2CountMap ) throws IOException { if ( pl != null ) { pl . expectedUpdates = - 1 ; pl . start ( "Adding elements..." ) ; } final long [ ] triple = new long [ 3 ] ; while ( elements . hasNext ( ) ) { Hashes . spooky4 ( transform . toBitVector ( elements . next ( ) ) , seed , triple ) ; add ( triple , values != null ? values . nextLong ( ) : filteredSize ) ; if ( pl != null ) pl . lightUpdate ( ) ; } if ( values != null && values . hasNext ( ) ) throw new IllegalStateException ( "The iterator on values contains more entries than the iterator on keys" ) ; if ( pl != null ) pl . done ( ) ; }
|
Adds the elements returned by an iterator to this store associating them with specified values possibly building the associated value frequency map .
|
40,462
|
public void addAll ( final Iterator < ? extends T > elements , final LongIterator values ) throws IOException { addAll ( elements , values , false ) ; }
|
Adds the elements returned by an iterator to this store associating them with specified values .
|
40,463
|
public void close ( ) throws IOException { if ( ! closed ) { LOGGER . debug ( "Wall clock for quicksort: " + Util . format ( quickSortWallTime / 1E9 ) + "s" ) ; closed = true ; for ( final WritableByteChannel channel : writableByteChannel ) channel . close ( ) ; for ( final File f : file ) f . delete ( ) ; } }
|
Closes this store disposing all associated resources .
|
40,464
|
public void reset ( final long seed ) throws IOException { if ( locked ) throw new IllegalStateException ( ) ; if ( DEBUG ) System . err . println ( "RESET(" + seed + ")" ) ; filteredSize = 0 ; this . seed = seed ; checkedForDuplicates = false ; Arrays . fill ( count , 0 ) ; for ( int i = 0 ; i < DISK_CHUNKS ; i ++ ) { writableByteChannel [ i ] . close ( ) ; byteBuffer [ i ] . clear ( ) ; writableByteChannel [ i ] = new FileOutputStream ( file [ i ] ) . getChannel ( ) ; } }
|
Resets this store using a new seed . All accumulated data are cleared and a new seed is reinstated .
|
40,465
|
public void checkAndRetry ( final Iterable < ? extends T > iterable , final LongIterable values ) throws IOException { final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator ( ) ; int duplicates = 0 ; for ( ; ; ) try { check ( ) ; break ; } catch ( final DuplicateException e ) { if ( duplicates ++ > 3 ) throw new IllegalArgumentException ( "The input list contains duplicates" ) ; LOGGER . warn ( "Found duplicate. Recomputing triples..." ) ; reset ( random . nextLong ( ) ) ; addAll ( iterable . iterator ( ) , values . iterator ( ) ) ; } checkedForDuplicates = true ; }
|
Checks that this store has no duplicate triples and try to rebuild if this fails to happen .
|
40,466
|
public LongBigList signatures ( final int signatureWidth , final ProgressLogger pl ) throws IOException { final LongBigList signatures = LongArrayBitVector . getInstance ( ) . asLongBigList ( signatureWidth ) ; final long signatureMask = - 1L >>> Long . SIZE - signatureWidth ; signatures . size ( size ( ) ) ; pl . expectedUpdates = size ( ) ; pl . itemsName = "signatures" ; pl . start ( "Signing..." ) ; for ( final ChunkedHashStore . Chunk chunk : this ) { final Iterator < long [ ] > chunkIterator = chunk . iterator ( ) ; for ( int i = chunk . size ( ) ; i -- != 0 ; ) { final long [ ] quadruple = chunkIterator . next ( ) ; signatures . set ( quadruple [ 3 ] , signatureMask & quadruple [ 0 ] ) ; pl . lightUpdate ( ) ; } } pl . done ( ) ; return signatures ; }
|
Generate a list of signatures using the lowest bits of the first hash in this store .
|
40,467
|
public int log2Chunks ( final int log2chunks ) { this . chunks = 1 << log2chunks ; diskChunkStep = ( int ) Math . max ( DISK_CHUNKS / chunks , 1 ) ; virtualDiskChunks = DISK_CHUNKS / diskChunkStep ; if ( DEBUG ) { System . err . print ( "Chunk sizes: " ) ; final double avg = filteredSize / ( double ) DISK_CHUNKS ; double var = 0 ; for ( int i = 0 ; i < DISK_CHUNKS ; i ++ ) { System . err . print ( i + ":" + count [ i ] + " " ) ; var += ( count [ i ] - avg ) * ( count [ i ] - avg ) ; } System . err . println ( ) ; System . err . println ( "Average: " + avg ) ; System . err . println ( "Variance: " + var / filteredSize ) ; } chunkShift = Long . SIZE - log2chunks ; LOGGER . debug ( "Number of chunks: " + chunks ) ; LOGGER . debug ( "Number of disk chunks: " + DISK_CHUNKS ) ; LOGGER . debug ( "Number of virtual disk chunks: " + virtualDiskChunks ) ; return chunkShift ; }
|
Sets the number of chunks .
|
40,468
|
public long [ ] select ( long rank , long [ ] dest , final int offset , final int length ) { if ( length == 0 ) return dest ; final long s = select ( rank ) ; dest [ offset ] = s ; int curr = ( int ) ( s / Long . SIZE ) ; long window = bits [ curr ] & - 1L << s ; window &= window - 1 ; for ( int i = 1 ; i < length ; i ++ ) { while ( window == 0 ) window = bits [ ++ curr ] ; dest [ offset + i ] = curr * Long . SIZE + Long . numberOfTrailingZeros ( window ) ; window &= window - 1 ; } return dest ; }
|
Performs a bulk select of consecutive ranks into a given array fragment .
|
40,469
|
public void add ( final Modulo2Equation equation ) { int i = 0 , j = 0 , k = 0 ; final int s = variables . size ( ) , t = equation . variables . size ( ) ; final int [ ] a = variables . elements ( ) , b = equation . variables . elements ( ) , result = new int [ s + t ] ; if ( t != 0 && s != 0 ) { for ( ; ; ) { if ( a [ i ] < b [ j ] ) { result [ k ++ ] = a [ i ++ ] ; if ( i == s ) break ; } else if ( a [ i ] > b [ j ] ) { result [ k ++ ] = b [ j ++ ] ; if ( j == t ) break ; } else { i ++ ; j ++ ; if ( i == s ) break ; if ( j == t ) break ; } } } while ( i < s ) result [ k ++ ] = a [ i ++ ] ; while ( j < t ) result [ k ++ ] = b [ j ++ ] ; c ^= equation . c ; variables . size ( k ) ; System . arraycopy ( result , 0 , variables . elements ( ) , 0 , k ) ; }
|
Adds the provided equation to this equation .
|
40,470
|
public static long scalarProduct ( final Modulo2Equation e , long [ ] solution ) { long sum = 0 ; for ( final IntListIterator iterator = e . variables . iterator ( ) ; iterator . hasNext ( ) ; ) sum ^= solution [ iterator . nextInt ( ) ] ; return sum ; }
|
Returns the modulo - 2 scalar product of the two provided bit vectors .
|
40,471
|
private static void next ( ) { final long t0 = s0 ; long t1 = s1 ; t1 ^= t0 ; s0 = Long . rotateLeft ( t0 , 55 ) ^ t1 ^ t1 << 14 ; s1 = Long . rotateLeft ( t1 , 36 ) ; }
|
55 - 14 - 36 63 x^128 + x^118 + x^117 + x^114 + x^112 + x^109 + x^108 + x^107 + x^106 + x^103 + x^102 + x^101 + x^99 + x^98 + x^96 + x^94 + x^93 + x^92 + x^91 + x^90 + x^89 + x^88 + x^85 + x^83 + x^80 + x^79 + x^78 + x^77 + x^76 + x^75 + x^71 + x^67 + x^65 + x^62 + x^60 + x^59 + x^58 + x^57 + x^56 + x^55 + x^54 + x^52 + x^50 + x^49 + x^46 + x^45 + x^42 + x^41 + x^40 + x^38 + x^37 + x^33 + x^31 + x^30 + x^29 + x^28 + x^23 + x^22 + x^21 + x^16 + x^15 + x^14 + 1
|
40,472
|
public Object convert ( String value , Class type ) { if ( isNullOrEmpty ( value ) ) { return null ; } if ( Character . isDigit ( value . charAt ( 0 ) ) ) { return resolveByOrdinal ( value , type ) ; } else { return resolveByName ( value , type ) ; } }
|
Enums are always final so I can suppress this warning safely
|
40,473
|
public void removeGeneratedClasses ( ) { ClassPool pool = ClassPool . getDefault ( ) ; for ( Class < ? > clazz : interfaces . values ( ) ) { CtClass ctClass = pool . getOrNull ( clazz . getName ( ) ) ; if ( ctClass != null ) { ctClass . detach ( ) ; logger . debug ( "class {} is detached" , clazz . getName ( ) ) ; } } }
|
Remove generated classes when application stops due reload context issues .
|
40,474
|
private boolean hasConstraints ( ControllerMethod controllerMethod ) { Method method = controllerMethod . getMethod ( ) ; if ( method . getParameterTypes ( ) . length == 0 ) { logger . debug ( "method {} has no parameters, skipping" , controllerMethod ) ; return false ; } BeanDescriptor bean = bvalidator . getConstraintsForClass ( controllerMethod . getController ( ) . getType ( ) ) ; if ( bean == null ) { return false ; } MethodDescriptor descriptor = bean . getConstraintsForMethod ( method . getName ( ) , method . getParameterTypes ( ) ) ; return descriptor != null && descriptor . hasConstrainedParameters ( ) ; }
|
Only accepts if method isn t parameterless and have at least one constraint .
|
40,475
|
protected String extractCategory ( ValuedParameter [ ] params , ConstraintViolation < Object > violation ) { Iterator < Node > path = violation . getPropertyPath ( ) . iterator ( ) ; Node method = path . next ( ) ; logger . debug ( "Constraint violation on method {}: {}" , method , violation ) ; StringBuilder cat = new StringBuilder ( ) ; cat . append ( params [ path . next ( ) . as ( ParameterNode . class ) . getParameterIndex ( ) ] . getName ( ) ) ; while ( path . hasNext ( ) ) { cat . append ( "." ) . append ( path . next ( ) ) ; } return cat . toString ( ) ; }
|
Returns the category for this constraint violation . By default the category returned is the full path for property . You can override this method if you prefer another strategy .
|
40,476
|
protected String extractInternacionalizedMessage ( ConstraintViolation < Object > v ) { return interpolator . interpolate ( v . getMessageTemplate ( ) , new BeanValidatorContext ( v ) , locale . get ( ) ) ; }
|
Returns the internacionalized message for this constraint violation .
|
40,477
|
public void intercept ( SimpleInterceptorStack stack ) { User current = info . getUser ( ) ; try { dao . refresh ( current ) ; } catch ( Exception e ) { } if ( current == null ) { I18nMessage msg = new I18nMessage ( "user" , "not_logged_user" ) ; msg . setBundle ( bundle ) ; result . include ( "errors" , asList ( msg ) ) ; result . redirectTo ( HomeController . class ) . login ( ) ; return ; } stack . next ( ) ; }
|
Intercepts the request and checks if there is a user logged in .
|
40,478
|
public void registerComponents ( XStream xstream ) { for ( Converter converter : converters ) { xstream . registerConverter ( converter ) ; logger . debug ( "registered Xstream converter for {}" , converter . getClass ( ) . getName ( ) ) ; } for ( SingleValueConverter converter : singleValueConverters ) { xstream . registerConverter ( converter ) ; logger . debug ( "registered Xstream converter for {}" , converter . getClass ( ) . getName ( ) ) ; } }
|
Method used to register all the XStream converters scanned to a XStream instance
|
40,479
|
@ Path ( "/musics/list/json" ) public void showAllMusicsAsJSON ( ) { result . use ( json ( ) ) . from ( musicDao . listAll ( ) ) . serialize ( ) ; }
|
Show all list of registered musics in json format
|
40,480
|
@ Path ( "/musics/list/xml" ) public void showAllMusicsAsXML ( ) { result . use ( xml ( ) ) . from ( musicDao . listAll ( ) ) . serialize ( ) ; }
|
Show all list of registered musics in xml format
|
40,481
|
@ Path ( "/musics/list/http" ) public void showAllMusicsAsHTTP ( ) { result . use ( http ( ) ) . body ( "<p class=\"content\">" + musicDao . listAll ( ) . toString ( ) + "</p>" ) ; }
|
Show all list of registered musics in http format
|
40,482
|
public Map < String , Collection < Message > > getGrouped ( ) { if ( grouped == null ) { grouped = FluentIterable . from ( delegate ) . index ( byCategoryMapping ( ) ) . asMap ( ) ; } return grouped ; }
|
Return messages grouped by category . This method can useful if you want to get messages for a specific category .
|
40,483
|
public MessageListItem from ( final String category ) { List < String > messages = FluentIterable . from ( delegate ) . filter ( byCategory ( category ) ) . transform ( toMessageString ( ) ) . toList ( ) ; return new MessageListItem ( messages ) ; }
|
Return all messages by category . This method can useful if you want to get messages from a specific category .
|
40,484
|
protected String extractControllerNameFrom ( Class < ? > type ) { String prefix = extractPrefix ( type ) ; if ( isNullOrEmpty ( prefix ) ) { String baseName = StringUtils . lowercaseFirst ( type . getSimpleName ( ) ) ; if ( baseName . endsWith ( "Controller" ) ) { return "/" + baseName . substring ( 0 , baseName . lastIndexOf ( "Controller" ) ) ; } return "/" + baseName ; } else { return prefix ; } }
|
You can override this method for use a different convention for your controller name given a type
|
40,485
|
protected Route getRouteStrategy ( ControllerMethod controllerMethod , Parameter [ ] parameterNames ) { return new FixedMethodStrategy ( originalUri , controllerMethod , this . supportedMethods , builder . build ( ) , priority , parameterNames ) ; }
|
Override this method to change the default Route implementation
|
40,486
|
public String buildGroupName ( Boolean doValidation ) { NameValidation . notEmpty ( appName , "appName" ) ; if ( doValidation ) { validateNames ( appName , stack , countries , devPhase , hardware , partners , revision , usedBy , redBlackSwap , zoneVar ) ; if ( detail != null && ! detail . isEmpty ( ) && ! NameValidation . checkDetail ( detail ) ) { throw new IllegalArgumentException ( "(Use alphanumeric characters only)" ) ; } } String labeledVars = "" ; labeledVars += generateIfSpecified ( NameConstants . COUNTRIES_KEY , countries ) ; labeledVars += generateIfSpecified ( NameConstants . DEV_PHASE_KEY , devPhase ) ; labeledVars += generateIfSpecified ( NameConstants . HARDWARE_KEY , hardware ) ; labeledVars += generateIfSpecified ( NameConstants . PARTNERS_KEY , partners ) ; labeledVars += generateIfSpecified ( NameConstants . REVISION_KEY , revision ) ; labeledVars += generateIfSpecified ( NameConstants . USED_BY_KEY , usedBy ) ; labeledVars += generateIfSpecified ( NameConstants . RED_BLACK_SWAP_KEY , redBlackSwap ) ; labeledVars += generateIfSpecified ( NameConstants . ZONE_KEY , zoneVar ) ; String result = combineAppStackDetail ( appName , stack , detail ) + labeledVars ; return result ; }
|
Construct and return the name of the auto scaling group .
|
40,487
|
public static String notEmpty ( String value , String variableName ) { if ( value == null ) { throw new NullPointerException ( "ERROR: Trying to use String with null " + variableName ) ; } if ( value . isEmpty ( ) ) { throw new IllegalArgumentException ( "ERROR: Illegal empty string for " + variableName ) ; } return value ; }
|
Validates if provided value is non - null and non - empty .
|
40,488
|
public static Boolean usesReservedFormat ( String name ) { return checkMatch ( name , PUSH_FORMAT_PATTERN ) || checkMatch ( name , LABELED_VARIABLE_PATTERN ) ; }
|
Determines whether a name ends with the reserved format - v000 where 0 represents any digit or starts with the reserved format z0 where z is any letter or contains a hyphen - separated token that starts with the z0 format .
|
40,489
|
public static < T > Map < String , List < T > > groupByClusterName ( List < T > inputs , AsgNameProvider < T > nameProvider ) { Map < String , List < T > > clusterNamesToAsgs = new HashMap < String , List < T > > ( ) ; for ( T input : inputs ) { String clusterName = Names . parseName ( nameProvider . extractAsgName ( input ) ) . getCluster ( ) ; if ( ! clusterNamesToAsgs . containsKey ( clusterName ) ) { clusterNamesToAsgs . put ( clusterName , new ArrayList < T > ( ) ) ; } clusterNamesToAsgs . get ( clusterName ) . add ( input ) ; } return clusterNamesToAsgs ; }
|
Groups a list of ASG related objects by cluster name .
|
40,490
|
public static Map < String , List < String > > groupAsgNamesByClusterName ( List < String > asgNames ) { return groupByClusterName ( asgNames , new AsgNameProvider < String > ( ) { public String extractAsgName ( String asgName ) { return asgName ; } } ) ; }
|
Groups a list of ASG names by cluster name .
|
40,491
|
public static AppVersion parseName ( String amiName ) { if ( amiName == null ) { return null ; } Matcher matcher = APP_VERSION_PATTERN . matcher ( amiName ) ; if ( ! matcher . matches ( ) ) { return null ; } AppVersion parsedName = new AppVersion ( ) ; parsedName . packageName = matcher . group ( 1 ) ; parsedName . version = matcher . group ( 2 ) ; boolean buildFirst = matcher . group ( 3 ) != null && matcher . group ( 3 ) . startsWith ( "h" ) ; String buildString = matcher . group ( buildFirst ? 3 : 4 ) ; parsedName . buildNumber = buildString != null ? buildString . substring ( 1 ) : null ; parsedName . commit = matcher . group ( buildFirst ? 4 : 3 ) ; parsedName . buildJobName = matcher . group ( 5 ) ; return parsedName ; }
|
Parses the appversion tag into its component parts .
|
40,492
|
public static BaseAmiInfo parseDescription ( String imageDescription ) { BaseAmiInfo info = new BaseAmiInfo ( ) ; if ( imageDescription == null ) { return info ; } info . baseAmiId = extractBaseAmiId ( imageDescription ) ; info . baseAmiName = extractBaseAmiName ( imageDescription ) ; if ( info . baseAmiName != null ) { Matcher dateMatcher = AMI_DATE_PATTERN . matcher ( info . baseAmiName ) ; if ( dateMatcher . matches ( ) ) { try { info . baseAmiDate = new SimpleDateFormat ( "yyyyMMdd" ) . parse ( dateMatcher . group ( 1 ) ) ; } catch ( Exception ignored ) { } } } return info ; }
|
Parse an AMI description into its component parts .
|
40,493
|
public boolean isExistingID ( ) { try { String userId = getPost ( ) . getString ( Defines . Jsonkey . Identity . getKey ( ) ) ; return ( userId != null && userId . equals ( prefHelper_ . getIdentity ( ) ) ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; return false ; } }
|
Return true if the user id provided for user identification is the same as existing id
|
40,494
|
public ContentMetadata addCustomMetadata ( String key , String value ) { customMetadata . put ( key , value ) ; return this ; }
|
Adds any custom metadata associated with the qualifying content item
|
40,495
|
public void setDialogWindowAttributes ( ) { requestWindowFeature ( Window . FEATURE_NO_TITLE ) ; getWindow ( ) . setBackgroundDrawable ( new ColorDrawable ( Color . TRANSPARENT ) ) ; getWindow ( ) . addFlags ( WindowManager . LayoutParams . FLAG_DIM_BEHIND ) ; getWindow ( ) . addFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN ) ; WindowManager . LayoutParams lp = new WindowManager . LayoutParams ( ) ; lp . copyFrom ( getWindow ( ) . getAttributes ( ) ) ; lp . width = WindowManager . LayoutParams . MATCH_PARENT ; lp . height = WindowManager . LayoutParams . MATCH_PARENT ; lp . gravity = Gravity . BOTTOM ; lp . dimAmount = 0.8f ; getWindow ( ) . setAttributes ( lp ) ; getWindow ( ) . setWindowAnimations ( android . R . anim . slide_in_left ) ; setCanceledOnTouchOutside ( true ) ; }
|
Set the window attributes for the invite dialog .
|
40,496
|
static DeviceInfo initialize ( Context context ) { if ( thisInstance_ == null ) { thisInstance_ = new DeviceInfo ( context ) ; } return thisInstance_ ; }
|
Initialize the singleton instance for deviceInfo class
|
40,497
|
void updateRequestWithV1Params ( JSONObject requestObj ) { try { SystemObserver . UniqueId hardwareID = getHardwareID ( ) ; if ( ! isNullOrEmptyOrBlank ( hardwareID . getId ( ) ) ) { requestObj . put ( Defines . Jsonkey . HardwareID . getKey ( ) , hardwareID . getId ( ) ) ; requestObj . put ( Defines . Jsonkey . IsHardwareIDReal . getKey ( ) , hardwareID . isReal ( ) ) ; } String brandName = SystemObserver . getPhoneBrand ( ) ; if ( ! isNullOrEmptyOrBlank ( brandName ) ) { requestObj . put ( Defines . Jsonkey . Brand . getKey ( ) , brandName ) ; } String modelName = SystemObserver . getPhoneModel ( ) ; if ( ! isNullOrEmptyOrBlank ( modelName ) ) { requestObj . put ( Defines . Jsonkey . Model . getKey ( ) , modelName ) ; } DisplayMetrics displayMetrics = SystemObserver . getScreenDisplay ( context_ ) ; requestObj . put ( Defines . Jsonkey . ScreenDpi . getKey ( ) , displayMetrics . densityDpi ) ; requestObj . put ( Defines . Jsonkey . ScreenHeight . getKey ( ) , displayMetrics . heightPixels ) ; requestObj . put ( Defines . Jsonkey . ScreenWidth . getKey ( ) , displayMetrics . widthPixels ) ; requestObj . put ( Defines . Jsonkey . WiFi . getKey ( ) , SystemObserver . getWifiConnected ( context_ ) ) ; requestObj . put ( Defines . Jsonkey . UIMode . getKey ( ) , SystemObserver . getUIMode ( context_ ) ) ; String osName = SystemObserver . getOS ( ) ; if ( ! isNullOrEmptyOrBlank ( osName ) ) { requestObj . put ( Defines . Jsonkey . OS . getKey ( ) , osName ) ; } requestObj . put ( Defines . Jsonkey . OSVersion . getKey ( ) , SystemObserver . getOSVersion ( ) ) ; String countryCode = SystemObserver . getISO2CountryCode ( ) ; if ( ! TextUtils . isEmpty ( countryCode ) ) { requestObj . put ( Defines . Jsonkey . Country . getKey ( ) , countryCode ) ; } String languageCode = SystemObserver . getISO2LanguageCode ( ) ; if ( ! TextUtils . isEmpty ( languageCode ) ) { requestObj . put ( Defines . Jsonkey . Language . getKey ( ) , languageCode ) ; } String localIpAddr = SystemObserver . getLocalIPAddress ( ) ; if ( ( ! TextUtils . isEmpty ( localIpAddr ) ) ) { requestObj . put ( Defines . Jsonkey . LocalIP . getKey ( ) , localIpAddr ) ; } } catch ( JSONException ignore ) { } }
|
Update the given server request JSON with device params
|
40,498
|
void updateLinkReferrerParams ( ) { String linkIdentifier = prefHelper_ . getLinkClickIdentifier ( ) ; if ( ! linkIdentifier . equals ( PrefHelper . NO_STRING_VALUE ) ) { try { getPost ( ) . put ( Defines . Jsonkey . LinkIdentifier . getKey ( ) , linkIdentifier ) ; getPost ( ) . put ( Defines . Jsonkey . FaceBookAppLinkChecked . getKey ( ) , prefHelper_ . getIsAppLinkTriggeredInit ( ) ) ; } catch ( JSONException ignore ) { } } String googleSearchInstallIdentifier = prefHelper_ . getGoogleSearchInstallIdentifier ( ) ; if ( ! googleSearchInstallIdentifier . equals ( PrefHelper . NO_STRING_VALUE ) ) { try { getPost ( ) . put ( Defines . Jsonkey . GoogleSearchInstallReferrer . getKey ( ) , googleSearchInstallIdentifier ) ; } catch ( JSONException ignore ) { } } String googlePlayReferrer = prefHelper_ . getGooglePlayReferrer ( ) ; if ( ! googlePlayReferrer . equals ( PrefHelper . NO_STRING_VALUE ) ) { try { getPost ( ) . put ( Defines . Jsonkey . GooglePlayInstallReferrer . getKey ( ) , googlePlayReferrer ) ; } catch ( JSONException ignore ) { } } if ( prefHelper_ . isFullAppConversion ( ) ) { try { getPost ( ) . put ( Defines . Jsonkey . AndroidAppLinkURL . getKey ( ) , prefHelper_ . getAppLink ( ) ) ; getPost ( ) . put ( Defines . Jsonkey . IsFullAppConv . getKey ( ) , true ) ; } catch ( JSONException ignore ) { } } }
|
Update link referrer params like play store referrer params For link clicked installs link click id is updated when install referrer broadcast is received Also update any googleSearchReferrer available with play store referrer broadcast
|
40,499
|
static String getPackageName ( Context context ) { String packageName = "" ; if ( context != null ) { try { final PackageInfo packageInfo = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) ; packageName = packageInfo . packageName ; } catch ( Exception e ) { PrefHelper . LogException ( "Error obtaining PackageName" , e ) ; } } return packageName ; }
|
Get the package name for this application .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.