idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
32,000 | public long getMemoryUsageBytes ( ) { long total = 0 ; for ( int i = 0 ; i < maps_ . length ; i ++ ) { if ( maps_ [ i ] != null ) { total += maps_ [ i ] . getMemoryUsageBytes ( ) ; } } return total ; } | Returns total bytes used by all internal maps |
32,001 | public long getKeyMemoryUsageBytes ( ) { long total = 0 ; for ( int i = 0 ; i < maps_ . length ; i ++ ) { if ( maps_ [ i ] != null ) { total += ( long ) ( maps_ [ i ] . getActiveEntries ( ) ) * keySizeBytes_ ; } } return total ; } | Returns total bytes used for key storage |
32,002 | int getActiveMaps ( ) { int levels = 0 ; final int iMapsLen = maps_ . length ; for ( int i = 0 ; i < iMapsLen ; i ++ ) { if ( maps_ [ i ] != null ) { levels ++ ; } } return levels ; } | Returns the number of active internal maps so far . Only the base map is initialized in the constructor so this method would return 1 . As more keys are promoted up to higher level maps the return value would grow until the last level HLL map is allocated . |
32,003 | private boolean propagateToSharedSketch ( final long hash ) { while ( localPropagationInProgress . get ( ) ) { } localPropagationInProgress . set ( true ) ; final boolean res = shared . propagate ( localPropagationInProgress , null , hash ) ; thetaLong_ = shared . getVolatileTheta ( ) ; return res ; } | Propagates a single hash value to the shared sketch |
32,004 | private void propagateToSharedSketch ( ) { while ( localPropagationInProgress . get ( ) ) { } final CompactSketch compactSketch = compact ( propagateOrderedCompact , null ) ; localPropagationInProgress . set ( true ) ; shared . propagate ( localPropagationInProgress , compactSketch , ConcurrentSharedThetaSketch . NOT_S... | Propagates the content of the buffer as a sketch to the shared sketch |
32,005 | private int countValidLevelsBelow ( final int tgtLvl ) { int count = 0 ; long bitPattern = ds_ . getBitPattern ( ) ; for ( int i = 0 ; ( i < tgtLvl ) && ( bitPattern > 0 ) ; ++ i , bitPattern >>>= 1 ) { if ( ( bitPattern & 1L ) > 0L ) { ++ count ; } } return count ; } | Counts number of full levels in the sketch below tgtLvl . Useful for computing the level offset in a compact sketch . |
32,006 | static void checkFamilyID ( final int familyID ) { final Family family = Family . idToFamily ( familyID ) ; if ( ! family . equals ( Family . QUANTILES ) ) { throw new SketchesArgumentException ( "Possible corruption: Invalid Family: " + family . toString ( ) ) ; } } | Checks the validity of the given family ID |
32,007 | static boolean checkPreLongsFlagsCap ( final int preambleLongs , final int flags , final long memCapBytes ) { final boolean empty = ( flags & EMPTY_FLAG_MASK ) > 0 ; final int minPre = Family . QUANTILES . getMinPreLongs ( ) ; final int maxPre = Family . QUANTILES . getMaxPreLongs ( ) ; final boolean valid = ( ( preamb... | Checks the consistency of the flag bits and the state of preambleLong and the memory capacity and returns the empty state . |
32,008 | static void checkHeapFlags ( final int flags ) { final int allowedFlags = READ_ONLY_FLAG_MASK | EMPTY_FLAG_MASK | COMPACT_FLAG_MASK | ORDERED_FLAG_MASK ; final int flagsMask = ~ allowedFlags ; if ( ( flags & flagsMask ) > 0 ) { throw new SketchesArgumentException ( "Possible corruption: Invalid flags field: " + Integer... | Checks just the flags field of the preamble . Allowed flags are Read Only Empty Compact and ordered . |
32,009 | static boolean checkIsCompactMemory ( final Memory srcMem ) { final int flags = extractFlags ( srcMem ) ; final int compactFlags = READ_ONLY_FLAG_MASK | COMPACT_FLAG_MASK ; return ( flags & compactFlags ) > 0 ; } | Checks just the flags field of an input Memory object . Returns true for a compact sketch false for an update sketch . Does not perform additional checks including sketch family . |
32,010 | static final void checkSplitPointsOrder ( final double [ ] values ) { if ( values == null ) { throw new SketchesArgumentException ( "Values cannot be null." ) ; } final int lenM1 = values . length - 1 ; for ( int j = 0 ; j < lenM1 ; j ++ ) { if ( values [ j ] < values [ j + 1 ] ) { continue ; } throw new SketchesArgume... | Checks the sequential validity of the given array of double values . They must be unique monotonically increasing and not NaN . |
32,011 | static int computeRetainedItems ( final int k , final long n ) { final int bbCnt = computeBaseBufferItems ( k , n ) ; final long bitPattern = computeBitPattern ( k , n ) ; final int validLevels = computeValidLevels ( bitPattern ) ; return bbCnt + ( validLevels * k ) ; } | Returns the number of retained valid items in the sketch given k and n . |
32,012 | static int lowLevelCompressBytes ( final byte [ ] byteArray , final int numBytesToEncode , final short [ ] encodingTable , final int [ ] compressedWords ) { int nextWordIndex = 0 ; long bitBuf = 0 ; int bufBits = 0 ; for ( int byteIndex = 0 ; byteIndex < numBytesToEncode ; byteIndex ++ ) { final int theByte = byteArray... | It is the caller s responsibility to ensure that the compressedWords array is long enough . |
32,013 | private static int [ ] uncompressTheSurprisingValues ( final CompressedState source ) { final int srcK = 1 << source . lgK ; final int numPairs = source . numCsv ; assert numPairs > 0 ; final int [ ] pairs = new int [ numPairs ] ; final int numBaseBits = CpcCompression . golombChooseNumberOfBaseBits ( srcK + numPairs ,... | the length of this array is known to the source sketch . |
32,014 | private static int [ ] trickyGetPairsFromWindow ( final byte [ ] window , final int k , final int numPairsToGet , final int emptySpace ) { final int outputLength = emptySpace + numPairsToGet ; final int [ ] pairs = new int [ outputLength ] ; int rowIndex = 0 ; int pairIndex = emptySpace ; for ( rowIndex = 0 ; rowIndex ... | will be filled in later by the caller . |
32,015 | private static void compressHybridFlavor ( final CompressedState target , final CpcSketch source ) { final int srcK = 1 << source . lgK ; final PairTable srcPairTable = source . pairTable ; final int srcNumPairs = srcPairTable . getNumPairs ( ) ; final int [ ] srcPairArr = PairTable . unwrappingGetItems ( srcPairTable ... | of a Pinned sketch before compressing it . Hence the name Hybrid . |
32,016 | private static void compressSlidingFlavor ( final CompressedState target , final CpcSketch source ) { compressTheWindow ( target , source ) ; final PairTable srcPairTable = source . pairTable ; final int numPairs = srcPairTable . getNumPairs ( ) ; if ( numPairs > 0 ) { final int [ ] pairs = PairTable . unwrappingGetIte... | Complicated by the existence of both a left fringe and a right fringe . |
32,017 | public void update ( final float value ) { if ( Float . isNaN ( value ) ) { return ; } if ( isEmpty ( ) ) { minValue_ = value ; maxValue_ = value ; } else { if ( value < minValue_ ) { minValue_ = value ; } if ( value > maxValue_ ) { maxValue_ = value ; } } if ( levels_ [ 0 ] == 0 ) { compressWhileUpdating ( ) ; } n_ ++... | Updates this sketch with the given data item . |
32,018 | public void merge ( final KllFloatsSketch other ) { if ( ( other == null ) || other . isEmpty ( ) ) { return ; } if ( m_ != other . m_ ) { throw new SketchesArgumentException ( "incompatible M: " + m_ + " and " + other . m_ ) ; } final long finalN = n_ + other . n_ ; for ( int i = other . levels_ [ 0 ] ; i < other . le... | Merges another sketch into this one . |
32,019 | public float getQuantile ( final double fraction ) { if ( isEmpty ( ) ) { return Float . NaN ; } if ( fraction == 0.0 ) { return minValue_ ; } if ( fraction == 1.0 ) { return maxValue_ ; } if ( ( fraction < 0.0 ) || ( fraction > 1.0 ) ) { throw new SketchesArgumentException ( "Fraction cannot be less than zero or great... | Returns an approximation to the value of the data item that would be preceded by the given fraction of a hypothetical sorted version of the input stream so far . |
32,020 | public static int getKFromEpsilon ( final double epsilon , final boolean pmf ) { final double eps = max ( epsilon , 4.7634E-5 ) ; final double kdbl = pmf ? exp ( log ( 2.446 / eps ) / 0.9433 ) : exp ( log ( 2.296 / eps ) / 0.9723 ) ; final double krnd = round ( kdbl ) ; final double del = abs ( krnd - kdbl ) ; final in... | thousands of trials |
32,021 | public byte [ ] toByteArray ( ) { final byte [ ] bytes = new byte [ getSerializedSizeBytes ( ) ] ; final boolean isSingleItem = n_ == 1 ; bytes [ PREAMBLE_INTS_BYTE ] = ( byte ) ( isEmpty ( ) || isSingleItem ? PREAMBLE_INTS_SHORT : PREAMBLE_INTS_FULL ) ; bytes [ SER_VER_BYTE ] = isSingleItem ? serialVersionUID2 : seria... | Returns serialized sketch in a byte array form . |
32,022 | public static KllFloatsSketch heapify ( final Memory mem ) { final int preambleInts = mem . getByte ( PREAMBLE_INTS_BYTE ) & 0xff ; final int serialVersion = mem . getByte ( SER_VER_BYTE ) & 0xff ; final int family = mem . getByte ( FAMILY_BYTE ) & 0xff ; final int flags = mem . getByte ( FLAGS_BYTE ) & 0xff ; final in... | Heapify takes the sketch image in Memory and instantiates an on - heap sketch . The resulting sketch will not retain any link to the source Memory . |
32,023 | static void checkK ( final int k ) { if ( ( k < MIN_K ) || ( k > MAX_K ) ) { throw new SketchesArgumentException ( "K must be >= " + MIN_K + " and <= " + MAX_K + ": " + k ) ; } } | Checks the validity of the given value k |
32,024 | private void compressWhileUpdating ( ) { final int level = findLevelToCompact ( ) ; if ( level == ( numLevels_ - 1 ) ) { addEmptyTopLevelToCompletelyFullSketch ( ) ; } final int rawBeg = levels_ [ level ] ; final int rawLim = levels_ [ level + 1 ] ; final int popAbove = levels_ [ level + 2 ] - rawLim ; final int rawPop... | It cannot be used while merging while reducing k or anything else . |
32,025 | public CompactDoublesSketch compact ( final WritableMemory dstMem ) { if ( dstMem == null ) { return HeapCompactDoublesSketch . createFromUpdateSketch ( this ) ; } return DirectCompactDoublesSketch . createFromUpdateSketch ( this , dstMem ) ; } | Returns a compact version of this sketch . If passing in a Memory object the compact sketch will use that direct memory ; otherwise an on - heap sketch will be returned . |
32,026 | public static < T > ItemsSketch < T > getInstance ( final Comparator < ? super T > comparator ) { return getInstance ( PreambleUtil . DEFAULT_K , comparator ) ; } | Obtains a new instance of an ItemsSketch using the DEFAULT_K . |
32,027 | public static < T > ItemsSketch < T > getInstance ( final int k , final Comparator < ? super T > comparator ) { final ItemsSketch < T > qs = new ItemsSketch < > ( k , comparator ) ; final int bufAlloc = 2 * Math . min ( DoublesSketch . MIN_K , k ) ; qs . n_ = 0 ; qs . combinedBufferItemCapacity_ = bufAlloc ; qs . combi... | Obtains a new instance of an ItemsSketch . |
32,028 | public static < T > ItemsSketch < T > getInstance ( final Memory srcMem , final Comparator < ? super T > comparator , final ArrayOfItemsSerDe < T > serDe ) { final long memCapBytes = srcMem . getCapacity ( ) ; if ( memCapBytes < 8 ) { throw new SketchesArgumentException ( "Memory too small: " + memCapBytes ) ; } final ... | Heapifies the given srcMem which must be a Memory image of a ItemsSketch |
32,029 | static < T > ItemsSketch < T > copy ( final ItemsSketch < T > sketch ) { final ItemsSketch < T > qsCopy = ItemsSketch . getInstance ( sketch . k_ , sketch . comparator_ ) ; qsCopy . n_ = sketch . n_ ; qsCopy . minValue_ = sketch . getMinValue ( ) ; qsCopy . maxValue_ = sketch . getMaxValue ( ) ; qsCopy . combinedBuffer... | Returns a copy of the given sketch |
32,030 | public void update ( final T dataItem ) { if ( dataItem == null ) { return ; } if ( ( maxValue_ == null ) || ( comparator_ . compare ( dataItem , maxValue_ ) > 0 ) ) { maxValue_ = dataItem ; } if ( ( minValue_ == null ) || ( comparator_ . compare ( dataItem , minValue_ ) < 0 ) ) { minValue_ = dataItem ; } if ( ( baseBu... | Updates this sketch with the given double data item |
32,031 | public T getQuantileUpperBound ( final double fraction ) { return getQuantile ( min ( 1.0 , fraction + Util . getNormalizedRankError ( k_ , false ) ) ) ; } | Gets the upper bound of the value interval in which the true quantile of the given rank exists with a confidence of at least 99% . |
32,032 | public T getQuantileLowerBound ( final double fraction ) { return getQuantile ( max ( 0 , fraction - Util . getNormalizedRankError ( k_ , false ) ) ) ; } | Gets the lower bound of the value interval in which the true quantile of the given rank exists with a confidence of at least 99% . |
32,033 | public void reset ( ) { n_ = 0 ; combinedBufferItemCapacity_ = 2 * Math . min ( DoublesSketch . MIN_K , k_ ) ; combinedBuffer_ = new Object [ combinedBufferItemCapacity_ ] ; baseBufferCount_ = 0 ; bitPattern_ = 0 ; minValue_ = null ; maxValue_ = null ; } | Resets this sketch to a virgin state but retains the original value of k . |
32,034 | public ItemsSketch < T > downSample ( final int newK ) { final ItemsSketch < T > newSketch = ItemsSketch . getInstance ( newK , comparator_ ) ; ItemsMergeImpl . downSamplingMergeInto ( this , newSketch ) ; return newSketch ; } | From an existing sketch this creates a new sketch that can have a smaller value of K . The original sketch is not modified . |
32,035 | public void putMemory ( final WritableMemory dstMem , final ArrayOfItemsSerDe < T > serDe ) { final byte [ ] byteArr = toByteArray ( serDe ) ; final long memCap = dstMem . getCapacity ( ) ; if ( memCap < byteArr . length ) { throw new SketchesArgumentException ( "Destination Memory not large enough: " + memCap + " < " ... | Puts the current sketch into the given Memory if there is sufficient space . Otherwise throws an error . |
32,036 | private void itemsArrayToCombinedBuffer ( final T [ ] itemsArray ) { final int extra = 2 ; minValue_ = itemsArray [ 0 ] ; maxValue_ = itemsArray [ 1 ] ; System . arraycopy ( itemsArray , extra , combinedBuffer_ , 0 , baseBufferCount_ ) ; long bits = bitPattern_ ; if ( bits > 0 ) { int index = extra + baseBufferCount_ ;... | Loads the Combined Buffer min and max from the given items array . The Combined Buffer is always in non - compact form and must be pre - allocated . |
32,037 | private void scanAllAsearchB ( ) { final long [ ] scanAArr = a_ . getCache ( ) ; final int arrLongsIn = scanAArr . length ; cache_ = new long [ arrLongsIn ] ; for ( int i = 0 ; i < arrLongsIn ; i ++ ) { final long hashIn = scanAArr [ i ] ; if ( ( hashIn <= 0L ) || ( hashIn >= thetaLong_ ) ) { continue ; } final int fou... | Sketch A is either unordered compact or hash table |
32,038 | public static double approximateLowerBoundOnP ( final long n , final long k , final double numStdDevs ) { checkInputs ( n , k ) ; if ( n == 0 ) { return 0.0 ; } else if ( k == 0 ) { return 0.0 ; } else if ( k == 1 ) { return ( exactLowerBoundOnPForKequalsOne ( n , deltaOfNumStdevs ( numStdDevs ) ) ) ; } else if ( k == ... | Computes lower bound of approximate Clopper - Pearson confidence interval for a binomial proportion . |
32,039 | public static double approximateUpperBoundOnP ( final long n , final long k , final double numStdDevs ) { checkInputs ( n , k ) ; if ( n == 0 ) { return 1.0 ; } else if ( k == n ) { return 1.0 ; } else if ( k == ( n - 1 ) ) { return ( exactUpperBoundOnPForKequalsNminusOne ( n , deltaOfNumStdevs ( numStdDevs ) ) ) ; } e... | Computes upper bound of approximate Clopper - Pearson confidence interval for a binomial proportion . |
32,040 | private static double erf_of_nonneg ( final double x ) { final double a1 = 0.0705230784 ; final double a3 = 0.0092705272 ; final double a5 = 0.0002765672 ; final double a2 = 0.0422820123 ; final double a4 = 0.0001520143 ; final double a6 = 0.0000430638 ; final double x2 = x * x ; final double x3 = x2 * x ; final double... | Abramowitz and Stegun formula 7 . 1 . 28 p . 88 ; Claims accuracy of about 7 decimal digits |
32,041 | private static double abramowitzStegunFormula26p5p22 ( final double a , final double b , final double yp ) { final double b2m1 = ( 2.0 * b ) - 1.0 ; final double a2m1 = ( 2.0 * a ) - 1.0 ; final double lambda = ( ( yp * yp ) - 3.0 ) / 6.0 ; final double htmp = ( 1.0 / a2m1 ) + ( 1.0 / b2m1 ) ; final double h = 2.0 / ht... | that the formula was typed in correctly . |
32,042 | public static < T > ReservoirItemsSketch < T > newInstance ( final int k , final ResizeFactor rf ) { return new ReservoirItemsSketch < > ( k , rf ) ; } | Construct a mergeable sampling sketch with up to k samples using a specified resize factor . |
32,043 | @ SuppressWarnings ( "unchecked" ) public T [ ] getSamples ( ) { if ( itemsSeen_ == 0 ) { return null ; } final Class < ? > clazz = data_ . get ( 0 ) . getClass ( ) ; return data_ . toArray ( ( T [ ] ) Array . newInstance ( clazz , 0 ) ) ; } | Returns a copy of the items in the reservoir or null if empty . The returned array length may be smaller than the reservoir capacity . |
32,044 | @ SuppressWarnings ( "unchecked" ) ReservoirItemsSketch < T > copy ( ) { return new ReservoirItemsSketch < > ( reservoirSize_ , currItemsAlloc_ , itemsSeen_ , rf_ , ( ArrayList < T > ) data_ . clone ( ) ) ; } | Used during union operations to ensure we do not overwrite an existing reservoir . Creates a shallow copy of the reservoir . |
32,045 | public CompactSketch intersect ( final Sketch a , final Sketch b ) { return intersect ( a , b , true , null ) ; } | Perform intersect set operation on the two given sketch arguments and return the result as an ordered CompactSketch on the heap . |
32,046 | static DirectCouponList newInstance ( final int lgConfigK , final TgtHllType tgtHllType , final WritableMemory dstMem ) { insertPreInts ( dstMem , LIST_PREINTS ) ; insertSerVer ( dstMem ) ; insertFamilyId ( dstMem ) ; insertLgK ( dstMem , lgConfigK ) ; insertLgArr ( dstMem , LG_INIT_LIST_SIZE ) ; insertFlags ( dstMem ,... | Standard factory for new DirectCouponList . This initializes the given WritableMemory . |
32,047 | static final int checkMaxLgArrLongs ( final Memory dstMem ) { final int preBytes = CONST_PREAMBLE_LONGS << 3 ; final long cap = dstMem . getCapacity ( ) ; final int maxLgArrLongs = Integer . numberOfTrailingZeros ( floorPowerOf2 ( ( int ) ( cap - preBytes ) ) >>> 3 ) ; if ( maxLgArrLongs < MIN_LG_ARR_LONGS ) { throw ne... | Returns the correct maximum lgArrLongs given the capacity of the Memory . Checks that the capacity is large enough for the minimum sized hash table . |
32,048 | static IntersectionImpl initNewHeapInstance ( final long seed ) { final IntersectionImpl impl = new IntersectionImpl ( null , seed , false ) ; impl . lgArrLongs_ = 0 ; impl . curCount_ = - 1 ; impl . thetaLong_ = Long . MAX_VALUE ; impl . empty_ = false ; impl . hashTable_ = null ; return impl ; } | Construct a new Intersection target on the java heap . |
32,049 | static IntersectionImpl initNewDirectInstance ( final long seed , final WritableMemory dstMem ) { final IntersectionImpl impl = new IntersectionImpl ( dstMem , seed , true ) ; insertPreLongs ( dstMem , CONST_PREAMBLE_LONGS ) ; insertSerVer ( dstMem , SER_VER ) ; insertFamilyID ( dstMem , Family . INTERSECTION . getID (... | Construct a new Intersection target direct to the given destination Memory . Called by SetOperation . Builder . |
32,050 | static IntersectionImplR heapifyInstance ( final Memory srcMem , final long seed ) { final IntersectionImpl impl = new IntersectionImpl ( null , seed , false ) ; final int preLongsMem = srcMem . getByte ( PREAMBLE_LONGS_BYTE ) & 0X3F ; final int serVer = srcMem . getByte ( SER_VER_BYTE ) & 0XFF ; final int famID = srcM... | Heapify an intersection target from a Memory image containing data . |
32,051 | @ SuppressWarnings ( { "unchecked" , "null" } ) public void update ( final Sketch < S > sketchIn ) { final boolean isFirstCall = isFirstCall_ ; isFirstCall_ = false ; if ( sketchIn == null ) { isEmpty_ = true ; sketch_ = null ; return ; } theta_ = min ( theta_ , sketchIn . getThetaLong ( ) ) ; isEmpty_ |= sketchIn . is... | Updates the internal set by intersecting it with the given sketch |
32,052 | private static double contClassicLB ( final double numSamplesF , final double theta , final double numSDev ) { final double nHat = ( numSamplesF - 0.5 ) / theta ; final double b = numSDev * Math . sqrt ( ( 1.0 - theta ) / theta ) ; final double d = 0.5 * b * Math . sqrt ( ( b * b ) + ( 4.0 * nHat ) ) ; final double cen... | our classic bounds but now with continuity correction |
32,053 | public static double getLowerBound ( final long numSamples , final double theta , final int numSDev , final boolean noDataSeen ) { if ( noDataSeen ) { return 0.0 ; } checkArgs ( numSamples , theta , numSDev ) ; final double lb = computeApproxBinoLB ( numSamples , theta , numSDev ) ; final double numSamplesF = numSample... | Returns the approximate lower bound value |
32,054 | public static double getUpperBound ( final long numSamples , final double theta , final int numSDev , final boolean noDataSeen ) { if ( noDataSeen ) { return 0.0 ; } checkArgs ( numSamples , theta , numSDev ) ; final double ub = computeApproxBinoUB ( numSamples , theta , numSDev ) ; final double numSamplesF = numSample... | Returns the approximate upper bound value |
32,055 | static final void checkArgs ( final long numSamples , final double theta , final int numSDev ) { if ( ( numSDev | ( numSDev - 1 ) | ( 3 - numSDev ) | numSamples ) < 0 ) { throw new SketchesArgumentException ( "numSDev must only be 1,2, or 3 and numSamples must >= 0: numSDev=" + numSDev + ", numSamples=" + numSamples ) ... | exposed only for test |
32,056 | public void update ( final ReservoirItemsSketch < T > sketchIn ) { if ( sketchIn == null ) { return ; } final ReservoirItemsSketch < T > ris = ( sketchIn . getK ( ) <= maxK_ ? sketchIn : sketchIn . downsampledCopy ( maxK_ ) ) ; final boolean isModifiable = ( sketchIn != ris ) ; if ( gadget_ == null ) { createNewGadget ... | Union the given sketch . This method can be repeatedly called . If the given sketch is null it is interpreted as an empty sketch . |
32,057 | public void update ( final T datum ) { if ( datum == null ) { return ; } if ( gadget_ == null ) { gadget_ = ReservoirItemsSketch . newInstance ( maxK_ ) ; } gadget_ . update ( datum ) ; } | Present this union with a single item to be added to the union . |
32,058 | public byte [ ] toByteArray ( final ArrayOfItemsSerDe < T > serDe ) { if ( ( gadget_ == null ) || ( gadget_ . getNumSamples ( ) == 0 ) ) { return toByteArray ( serDe , null ) ; } else { return toByteArray ( serDe , gadget_ . getValueAtPosition ( 0 ) . getClass ( ) ) ; } } | Returns a byte array representation of this union |
32,059 | static double getRelErr ( final boolean upperBound , final boolean oooFlag , final int lgK , final int stdDev ) { final int idx = ( ( lgK - 4 ) * 3 ) + ( stdDev - 1 ) ; final int sw = ( oooFlag ? 2 : 0 ) | ( upperBound ? 1 : 0 ) ; double f = 0 ; switch ( sw ) { case 0 : { f = HIP_LB [ idx ] ; break ; } case 1 : { f = H... | Return Relative Error for UB or LB for HIP or Non - HIP as a function of numStdDev . |
32,060 | public double getEstimate ( ) { if ( ! hasHip ( mem ) ) { return getIconEstimate ( PreambleUtil . getLgK ( mem ) , getNumCoupons ( mem ) ) ; } return getHipAccum ( mem ) ; } | Returns the best estimate of the cardinality of the sketch . |
32,061 | static CompactSketch heapifyInstance ( final Memory srcMem , final long seed ) { final short memSeedHash = ( short ) extractSeedHash ( srcMem ) ; final short computedSeedHash = computeSeedHash ( seed ) ; checkSeedHashes ( memSeedHash , computedSeedHash ) ; final int preLongs = extractPreLongs ( srcMem ) ; final boolean... | Heapifies the given source Memory with seed |
32,062 | static CompactSketch compact ( final UpdateSketch sketch ) { final int curCount = sketch . getRetainedEntries ( true ) ; long thetaLong = sketch . getThetaLong ( ) ; boolean empty = sketch . isEmpty ( ) ; thetaLong = thetaOnCompact ( empty , curCount , thetaLong ) ; empty = emptyOnCompact ( curCount , thetaLong ) ; fin... | Converts the given UpdateSketch to this compact form . |
32,063 | public static double select ( final double [ ] arr , int lo , int hi , final int pivot ) { while ( hi > lo ) { final int j = partition ( arr , lo , hi ) ; if ( j == pivot ) { return arr [ pivot ] ; } if ( j > pivot ) { hi = j - 1 ; } else { lo = j + 1 ; } } return arr [ pivot ] ; } | Gets the 0 - based kth order statistic from the array . Warning! This changes the ordering of elements in the given array! |
32,064 | public static double selectIncludingZeros ( final double [ ] arr , final int pivot ) { final int arrSize = arr . length ; final int adj = pivot - 1 ; return select ( arr , 0 , arrSize - 1 , adj ) ; } | Gets the 1 - based kth order statistic from the array including any zero values in the array . Warning! This changes the ordering of elements in the given array! |
32,065 | public static double selectExcludingZeros ( final double [ ] arr , final int nonZeros , final int pivot ) { if ( pivot > nonZeros ) { return 0L ; } final int arrSize = arr . length ; final int zeros = arrSize - nonZeros ; final int adjK = ( pivot + zeros ) - 1 ; return select ( arr , 0 , arrSize - 1 , adjK ) ; } | Gets the 1 - based kth order statistic from the array excluding any zero values in the array . Warning! This changes the ordering of elements in the given array! |
32,066 | static final CouponHashSet heapifySet ( final Memory mem ) { final int lgConfigK = extractLgK ( mem ) ; final TgtHllType tgtHllType = extractTgtHllType ( mem ) ; final CurMode curMode = extractCurMode ( mem ) ; final int memArrStart = ( curMode == CurMode . LIST ) ? LIST_INT_ARR_START : HASH_SET_INT_ARR_START ; final C... | will also accept List but results in a Set |
32,067 | static HeapQuickSelectSketch heapifyInstance ( final Memory srcMem , final long seed ) { final int preambleLongs = extractPreLongs ( srcMem ) ; final int lgNomLongs = extractLgNomLongs ( srcMem ) ; final int lgArrLongs = extractLgArrLongs ( srcMem ) ; checkUnionQuickSelectFamily ( srcMem , preambleLongs , lgNomLongs ) ... | Heapify a sketch from a Memory UpdateSketch or Union object containing sketch data . |
32,068 | private final void quickSelectAndRebuild ( ) { final int arrLongs = 1 << lgArrLongs_ ; final int pivot = ( 1 << lgNomLongs_ ) + 1 ; thetaLong_ = selectExcludingZeros ( cache_ , curCount_ , pivot ) ; final long [ ] tgtArr = new long [ arrLongs ] ; curCount_ = HashOperations . hashArrayInsert ( cache_ , tgtArr , lgArrLon... | array stays the same size . Changes theta and thus count |
32,069 | public T items ( final int i ) { loadArrays ( ) ; return ( sampleLists == null ? null : sampleLists . items [ i ] ) ; } | Returns a single item from the samples contained in the sketch . Does not perform bounds checking on the input . If this is the first getter call copies data arrays from the sketch . |
32,070 | public double weights ( final int i ) { loadArrays ( ) ; return ( sampleLists == null ? Double . NaN : sampleLists . weights [ i ] ) ; } | Returns a single weight from the samples contained in the sketch . Does not perform bounds checking on the input . If this is the first getter call copies data arrays from the sketch . |
32,071 | public SetOperationBuilder setNominalEntries ( final int nomEntries ) { bLgNomLongs = Integer . numberOfTrailingZeros ( ceilingPowerOf2 ( nomEntries ) ) ; if ( ( bLgNomLongs > MAX_LG_NOM_LONGS ) || ( bLgNomLongs < MIN_LG_NOM_LONGS ) ) { throw new SketchesArgumentException ( "Nominal Entries must be >= 16 and <= 6710886... | Sets the Nominal Entries for this set operation . The minimum value is 16 and the maximum value is 67 108 864 which is 2^26 . Be aware that Unions as large as this maximum value have not been thoroughly tested or characterized for performance . |
32,072 | public SetOperation build ( final Family family , final WritableMemory dstMem ) { SetOperation setOp = null ; switch ( family ) { case UNION : { if ( dstMem == null ) { setOp = UnionImpl . initNewHeapInstance ( bLgNomLongs , bSeed , bP , bRF ) ; } else { setOp = UnionImpl . initNewDirectInstance ( bLgNomLongs , bSeed ,... | Returns a SetOperation with the current configuration of this Builder the given Family and the given destination memory . Note that the destination memory cannot be used with AnotB . |
32,073 | static ReversePurgeLongHashMap getInstance ( final String string ) { final String [ ] tokens = string . split ( "," ) ; if ( tokens . length < 2 ) { throw new SketchesArgumentException ( "String not long enough to specify length and capacity." ) ; } final int numActive = Integer . parseInt ( tokens [ 0 ] ) ; final int ... | Returns an instance of this class from the given String which must be a String representation of this class . |
32,074 | String serializeToString ( ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( String . format ( "%d,%d," , numActive , keys . length ) ) ; for ( int i = 0 ; i < keys . length ; i ++ ) { if ( states [ i ] != 0 ) { sb . append ( String . format ( "%d,%d," , keys [ i ] , values [ i ] ) ) ; } } return sb . ... | Returns a String representation of this hash map . |
32,075 | void keepOnlyPositiveCounts ( ) { int firstProbe = keys . length - 1 ; while ( states [ firstProbe ] > 0 ) { firstProbe -- ; } for ( int probe = firstProbe ; probe -- > 0 ; ) { if ( ( states [ probe ] > 0 ) && ( values [ probe ] <= 0 ) ) { hashDelete ( probe ) ; numActive -- ; } } for ( int probe = keys . length ; prob... | Processes the map arrays and retains only keys with positive counts . |
32,076 | public static double getLowerBoundForBoverA ( final Sketch sketchA , final Sketch sketchB ) { final double thetaA = sketchA . getTheta ( ) ; final double thetaB = sketchB . getTheta ( ) ; checkThetas ( thetaA , thetaB ) ; final int countB = sketchB . getRetainedEntries ( true ) ; final int countA = ( thetaB == thetaA )... | Gets the approximate lower bound for B over A based on a 95% confidence interval |
32,077 | static < T > void blockyTandemMergeSort ( final T [ ] keyArr , final long [ ] valArr , final int arrLen , final int blkSize , final Comparator < ? super T > comparator ) { assert blkSize >= 1 ; if ( arrLen <= blkSize ) { return ; } int numblks = arrLen / blkSize ; if ( ( numblks * blkSize ) < arrLen ) { numblks += 1 ; ... | also used by ItemsAuxiliary |
32,078 | public static int decodeValue ( final short encodedSize ) { final int value = encodedSize & 0xFFFF ; if ( value > MAX_ENC_VALUE ) { throw new SketchesArgumentException ( "Maximum valid encoded value is " + Integer . toHexString ( MAX_ENC_VALUE ) + ", found: " + value ) ; } final int p = ( value >>> EXPONENT_SHIFT ) & E... | Decodes the 16 - bit reservoir size value into an int . |
32,079 | public static ConcurrentLimitRule of ( int concurrentLimit , TimeUnit timeOutUnit , long timeOut ) { requireNonNull ( timeOutUnit , "time out unit can not be null" ) ; return new ConcurrentLimitRule ( concurrentLimit , timeOutUnit . toMillis ( timeOut ) ) ; } | Initialise a concurrent rate limit . |
32,080 | public static RequestLimitRule of ( Duration duration , long limit ) { checkDuration ( duration ) ; if ( limit < 0 ) { throw new IllegalArgumentException ( "limit must be greater than zero." ) ; } int durationSeconds = ( int ) duration . getSeconds ( ) ; return new RequestLimitRule ( durationSeconds , limit , durationS... | Initialise a request rate limit . Imagine the whole duration window as being one large bucket with a single count . |
32,081 | public RequestLimitRule withName ( String name ) { return new RequestLimitRule ( this . durationSeconds , this . limit , this . precision , name , this . keys ) ; } | Applies a name to the rate limit that is useful for metrics . |
32,082 | public RequestLimitRule matchingKeys ( String ... keys ) { Set < String > keySet = keys . length > 0 ? new HashSet < > ( Arrays . asList ( keys ) ) : null ; return matchingKeys ( keySet ) ; } | Applies a key to the rate limit that defines to which keys the rule applies empty for any unmatched key . |
32,083 | public RequestLimitRule matchingKeys ( Set < String > keys ) { return new RequestLimitRule ( this . durationSeconds , this . limit , this . precision , this . name , keys ) ; } | Applies a key to the rate limit that defines to which keys the rule applies null for any unmatched key . |
32,084 | public void addScopeBindings ( Map < Class < ? extends Annotation > , Scope > bindings ) { if ( scopeCleaner . isRunning ( ) ) { scopeBindings . putAll ( bindings ) ; } } | allows late - binding of scopes to PreDestroyMonitor useful if more than one Injector contributes scope bindings |
32,085 | public void close ( ) throws Exception { if ( scopeCleaner . close ( ) ) { LOGGER . info ( "closing PreDestroyMonitor..." ) ; List < Map . Entry < Object , UnscopedCleanupAction > > actions = new ArrayList < > ( cleanupActions . entrySet ( ) ) ; if ( actions . size ( ) > 0 ) { LOGGER . warn ( "invoking predestroy actio... | final cleanup of managed instances if any |
32,086 | public InjectorBuilder combineWith ( Module ... modules ) { List < Module > m = new ArrayList < > ( ) ; m . add ( module ) ; m . addAll ( Arrays . asList ( modules ) ) ; this . module = Modules . combine ( m ) ; return this ; } | Add additional bindings to the module tracked by the DSL |
32,087 | public < T > InjectorBuilder forEachElement ( ElementVisitor < T > visitor , Consumer < T > consumer ) { Elements . getElements ( module ) . forEach ( element -> Optional . ofNullable ( element . acceptVisitor ( visitor ) ) . ifPresent ( consumer ) ) ; return this ; } | Iterate through all elements of the current module and pass the output of the ElementVisitor to the provided consumer . null responses from the visitor are ignored . |
32,088 | public < T > InjectorBuilder forEachElement ( ElementVisitor < T > visitor ) { Elements . getElements ( module ) . forEach ( element -> element . acceptVisitor ( visitor ) ) ; return this ; } | Call the provided visitor for all elements of the current module . |
32,089 | public InjectorBuilder filter ( ElementVisitor < Boolean > predicate ) { List < Element > elements = new ArrayList < Element > ( ) ; for ( Element element : Elements . getElements ( Stage . TOOL , module ) ) { if ( element . acceptVisitor ( predicate ) ) { elements . add ( element ) ; } } this . module = Elements . get... | Filter out elements for which the provided visitor returns true . |
32,090 | public static Module combineAndOverride ( List < ? extends Module > modules ) { Iterator < ? extends Module > iter = modules . iterator ( ) ; Module current = Modules . EMPTY_MODULE ; if ( iter . hasNext ( ) ) { current = iter . next ( ) ; if ( iter . hasNext ( ) ) { current = Modules . override ( current ) . with ( it... | Generate a single module that is produced by accumulating and overriding each module with the next . |
32,091 | public static Module fromClass ( final Class < ? > cls , final boolean override ) { List < Module > modules = new ArrayList < > ( ) ; for ( final Annotation annot : cls . getDeclaredAnnotations ( ) ) { final Class < ? extends Annotation > type = annot . annotationType ( ) ; Bootstrap bootstrap = type . getAnnotation ( ... | Create a single module that derived from all bootstrap annotations on a class where that class itself is a module . |
32,092 | public < T > Governator setFeature ( GovernatorFeature < T > feature , T value ) { this . featureOverrides . put ( feature , value ) ; return this ; } | Set a feature |
32,093 | private LifecycleInjector run ( Module externalModule , final String [ ] args ) { return InjectorBuilder . fromModules ( modules ) . combineWith ( externalModule ) . map ( new ModuleTransformer ( ) { public Module transform ( Module module ) { List < Module > modulesToTransform = Collections . singletonList ( module ) ... | Create the injector and call any LifecycleListeners |
32,094 | public String toFile ( ) throws Exception { File file = File . createTempFile ( "GuiceDependencies_" , ".dot" ) ; toFile ( file ) ; return file . getCanonicalPath ( ) ; } | Writes the Dot graph to a new temp file . |
32,095 | public void toFile ( File file ) throws Exception { PrintWriter out = new PrintWriter ( file , "UTF-8" ) ; try { out . write ( graph ( ) ) ; } finally { Closeables . close ( out , true ) ; } } | Writes the Dot graph to a given file . |
32,096 | public String graph ( ) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; PrintWriter out = new PrintWriter ( baos ) ; Injector localInjector = Guice . createInjector ( new GraphvizModule ( ) ) ; GraphvizGrapher renderer = localInjector . getInstance ( GraphvizGrapher . class ) ; renderer ... | Returns a String containing the Dot graph definition . |
32,097 | public boolean isGuiceConstructorInjected ( Class < ? > c ) { for ( Constructor < ? > con : c . getDeclaredConstructors ( ) ) { if ( isInjectable ( con ) ) { return true ; } } return false ; } | Determine if a class is an implicit Guice component that can be instantiated by Guice and the life - cycle managed by Jersey . |
32,098 | public Map < Scope , ComponentScope > createScopeMap ( ) { Map < Scope , ComponentScope > result = new HashMap < Scope , ComponentScope > ( ) ; result . put ( Scopes . SINGLETON , ComponentScope . Singleton ) ; result . put ( Scopes . NO_SCOPE , ComponentScope . PerRequest ) ; result . put ( ServletScopes . REQUEST , C... | Maps a Guice scope to a Jersey scope . |
32,099 | void addColumn ( String columnName ) { data . add ( new ArrayList < String > ( ) ) ; columnNames . add ( columnName ) ; } | Add a column |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.