idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
23,600 | public static int days ( EvaluationContext ctx , Object endDate , Object startDate ) { return datedif ( ctx , startDate , endDate , "d" ) ; } | Returns the number of days between two dates . |
23,601 | public static Temporal edate ( EvaluationContext ctx , Object date , Object months ) { Temporal dateOrDateTime = Conversions . toDateOrDateTime ( date , ctx ) ; int _months = Conversions . toInteger ( months , ctx ) ; return dateOrDateTime . plus ( _months , ChronoUnit . MONTHS ) ; } | Moves a date by the given number of months |
23,602 | public static OffsetTime time ( EvaluationContext ctx , Object hours , Object minutes , Object seconds ) { int _hours = Conversions . toInteger ( hours , ctx ) ; int _minutes = Conversions . toInteger ( minutes , ctx ) ; int _seconds = Conversions . toInteger ( seconds , ctx ) ; LocalTime localTime = LocalTime . of ( _hours , _minutes , _seconds ) ; return ZonedDateTime . of ( LocalDate . now ( ctx . getTimezone ( ) ) , localTime , ctx . getTimezone ( ) ) . toOffsetDateTime ( ) . toOffsetTime ( ) ; } | Defines a time value |
23,603 | public static OffsetTime timevalue ( EvaluationContext ctx , Object text ) { return Conversions . toTime ( text , ctx ) ; } | Converts time stored in text to an actual time |
23,604 | public static LocalDate today ( EvaluationContext ctx ) { return ctx . getNow ( ) . atZone ( ctx . getTimezone ( ) ) . toLocalDate ( ) ; } | Returns the current date |
23,605 | public static int year ( EvaluationContext ctx , Object date ) { return Conversions . toDateOrDateTime ( date , ctx ) . get ( ChronoField . YEAR ) ; } | Returns only the year of a date |
23,606 | public static BigDecimal abs ( EvaluationContext ctx , Object number ) { return Conversions . toDecimal ( number , ctx ) . abs ( ) ; } | Returns the absolute value of a number |
23,607 | public static BigDecimal exp ( EvaluationContext ctx , Object number ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; return ExpressionUtils . decimalPow ( E , _number ) ; } | Returns e raised to the power of number |
23,608 | public static int _int ( EvaluationContext ctx , Object number ) { return Conversions . toDecimal ( number , ctx ) . setScale ( 0 , RoundingMode . FLOOR ) . intValue ( ) ; } | Rounds a number down to the nearest integer |
23,609 | public static BigDecimal min ( EvaluationContext ctx , Object ... args ) { if ( args . length == 0 ) { throw new RuntimeException ( "Wrong number of arguments" ) ; } BigDecimal result = null ; for ( Object arg : args ) { BigDecimal _arg = Conversions . toDecimal ( arg , ctx ) ; result = result != null ? _arg . min ( result ) : _arg ; } return result ; } | Returns the minimum of all arguments |
23,610 | public static BigDecimal mod ( EvaluationContext ctx , Object number , Object divisor ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; BigDecimal _divisor = Conversions . toDecimal ( divisor , ctx ) ; return _number . subtract ( _divisor . multiply ( new BigDecimal ( _int ( ctx , _number . divide ( _divisor , 10 , RoundingMode . HALF_UP ) ) ) ) ) ; } | Returns the remainder after number is divided by divisor |
23,611 | public static BigDecimal power ( EvaluationContext ctx , Object number , Object power ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; BigDecimal _power = Conversions . toDecimal ( power , ctx ) ; return ExpressionUtils . decimalPow ( _number , _power ) ; } | Returns the result of a number raised to a power |
23,612 | public static int randbetween ( EvaluationContext ctx , Object bottom , Object top ) { int _bottom = Conversions . toInteger ( bottom , ctx ) ; int _top = Conversions . toInteger ( top , ctx ) ; return ( int ) ( Math . random ( ) * ( _top + 1 - _bottom ) ) + _bottom ; } | Returns a random integer number between the numbers you specify |
23,613 | public static BigDecimal round ( EvaluationContext ctx , Object number , Object numDigits ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; int _numDigits = Conversions . toInteger ( numDigits , ctx ) ; return ExpressionUtils . decimalRound ( _number , _numDigits , RoundingMode . HALF_UP ) ; } | Rounds a number to a specified number of digits |
23,614 | public static BigDecimal rounddown ( EvaluationContext ctx , Object number , Object numDigits ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; int _numDigits = Conversions . toInteger ( numDigits , ctx ) ; return ExpressionUtils . decimalRound ( _number , _numDigits , RoundingMode . DOWN ) ; } | Rounds a number down toward zero |
23,615 | public static BigDecimal roundup ( EvaluationContext ctx , Object number , Object numDigits ) { BigDecimal _number = Conversions . toDecimal ( number , ctx ) ; int _numDigits = Conversions . toInteger ( numDigits , ctx ) ; return ExpressionUtils . decimalRound ( _number , _numDigits , RoundingMode . UP ) ; } | Rounds a number up away from zero |
23,616 | public static BigDecimal sum ( EvaluationContext ctx , Object ... args ) { if ( args . length == 0 ) { throw new RuntimeException ( "Wrong number of arguments" ) ; } BigDecimal result = BigDecimal . ZERO ; for ( Object arg : args ) { result = result . add ( Conversions . toDecimal ( arg , ctx ) ) ; } return result ; } | Returns the sum of all arguments |
23,617 | public static int trunc ( EvaluationContext ctx , Object number ) { return Conversions . toDecimal ( number , ctx ) . setScale ( 0 , RoundingMode . DOWN ) . intValue ( ) ; } | Truncates a number to an integer by removing the fractional part of the number |
23,618 | public static boolean and ( EvaluationContext ctx , Object ... args ) { for ( Object arg : args ) { if ( ! Conversions . toBoolean ( arg , ctx ) ) { return false ; } } return true ; } | Returns TRUE if and only if all its arguments evaluate to TRUE |
23,619 | public static Object _if ( EvaluationContext ctx , Object logicalTest , @ IntegerDefault ( 0 ) Object valueIfTrue , @ BooleanDefault ( false ) Object valueIfFalse ) { return Conversions . toBoolean ( logicalTest , ctx ) ? valueIfTrue : valueIfFalse ; } | Returns one value if the condition evaluates to TRUE and another value if it evaluates to FALSE |
23,620 | public ApiResponse < ModelApiResponse > pingWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = pingValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < ModelApiResponse > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Check connection Return 200 if user is authenticated otherwise 403 |
23,621 | public ApiResponse < Object > retrievePCTokenUsingPOSTWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = retrievePCTokenUsingPOSTValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < Object > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarReturnType ) ; } | Retrieve PC token Returns PC token |
23,622 | public static String field ( EvaluationContext ctx , Object text , Object index , @ StringDefault ( " " ) Object delimiter ) { String _text = Conversions . toString ( text , ctx ) ; int _index = Conversions . toInteger ( index , ctx ) ; String _delimiter = Conversions . toString ( delimiter , ctx ) ; String [ ] splits = StringUtils . splitByWholeSeparator ( _text , _delimiter ) ; if ( _index < 1 ) { throw new RuntimeException ( "Field index cannot be less than 1" ) ; } if ( _index <= splits . length ) { return splits [ _index - 1 ] ; } else { return "" ; } } | Reference a field in string separated by a delimiter |
23,623 | public static String first_word ( EvaluationContext ctx , Object text ) { return word ( ctx , text , 1 , false ) ; } | Returns the first word in the given text string |
23,624 | public static String percent ( EvaluationContext ctx , Object number ) { BigDecimal percent = Conversions . toDecimal ( number , ctx ) . multiply ( new BigDecimal ( 100 ) ) ; return Conversions . toInteger ( percent , ctx ) + "%" ; } | Formats a number as a percentage |
23,625 | public static BigDecimal epoch ( EvaluationContext ctx , Object datetime ) { Instant instant = Conversions . toDateTime ( datetime , ctx ) . toInstant ( ) ; BigDecimal nanos = new BigDecimal ( instant . getEpochSecond ( ) * 1000000000 + instant . getNano ( ) ) ; return nanos . divide ( new BigDecimal ( 1000000000 ) ) ; } | Converts the given date to the number of nanoseconds since January 1st 1970 UTC |
23,626 | public static String read_digits ( EvaluationContext ctx , Object text ) { String _text = Conversions . toString ( text , ctx ) . trim ( ) ; if ( StringUtils . isEmpty ( _text ) ) { return "" ; } if ( _text . startsWith ( "+" ) ) { _text = _text . substring ( 1 ) ; } if ( _text . length ( ) == 9 ) { return StringUtils . join ( _text . substring ( 0 , 3 ) . toCharArray ( ) , ' ' ) + " , " + StringUtils . join ( _text . substring ( 3 , 5 ) . toCharArray ( ) , ' ' ) + " , " + StringUtils . join ( _text . substring ( 5 ) . toCharArray ( ) , ' ' ) ; } else if ( _text . length ( ) % 3 == 0 && _text . length ( ) > 3 ) { List < String > chunks = chunk ( _text , 3 ) ; return StringUtils . join ( StringUtils . join ( chunks , ',' ) . toCharArray ( ) , ' ' ) ; } else if ( _text . length ( ) % 4 == 0 ) { List < String > chunks = chunk ( _text , 4 ) ; return StringUtils . join ( StringUtils . join ( chunks , ',' ) . toCharArray ( ) , ' ' ) ; } else { return StringUtils . join ( _text . toCharArray ( ) , ',' ) ; } } | Formats digits in text for reading in TTS |
23,627 | public static String remove_first_word ( EvaluationContext ctx , Object text ) { String _text = StringUtils . stripStart ( Conversions . toString ( text , ctx ) , null ) ; String firstWord = first_word ( ctx , _text ) ; if ( StringUtils . isNotEmpty ( firstWord ) ) { return StringUtils . stripStart ( _text . substring ( firstWord . length ( ) ) , null ) ; } else { return "" ; } } | Removes the first word from the given text string |
23,628 | public static String word ( EvaluationContext ctx , Object text , Object number , @ BooleanDefault ( false ) Object bySpaces ) { return word_slice ( ctx , text , number , Conversions . toInteger ( number , ctx ) + 1 , bySpaces ) ; } | Extracts the nth word from the given text string |
23,629 | public static int word_count ( EvaluationContext ctx , Object text , @ BooleanDefault ( false ) Object bySpaces ) { String _text = Conversions . toString ( text , ctx ) ; boolean _bySpaces = Conversions . toBoolean ( bySpaces , ctx ) ; return getWords ( _text , _bySpaces ) . size ( ) ; } | Returns the number of words in the given text string |
23,630 | public static String word_slice ( EvaluationContext ctx , Object text , Object start , @ IntegerDefault ( 0 ) Object stop , @ BooleanDefault ( false ) Object bySpaces ) { String _text = Conversions . toString ( text , ctx ) ; int _start = Conversions . toInteger ( start , ctx ) ; Integer _stop = Conversions . toInteger ( stop , ctx ) ; boolean _bySpaces = Conversions . toBoolean ( bySpaces , ctx ) ; if ( _start == 0 ) { throw new RuntimeException ( "Start word cannot be zero" ) ; } else if ( _start > 0 ) { _start -= 1 ; } if ( _stop == 0 ) { _stop = null ; } else if ( _stop > 0 ) { _stop -= 1 ; } List < String > words = getWords ( _text , _bySpaces ) ; List < String > selection = ExpressionUtils . slice ( words , _start , _stop ) ; return StringUtils . join ( selection , ' ' ) ; } | Extracts a substring spanning from start up to but not - including stop |
23,631 | public static String format_date ( EvaluationContext ctx , Object text ) { ZonedDateTime _dt = Conversions . toDateTime ( text , ctx ) . withZoneSameInstant ( ctx . getTimezone ( ) ) ; return ctx . getDateFormatter ( true ) . format ( _dt ) ; } | Formats a date according to the default org format |
23,632 | public static String regex_group ( EvaluationContext ctx , Object text , Object pattern , Object groupNum ) { String _text = Conversions . toString ( text , ctx ) ; String _pattern = Conversions . toString ( pattern , ctx ) ; int _groupNum = Conversions . toInteger ( groupNum , ctx ) ; try { int flags = Pattern . CASE_INSENSITIVE | Pattern . MULTILINE ; Pattern regex = Pattern . compile ( _pattern , flags ) ; Matcher matcher = regex . matcher ( _text ) ; if ( matcher . find ( ) ) { if ( _groupNum < 0 || _groupNum > matcher . groupCount ( ) ) { throw new RuntimeException ( "No such matching group " + _groupNum ) ; } return matcher . group ( _groupNum ) ; } } catch ( PatternSyntaxException ignored ) { } return "" ; } | Tries to match the text with the given pattern and returns the value of matching group |
23,633 | private static List < String > getWords ( String text , boolean bySpaces ) { if ( bySpaces ) { List < String > words = new ArrayList < > ( ) ; for ( String split : text . split ( "\\s+" ) ) { if ( StringUtils . isNotEmpty ( split ) ) { words . add ( split ) ; } } return words ; } else { return Arrays . asList ( ExpressionUtils . tokenize ( text ) ) ; } } | Helper function which splits the given text string into words . If by_spaces is false then text like 01 - 02 - 2014 will be split into 3 separate words . For backwards compatibility this is the default for all expression functions . |
23,634 | private static List < String > chunk ( String text , int size ) { List < String > chunks = new ArrayList < > ( ) ; for ( int i = 0 ; i < text . length ( ) ; i += size ) { chunks . add ( StringUtils . substring ( text , i , i + size ) ) ; } return chunks ; } | Splits a string into equally sized chunks |
23,635 | public CorsHeaderPlugin flag ( String flagValue ) { if ( isRegistered ( ) ) throw new UnsupportedOperationException ( "CorsHeaderPlugin.flag(String) must be called before register()" ) ; if ( ! flags . contains ( flagValue ) ) { flags . add ( flagValue ) ; } return this ; } | Set a flag on the automatically generated OPTIONS route for pre - flight CORS requests . |
23,636 | private void addPreflightOptionsRequestSupport ( RestExpress server , CorsOptionsController corsOptionsController ) { RouteBuilder rb ; for ( String pattern : methodsByPattern . keySet ( ) ) { rb = server . uri ( pattern , corsOptionsController ) . action ( "options" , HttpMethod . OPTIONS ) . noSerialization ( ) . flag ( Flags . Auth . PUBLIC_ROUTE ) . flag ( Flags . Auth . NO_AUTHORIZATION ) ; for ( String flag : flags ) { rb . flag ( flag ) ; } for ( Entry < String , Object > entry : parameters . entrySet ( ) ) { rb . parameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } routeBuilders . add ( rb ) ; } } | Add an OPTIONS method supported on all routes for the pre - flight CORS request . |
23,637 | public void process ( Request request ) { String correlationId = request . getHeader ( CORRELATION_ID ) ; if ( correlationId == null ) { correlationId = UUID . randomUUID ( ) . toString ( ) ; } RequestContext . put ( CORRELATION_ID , correlationId ) ; request . addHeader ( CORRELATION_ID , correlationId ) ; } | Preprocessor method to pull the Correlation - Id header or assign one as well as placing it in the RequestContext . |
23,638 | public void process ( Request request , Response response ) { if ( ! response . hasHeader ( CORRELATION_ID ) ) { response . addHeader ( CORRELATION_ID , request . getHeader ( CORRELATION_ID ) ) ; } } | Postprocessor method that assigns the Correlation - Id from the request to a header on the Response . |
23,639 | protected void extractBundleContent ( String bundleRootPath , String toDirRoot ) throws IOException { File toDir = new File ( toDirRoot ) ; if ( ! toDir . isDirectory ( ) ) { throw new RuntimeException ( "[" + toDir . getAbsolutePath ( ) + "] is not a valid directory or does not exist!" ) ; } toDir = new File ( toDir , bundle . getSymbolicName ( ) ) ; toDir = new File ( toDir , bundle . getVersion ( ) . toString ( ) ) ; FileUtils . forceMkdir ( toDir ) ; bundleExtractDir = toDir ; Enumeration < String > entryPaths = bundle . getEntryPaths ( bundleRootPath ) ; if ( entryPaths != null ) { while ( entryPaths . hasMoreElements ( ) ) { extractContent ( bundleRootPath , entryPaths . nextElement ( ) , bundleExtractDir ) ; } } } | Extracts content from the bundle to a directory . |
23,640 | protected void handleAnotherVersionAtStartup ( Bundle bundle ) throws BundleException { Version myVersion = this . bundle . getVersion ( ) ; Version otherVersion = bundle . getVersion ( ) ; if ( myVersion . compareTo ( otherVersion ) > 0 ) { handleNewerVersionAtStartup ( bundle ) ; } else { handleOlderVersionAtStartup ( bundle ) ; } } | Called when another version of this bundle is found in the bundle context . |
23,641 | public long getId ( final String agent ) { try { return worker . getId ( agent ) ; } catch ( final InvalidUserAgentError e ) { LOGGER . error ( "Invalid user agent ({})" , agent ) ; throw new SnowizardException ( Response . Status . BAD_REQUEST , "Invalid User-Agent header" , e ) ; } catch ( final InvalidSystemClock e ) { LOGGER . error ( "Invalid system clock" , e ) ; throw new SnowizardException ( Response . Status . INTERNAL_SERVER_ERROR , e . getMessage ( ) , e ) ; } } | Get a new ID and handle any thrown exceptions |
23,642 | @ Produces ( MediaType . TEXT_PLAIN ) @ CacheControl ( mustRevalidate = true , noCache = true , noStore = true ) public String getIdAsString ( @ HeaderParam ( HttpHeaders . USER_AGENT ) final String agent ) { return String . valueOf ( getId ( agent ) ) ; } | Get a new ID as plain text |
23,643 | @ JSONP ( callback = "callback" , queryParam = "callback" ) @ Produces ( { MediaType . APPLICATION_JSON , MediaTypeAdditional . APPLICATION_JAVASCRIPT } ) @ CacheControl ( mustRevalidate = true , noCache = true , noStore = true ) public Id getIdAsJSON ( @ HeaderParam ( HttpHeaders . USER_AGENT ) final String agent ) { return new Id ( getId ( agent ) ) ; } | Get a new ID as JSON |
23,644 | @ Produces ( ProtocolBufferMediaType . APPLICATION_PROTOBUF ) @ CacheControl ( mustRevalidate = true , noCache = true , noStore = true ) public SnowizardResponse getIdAsProtobuf ( @ HeaderParam ( HttpHeaders . USER_AGENT ) final String agent , @ QueryParam ( "count" ) final Optional < IntParam > count ) { final List < Long > ids = Lists . newArrayList ( ) ; if ( count . isPresent ( ) ) { for ( int i = 0 ; i < count . get ( ) . get ( ) ; i ++ ) { ids . add ( getId ( agent ) ) ; } } else { ids . add ( getId ( agent ) ) ; } return SnowizardResponse . newBuilder ( ) . addAllId ( ids ) . build ( ) ; } | Get one or more IDs as a Google Protocol Buffer response |
23,645 | public RoutesMetadataPlugin flag ( String flagValue ) { for ( RouteBuilder routeBuilder : routeBuilders ) { routeBuilder . flag ( flagValue ) ; } return this ; } | RouteBuilder route augmentation delegates . |
23,646 | static int getBitsPerItemForFpRate ( double fpProb , double loadFactor ) { return DoubleMath . roundToInt ( DoubleMath . log2 ( ( 1 / fpProb ) + 3 ) / loadFactor , RoundingMode . UP ) ; } | Calculates how many bits are needed to reach a given false positive rate . |
23,647 | static long getBucketsNeeded ( long maxKeys , double loadFactor , int bucketSize ) { long bucketsNeeded = DoubleMath . roundToLong ( ( 1.0 / loadFactor ) * maxKeys / bucketSize , RoundingMode . UP ) ; long bitPos = Long . highestOneBit ( bucketsNeeded ) ; if ( bucketsNeeded > bitPos ) bitPos = bitPos << 1 ; return bitPos ; } | Calculates how many buckets are needed to hold the chosen number of keys taking the standard load factor into account . |
23,648 | private boolean trySwapVictimIntoEmptySpot ( ) { long curIndex = victim . getI2 ( ) ; bucketLocker . lockSingleBucketWrite ( curIndex ) ; long curTag = table . swapRandomTagInBucket ( curIndex , victim . getTag ( ) ) ; bucketLocker . unlockSingleBucketWrite ( curIndex ) ; long altIndex = hasher . altIndex ( curIndex , curTag ) ; bucketLocker . lockSingleBucketWrite ( altIndex ) ; try { if ( table . insertToBucket ( altIndex , curTag ) ) { hasVictim = false ; return true ; } else { victim . setTag ( curTag ) ; victim . setI1 ( curIndex ) ; victim . setI2 ( altIndex ) ; } } finally { bucketLocker . unlockSingleBucketWrite ( altIndex ) ; } return false ; } | if we kicked a tag we need to move it to alternate position possibly kicking another tag there repeating the process until we succeed or run out of chances |
23,649 | private void insertIfVictim ( ) { long victimLockstamp = writeLockVictimIfSet ( ) ; if ( victimLockstamp == 0L ) return ; try { bucketLocker . lockBucketsWrite ( victim . getI1 ( ) , victim . getI2 ( ) ) ; try { if ( table . insertToBucket ( victim . getI1 ( ) , victim . getTag ( ) ) || table . insertToBucket ( victim . getI2 ( ) , victim . getTag ( ) ) ) { hasVictim = false ; } } finally { bucketLocker . unlockBucketsWrite ( victim . getI1 ( ) , victim . getI2 ( ) ) ; } } finally { victimLock . unlock ( victimLockstamp ) ; } } | Attempts to insert the victim item if it exists . Remember that inserting from the victim cache to the main table DOES NOT affect the count since items in the victim cache are technically still in the table |
23,650 | private static boolean isHashConfigurationIsSupported ( long numBuckets , int tagBits , int hashSize ) { int hashBitsNeeded = getTotalBitsNeeded ( numBuckets , tagBits ) ; switch ( hashSize ) { case 32 : case 64 : return hashBitsNeeded <= hashSize ; default : } if ( hashSize >= 128 ) return tagBits <= 64 && getIndexBitsUsed ( numBuckets ) <= 64 ; return false ; } | Determines if the chosen hash function is long enough for the table configuration used . |
23,651 | HashCode hashObjWithSalt ( T object , int moreSalt ) { Hasher hashInst = hasher . newHasher ( ) ; hashInst . putObject ( object , funnel ) ; hashInst . putLong ( seedNSalt ) ; hashInst . putInt ( moreSalt ) ; return hashInst . hash ( ) ; } | hashes the object with an additional salt . For purpose of the cuckoo filter this is used when the hash generated for an item is all zeros . All zeros is the same as an empty bucket so obviously it s not a valid tag . |
23,652 | static int oversize ( int minTargetSize , int bytesPerElement ) { if ( minTargetSize < 0 ) { throw new IllegalArgumentException ( "invalid array size " + minTargetSize ) ; } if ( minTargetSize == 0 ) { return 0 ; } if ( minTargetSize > MAX_ARRAY_LENGTH ) { throw new IllegalArgumentException ( "requested array size " + minTargetSize + " exceeds maximum array in java (" + MAX_ARRAY_LENGTH + ")" ) ; } int extra = minTargetSize >> 3 ; if ( extra < 3 ) { extra = 3 ; } int newSize = minTargetSize + extra ; if ( newSize + 7 < 0 || newSize + 7 > MAX_ARRAY_LENGTH ) { return MAX_ARRAY_LENGTH ; } if ( Constants . JRE_IS_64BIT ) { switch ( bytesPerElement ) { case 4 : return ( newSize + 1 ) & 0x7ffffffe ; case 2 : return ( newSize + 3 ) & 0x7ffffffc ; case 1 : return ( newSize + 7 ) & 0x7ffffff8 ; case 8 : default : return newSize ; } } else { switch ( bytesPerElement ) { case 2 : return ( newSize + 1 ) & 0x7ffffffe ; case 1 : return ( newSize + 3 ) & 0x7ffffffc ; case 4 : case 8 : default : return newSize ; } } } | Returns an array size > ; = minTargetSize generally over - allocating exponentially to achieve amortized linear - time cost as the array grows . |
23,653 | long prevSetBit ( long index ) { assert index >= 0 && index < numBits : "index=" + index + " numBits=" + numBits ; int i = ( int ) ( index >> 6 ) ; final int subIndex = ( int ) ( index & 0x3f ) ; long word = ( bits [ i ] << ( 63 - subIndex ) ) ; if ( word != 0 ) { return ( i << 6 ) + subIndex - Long . numberOfLeadingZeros ( word ) ; } while ( -- i >= 0 ) { word = bits [ i ] ; if ( word != 0 ) { return ( i << 6 ) + 63 - Long . numberOfLeadingZeros ( word ) ; } } return - 1 ; } | Returns the index of the last set bit before or on the index specified . - 1 is returned if there are no more set bits . |
23,654 | void or ( LongBitSet other ) { assert other . numWords <= numWords : "numWords=" + numWords + ", other.numWords=" + other . numWords ; int pos = Math . min ( numWords , other . numWords ) ; while ( -- pos >= 0 ) { bits [ pos ] |= other . bits [ pos ] ; } } | this = this OR other |
23,655 | boolean intersects ( LongBitSet other ) { int pos = Math . min ( numWords , other . numWords ) ; while ( -- pos >= 0 ) { if ( ( bits [ pos ] & other . bits [ pos ] ) != 0 ) return true ; } return false ; } | returns true if the sets have any elements in common |
23,656 | void andNot ( LongBitSet other ) { int pos = Math . min ( numWords , other . numWords ) ; while ( -- pos >= 0 ) { bits [ pos ] &= ~ other . bits [ pos ] ; } } | this = this AND NOT other |
23,657 | void flip ( long index ) { assert index >= 0 && index < numBits : "index=" + index + " numBits=" + numBits ; int wordNum = ( int ) ( index >> 6 ) ; long bitmask = 1L << index ; bits [ wordNum ] ^= bitmask ; } | Flip the bit at the provided index . |
23,658 | static FilterTable create ( int bitsPerTag , long numBuckets ) { checkArgument ( bitsPerTag < 48 , "tagBits (%s) should be less than 48 bits" , bitsPerTag ) ; checkArgument ( bitsPerTag > 4 , "tagBits (%s) must be > 4" , bitsPerTag ) ; checkArgument ( numBuckets > 1 , "numBuckets (%s) must be > 1" , numBuckets ) ; long bitsPerBucket = IntMath . checkedMultiply ( CuckooFilter . BUCKET_SIZE , bitsPerTag ) ; long bitSetSize = LongMath . checkedMultiply ( bitsPerBucket , numBuckets ) ; LongBitSet memBlock = new LongBitSet ( bitSetSize ) ; return new FilterTable ( memBlock , bitsPerTag , numBuckets ) ; } | Creates a FilterTable |
23,659 | boolean insertToBucket ( long bucketIndex , long tag ) { for ( int i = 0 ; i < CuckooFilter . BUCKET_SIZE ; i ++ ) { if ( checkTag ( bucketIndex , i , 0 ) ) { writeTagNoClear ( bucketIndex , i , tag ) ; return true ; } } return false ; } | inserts a tag into an empty position in the chosen bucket . |
23,660 | long swapRandomTagInBucket ( long curIndex , long tag ) { int randomBucketPosition = ThreadLocalRandom . current ( ) . nextInt ( CuckooFilter . BUCKET_SIZE ) ; return readTagAndSet ( curIndex , randomBucketPosition , tag ) ; } | Replaces a tag in a random position in the given bucket and returns the tag that was replaced . |
23,661 | boolean findTag ( long i1 , long i2 , long tag ) { for ( int i = 0 ; i < CuckooFilter . BUCKET_SIZE ; i ++ ) { if ( checkTag ( i1 , i , tag ) || checkTag ( i2 , i , tag ) ) return true ; } return false ; } | Finds a tag if present in two buckets . |
23,662 | boolean deleteFromBucket ( long i1 , long tag ) { for ( int i = 0 ; i < CuckooFilter . BUCKET_SIZE ; i ++ ) { if ( checkTag ( i1 , i , tag ) ) { deleteTag ( i1 , i ) ; return true ; } } return false ; } | Deletes an item from the table if it is found in the bucket |
23,663 | long readTag ( long bucketIndex , int posInBucket ) { long tagStartIdx = getTagOffset ( bucketIndex , posInBucket ) ; long tag = 0 ; long tagEndIdx = tagStartIdx + bitsPerTag ; for ( long i = memBlock . nextSetBit ( tagStartIdx ) ; i >= 0 && i < tagEndIdx ; i = memBlock . nextSetBit ( i + 1L ) ) { tag |= 1 << ( i - tagStartIdx ) ; } return tag ; } | Works but currently only used for testing |
23,664 | long readTagAndSet ( long bucketIndex , int posInBucket , long newTag ) { long tagStartIdx = getTagOffset ( bucketIndex , posInBucket ) ; long tag = 0 ; long tagEndIdx = tagStartIdx + bitsPerTag ; int tagPos = 0 ; for ( long i = tagStartIdx ; i < tagEndIdx ; i ++ ) { if ( ( newTag & ( 1L << tagPos ) ) != 0 ) { if ( memBlock . getAndSet ( i ) ) { tag |= 1 << tagPos ; } } else { if ( memBlock . getAndClear ( i ) ) { tag |= 1 << tagPos ; } } tagPos ++ ; } return tag ; } | Reads a tag and sets the bits to a new tag at same time for max speedification |
23,665 | boolean checkTag ( long bucketIndex , int posInBucket , long tag ) { long tagStartIdx = getTagOffset ( bucketIndex , posInBucket ) ; final int bityPerTag = bitsPerTag ; for ( long i = 0 ; i < bityPerTag ; i ++ ) { if ( memBlock . get ( i + tagStartIdx ) != ( ( tag & ( 1L << i ) ) != 0 ) ) return false ; } return true ; } | Check if a tag in a given position in a bucket matches the tag you passed it . Faster than regular read because it stops checking if it finds a non - matching bit . |
23,666 | void writeTagNoClear ( long bucketIndex , int posInBucket , long tag ) { long tagStartIdx = getTagOffset ( bucketIndex , posInBucket ) ; for ( int i = 0 ; i < bitsPerTag ; i ++ ) { if ( ( tag & ( 1L << i ) ) != 0 ) { memBlock . set ( tagStartIdx + i ) ; } } } | Writes a tag to a bucket position . Faster than regular write because it assumes tag starts with all zeros but doesn t work properly if the position wasn t empty . |
23,667 | private static Object invoke ( Object obj , String method , Object ... args ) throws NoSuchMethodException , InvocationTargetException , IllegalAccessException { Class < ? > [ ] argumentTypes = new Class [ args . length ] ; for ( int i = 0 ; i < args . length ; ++ i ) { argumentTypes [ i ] = args [ i ] . getClass ( ) ; } Method m = obj . getClass ( ) . getMethod ( method , argumentTypes ) ; m . setAccessible ( true ) ; return m . invoke ( obj , args ) ; } | Invoke a method using reflection |
23,668 | private void invokeIgnoreExceptions ( Object obj , String method , Object ... args ) { try { invoke ( obj , method , args ) ; } catch ( NoSuchMethodException e ) { logger . trace ( "Unable to log progress" , e ) ; } catch ( InvocationTargetException e ) { logger . trace ( "Unable to log progress" , e ) ; } catch ( IllegalAccessException e ) { logger . trace ( "Unable to log progress" , e ) ; } } | Invoke a method using reflection but don t throw any exceptions . Just log errors instead . |
23,669 | public static void optimizeTable ( FluoConfiguration fluoConfig , TableOptimizations tableOptim ) throws Exception { Connector conn = getConnector ( fluoConfig ) ; TreeSet < Text > splits = new TreeSet < > ( ) ; for ( Bytes split : tableOptim . getSplits ( ) ) { splits . add ( new Text ( split . toArray ( ) ) ) ; } String table = fluoConfig . getAccumuloTable ( ) ; conn . tableOperations ( ) . addSplits ( table , splits ) ; if ( tableOptim . getTabletGroupingRegex ( ) != null && ! tableOptim . getTabletGroupingRegex ( ) . isEmpty ( ) ) { try { conn . tableOperations ( ) . setProperty ( table , RGB_PATTERN_PROP , tableOptim . getTabletGroupingRegex ( ) ) ; conn . tableOperations ( ) . setProperty ( table , RGB_DEFAULT_PROP , "none" ) ; conn . tableOperations ( ) . setProperty ( table , TABLE_BALANCER_PROP , RGB_CLASS ) ; } catch ( AccumuloException e ) { logger . warn ( "Unable to setup regex balancer (this is expected to fail in Accumulo 1.6.X) : " + e . getMessage ( ) ) ; logger . debug ( "Unable to setup regex balancer (this is expected to fail in Accumulo 1.6.X)" , e ) ; } } } | Make the requested table optimizations . |
23,670 | public void filteredAdd ( LogEntry entry , Predicate < LogEntry > filter ) { if ( filter . test ( entry ) ) { add ( entry ) ; } } | Adds LogEntry to TxLog if it passes filter |
23,671 | public Map < RowColumn , Bytes > getOperationMap ( LogEntry . Operation op ) { Map < RowColumn , Bytes > opMap = new HashMap < > ( ) ; for ( LogEntry entry : logEntries ) { if ( entry . getOp ( ) . equals ( op ) ) { opMap . put ( new RowColumn ( entry . getRow ( ) , entry . getColumn ( ) ) , entry . getValue ( ) ) ; } } return opMap ; } | Returns a map of RowColumn changes given an operation |
23,672 | private String getProjectStageNameFromJNDI ( ) { try { InitialContext context = new InitialContext ( ) ; Object obj = context . lookup ( ProjectStage . PROJECT_STAGE_JNDI_NAME ) ; if ( obj != null ) { return obj . toString ( ) . trim ( ) ; } } catch ( NamingException e ) { } return null ; } | Performs a JNDI lookup to obtain the current project stage . The method use the standard JNDI name for the JSF project stage for the lookup |
23,673 | public static RecordingTransactionBase wrap ( TransactionBase txb , Predicate < LogEntry > filter ) { return new RecordingTransactionBase ( txb , filter ) ; } | Creates a RecordingTransactionBase using the provided LogEntry filter function and existing TransactionBase |
23,674 | public ThreadDumpRuntime fromCurrentProcess ( ) throws IOException , InterruptedException { final String jvmName = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; final int index = jvmName . indexOf ( '@' ) ; if ( index < 1 ) throw new IOException ( "Unable to extract PID from " + jvmName ) ; long pid ; try { pid = Long . parseLong ( jvmName . substring ( 0 , index ) ) ; } catch ( NumberFormatException e ) { throw new IOException ( "Unable to extract PID from " + jvmName ) ; } return fromProcess ( pid ) ; } | Extract runtime from current process . |
23,675 | @ SuppressWarnings ( { "unchecked" , "rawtypes" , "unused" } ) public void afterPhase ( final PhaseEvent event ) { if ( PhaseId . RENDER_RESPONSE . equals ( event . getPhaseId ( ) ) ) { RenderContext contextInstance = getContextInstance ( ) ; if ( contextInstance != null ) { Integer id = contextInstance . getId ( ) ; RenderContext removed = getRenderContextMap ( ) . remove ( id ) ; Map < Contextual < ? > , Object > componentInstanceMap = getComponentInstanceMap ( ) ; Map < Contextual < ? > , CreationalContext < ? > > creationalContextMap = getCreationalContextMap ( ) ; if ( ( componentInstanceMap != null ) && ( creationalContextMap != null ) ) { for ( Entry < Contextual < ? > , Object > componentEntry : componentInstanceMap . entrySet ( ) ) { Contextual contextual = componentEntry . getKey ( ) ; Object instance = componentEntry . getValue ( ) ; CreationalContext creational = creationalContextMap . get ( contextual ) ; contextual . destroy ( instance , creational ) ; } } } } } | Destroy the current context since Render Response has completed . |
23,676 | protected boolean elements ( String ... name ) { if ( name == null || name . length != stack . size ( ) ) { return false ; } for ( int i = 0 ; i < name . length ; i ++ ) { if ( ! name [ i ] . equals ( stack . get ( i ) ) ) { return false ; } } return true ; } | Checks whether the element stack currently contains exactly the elements supplied by the caller . This method can be used to find the current position in the document . The first argument is always the root element of the document the second is a child of the root element and so on . The method uses the local names of the elements only . Namespaces are ignored . |
23,677 | public static Predicate < LogEntry > getFilter ( ) { return le -> le . getOp ( ) . equals ( LogEntry . Operation . DELETE ) || le . getOp ( ) . equals ( LogEntry . Operation . SET ) ; } | Returns LogEntry filter for Accumulo replication . |
23,678 | public static void generateMutations ( long seq , TxLog txLog , Consumer < Mutation > consumer ) { Map < Bytes , Mutation > mutationMap = new HashMap < > ( ) ; for ( LogEntry le : txLog . getLogEntries ( ) ) { LogEntry . Operation op = le . getOp ( ) ; Column col = le . getColumn ( ) ; byte [ ] cf = col . getFamily ( ) . toArray ( ) ; byte [ ] cq = col . getQualifier ( ) . toArray ( ) ; byte [ ] cv = col . getVisibility ( ) . toArray ( ) ; if ( op . equals ( LogEntry . Operation . DELETE ) || op . equals ( LogEntry . Operation . SET ) ) { Mutation m = mutationMap . computeIfAbsent ( le . getRow ( ) , k -> new Mutation ( k . toArray ( ) ) ) ; if ( op . equals ( LogEntry . Operation . DELETE ) ) { if ( col . isVisibilitySet ( ) ) { m . putDelete ( cf , cq , new ColumnVisibility ( cv ) , seq ) ; } else { m . putDelete ( cf , cq , seq ) ; } } else { if ( col . isVisibilitySet ( ) ) { m . put ( cf , cq , new ColumnVisibility ( cv ) , seq , le . getValue ( ) . toArray ( ) ) ; } else { m . put ( cf , cq , seq , le . getValue ( ) . toArray ( ) ) ; } } } } mutationMap . values ( ) . forEach ( consumer ) ; } | Generates Accumulo mutations from a Transaction log . Used to Replicate Fluo table to Accumulo . |
23,679 | public UIForm locateForm ( ) { UIComponent parent = this . getParent ( ) ; while ( ! ( parent instanceof UIForm ) ) { if ( ( parent == null ) || ( parent instanceof UIViewRoot ) ) { throw new IllegalStateException ( "The UIValidateForm (<s:validateForm />) component must be placed within a UIForm (<h:form>)" ) ; } parent = parent . getParent ( ) ; } return ( UIForm ) parent ; } | Attempt to locate the form in which this component resides . If the component is not within a UIForm tag throw an exception . |
23,680 | private Bytes getMinimalRow ( ) { return Bytes . builder ( bucketRow . length ( ) + 1 ) . append ( bucketRow ) . append ( ':' ) . toBytes ( ) ; } | Computes the minimal row for a bucket |
23,681 | public ThreadType onlyThread ( ) throws IllegalStateException { if ( size ( ) != 1 ) throw new IllegalStateException ( "Exactly one thread expected in the set. Found " + size ( ) ) ; return threads . iterator ( ) . next ( ) ; } | Extract the only thread from set . |
23,682 | public SetType getBlockedThreads ( ) { Set < ThreadLock > acquired = new HashSet < ThreadLock > ( ) ; for ( ThreadType thread : threads ) { acquired . addAll ( thread . getAcquiredLocks ( ) ) ; } Set < ThreadType > blocked = new HashSet < ThreadType > ( ) ; for ( ThreadType thread : runtime . getThreads ( ) ) { if ( acquired . contains ( thread . getWaitingToLock ( ) ) ) { blocked . add ( thread ) ; } } return runtime . getThreadSet ( blocked ) ; } | Get threads blocked by any of current threads . |
23,683 | public SetType getBlockingThreads ( ) { Set < ThreadLock > waitingTo = new HashSet < ThreadLock > ( ) ; for ( ThreadType thread : threads ) { if ( thread . getWaitingToLock ( ) != null ) { waitingTo . add ( thread . getWaitingToLock ( ) ) ; } } Set < ThreadType > blocking = new HashSet < ThreadType > ( ) ; for ( ThreadType thread : runtime . getThreads ( ) ) { Set < ThreadLock > threadHolding = thread . getAcquiredLocks ( ) ; threadHolding . retainAll ( waitingTo ) ; if ( ! threadHolding . isEmpty ( ) ) { blocking . add ( thread ) ; } } return runtime . getThreadSet ( blocking ) ; } | Get threads blocking any of current threads . |
23,684 | public SetType where ( ProcessThread . Predicate pred ) { HashSet < ThreadType > subset = new HashSet < ThreadType > ( size ( ) / 2 ) ; for ( ThreadType thread : threads ) { if ( pred . isValid ( thread ) ) subset . add ( thread ) ; } return runtime . getThreadSet ( subset ) ; } | Get subset of current threads . |
23,685 | public < T extends SingleThreadSetQuery . Result < SetType , RuntimeType , ThreadType > > T query ( SingleThreadSetQuery < T > query ) { return query . < SetType , RuntimeType , ThreadType > query ( ( SetType ) this ) ; } | Run query using this as an initial thread set . |
23,686 | @ SuppressWarnings ( "unused" ) private static MBeanServerConnection getServerConnection ( int pid ) { try { JMXServiceURL serviceURL = new JMXServiceURL ( connectorAddress ( pid ) ) ; return JMXConnectorFactory . connect ( serviceURL ) . getMBeanServerConnection ( ) ; } catch ( MalformedURLException ex ) { throw failed ( "JMX connection failed" , ex ) ; } catch ( IOException ex ) { throw failed ( "JMX connection failed" , ex ) ; } } | This has to be called by reflection so it can as well be private to stress this is not an API |
23,687 | private Monitor getMonitorJustAcquired ( List < ThreadLock . Monitor > monitors ) { if ( monitors . isEmpty ( ) ) return null ; Monitor monitor = monitors . get ( 0 ) ; if ( monitor . getDepth ( ) != 0 ) return null ; for ( Monitor duplicateCandidate : monitors ) { if ( monitor . equals ( duplicateCandidate ) ) continue ; if ( monitor . getLock ( ) . equals ( duplicateCandidate . getLock ( ) ) ) return null ; } return monitor ; } | get monitor acquired on current stackframe null when it was acquired earlier or not monitor is held |
23,688 | public void setupDecorateMethods ( ClassLoader cl ) { synchronized ( STAR_IMPORTS ) { if ( DECORATED ) return ; GroovyShell shell = new GroovyShell ( cl , new Binding ( ) , getCompilerConfiguration ( ) ) ; try { shell . run ( new InputStreamReader ( this . getClass ( ) . getResourceAsStream ( "extend.groovy" ) ) , "dumpling-metaclass-setup" , Collections . emptyList ( ) ) ; } catch ( Exception ex ) { AssertionError err = new AssertionError ( "Unable to decorate object model" ) ; err . initCause ( ex ) ; throw err ; } DECORATED = true ; } } | Decorate Dumpling API with groovy extensions . |
23,689 | private void performObservation ( PhaseEvent event , PhaseIdType phaseIdType ) { UIViewRoot viewRoot = ( UIViewRoot ) event . getFacesContext ( ) . getViewRoot ( ) ; List < ? extends Annotation > restrictionsForPhase = getRestrictionsForPhase ( phaseIdType , viewRoot . getViewId ( ) ) ; if ( restrictionsForPhase != null ) { log . debugf ( "Enforcing on phase %s" , phaseIdType ) ; enforce ( event . getFacesContext ( ) , viewRoot , restrictionsForPhase ) ; } } | Inspect the annotations in the ViewConfigStore enforcing any restrictions applicable to this phase |
23,690 | public boolean isAnnotationApplicableToPhase ( Annotation annotation , PhaseIdType currentPhase , PhaseIdType [ ] defaultPhases ) { Method restrictAtViewMethod = getRestrictAtViewMethod ( annotation ) ; PhaseIdType [ ] phasedIds = null ; if ( restrictAtViewMethod != null ) { log . warnf ( "Annotation %s is using the restrictAtViewMethod. Use a @RestrictAtPhase qualifier on the annotation instead." ) ; phasedIds = getRestrictedPhaseIds ( restrictAtViewMethod , annotation ) ; } RestrictAtPhase restrictAtPhaseQualifier = AnnotationInspector . getAnnotation ( annotation . annotationType ( ) , RestrictAtPhase . class , beanManager ) ; if ( restrictAtPhaseQualifier != null ) { log . debug ( "Using Phases found in @RestrictAtView qualifier on the annotation." ) ; phasedIds = restrictAtPhaseQualifier . value ( ) ; } if ( phasedIds == null ) { log . debug ( "Falling back on default phase ids" ) ; phasedIds = defaultPhases ; } if ( Arrays . binarySearch ( phasedIds , currentPhase ) >= 0 ) { return true ; } return false ; } | Inspect an annotation to see if it specifies a view in which it should be . Fall back on default view otherwise . |
23,691 | public Method getRestrictAtViewMethod ( Annotation annotation ) { Method restrictAtViewMethod ; try { restrictAtViewMethod = annotation . annotationType ( ) . getDeclaredMethod ( "restrictAtPhase" ) ; } catch ( NoSuchMethodException ex ) { restrictAtViewMethod = null ; } catch ( SecurityException ex ) { throw new IllegalArgumentException ( "restrictAtView method must be accessible" , ex ) ; } return restrictAtViewMethod ; } | Utility method to extract the restrictAtPhase method from an annotation |
23,692 | public PhaseIdType [ ] getRestrictedPhaseIds ( Method restrictAtViewMethod , Annotation annotation ) { PhaseIdType [ ] phaseIds ; try { phaseIds = ( PhaseIdType [ ] ) restrictAtViewMethod . invoke ( annotation ) ; } catch ( IllegalAccessException ex ) { throw new IllegalArgumentException ( "restrictAtView method must be accessible" , ex ) ; } catch ( InvocationTargetException ex ) { throw new RuntimeException ( ex ) ; } return phaseIds ; } | Retrieve the default PhaseIdTypes defined by the restrictAtViewMethod in the annotation |
23,693 | public static TableOptimizations getConfiguredOptimizations ( FluoConfiguration fluoConfig ) { try ( FluoClient client = FluoFactory . newClient ( fluoConfig ) ) { SimpleConfiguration appConfig = client . getAppConfiguration ( ) ; TableOptimizations tableOptim = new TableOptimizations ( ) ; SimpleConfiguration subset = appConfig . subset ( PREFIX . substring ( 0 , PREFIX . length ( ) - 1 ) ) ; Iterator < String > keys = subset . getKeys ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; String clazz = subset . getString ( key ) ; try { TableOptimizationsFactory factory = Class . forName ( clazz ) . asSubclass ( TableOptimizationsFactory . class ) . newInstance ( ) ; tableOptim . merge ( factory . getTableOptimizations ( key , appConfig ) ) ; } catch ( InstantiationException | IllegalAccessException | ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } } return tableOptim ; } } | A utility method to get all registered table optimizations . Many recipes will automatically register table optimizations when configured . |
23,694 | public void addTransientRange ( String id , RowRange range ) { String start = DatatypeConverter . printHexBinary ( range . getStart ( ) . toArray ( ) ) ; String end = DatatypeConverter . printHexBinary ( range . getEnd ( ) . toArray ( ) ) ; appConfig . setProperty ( PREFIX + id , start + ":" + end ) ; } | This method is expected to be called before Fluo is initialized to register transient ranges . |
23,695 | public List < RowRange > getTransientRanges ( ) { List < RowRange > ranges = new ArrayList < > ( ) ; Iterator < String > keys = appConfig . getKeys ( PREFIX . substring ( 0 , PREFIX . length ( ) - 1 ) ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; String val = appConfig . getString ( key ) ; String [ ] sa = val . split ( ":" ) ; RowRange rowRange = new RowRange ( Bytes . of ( DatatypeConverter . parseHexBinary ( sa [ 0 ] ) ) , Bytes . of ( DatatypeConverter . parseHexBinary ( sa [ 1 ] ) ) ) ; ranges . add ( rowRange ) ; } return ranges ; } | This method is expected to be called after Fluo is initialized to get the ranges that were registered before initialization . |
23,696 | @ SuppressWarnings ( "unchecked" ) protected List < T > getEnabledListeners ( Class < ? extends T > ... classes ) { List < T > listeners = new ArrayList < T > ( ) ; for ( Class < ? extends T > clazz : classes ) { Set < Bean < ? > > beans = getBeanManager ( ) . getBeans ( clazz ) ; if ( ! beans . isEmpty ( ) ) { Bean < T > bean = ( Bean < T > ) getBeanManager ( ) . resolve ( beans ) ; CreationalContext < T > context = getBeanManager ( ) . createCreationalContext ( bean ) ; listeners . add ( ( T ) getBeanManager ( ) . getReference ( bean , clazz , context ) ) ; } } return listeners ; } | Create contextual instances for the specified listener classes excluding any listeners that do not correspond to an enabled bean . |
23,697 | public void update ( TransactionBase tx , Map < K , V > updates ) { combineQ . addAll ( tx , updates ) ; } | Queues updates for a collision free map . These updates will be made by an Observer executing another transaction . This method will not collide with other transaction queuing updates for the same keys . |
23,698 | public static void configure ( FluoConfiguration fluoConfig , Options opts ) { org . apache . fluo . recipes . core . combine . CombineQueue . FluentOptions cqopts = CombineQueue . configure ( opts . mapId ) . keyType ( opts . keyType ) . valueType ( opts . valueType ) . buckets ( opts . numBuckets ) ; if ( opts . bucketsPerTablet != null ) { cqopts . bucketsPerTablet ( opts . bucketsPerTablet ) ; } if ( opts . bufferSize != null ) { cqopts . bufferSize ( opts . bufferSize ) ; } cqopts . save ( fluoConfig ) ; opts . save ( fluoConfig . getAppConfiguration ( ) ) ; fluoConfig . addObserver ( new org . apache . fluo . api . config . ObserverSpecification ( CollisionFreeMapObserver . class . getName ( ) , ImmutableMap . of ( "mapId" , opts . mapId ) ) ) ; } | This method configures a collision free map for use . It must be called before initializing Fluo . |
23,699 | public static void configure ( FluoConfiguration fluoConfig , Options opts ) { SimpleConfiguration appConfig = fluoConfig . getAppConfiguration ( ) ; opts . save ( appConfig ) ; fluoConfig . addObserver ( new org . apache . fluo . api . config . ObserverSpecification ( ExportObserver . class . getName ( ) , Collections . singletonMap ( "queueId" , opts . fluentCfg . queueId ) ) ) ; } | Call this method before initializing Fluo . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.