idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
31,800 | public static SingleItemSketch create ( final long datum , final long seed ) { final long [ ] data = { datum } ; return new SingleItemSketch ( hash ( data , seed ) [ 0 ] >>> 1 ) ; } | Create this sketch with a long and a seed . |
31,801 | public static SingleItemSketch create ( final String datum , final long seed ) { if ( ( datum == null ) || datum . isEmpty ( ) ) { return null ; } final byte [ ] data = datum . getBytes ( UTF_8 ) ; return new SingleItemSketch ( hash ( data , seed ) [ 0 ] >>> 1 , seed ) ; } | Create this sketch with the given String and a seed . The string is converted to a byte array using UTF8 encoding . If the string is null or empty no create attempt is made and the method returns null . |
31,802 | public static SingleItemSketch create ( final byte [ ] data , final long seed ) { if ( ( data == null ) || ( data . length == 0 ) ) { return null ; } return new SingleItemSketch ( hash ( data , seed ) [ 0 ] >>> 1 , seed ) ; } | Create this sketch with the given byte array and a seed . If the byte array is null or empty no create attempt is made and the method returns null . |
31,803 | public void reset ( ) { isEmpty_ = true ; count_ = 0 ; theta_ = ( long ) ( Long . MAX_VALUE * ( double ) samplingProbability_ ) ; final int startingCapacity = Util . getStartingCapacity ( nomEntries_ , lgResizeFactor_ ) ; lgCurrentCapacity_ = Integer . numberOfTrailingZeros ( startingCapacity ) ; keys_ = new long [ sta... | Resets this sketch an empty state . |
31,804 | @ SuppressWarnings ( "unchecked" ) public CompactSketch < S > compact ( ) { if ( getRetainedEntries ( ) == 0 ) { return new CompactSketch < > ( null , null , theta_ , isEmpty_ ) ; } final long [ ] keys = new long [ getRetainedEntries ( ) ] ; final S [ ] summaries = ( S [ ] ) Array . newInstance ( summaries_ . getClass ... | Converts the current state of the sketch into a compact sketch |
31,805 | public VarOptItemsSketch < T > getResult ( ) { if ( gadget_ . getNumMarksInH ( ) == 0 ) { return simpleGadgetCoercer ( ) ; } else { final VarOptItemsSketch < T > tmp = detectAndHandleSubcaseOfPseudoExact ( ) ; if ( tmp != null ) { return tmp ; } else { return migrateMarkedItemsByDecreasingK ( ) ; } } } | Gets the varopt sketch resulting from the union of any input sketches . |
31,806 | private VarOptItemsSketch < T > markMovingGadgetCoercer ( ) { final int resultK = gadget_ . getHRegionCount ( ) + gadget_ . getRRegionCount ( ) ; int resultH = 0 ; int resultR = 0 ; int nextRPos = resultK ; final ArrayList < T > data = new ArrayList < > ( resultK + 1 ) ; final ArrayList < Double > weights = new ArrayLi... | This coercer directly transfers marked items from the gadget s H into the result s R . Deciding whether that is a valid thing to do is the responsibility of the caller . Currently this is only used for a subcase of pseudo - exact but later it might be used by other subcases as well . |
31,807 | static final long [ ] compactCache ( final long [ ] srcCache , final int curCount , final long thetaLong , final boolean dstOrdered ) { if ( curCount == 0 ) { return new long [ 0 ] ; } final long [ ] cacheOut = new long [ curCount ] ; final int len = srcCache . length ; int j = 0 ; for ( int i = 0 ; i < len ; i ++ ) { ... | Compact the given array . The source cache can be a hash table with interstitial zeros or dirty values . |
31,808 | static final long [ ] compactCachePart ( final long [ ] srcCache , final int lgArrLongs , final int curCount , final long thetaLong , final boolean dstOrdered ) { if ( curCount == 0 ) { return new long [ 0 ] ; } final long [ ] cacheOut = new long [ curCount ] ; final int len = 1 << lgArrLongs ; int j = 0 ; for ( int i ... | Compact first 2^lgArrLongs of given array |
31,809 | static final Memory loadCompactMemory ( final long [ ] compactCache , final short seedHash , final int curCount , final long thetaLong , final WritableMemory dstMem , final byte flags , final int preLongs ) { assert ( dstMem != null ) && ( compactCache != null ) ; final int outLongs = preLongs + curCount ; final int ou... | compactCache and dstMem must be valid |
31,810 | public static LongsSketch getInstance ( final String string ) { final String [ ] tokens = string . split ( "," ) ; if ( tokens . length < ( STR_PREAMBLE_TOKENS + 2 ) ) { throw new SketchesArgumentException ( "String not long enough: " + tokens . length ) ; } final int serVer = Integer . parseInt ( tokens [ 0 ] ) ; fina... | Returns a sketch instance of this class from the given String which must be a String representation of this sketch class . |
31,811 | public String serializeToString ( ) { final StringBuilder sb = new StringBuilder ( ) ; final int serVer = SER_VER ; final int famID = Family . FREQUENCY . getID ( ) ; final int lgMaxMapSz = lgMaxMapSize ; final int flags = ( hashMap . getNumActive ( ) == 0 ) ? EMPTY_FLAG_MASK : 0 ; final String fmt = "%d,%d,%d,%d,%d,%d... | Returns a String representation of this sketch |
31,812 | static ReversePurgeLongHashMap deserializeFromStringArray ( final String [ ] tokens ) { final int ignore = STR_PREAMBLE_TOKENS ; final int numActive = Integer . parseInt ( tokens [ ignore ] ) ; final int length = Integer . parseInt ( tokens [ ignore + 1 ] ) ; final ReversePurgeLongHashMap hashMap = new ReversePurgeLong... | Deserializes an array of String tokens into a hash map object of this class . |
31,813 | final int findKey ( final byte [ ] key ) { final int keyLen = key . length ; final long [ ] hash = MurmurHash3 . hash ( key , SEED ) ; int entryIndex = getIndex ( hash [ 0 ] , tableEntries_ ) ; final int stride = getStride ( hash [ 1 ] , tableEntries_ ) ; final int loopIndex = entryIndex ; do { if ( isBitClear ( stateA... | Returns the entry index for the given key given the array of keys if found . Otherwise returns the one s complement of first empty entry found ; |
31,814 | private static final int findEmpty ( final byte [ ] key , final int tableEntries , final byte [ ] stateArr ) { final long [ ] hash = MurmurHash3 . hash ( key , SEED ) ; int entryIndex = getIndex ( hash [ 0 ] , tableEntries ) ; final int stride = getStride ( hash [ 1 ] , tableEntries ) ; final int loopIndex = entryIndex... | Find the first empty slot for the given key . Only used by resize where it is known that the key does not exist in the table . Throws an exception if no empty slots . |
31,815 | private final boolean updateHll ( final int entryIndex , final int coupon ) { final int newValue = coupon16Value ( coupon ) ; final int hllIdx = coupon & ( k_ - 1 ) ; final int longIdx = hllIdx / 10 ; final int shift = ( ( hllIdx % 10 ) * 6 ) & SIX_BIT_MASK ; long hllLong = arrOfHllArr_ [ ( entryIndex * hllArrLongs_ ) ... | This method is specifically tied to the HLL array layout |
31,816 | private static short [ ] makeDecodingTable ( final short [ ] encodingTable , final int numByteValues ) { final short [ ] decodingTable = new short [ 4096 ] ; for ( int byteValue = 0 ; byteValue < numByteValues ; byteValue ++ ) { final int encodingEntry = encodingTable [ byteValue ] & 0xFFFF ; final int codeValue = enco... | Given an encoding table that maps unsigned bytes to codewords of length at most 12 this builds a size - 4096 decoding table . |
31,817 | static void validateDecodingTable ( final short [ ] decodingTable , final short [ ] encodingTable ) { for ( int decodeThis = 0 ; decodeThis < 4096 ; decodeThis ++ ) { final int tmpD = decodingTable [ decodeThis ] & 0xFFFF ; final int decodedByte = tmpD & 0xff ; final int decodedLength = tmpD >> 8 ; final int tmpE = enc... | These short arrays are being treated as unsigned |
31,818 | static DoublesUnionImpl directInstance ( final int maxK , final WritableMemory dstMem ) { final DirectUpdateDoublesSketch sketch = DirectUpdateDoublesSketch . newInstance ( maxK , dstMem ) ; final DoublesUnionImpl union = new DoublesUnionImpl ( maxK ) ; union . maxK_ = maxK ; union . gadget_ = sketch ; return union ; } | Returns a empty DoublesUnion object that refers to the given direct off - heap Memory which will be initialized to the empty state . |
31,819 | static DoublesUnionImpl heapifyInstance ( final DoublesSketch sketch ) { final int k = sketch . getK ( ) ; final DoublesUnionImpl union = new DoublesUnionImpl ( k ) ; union . maxK_ = k ; union . gadget_ = copyToHeap ( sketch ) ; return union ; } | Returns a Heap DoublesUnion object that has been initialized with the data from the given sketch . |
31,820 | static DoublesUnionImpl wrapInstance ( final WritableMemory mem ) { final DirectUpdateDoublesSketch sketch = DirectUpdateDoublesSketch . wrapInstance ( mem ) ; final DoublesUnionImpl union = new DoublesUnionImpl ( sketch . getK ( ) ) ; union . gadget_ = sketch ; return union ; } | Returns an updatable Union object that wraps off - heap data structure of the given memory image of a non - compact DoublesSketch . The data structures of the Union remain off - heap . |
31,821 | public static Sketch heapify ( final Memory srcMem , final long seed ) { final int serVer = srcMem . getByte ( SER_VER_BYTE ) ; if ( serVer == 3 ) { final byte famID = srcMem . getByte ( FAMILY_BYTE ) ; final boolean ordered = ( srcMem . getByte ( FLAGS_BYTE ) & ORDERED_FLAG_MASK ) != 0 ; return constructHeapSketch ( f... | Heapify takes the sketch image in Memory and instantiates an on - heap Sketch using the given seed . The resulting sketch will not retain any link to the source Memory . |
31,822 | static final boolean isValidSketchID ( final int id ) { return ( id == Family . ALPHA . getID ( ) ) || ( id == Family . QUICKSELECT . getID ( ) ) || ( id == Family . COMPACT . getID ( ) ) ; } | Returns true if given Family id is one of the theta sketches |
31,823 | static final void checkSketchAndMemoryFlags ( final Sketch sketch ) { final Memory mem = sketch . getMemory ( ) ; if ( mem == null ) { return ; } final int flags = PreambleUtil . extractFlags ( mem ) ; if ( ( ( flags & COMPACT_FLAG_MASK ) > 0 ) ^ sketch . isCompact ( ) ) { throw new SketchesArgumentException ( "Possibl... | Checks Ordered and Compact flags for integrity between sketch and Memory |
31,824 | private static final Sketch constructHeapSketch ( final byte famID , final boolean ordered , final Memory srcMem , final long seed ) { final boolean compact = ( srcMem . getByte ( FLAGS_BYTE ) & COMPACT_FLAG_MASK ) != 0 ; final Family family = idToFamily ( famID ) ; switch ( family ) { case ALPHA : { if ( compact ) { t... | Instantiates a Heap Sketch from Memory . |
31,825 | public static < T > ItemsUnion < T > getInstance ( final Comparator < ? super T > comparator ) { return new ItemsUnion < T > ( PreambleUtil . DEFAULT_K , comparator , null ) ; } | Create an instance of ItemsUnion with the default k |
31,826 | public static < T > ItemsUnion < T > getInstance ( final int maxK , final Comparator < ? super T > comparator ) { return new ItemsUnion < > ( maxK , comparator , null ) ; } | Create an instance of ItemsUnion |
31,827 | public static < T > ItemsUnion < T > getInstance ( final Memory srcMem , final Comparator < ? super T > comparator , final ArrayOfItemsSerDe < T > serDe ) { final ItemsSketch < T > gadget = ItemsSketch . getInstance ( srcMem , comparator , serDe ) ; return new ItemsUnion < > ( gadget . getK ( ) , gadget . getComparator... | Heapify the given srcMem into a Union object . |
31,828 | public static < T > ItemsUnion < T > getInstance ( final ItemsSketch < T > sketch ) { return new ItemsUnion < > ( sketch . getK ( ) , sketch . getComparator ( ) , ItemsSketch . copy ( sketch ) ) ; } | Create an instance of ItemsUnion based on ItemsSketch |
31,829 | public void update ( final ItemsSketch < T > sketchIn ) { gadget_ = updateLogic ( maxK_ , comparator_ , gadget_ , sketchIn ) ; } | Iterative union operation which means this method can be repeatedly called . Merges the given sketch into this union object . The given sketch is not modified . It is required that the ratio of the two K values be a power of 2 . This is easily satisfied if each of the K values is already a power of 2 . If the given ske... |
31,830 | public void update ( final Memory srcMem , final ArrayOfItemsSerDe < T > serDe ) { final ItemsSketch < T > that = ItemsSketch . getInstance ( srcMem , comparator_ , serDe ) ; gadget_ = updateLogic ( maxK_ , comparator_ , gadget_ , that ) ; } | Iterative union operation which means this method can be repeatedly called . Merges the given Memory image of a ItemsSketch into this union object . The given Memory object is not modified and a link to it is not retained . It is required that the ratio of the two K values be a power of 2 . This is easily satisfied if ... |
31,831 | public ItemsSketch < T > getResult ( ) { if ( gadget_ == null ) { return ItemsSketch . getInstance ( maxK_ , comparator_ ) ; } return ItemsSketch . copy ( gadget_ ) ; } | Gets the result of this Union operation as a copy of the internal state . This enables further union update operations on this state . |
31,832 | static long checkPreambleSize ( final Memory mem ) { final long cap = mem . getCapacity ( ) ; if ( cap < 8 ) { throwNotBigEnough ( cap , 8 ) ; } final long pre0 = mem . getLong ( 0 ) ; final int preLongs = ( int ) ( pre0 & 0X3FL ) ; final int required = Math . max ( preLongs << 3 , 8 ) ; if ( cap < required ) { throwNo... | Checks Memory for capacity to hold the preamble and returns the first 8 bytes . |
31,833 | static UnionImpl initNewHeapInstance ( final int lgNomLongs , final long seed , final float p , final ResizeFactor rf ) { final UpdateSketch gadget = new HeapQuickSelectSketch ( lgNomLongs , seed , p , rf , true ) ; final UnionImpl unionImpl = new UnionImpl ( gadget , seed ) ; unionImpl . unionThetaLong_ = gadget . get... | Construct a new Union SetOperation on the java heap . Called by SetOperationBuilder . |
31,834 | static UnionImpl initNewDirectInstance ( final int lgNomLongs , final long seed , final float p , final ResizeFactor rf , final MemoryRequestServer memReqSvr , final WritableMemory dstMem ) { final UpdateSketch gadget = new DirectQuickSelectSketch ( lgNomLongs , seed , p , rf , memReqSvr , dstMem , true ) ; final Union... | Construct a new Direct Union in the off - heap destination Memory . Called by SetOperationBuilder . |
31,835 | static UnionImpl heapifyInstance ( final Memory srcMem , final long seed ) { Family . UNION . checkFamilyID ( extractFamilyID ( srcMem ) ) ; final UpdateSketch gadget = HeapQuickSelectSketch . heapifyInstance ( srcMem , seed ) ; final UnionImpl unionImpl = new UnionImpl ( gadget , seed ) ; unionImpl . unionThetaLong_ =... | Heapify a Union from a Memory Union object containing data . Called by SetOperation . |
31,836 | static UnionImpl fastWrap ( final WritableMemory srcMem , final long seed ) { Family . UNION . checkFamilyID ( extractFamilyID ( srcMem ) ) ; final UpdateSketch gadget = DirectQuickSelectSketch . fastWritableWrap ( srcMem , seed ) ; final UnionImpl unionImpl = new UnionImpl ( gadget , seed ) ; unionImpl . unionThetaLon... | Fast - wrap a Union object around a Union Memory object containing data . This does NO validity checking of the given Memory . |
31,837 | static UnionImpl wrapInstance ( final Memory srcMem , final long seed ) { Family . UNION . checkFamilyID ( extractFamilyID ( srcMem ) ) ; final UpdateSketch gadget = DirectQuickSelectSketchR . readOnlyWrap ( srcMem , seed ) ; final UnionImpl unionImpl = new UnionImpl ( gadget , seed ) ; unionImpl . unionThetaLong_ = ex... | Wrap a Union object around a Union Memory object containing data . Called by SetOperation . |
31,838 | private void processVer1 ( final Memory skMem ) { final long thetaLongIn = skMem . getLong ( THETA_LONG ) ; unionThetaLong_ = min ( unionThetaLong_ , thetaLongIn ) ; final int curCount = skMem . getInt ( RETAINED_ENTRIES_INT ) ; final int preLongs = 3 ; for ( int i = 0 ; i < curCount ; i ++ ) { final int offsetBytes = ... | can only be compact ordered size > 24 |
31,839 | private void processVer2 ( final Memory skMem ) { Util . checkSeedHashes ( seedHash_ , skMem . getShort ( SEED_HASH_SHORT ) ) ; final int preLongs = skMem . getByte ( PREAMBLE_LONGS_BYTE ) & 0X3F ; final int curCount = skMem . getInt ( RETAINED_ENTRIES_INT ) ; final long thetaLongIn ; if ( preLongs == 1 ) { return ; } ... | can only be compact ordered size > = 8 |
31,840 | private void processVer3 ( final Memory skMem ) { Util . checkSeedHashes ( seedHash_ , skMem . getShort ( SEED_HASH_SHORT ) ) ; final int preLongs = skMem . getByte ( PREAMBLE_LONGS_BYTE ) & 0X3F ; final int curCount ; final long thetaLongIn ; if ( preLongs == 1 ) { final int flags = skMem . getByte ( FLAGS_BYTE ) ; if... | could be unordered ordered compact or not size > = 8 |
31,841 | static double usingXArrAndYStride ( final double [ ] xArr , final double yStride , final double x ) { final int xArrLen = xArr . length ; final int xArrLenM1 = xArrLen - 1 ; final int offset ; assert ( ( xArrLen >= 4 ) && ( x >= xArr [ 0 ] ) && ( x <= xArr [ xArrLenM1 ] ) ) ; if ( x == xArr [ xArrLenM1 ] ) { return ( y... | Used by HllEstimators |
31,842 | public static final Union heapify ( final Memory mem ) { final int lgK = HllUtil . checkLgK ( mem . getByte ( PreambleUtil . LG_K_BYTE ) ) ; final HllSketch sk = HllSketch . heapify ( mem ) ; final Union union = new Union ( lgK ) ; union . update ( sk ) ; return union ; } | Construct a union operator populated with the given Memory image of an HllSketch . |
31,843 | public void update ( final HllSketch sketch ) { gadget . hllSketchImpl = unionImpl ( sketch . hllSketchImpl , gadget . hllSketchImpl , lgMaxK ) ; } | Update this union operator with the given sketch . |
31,844 | private static final HllSketchImpl copyOrDownsampleHll ( final HllSketchImpl srcImpl , final int tgtLgK ) { assert srcImpl . getCurMode ( ) == HLL ; final AbstractHllArray src = ( AbstractHllArray ) srcImpl ; final int srcLgK = src . getLgConfigK ( ) ; if ( ( srcLgK <= tgtLgK ) && ( src . getTgtHllType ( ) == TgtHllTyp... | Caller must ultimately manage oooFlag as caller has more info |
31,845 | public Group init ( final String priKey , final int count , final double estimate , final double ub , final double lb , final double fraction , final double rse ) { this . count = count ; est = estimate ; this . ub = ub ; this . lb = lb ; this . fraction = fraction ; this . rse = rse ; this . priKey = priKey ; return t... | Specifies the parameters to be listed as columns |
31,846 | public static double getEstimate ( final Memory srcMem ) { checkIfValidThetaSketch ( srcMem ) ; return Sketch . estimate ( getThetaLong ( srcMem ) , getRetainedEntries ( srcMem ) , getEmpty ( srcMem ) ) ; } | Gets the unique count estimate from a valid memory image of a Sketch |
31,847 | protected void rebuild ( final int newCapacity ) { final int numValues = getNumValues ( ) ; checkIfEnoughMemory ( mem_ , newCapacity , numValues ) ; final int currCapacity = getCurrentCapacity ( ) ; final long [ ] keys = new long [ currCapacity ] ; final double [ ] values = new double [ currCapacity * numValues ] ; mem... | rebuild in the same memory |
31,848 | static HeapAlphaSketch newHeapInstance ( final int lgNomLongs , final long seed , final float p , final ResizeFactor rf ) { if ( lgNomLongs < ALPHA_MIN_LG_NOM_LONGS ) { throw new SketchesArgumentException ( "This sketch requires a minimum nominal entries of " + ( 1 << ALPHA_MIN_LG_NOM_LONGS ) ) ; } final double nomLong... | Get a new sketch instance on the java heap . |
31,849 | static HeapAlphaSketch heapifyInstance ( final Memory srcMem , final long seed ) { final int preambleLongs = extractPreLongs ( srcMem ) ; final int lgNomLongs = extractLgNomLongs ( srcMem ) ; final int lgArrLongs = extractLgArrLongs ( srcMem ) ; checkAlphaFamily ( srcMem , preambleLongs , lgNomLongs ) ; checkMemIntegri... | Heapify a sketch from a Memory object containing sketch data . |
31,850 | private static final int getR ( final double theta , final double alpha , final double p ) { final double split1 = ( p * ( alpha + 1.0 ) ) / 2.0 ; if ( theta > split1 ) { return 0 ; } if ( theta > ( alpha * split1 ) ) { return 1 ; } return 2 ; } | Computes whether there have been 0 1 or 2 or more actual insertions into the cache in a numerically safe way . |
31,851 | public static ArrayOfDoublesUnion wrap ( final Memory mem , final long seed ) { return wrapUnionImpl ( ( WritableMemory ) mem , seed , false ) ; } | Wrap the given Memory and seed as an ArrayOfDoublesUnion |
31,852 | public void update ( final ArrayOfDoublesSketch sketchIn ) { if ( sketchIn == null ) { return ; } Util . checkSeedHashes ( seedHash_ , sketchIn . getSeedHash ( ) ) ; if ( sketch_ . getNumValues ( ) != sketchIn . getNumValues ( ) ) { throw new SketchesArgumentException ( "Incompatible sketches: number of values mismatch... | Updates the union by adding a set of entries from a given sketch |
31,853 | public ArrayOfDoublesCompactSketch getResult ( final WritableMemory dstMem ) { if ( sketch_ . getRetainedEntries ( ) > sketch_ . getNominalEntries ( ) ) { theta_ = Math . min ( theta_ , sketch_ . getNewTheta ( ) ) ; } if ( dstMem == null ) { return new HeapArrayOfDoublesCompactSketch ( sketch_ , theta_ ) ; } return new... | Returns the resulting union in the form of a compact sketch |
31,854 | static final void extractCommonHll ( final Memory srcMem , final HllArray hllArray ) { hllArray . putOutOfOrderFlag ( extractOooFlag ( srcMem ) ) ; hllArray . putCurMin ( extractCurMin ( srcMem ) ) ; hllArray . putHipAccum ( extractHipAccum ( srcMem ) ) ; hllArray . putKxQ0 ( extractKxQ0 ( srcMem ) ) ; hllArray . putKx... | used by heapify by all Heap HLL |
31,855 | static byte [ ] compactMemoryToByteArray ( final Memory srcMem , final int preLongs , final int curCount ) { final int outBytes = ( curCount + preLongs ) << 3 ; final byte [ ] byteArrOut = new byte [ outBytes ] ; srcMem . getByteArray ( 0 , byteArrOut , 0 , outBytes ) ; return byteArrOut ; } | Serializes a Memory based compact sketch to a byte array |
31,856 | static final void quickSelectAndRebuild ( final WritableMemory mem , final int preambleLongs , final int lgNomLongs ) { final int lgArrLongs = extractLgArrLongs ( mem ) ; final int curCount = extractCurCount ( mem ) ; final int arrLongs = 1 << lgArrLongs ; final long [ ] tmpArr = new long [ arrLongs ] ; final int preBy... | Rebuild the hashTable in the given Memory at its current size . Changes theta and thus count . This assumes a Memory preamble of standard form with correct values of curCount and thetaLong . ThetaLong and curCount will change . Afterwards caller must update local class members curCount and thetaLong from Memory . |
31,857 | static final void resize ( final WritableMemory mem , final int preambleLongs , final int srcLgArrLongs , final int tgtLgArrLongs ) { final int preBytes = preambleLongs << 3 ; final int srcHTLen = 1 << srcLgArrLongs ; final long [ ] srcHTArr = new long [ srcHTLen ] ; mem . getLongArray ( preBytes , srcHTArr , 0 , srcHT... | Resizes existing hash array into a larger one within a single Memory assuming enough space . This assumes a Memory preamble of standard form with the correct value of thetaLong . The Memory lgArrLongs will change . Afterwards the caller must update local copies of lgArrLongs and hashTableThreshold from Memory . |
31,858 | static final int actLgResizeFactor ( final long capBytes , final int lgArrLongs , final int preLongs , final int lgRF ) { final int maxHTLongs = Util . floorPowerOf2 ( ( ( int ) ( capBytes >>> 3 ) - preLongs ) ) ; final int lgFactor = Math . max ( Integer . numberOfTrailingZeros ( maxHTLongs ) - lgArrLongs , 0 ) ; retu... | Returns the actual log2 Resize Factor that can be used to grow the hash table . This will be an integer value between zero and the given lgRF inclusive ; |
31,859 | public UpdateSketchBuilder setLogNominalEntries ( final int lgNomEntries ) { bLgNomLongs = lgNomEntries ; if ( ( bLgNomLongs > MAX_LG_NOM_LONGS ) || ( bLgNomLongs < MIN_LG_NOM_LONGS ) ) { throw new SketchesArgumentException ( "Log Nominal Entries must be >= 4 and <= 26: " + lgNomEntries ) ; } return this ; } | Alternative method of setting the Nominal Entries for this sketch from the log_base2 value . This value is also used for building a shared concurrent sketch . The minimum value is 4 and the maximum value is 26 . Be aware that sketches as large as this maximum value may not have been thoroughly tested or characterized f... |
31,860 | public UpdateSketchBuilder setLocalNominalEntries ( final int nomEntries ) { bLocalLgNomLongs = Integer . numberOfTrailingZeros ( ceilingPowerOf2 ( nomEntries ) ) ; if ( ( bLocalLgNomLongs > MAX_LG_NOM_LONGS ) || ( bLocalLgNomLongs < MIN_LG_NOM_LONGS ) ) { throw new SketchesArgumentException ( "Nominal Entries must be ... | Sets the Nominal Entries for the concurrent local sketch . The minimum value is 16 and the maximum value is 67 108 864 which is 2^26 . Be aware that sketches as large as this maximum value have not been thoroughly tested or characterized for performance . |
31,861 | public UpdateSketchBuilder setLocalLogNominalEntries ( final int lgNomEntries ) { bLocalLgNomLongs = lgNomEntries ; if ( ( bLocalLgNomLongs > MAX_LG_NOM_LONGS ) || ( bLocalLgNomLongs < MIN_LG_NOM_LONGS ) ) { throw new SketchesArgumentException ( "Log Nominal Entries must be >= 4 and <= 26: " + lgNomEntries ) ; } return... | Alternative method of setting the Nominal Entries for a local concurrent sketch from the log_base2 value . The minimum value is 4 and the maximum value is 26 . Be aware that sketches as large as this maximum value have not been thoroughly tested or characterized for performance . |
31,862 | public UpdateSketch buildLocal ( final UpdateSketch shared ) { if ( ( shared == null ) || ! ( shared instanceof ConcurrentSharedThetaSketch ) ) { throw new SketchesStateException ( "The concurrent shared sketch must be built first." ) ; } return new ConcurrentHeapThetaBuffer ( bLocalLgNomLongs , bSeed , ( ConcurrentSha... | Returns a local concurrent UpdateSketch to be used as a per - thread local buffer along with the given concurrent shared UpdateSketch and the current configuration of this Builder |
31,863 | CpcSketch copy ( ) { final CpcSketch copy = new CpcSketch ( lgK , seed ) ; copy . numCoupons = numCoupons ; copy . mergeFlag = mergeFlag ; copy . fiCol = fiCol ; copy . windowOffset = windowOffset ; copy . slidingWindow = ( slidingWindow == null ) ? null : slidingWindow . clone ( ) ; copy . pairTable = ( pairTable == n... | Returns a copy of this sketch |
31,864 | public static int getMaxSerializedBytes ( final int lgK ) { checkLgK ( lgK ) ; if ( lgK <= 19 ) { return empiricalMaxBytes [ lgK - 4 ] + 40 ; } final int k = 1 << lgK ; return ( int ) ( 0.6 * k ) + 40 ; } | The actual size of a compressed CPC sketch has a small random variance but the following empirically measured size should be large enough for at least 99 . 9 percent of sketches . |
31,865 | public static CpcSketch heapify ( final Memory mem , final long seed ) { final CompressedState state = CompressedState . importFromMemory ( mem ) ; return uncompress ( state , seed ) ; } | Return the given Memory as a CpcSketch on the Java heap . |
31,866 | public static CpcSketch heapify ( final byte [ ] byteArray , final long seed ) { final Memory mem = Memory . wrap ( byteArray ) ; return heapify ( mem , seed ) ; } | Return the given byte array as a CpcSketch on the Java heap . |
31,867 | public final void reset ( ) { numCoupons = 0 ; mergeFlag = false ; fiCol = 0 ; windowOffset = 0 ; slidingWindow = null ; pairTable = null ; kxp = 1 << lgK ; hipEstAccum = 0 ; } | Resets this sketch to empty but retains the original LgK and Seed . |
31,868 | public byte [ ] toByteArray ( ) { final CompressedState state = CompressedState . compress ( this ) ; final long cap = state . getRequiredSerializedBytes ( ) ; final WritableMemory wmem = WritableMemory . allocate ( ( int ) cap ) ; state . exportToMemory ( wmem ) ; return ( byte [ ] ) wmem . getArray ( ) ; } | Return this sketch as a compressed byte array . |
31,869 | public void update ( final long datum ) { final long [ ] data = { datum } ; final long [ ] arr = hash ( data , seed ) ; hashUpdate ( arr [ 0 ] , arr [ 1 ] ) ; } | Present the given long as a potential unique item . |
31,870 | public void update ( final int [ ] data ) { if ( ( data == null ) || ( data . length == 0 ) ) { return ; } final long [ ] arr = hash ( data , seed ) ; hashUpdate ( arr [ 0 ] , arr [ 1 ] ) ; } | Present the given integer array as a potential unique item . If the integer array is null or empty no update attempt is made and the method returns . |
31,871 | Format getFormat ( ) { final int ordinal ; final Flavor f = getFlavor ( ) ; if ( ( f == Flavor . HYBRID ) || ( f == Flavor . SPARSE ) ) { ordinal = 2 | ( mergeFlag ? 0 : 1 ) ; } else { ordinal = ( ( slidingWindow != null ) ? 4 : 0 ) | ( ( ( pairTable != null ) && ( pairTable . getNumPairs ( ) > 0 ) ) ? 2 : 0 ) | ( merg... | Returns the Format of the serialized form of this sketch . |
31,872 | private static void promoteSparseToWindowed ( final CpcSketch sketch ) { final int lgK = sketch . lgK ; final int k = ( 1 << lgK ) ; final long c32 = sketch . numCoupons << 5 ; assert ( ( c32 == ( 3 * k ) ) || ( ( lgK == 4 ) && ( c32 > ( 3 * k ) ) ) ) ; final byte [ ] window = new byte [ k ] ; final PairTable newTable ... | In terms of flavor this promotes SPARSE to HYBRID . |
31,873 | static void refreshKXP ( final CpcSketch sketch , final long [ ] bitMatrix ) { final int k = ( 1 << sketch . lgK ) ; final double [ ] byteSums = new double [ 8 ] ; for ( int j = 0 ; j < 8 ; j ++ ) { byteSums [ j ] = 0.0 ; } for ( int i = 0 ; i < k ; i ++ ) { long row = bitMatrix [ i ] ; for ( int j = 0 ; j < 8 ; j ++ )... | Also used in test |
31,874 | private static void modifyOffset ( final CpcSketch sketch , final int newOffset ) { assert ( ( newOffset >= 0 ) && ( newOffset <= 56 ) ) ; assert ( newOffset == ( sketch . windowOffset + 1 ) ) ; assert ( newOffset == CpcUtil . determineCorrectOffset ( sketch . lgK , sketch . numCoupons ) ) ; assert ( sketch . slidingWi... | This moves the sliding window |
31,875 | private static void updateHIP ( final CpcSketch sketch , final int rowCol ) { final int k = 1 << sketch . lgK ; final int col = rowCol & 63 ; final double oneOverP = k / sketch . kxp ; sketch . hipEstAccum += oneOverP ; sketch . kxp -= invPow2 ( col + 1 ) ; } | Call this whenever a new coupon has been collected . |
31,876 | private static void updateWindowed ( final CpcSketch sketch , final int rowCol ) { assert ( ( sketch . windowOffset >= 0 ) && ( sketch . windowOffset <= 56 ) ) ; final int k = 1 << sketch . lgK ; final long c32pre = sketch . numCoupons << 5 ; assert c32pre >= ( 3L * k ) ; final long c8pre = sketch . numCoupons << 3 ; f... | The flavor is HYBRID PINNED or SLIDING . |
31,877 | static CpcSketch uncompress ( final CompressedState source , final long seed ) { checkSeedHashes ( computeSeedHash ( seed ) , source . seedHash ) ; final CpcSketch sketch = new CpcSketch ( source . lgK , seed ) ; sketch . numCoupons = source . numCoupons ; sketch . windowOffset = source . getWindowOffset ( ) ; sketch .... | also used in test |
31,878 | void hashUpdate ( final long hash0 , final long hash1 ) { int col = Long . numberOfLeadingZeros ( hash1 ) ; if ( col < fiCol ) { return ; } if ( col > 63 ) { col = 63 ; } final long c = numCoupons ; if ( c == 0 ) { promoteEmptyToSparse ( this ) ; } final long k = 1L << lgK ; final int row = ( int ) ( hash0 & ( k - 1L )... | Used here and for testing |
31,879 | void rowColUpdate ( final int rowCol ) { final int col = rowCol & 63 ; if ( col < fiCol ) { return ; } final long c = numCoupons ; if ( c == 0 ) { promoteEmptyToSparse ( this ) ; } final long k = 1L << lgK ; if ( ( c << 5 ) < ( 3L * k ) ) { updateSparse ( this , rowCol ) ; } else { updateWindowed ( this , rowCol ) ; } ... | Used by union and in testing |
31,880 | static long [ ] getBitMatrix ( final CpcUnion union ) { checkUnionState ( union ) ; return ( union . bitMatrix != null ) ? union . bitMatrix : CpcUtil . bitMatrixOfSketch ( union . accumulator ) ; } | used for testing only |
31,881 | public UpdatableSketchBuilder < U , S > setSamplingProbability ( final float samplingProbability ) { if ( ( samplingProbability < 0 ) || ( samplingProbability > 1f ) ) { throw new SketchesArgumentException ( "sampling probability must be between 0 and 1" ) ; } samplingProbability_ = samplingProbability ; return this ; ... | This is to set sampling probability . Default probability is 1 . |
31,882 | public UpdatableSketch < U , S > build ( ) { return new UpdatableSketch < > ( nomEntries_ , resizeFactor_ . lg ( ) , samplingProbability_ , summaryFactory_ ) ; } | Returns an UpdatableSketch with the current configuration of this Builder . |
31,883 | private void srcMemoryToCombinedBuffer ( final Memory srcMem , final int serVer , final boolean srcIsCompact , final int combBufCap ) { final int preLongs = 2 ; final int extra = ( serVer == 1 ) ? 3 : 2 ; final int preBytes = ( preLongs + extra ) << 3 ; final int k = getK ( ) ; combinedBuffer_ = new double [ combBufCap... | Loads the Combined Buffer from the given source Memory . The resulting Combined Buffer is allocated in this method and is always in compact form . |
31,884 | static final void internalHll4Update ( final AbstractHllArray host , final int slotNo , final int newValue ) { assert ( ( 0 <= slotNo ) && ( slotNo < ( 1 << host . getLgConfigK ( ) ) ) ) ; assert ( newValue > 0 ) ; final int curMin = host . getCurMin ( ) ; AuxHashMap auxHashMap = host . getAuxHashMap ( ) ; final int ra... | Only called by Hll4Array and DirectHll4Array |
31,885 | public static double getLowerBoundForBoverA ( final long a , final long b , final double f ) { checkInputs ( a , b , f ) ; if ( a == 0 ) { return 0.0 ; } if ( f == 1.0 ) { return ( double ) b / a ; } return approximateLowerBoundOnP ( a , b , NUM_STD_DEVS * hackyAdjuster ( f ) ) ; } | Return the approximate lower bound based on a 95% confidence interval |
31,886 | public static double getUpperBoundForBoverA ( final long a , final long b , final double f ) { checkInputs ( a , b , f ) ; if ( a == 0 ) { return 1.0 ; } if ( f == 1.0 ) { return ( double ) b / a ; } return approximateUpperBoundOnP ( a , b , NUM_STD_DEVS * hackyAdjuster ( f ) ) ; } | Return the approximate upper bound based on a 95% confidence interval |
31,887 | private static double hackyAdjuster ( final double f ) { final double tmp = Math . sqrt ( 1.0 - f ) ; return ( f <= 0.5 ) ? tmp : tmp + ( 0.01 * ( f - 0.5 ) ) ; } | This hackyAdjuster is tightly coupled with the width of the confidence interval normally specified with number of standard deviations . To simplify this interface the number of standard deviations has been fixed to 2 . 0 which corresponds to a confidence interval of 95% . |
31,888 | static final int coupon16 ( final byte [ ] identifier ) { final long [ ] hash = MurmurHash3 . hash ( identifier , SEED ) ; final int hllIdx = ( int ) ( ( ( hash [ 0 ] >>> 1 ) % 1024 ) & TEN_BIT_MASK ) ; final int lz = Long . numberOfLeadingZeros ( hash [ 1 ] ) ; final int value = ( lz > 62 ? 62 : lz ) + 1 ; return ( va... | Returns the HLL array index and value as a 16 - bit coupon given the identifier to be hashed and k . |
31,889 | public static < S extends Summary > Sketch < S > heapifySketch ( final Memory mem , final SummaryDeserializer < S > deserializer ) { final SerializerDeserializer . SketchType sketchType = SerializerDeserializer . getSketchType ( mem ) ; if ( sketchType == SerializerDeserializer . SketchType . QuickSelectSketch ) { retu... | Instantiate Sketch from a given Memory |
31,890 | public static < U , S extends UpdatableSummary < U > > UpdatableSketch < U , S > heapifyUpdatableSketch ( final Memory mem , final SummaryDeserializer < S > deserializer , final SummaryFactory < S > summaryFactory ) { return new UpdatableSketch < U , S > ( mem , deserializer , summaryFactory ) ; } | Instantiate UpdatableSketch from a given Memory |
31,891 | public void update ( final long [ ] data ) { if ( ( data == null ) || ( data . length == 0 ) ) { return ; } couponUpdate ( coupon ( hash ( data , DEFAULT_UPDATE_SEED ) ) ) ; } | Present the given long array as a potential unique item . If the long array is null or empty no update attempt is made and the method returns . |
31,892 | public static long hash ( final long in , final long seed ) { long hash = seed + P5 ; hash += 8 ; long k1 = in ; k1 *= P2 ; k1 = Long . rotateLeft ( k1 , 31 ) ; k1 *= P1 ; hash ^= k1 ; hash = ( Long . rotateLeft ( hash , 27 ) * P1 ) + P4 ; return finalize ( hash ) ; } | Returns a 64 - bit hash . |
31,893 | @ SuppressWarnings ( "null" ) public byte [ ] toByteArray ( ) { int summariesBytesLength = 0 ; byte [ ] [ ] summariesBytes = null ; final int count = getRetainedEntries ( ) ; if ( count > 0 ) { summariesBytes = new byte [ count ] [ ] ; for ( int i = 0 ; i < count ; i ++ ) { summariesBytes [ i ] = summaries_ [ i ] . toB... | 0 || | Flags | SkType | FamID | SerVer | Preamble_Longs | |
31,894 | static ArrayOfDoublesUnion heapifyUnion ( final Memory mem , final long seed ) { final SerializerDeserializer . SketchType type = SerializerDeserializer . getSketchType ( mem ) ; if ( type == SerializerDeserializer . SketchType . ArrayOfDoublesQuickSelectSketch ) { final ArrayOfDoublesQuickSelectSketch sketch = new Hea... | This is to create an instance given a serialized form and a custom seed |
31,895 | private static int asInteger ( final long [ ] data , final int n ) { int t ; int cnt = 0 ; long seed = 0 ; if ( n < 2 ) { throw new SketchesArgumentException ( "Given value of n must be > 1." ) ; } if ( n > ( 1 << 30 ) ) { while ( ++ cnt < 10000 ) { final long [ ] h = MurmurHash3 . hash ( data , seed ) ; t = ( int )... | Returns a deterministic uniform random integer with a minimum inclusive value of zero and a maximum exclusive value of n given the input data . |
31,896 | public static int modulo ( final long h0 , final long h1 , final int divisor ) { final long d = divisor ; final long modH0 = ( h0 < 0L ) ? addRule ( mulRule ( BIT62 , 2L , d ) , ( h0 & MAX_LONG ) , d ) : h0 % d ; final long modH1 = ( h1 < 0L ) ? addRule ( mulRule ( BIT62 , 2L , d ) , ( h1 & MAX_LONG ) , d ) : h1 % d ; ... | Returns the remainder from the modulo division of the 128 - bit output of the murmurHash3 by the divisor . |
31,897 | public List < Group > getResult ( final int [ ] priKeyIndices , final int limit , final int numStdDev , final char sep ) { final PostProcessor proc = new PostProcessor ( this , new Group ( ) , sep ) ; return proc . getGroupList ( priKeyIndices , numStdDev , limit ) ; } | Returns an ordered List of Groups of the most frequent distinct population of subset tuples represented by the count of entries of each group . |
31,898 | public double getLowerBound ( final int numStdDev , final int numSubsetEntries ) { if ( ! isEstimationMode ( ) ) { return numSubsetEntries ; } return BinomialBoundsN . getLowerBound ( numSubsetEntries , getTheta ( ) , numStdDev , isEmpty ( ) ) ; } | Gets the estimate of the lower bound of the true distinct population represented by the count of entries in a group . |
31,899 | public double getUpperBound ( final int numStdDev , final int numSubsetEntries ) { if ( ! isEstimationMode ( ) ) { return numSubsetEntries ; } return BinomialBoundsN . getUpperBound ( numSubsetEntries , getTheta ( ) , numStdDev , isEmpty ( ) ) ; } | Gets the estimate of the upper bound of the true distinct population represented by the count of entries in a group . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.