@Override public Selection selectIsIn(Collection<String> strings) { IntOpenHashSet keys = new IntOpenHashSet(strings.size()); for (String string : strings) { int key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getInt(i))) { results.add(i); } } return results; }
@Override public int countUnique() { IntOpenHashSet hashSet = new IntOpenHashSet(data); hashSet.remove(TimeColumnType.missingValueIndicator()); return hashSet.size(); }
/** * Initialize the original set of recipient <code>Gateway</code>s. * * @param originalGatewaysReceivers The original recipient <code>Gateway</code>s. */ public void initializeReceipientDSIds(List<Integer> originalGatewaysReceivers) { this.receipientDSIds = new IntOpenHashSet(2); for (Integer id : originalGatewaysReceivers) { this.receipientDSIds.add(id); } }
private void initFloatValues() { if (predicate != null) { return; } synchronized (initLock) { if (predicate != null) { return; } IntArrayList floatBits = new IntArrayList(values.size()); for (String value : values) { Float floatValue = Floats.tryParse(value); if (floatValue != null) { floatBits.add(Float.floatToIntBits(floatValue)); } } if (floatBits.size() > NUMERIC_HASHING_THRESHOLD) { final IntOpenHashSet floatBitsHashSet = new IntOpenHashSet(floatBits); predicate = input -> floatBitsHashSet.contains(Float.floatToIntBits(input)); } else { final int[] floatBitsArray = floatBits.toIntArray(); Arrays.sort(floatBitsArray); predicate = input -> Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0; } } }
public IntColumnPreIndexStatsCollector(String column, StatsCollectorConfig statsCollectorConfig) { super(column, statsCollectorConfig); rawIntSet = new IntOpenHashSet(INITIAL_HASH_SET_SIZE); aggregatedIntSet = new IntOpenHashSet(INITIAL_HASH_SET_SIZE); }
IntOpenHashSet set = new IntOpenHashSet(); for (int j = 0; j <= i; j += NUM_GROUPS / MAX_SIZE_OF_SET) { set.add(j); String group = _groups.get(i); Assert.assertEquals(((Double) trimmedSumResultMap.get(group)).intValue(), i, ERROR_MESSAGE); Assert.assertEquals(((IntOpenHashSet) trimmedDistinctCountResultMap.get(group)).size(), i / (NUM_GROUPS / MAX_SIZE_OF_SET) + 1, ERROR_MESSAGE); finalDistinctCountResultMap.put(entry.getKey(), ((IntOpenHashSet) entry.getValue()).size());
FileUtils.deleteQuietly(TEMP_DIR); IntOpenHashSet intSet = new IntOpenHashSet(); while (intSet.size() < NUM_VALUES) { intSet.add(RANDOM.nextInt()); _intValues = intSet.toIntArray(); Arrays.sort(_intValues);
private UniqueInt(Var var, boolean sorted) { super(sorted); IntOpenHashSet keySet = new IntOpenHashSet(); for (int i = 0; i < var.rowCount(); i++) { int key = var.getInt(i); if (!keySet.contains(key)) { keySet.add(key); } } int[] elements = keySet.toIntArray(); if (sorted) { IntArrays.quickSort(elements, new UniqueIntComparator()); } Int2IntOpenHashMap uniqueKeys = new Int2IntOpenHashMap(); values = new IntArrayList(elements); for (int i = 0; i < elements.length; i++) { uniqueKeys.put(elements[i], i); } rowLists = new Int2ObjectOpenHashMap<>(); for (int i = 0; i < var.rowCount(); i++) { int key = var.getInt(i); int id = uniqueKeys.get(key); if (!rowLists.containsKey(id)) { rowLists.put(id, new IntArrayList()); } rowLists.get(id).add(i); } updateIdsByRow(var.rowCount()); }
final DataInputStream dis = new DataInputStream(new FileInputStream(corpus)); boolean inDoc = type != SourceType.FIRST; final IntOpenHashSet seen = new IntOpenHashSet(); long read = 0; while (dis.available() > 0) { if (type == SourceType.SIMPLE) { p.J++; seen.clear(); } else { if (inDoc) { p.J++; seen.clear(); inDoc = false; } else { if (tk < W) { p.mu.add(tk,1); if (!seen.contains(tk)) { p.df.add(tk,1); seen.add(tk);
/** * Helper method to set value for a groupKey into the result holder. * * @param groupByResultHolder Result holder * @param groupKey Group-key for which to set the value * @param value Value for the group key */ private void setValueForGroupKey(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey, int value) { IntOpenHashSet valueSet = getValueSet(groupByResultHolder, groupKey); valueSet.add(value); }
Random negRand = new Random(seed + 1); IntOpenHashSet indices = new IntOpenHashSet(); for (int s = 0; s < sentences.length; s++) { int len = sentences[s].length; for (int p = 0; p < len; p++) { int word = sentences[s][p]; indices.add(word); target = negRand.nextInt(numNode); } while (target == word); indices.add(target); return indices.toIntArray();
public boolean contains(long id) { if (id >= 0 && id <= 0x00000000FFFFFFFFL) { return this.ints.contains((int) id); } else { return this.longs.contains(id); } }
@Override public int[] successorArray() { if (outdegree < 0) { final int d = it0.outdegree(); final int[] s = it0.successorArray(); successors.clear(); for (int i = 0; i < d; i++) { final LazyIntIterator s1 = g1.successors(s[i]); int x; while ((x = s1.nextInt()) >= 0) successors.add(x); } outdegree = successors.size(); succ = IntArrays.ensureCapacity(succ, outdegree, 0); successors.toArray(succ); IntArrays.quickSort(succ, 0, outdegree); } return succ; }
@Override public int nextInt() { curr++; outdegree = bg.sample(); successors.clear(); if (! loops) successors.add(curr); for(int i = 0; i < outdegree; i++) while(! successors.add(random.nextInt(n))); if (! loops) successors.remove(curr); successorArray = IntArrays.grow(successorArray, outdegree); successors.toArray(successorArray); IntArrays.quickSort(successorArray, 0, outdegree); return curr; }
@Nonnull @Override public Integer extractFinalResult(@Nonnull IntOpenHashSet intermediateResult) { return intermediateResult.size(); }
/** * Serializes an AnchorText object * * @param out * Output Stream */ public void write(DataOutput out) throws IOException { out.writeByte(type); if(hasValidText()) { out.writeUTF(text); } if(hasValidDocumentList()) { out.writeInt(documentList.size()); IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { out.writeInt(iterator.next()); } } if(hasValidWeight()) { out.writeFloat(weight); } }
/** * Checks whether two lines of anchor text share a source/target document * * @param other The other anchor text * @return True if this line of anchor text has a common source/target * with the other line of anchor text. */ public boolean intersects(AnchorText other) { if(!hasValidDocumentList() || !other.hasValidDocumentList()) { return false; } if(getSize() < other.getSize()) { IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { if(other.containsDocument(iterator.next())) { return true; } } } else { IntIterator iterator = other.documentList.iterator(); while(iterator.hasNext()) { if(documentList.contains(iterator.next())) { return true; } } } return false; }
@Override public boolean addAll(Collection<? extends Integer> c) { // The resulting collection will be at least c.size() big if (f <= .5) ensureCapacity(c.size()); // The resulting collection will be sized for c.size() elements else tryCapacity(size() + c.size()); // The resulting collection will be tentatively sized for size() + c.size() // elements return super.addAll(c); } @Override