use of it.unimi.dsi.fastutil.ints.IntOpenHashSet in project angel by Tencent.
the class InitParam method split.
@Override
public List<PartitionUpdateParam> split() {
List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
IntOpenHashSet serverIds = new IntOpenHashSet();
List<PartitionUpdateParam> params = new ArrayList<>();
for (PartitionKey pkey : pkeys) {
int serverId = PSAgentContext.get().getMatrixMetaManager().getMasterPS(pkey).getIndex();
if (!serverIds.contains(serverId)) {
serverIds.add(serverId);
params.add(new InitPartitionParam(matrixId, pkey, numPartitions, maxIndex, maxLength, negative, order, partDim, window));
}
}
return params;
}
use of it.unimi.dsi.fastutil.ints.IntOpenHashSet in project angel by Tencent.
the class LINESecondOrderModel method dot.
@Override
public float[] dot(ByteBuf edges) {
Random negativeSeed = new Random(seed);
IntOpenHashSet numInputs = new IntOpenHashSet();
IntOpenHashSet numOutputs = new IntOpenHashSet();
int batchSize = edges.readInt();
float[] partialDots = new float[batchSize * (1 + negative)];
int dotInc = 0;
for (int position = 0; position < batchSize; position++) {
int src = edges.readInt();
// Skip-Gram model
float[] inputs = layers[src / numNodeOneRow];
int l1 = (src % numNodeOneRow) * dim * 2;
numInputs.add(src);
// Negative sampling
int target;
for (int a = 0; a < negative + 1; a++) {
if (a == 0)
target = edges.readInt();
else
do {
target = negativeSeed.nextInt(maxIndex);
} while (target == src);
numOutputs.add(target);
float[] outputs = layers[target / numNodeOneRow];
int l2 = (target % numNodeOneRow) * dim * 2 + dim;
float f = 0.0f;
for (int b = 0; b < dim; b++) f += inputs[l1 + b] * outputs[l2 + b];
partialDots[dotInc++] = f;
}
}
this.numInputsToUpdate = numInputs.size();
this.numOutputsToUpdate = numOutputs.size();
return partialDots;
}
use of it.unimi.dsi.fastutil.ints.IntOpenHashSet in project pinot by linkedin.
the class DistinctCountMVAggregationFunction method getOrCreateHashSetForGroupKey.
/**
* Returns the hash-set for the given group-key. Creates and returns one, if it does not exist.
*
* @param groupByResultHolder Result Holder
* @param groupKey Group key for which to get the hash set.
* @return Hash-set for the group key
*/
private IntOpenHashSet getOrCreateHashSetForGroupKey(@Nonnull GroupByResultHolder groupByResultHolder, int groupKey) {
IntOpenHashSet valueSet = groupByResultHolder.getResult(groupKey);
if (valueSet == null) {
valueSet = new IntOpenHashSet();
groupByResultHolder.setValueForKey(groupKey, valueSet);
}
return valueSet;
}
use of it.unimi.dsi.fastutil.ints.IntOpenHashSet in project druid by druid-io.
the class InDimFilter method getFloatPredicateSupplier.
private Supplier<DruidFloatPredicate> getFloatPredicateSupplier() {
return new Supplier<DruidFloatPredicate>() {
private final Object initLock = new Object();
private DruidFloatPredicate predicate;
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 = new DruidFloatPredicate() {
@Override
public boolean applyFloat(float input) {
return floatBitsHashSet.contains(Float.floatToIntBits(input));
}
};
} else {
final int[] floatBitsArray = floatBits.toIntArray();
Arrays.sort(floatBitsArray);
predicate = new DruidFloatPredicate() {
@Override
public boolean applyFloat(float input) {
return Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0;
}
};
}
}
}
@Override
public DruidFloatPredicate get() {
initFloatValues();
return predicate;
}
};
}
use of it.unimi.dsi.fastutil.ints.IntOpenHashSet in project geode by apache.
the class GatewaySenderEventCallbackArgument method fromData.
@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());
}
}
Aggregations