public IntColumnPreIndexStatsCollector(String column, StatsCollectorConfig statsCollectorConfig) { super(column, statsCollectorConfig); rawIntSet = new IntOpenHashSet(INITIAL_HASH_SET_SIZE); aggregatedIntSet = new IntOpenHashSet(INITIAL_HASH_SET_SIZE); }
@Nonnull @Override public IntOpenHashSet extractAggregationResult(@Nonnull AggregationResultHolder aggregationResultHolder) { IntOpenHashSet valueSet = aggregationResultHolder.getResult(); if (valueSet == null) { return new IntOpenHashSet(); } else { return valueSet; } }
@Override public IntSet deserialize(ByteBuffer byteBuffer) { int size = byteBuffer.getInt(); IntSet intSet = new IntOpenHashSet(size); for (int i = 0; i < size; i++) { intSet.add(byteBuffer.getInt()); } return intSet; } };
@Nonnull @Override public IntOpenHashSet extractGroupByResult(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey) { IntOpenHashSet valueSet = groupByResultHolder.getResult(groupKey); if (valueSet == null) { return new IntOpenHashSet(); } else { return valueSet; } }
/** * 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); } }
/** * Constructor. * * @param geca The original callback argument set by the caller or null if there was not callback * arg */ public GatewaySenderEventCallbackArgument(GatewaySenderEventCallbackArgument geca) { super(geca.getOriginalCallbackArg()); // _originalEventId = geca._originalEventId; originatingDSId = geca.originatingDSId; if (geca.receipientDSIds != null) { receipientDSIds = new IntOpenHashSet(geca.receipientDSIds); } }
/** * Returns the value set from the result holder or creates a new one if it does not exist. * * @param aggregationResultHolder Result holder * @return Value set from the result holder */ protected static IntOpenHashSet getValueSet(@Nonnull AggregationResultHolder aggregationResultHolder) { IntOpenHashSet valueSet = aggregationResultHolder.getResult(); if (valueSet == null) { valueSet = new IntOpenHashSet(); aggregationResultHolder.setValue(valueSet); } return valueSet; }
/** * Returns the value set for the given group key. If one does not exist, creates a new one and returns that. * * @param groupByResultHolder Result holder * @param groupKey Group key for which to return the value set * @return Value set for the group key */ protected static IntOpenHashSet getValueSet(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey) { IntOpenHashSet valueSet = groupByResultHolder.getResult(groupKey); if (valueSet == null) { valueSet = new IntOpenHashSet(); groupByResultHolder.setValueForKey(groupKey, valueSet); } return valueSet; } }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.originatingDSId = DataSerializer.readInteger(in); this.receipientDSIds = new IntOpenHashSet(2); int numberOfRecipientGateways = in.readInt(); for (int i = 0; i < numberOfRecipientGateways; i++) { this.receipientDSIds.add(in.readInt()); } }
IntRawValueBasedNotInPredicateEvaluator(NotInPredicate notInPredicate) { String[] values = notInPredicate.getValues(); _nonMatchingValues = new IntOpenHashSet(HashUtil.getMinHashSetSize(values.length)); for (String value : values) { _nonMatchingValues.add(Integer.parseInt(value)); } }
IntRawValueBasedInPredicateEvaluator(InPredicate inPredicate) { String[] values = inPredicate.getValues(); _matchingValues = new IntOpenHashSet(HashUtil.getMinHashSetSize(values.length)); for (String value : values) { _matchingValues.add(Integer.parseInt(value)); } }
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; } } }
private IntOpenHashSet[] getUserItemsSet(SequentialAccessSparseMatrix sparseMatrix) { IntOpenHashSet[] tempUserItemsSet = new IntOpenHashSet[numUsers]; for (int userIdx = 0; userIdx < numUsers; ++userIdx) { int[] itemIndices = sparseMatrix.row(userIdx).getIndices(); IntOpenHashSet itemSet = new IntOpenHashSet(itemIndices.length); for(int index = 0; index< itemIndices.length; index++){ itemSet.add(itemIndices[index]); } tempUserItemsSet[userIdx] = itemSet; } return tempUserItemsSet; } }
@Override public int countUnique() { IntOpenHashSet hashSet = new IntOpenHashSet(data); hashSet.remove(TimeColumnType.missingValueIndicator()); return hashSet.size(); }
@Test public void testIntSet() { for (int i = 0; i < NUM_ITERATIONS; i++) { int size = RANDOM.nextInt(100); IntSet expected = new IntOpenHashSet(size); for (int j = 0; j < size; j++) { expected.add(RANDOM.nextInt()); } byte[] bytes = ObjectSerDeUtils.serialize(expected); IntSet actual = ObjectSerDeUtils.deserialize(bytes, ObjectSerDeUtils.ObjectType.IntSet); // NOTE: use Object comparison instead of Collection comparison because the order might be different assertEquals((Object) actual, expected, ERROR_MESSAGE); } }
@Override public int countUnique() { IntSet ints = new IntOpenHashSet(size()); for (int i = 0; i < size(); i++) { ints.add(data.getInt(i)); } return ints.size(); }
@Override public TimeColumn unique() { IntSet ints = new IntOpenHashSet(data); TimeColumn column = emptyCopy(ints.size()); column.data = IntArrayList.wrap(ints.toIntArray()); column.setName(name() + " Unique values"); return column; }
@Override public int countUnique() { IntSet uniqueElements = new IntOpenHashSet(); for (int i = 0; i < size(); i++) { if (!isMissingValue(getInt(i))) { uniqueElements.add(getInt(i)); } } return uniqueElements.size(); }
DictionaryBasedInPredicateEvaluator(InPredicate inPredicate, Dictionary dictionary) { String[] values = inPredicate.getValues(); _matchingDictIdSet = new IntOpenHashSet(HashUtil.getMinHashSetSize(values.length)); for (String value : values) { int dictId = dictionary.indexOf(value); if (dictId >= 0) { _matchingDictIdSet.add(dictId); } } _numMatchingDictIds = _matchingDictIdSet.size(); if (_numMatchingDictIds == 0) { _alwaysFalse = true; } else if (dictionary.length() == _numMatchingDictIds) { _alwaysTrue = true; } }
@Override public DateColumn unique() { IntSet ints = new IntOpenHashSet(data.size()); for (int i = 0; i < size(); i++) { ints.add(data.getInt(i)); } DateColumn copy = emptyCopy(ints.size()); copy.setName(name() + " Unique values"); copy.data = IntArrayList.wrap(ints.toIntArray()); return copy; }