本文整理汇总了Java中it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap类的典型用法代码示例。如果您正苦于以下问题:Java Long2IntOpenHashMap类的具体用法?Java Long2IntOpenHashMap怎么用?Java Long2IntOpenHashMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Long2IntOpenHashMap类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了Long2IntOpenHashMap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSeedIteration
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
@Test
public void testSeedIteration() throws Exception {
SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
salsaInternalState,
new LeftSalsaIteration(salsaInternalState),
new RightSalsaIteration(salsaInternalState),
new FinalSalsaIteration(salsaInternalState)
);
salsaIterations.resetWithRequest(salsaRequest, random);
salsaIterations.seedLeftSideForFirstIteration();
Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(3);
expectedCurrentLeftNodes.put(1, 900);
expectedCurrentLeftNodes.put(2, 91);
expectedCurrentLeftNodes.put(3, 10);
assertEquals(expectedCurrentLeftNodes, salsaInternalState.getCurrentLeftNodes());
}
示例2: testNonZeroDegreeSeedIteration
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
@Test
public void testNonZeroDegreeSeedIteration() throws Exception {
SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
salsaInternalStateSmallSeed,
new LeftSalsaIteration(salsaInternalStateSmallSeed),
new RightSalsaIteration(salsaInternalStateSmallSeed),
new FinalSalsaIteration(salsaInternalStateSmallSeed)
);
salsaIterations.resetWithRequest(salsaRequestSmallSeed, random);
salsaIterations.seedLeftSideForFirstIteration();
Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(1);
expectedCurrentLeftNodes.put(1, 1000);
assertEquals(expectedCurrentLeftNodes, salsaInternalStateSmallSeed.getCurrentLeftNodes());
}
示例3: CommonInternalState
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
/**
* Get a new instance of a fresh internal state.
*
* @param salsaStats is the stats object to use
* @param expectedNodesToHit is the number of nodes the random walk is expected to hit
*/
public CommonInternalState(
SalsaStats salsaStats,
int expectedNodesToHit) {
this.salsaStats = salsaStats;
this.currentLeftNodes = new Long2IntOpenHashMap(expectedNodesToHit);
this.currentRightNodes = new Long2IntOpenHashMap(expectedNodesToHit);
this.visitedRightNodes = new Long2ObjectOpenHashMap<NodeInfo>(expectedNodesToHit);
this.nonZeroSeedSet = new LongOpenHashSet(expectedNodesToHit);
}
示例4: testSingleRightIteration
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
@Test
public void testSingleRightIteration() throws Exception {
SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
salsaInternalState,
new LeftSalsaIteration(salsaInternalState),
new RightSalsaIteration(salsaInternalState),
new FinalSalsaIteration(salsaInternalState)
);
salsaIterations.resetWithRequest(salsaRequest, random);
SingleSalsaIteration leftSalsaIteration =
new LeftSalsaIteration(salsaInternalState);
leftSalsaIteration.resetWithRequest(salsaRequest, random);
SingleSalsaIteration rightSalsaIteration =
new RightSalsaIteration(salsaInternalState);
rightSalsaIteration.resetWithRequest(salsaRequest, random);
salsaIterations.seedLeftSideForFirstIteration();
leftSalsaIteration.runSingleIteration();
rightSalsaIteration.runSingleIteration();
Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(3);
expectedCurrentLeftNodes.put(1, 728);
expectedCurrentLeftNodes.put(2, 86);
expectedCurrentLeftNodes.put(3, 187);
assertTrue(salsaInternalState.getCurrentRightNodes().isEmpty());
assertEquals(expectedCurrentLeftNodes, salsaInternalState.getCurrentLeftNodes());
}
示例5: createGroupKeyMap
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
/**
* Helper method to create the group-key map, depending on the data type.
* Uses primitive maps when possible.
*
* @param keyType DataType for the key
* @return Map
*/
private Map createGroupKeyMap(FieldSpec.DataType keyType) {
Map map;
switch (keyType) {
case INT:
Int2IntMap intMap = new Int2IntOpenHashMap();
intMap.defaultReturnValue(INVALID_ID);
map = intMap;
break;
case LONG:
Long2IntOpenHashMap longMap = new Long2IntOpenHashMap();
longMap.defaultReturnValue(INVALID_ID);
map = longMap;
break;
case FLOAT:
Float2IntOpenHashMap floatMap = new Float2IntOpenHashMap();
floatMap.defaultReturnValue(INVALID_ID);
map = floatMap;
break;
case DOUBLE:
Double2IntOpenHashMap doubleMap = new Double2IntOpenHashMap();
doubleMap.defaultReturnValue(INVALID_ID);
map = doubleMap;
break;
case STRING:
Object2IntOpenHashMap<String> stringMap = new Object2IntOpenHashMap<>();
stringMap.defaultReturnValue(INVALID_ID);
map = stringMap;
break;
default:
throw new IllegalArgumentException("Illegal data type for no-dictionary key generator: " + keyType);
}
return map;
}
示例6: OnHeapLongDictionary
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
/**
* Constructor for the class.
* Populates the value <-> mappings.
*
* @param dataBuffer Pinot data buffer
* @param length Length of the dictionary
*/
public OnHeapLongDictionary(PinotDataBuffer dataBuffer, int length) {
super(dataBuffer, length, V1Constants.Numbers.LONG_SIZE, (byte) 0);
_valToDictId = new Long2IntOpenHashMap(length);
_valToDictId.defaultReturnValue(-1);
_dictIdToVal = new long[length];
for (int dictId = 0; dictId < length; dictId++) {
long value = getLong(dictId);
_dictIdToVal[dictId] = value;
_valToDictId.put(value, dictId);
}
}
示例7: testPowerLawDegreeEdgeIterator
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
@Test
public void testPowerLawDegreeEdgeIterator() throws Exception {
int maxNumNodes = 4;
int maxDegree = 6;
PowerLawDegreeEdgePool powerLawDegreeEdgePool =
new PowerLawDegreeEdgePool(maxNumNodes, maxDegree, 2.0, new NullStatsReceiver());
addEdgesToPool(powerLawDegreeEdgePool);
PowerLawDegreeEdgeRandomIterator powerLawDegreeEdgeRandomIterator =
new PowerLawDegreeEdgeRandomIterator(powerLawDegreeEdgePool);
Random random = new Random(90238490238409L);
int numSamples = 5;
powerLawDegreeEdgeRandomIterator.resetForNode(1, numSamples, random);
assertEquals(new IntArrayList(new int[]{13, 13, 11, 15, 14}),
new IntArrayList(powerLawDegreeEdgeRandomIterator));
powerLawDegreeEdgeRandomIterator.resetForNode(2, numSamples, random);
assertEquals(new IntArrayList(new int[]{22, 22, 21, 23, 22}),
new IntArrayList(powerLawDegreeEdgeRandomIterator));
powerLawDegreeEdgeRandomIterator.resetForNode(3, numSamples, random);
assertEquals(new IntArrayList(new int[]{31, 31, 31, 31, 31}),
new IntArrayList(powerLawDegreeEdgeRandomIterator));
powerLawDegreeEdgeRandomIterator.resetForNode(4, numSamples, random);
assertEquals(new IntArrayList(new int[]{43, 41, 43, 41, 42}),
new IntArrayList(powerLawDegreeEdgeRandomIterator));
powerLawDegreeEdgeRandomIterator.resetForNode(5, numSamples, random);
assertEquals(new IntArrayList(new int[]{51, 51, 51, 51, 51}),
new IntArrayList(powerLawDegreeEdgeRandomIterator));
// Test a larger sample
powerLawDegreeEdgeRandomIterator.resetForNode(4, 900, random);
Long2IntMap occurrenceCounts = new Long2IntOpenHashMap(3);
for (int sample : new IntArrayList(powerLawDegreeEdgeRandomIterator)) {
occurrenceCounts.put(sample, occurrenceCounts.get(sample) + 1);
}
assertEquals(301, occurrenceCounts.get(41));
assertEquals(296, occurrenceCounts.get(42));
assertEquals(303, occurrenceCounts.get(43));
}
示例8: buildFrequentTwoItemsets
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
/**
* Build the 2-itemsets.
*
* @param oneitems Frequent 1-itemsets
* @param relation Data relation
* @param dim Maximum dimensionality
* @param needed Minimum support needed
* @param ids Objects to process
* @param survivors Output: objects that had at least two 1-frequent items.
* @return Frequent 2-itemsets
*/
protected List<SparseItemset> buildFrequentTwoItemsets(List<OneItemset> oneitems, final Relation<BitVector> relation, final int dim, final int needed, DBIDs ids, ArrayModifiableDBIDs survivors) {
int f1 = 0;
long[] mask = BitsUtil.zero(dim);
for(OneItemset supported : oneitems) {
BitsUtil.setI(mask, supported.item);
f1++;
}
if(LOG.isStatistics()) {
LOG.statistics(new LongStatistic(STAT + "2-items.candidates", f1 * (long) (f1 - 1)));
}
// We quite aggressively size the map, assuming that almost each combination
// is present somewhere. If this won't fit into memory, we're likely running
// OOM somewhere later anyway!
Long2IntOpenHashMap map = new Long2IntOpenHashMap((f1 * (f1 - 1)) >>> 1);
final long[] scratch = BitsUtil.zero(dim);
for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) {
BitsUtil.setI(scratch, mask);
relation.get(iditer).andOnto(scratch);
int lives = 0;
for(int i = BitsUtil.nextSetBit(scratch, 0); i >= 0; i = BitsUtil.nextSetBit(scratch, i + 1)) {
for(int j = BitsUtil.nextSetBit(scratch, i + 1); j >= 0; j = BitsUtil.nextSetBit(scratch, j + 1)) {
long key = (((long) i) << 32) | j;
map.put(key, 1 + map.get(key));
++lives;
}
}
if(lives > 2) {
survivors.add(iditer);
}
}
// Generate candidates of length 2.
List<SparseItemset> frequent = new ArrayList<>(f1 * (int) FastMath.sqrt(f1));
for(ObjectIterator<Long2IntMap.Entry> iter = map.long2IntEntrySet().fastIterator(); iter.hasNext();) {
Long2IntMap.Entry entry = iter.next();
if(entry.getIntValue() >= needed) {
int ii = (int) (entry.getLongKey() >>> 32);
int ij = (int) (entry.getLongKey() & -1L);
frequent.add(new SparseItemset(new int[] { ii, ij }, entry.getIntValue()));
}
}
// The hashmap may produce them out of order.
Collections.sort(frequent);
if(LOG.isStatistics()) {
LOG.statistics(new LongStatistic(STAT + "2-items.frequent", frequent.size()));
}
return frequent;
}
示例9: UnionFindMapStorage
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
public UnionFindMapStorage(GraphDatabaseService db) {
this.db = db;
this.rootMap = new Long2LongOpenHashMap();
this.rankMap = new Long2IntOpenHashMap();
this.nodes = new NodeCounter().getNodeCount(db);
}
示例10: LongToIdMap
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
public LongToIdMap() {
_valueToIdMap = new Long2IntOpenHashMap();
_valueToIdMap.defaultReturnValue(INVALID_KEY);
_idToValueMap = new LongArrayList();
}
示例11: LexCoocTable
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; //导入依赖的package包/类
/**
* Constructor.
*
* @param initialCapacity
*/
public LexCoocTable(int initialCapacity) {
counts = new Long2IntOpenHashMap(initialCapacity);
counts.defaultReturnValue(0);
}