public ConsecutiveItemsHugeTidList(Counters counters, int highestTidList) { long startPos = 0; int top = Math.min(highestTidList, counters.getMaxFrequent() + 1); this.indexAndFreqs = new long[top * 2]; for (int i = 0; i < top; i++) { int itemIndex = i << 1; int count = counters.distinctTransactionsCounts[i]; if (count > 0) { this.indexAndFreqs[itemIndex] = startPos; startPos += count; } else { this.indexAndFreqs[itemIndex] = -1; } } this.tidLists = IntBigArrays.newBigArray(startPos); }
/** * Creates a new hash big set. * * <p>The actual table size will be the least power of two greater than * <code>expected</code>/<code>f</code>. * * @param expected the expected number of elements in the set. * @param f the load factor. */ public Long2IntOpenHashBigMap( final long expected, final float f ) { if ( f <= 0 || f > 1 ) throw new IllegalArgumentException( "Load factor must be greater than 0 and smaller than or equal to 1" ); if ( n < 0 ) throw new IllegalArgumentException( "The expected number of elements must be nonnegative" ); this.f = f; n = bigArraySize( expected, f ); maxFill = maxFill( n, f ); key = LongBigArrays.newBigArray( n ); value = IntBigArrays.newBigArray( n ); used = BooleanBigArrays.newBigArray( n ); initMasks(); }
@Override public TransactionsList clone() { try { IntHugeTransactionsList o = (IntHugeTransactionsList) super.clone(); o.indexSegmentsAndFreqs = Arrays.copyOf(this.indexSegmentsAndFreqs, this.indexSegmentsAndFreqs.length); o.concatenated = IntBigArrays.copy(this.concatenated); o.size = this.size; return o; } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; }
@Override public void addTransaction(int item, int transaction) { int itemIndex = item << 1; if (itemIndex > this.indexAndFreqs.length || this.indexAndFreqs[itemIndex] == -1) { throw new IllegalArgumentException("item " + item + " has no tidlist"); } long start = this.indexAndFreqs[itemIndex]; long index = this.indexAndFreqs[itemIndex + 1]; IntBigArrays.set(tidLists, start + index, transaction); this.indexAndFreqs[itemIndex + 1]++; }
@Override public TidList clone() { try { ConsecutiveItemsHugeTidList c = (ConsecutiveItemsHugeTidList) super.clone(); c.indexAndFreqs = Arrays.copyOf(this.indexAndFreqs, this.indexAndFreqs.length); c.tidLists = IntBigArrays.copy(this.tidLists); return c; } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; }
protected void rehash( final long newN ) { final boolean used[][] = this.used; final long key[][] = this.key; final int[][] value = this.value; final boolean newUsed[][] = BooleanBigArrays.newBigArray( newN ); final long newKey[][] = LongBigArrays.newBigArray( newN ); final int newValue[][] = IntBigArrays.newBigArray( newN ); final long newMask = newN - 1; final int newSegmentMask = newKey[ 0 ].length - 1; final int newBaseMask = newKey.length - 1; int base = 0, displ = 0; long h; long k; for ( long i = size; i-- != 0; ) { while ( !used[ base ][ displ ] ) base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) ); k = key[ base ][ displ ]; h = it.unimi.dsi.fastutil.HashCommon.murmurHash3( k ); // The starting point. int d = (int)( h & newSegmentMask ); int b = (int)( ( h & newMask ) >>> BigArrays.SEGMENT_SHIFT ); while ( newUsed[ b ][ d ] ) b = ( b + ( ( d = ( d + 1 ) & newSegmentMask ) == 0 ? 1 : 0 ) ) & newBaseMask; newUsed[ b ][ d ] = true; newKey[ b ][ d ] = k; newValue[ b ][ d ] = value[ base ][ displ ]; base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) ); } this.n = newN; this.key = newKey; this.value = newValue; this.used = newUsed; initMasks(); maxFill = maxFill( n, f ); }
public IntHugeTransactionsList(long transactionsLength, int nbTransactions) { this.indexSegmentsAndFreqs = new int[nbTransactions * 3]; Arrays.fill(this.indexSegmentsAndFreqs, -1); this.concatenated = IntBigArrays.newBigArray(transactionsLength); }
@Override public int next() { return IntBigArrays.get(tidLists, this.i++); }