本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2ObjectMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java Int2ObjectMap.get方法的具体用法?Java Int2ObjectMap.get怎么用?Java Int2ObjectMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.Int2ObjectMap
的用法示例。
在下文中一共展示了Int2ObjectMap.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predict
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private static double predict(final int user, final int itemI,
@Nonnull final Int2ObjectMap<Int2FloatMap> knnItems, final int excludeIndex,
@Nonnull final FloatMatrix weightMatrix) {
final Int2FloatMap kNNu = knnItems.get(user);
if (kNNu == null) {
return 0.d;
}
double pred = 0.d;
for (Int2FloatMap.Entry e : Fastutil.fastIterable(kNNu)) {
final int itemK = e.getIntKey();
if (itemK == excludeIndex) {
continue;
}
float ruk = e.getFloatValue();
pred += ruk * weightMatrix.get(itemI, itemK, 0.d);
}
return pred;
}
示例2: initialize
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private int initialize(Int2ObjectMap<CustomTimeBucket> idToTimeBucket)
{
Preconditions.checkNotNull(idToTimeBucket);
int tempId = Integer.MIN_VALUE;
for (int timeBucketId : idToTimeBucket.keySet()) {
tempId = Math.max(tempId, timeBucketId);
CustomTimeBucket customTimeBucket = idToTimeBucket.get(timeBucketId);
textToTimeBucket.put(customTimeBucket.getText(), customTimeBucket);
Preconditions.checkNotNull(customTimeBucket);
timeBucketToId.put(customTimeBucket, timeBucketId);
}
return tempId;
}
示例3: bipartiteMatch
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private Collection<Alignment> bipartiteMatch(Int2ObjectMap<Entity> schema1, Int2ObjectMap<Entity> schema2, Mat m) {
MunkRes munkRes = new MunkRes(m);
double[] sim = m.sim();
final Collection<Alignment> alignmentSet = new ArrayList<>();
for(IntPair ip : munkRes.execute()) {
if(m.contains(ip._1, ip._2)) {
final String e1id = schema1.get(ip._1).id;
final String e2id = schema2.get(ip._2).id;
final double s = sim[m.ij2index(ip._1, ip._2)];
alignmentSet.add(new Alignment(e1id, e2id, Math.min(s,1.0)));
}
}
System.err.printf("Produced %d matches from %d x %d\n", alignmentSet.size(), schema1.size(), schema2.size());
return alignmentSet;
}
示例4: main
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
public static void main(String[] args) {
// create new map,
Int2ObjectMap<String> map =
new Int2ObjectOpenHashMap();
// put/get method has primitive arg, no unboxing!
map.put(1, "aa");
map.get(1);
//but it also implements full mapdb interface
Map<Integer, String> map2 = map;
}
示例5: initGraph
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Override
protected void initGraph() {
Int2ObjectMap<Node> nodes = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < 9; i++) {
Node n = db.createNode();
n.setProperty("id", i);
nodes.put(i, n);
}
for (int i = 0; i < 9; i++) {
Node src = nodes.get(i);
Node dst = (i + 1) % 3 != 0 ? nodes.get(i + 1) : nodes.get(i - 2);
src.createRelationshipTo(dst, CommonsRelationshipTypes.KNOWS);
// dst.createRelationshipTo(src, CommonsRelationshipTypes.KNOWS);
}
nodes.get(0).createRelationshipTo(nodes.get(3), CommonsRelationshipTypes.KNOWS);
nodes.get(3).createRelationshipTo(nodes.get(6), CommonsRelationshipTypes.KNOWS);
nodes.get(6).createRelationshipTo(nodes.get(0), CommonsRelationshipTypes.KNOWS);
// for (int i = 0; i < 9; i += 3) {
// Node src = nodes.get(i);
// Node dst1 = nodes.get((i + 3) % 9);
// Node dst2 = nodes.get((i + 6) % 9);
// src.createRelationshipTo(dst1, CommonsRelationshipTypes.KNOWS);
// // dst1.createRelationshipTo(src, CommonsRelationshipTypes.KNOWS);
// src.createRelationshipTo(dst2, CommonsRelationshipTypes.KNOWS);
// // dst2.createRelationshipTo(src, CommonsRelationshipTypes.KNOWS);
// }
}
示例6: getGroupStats
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Override
public Iterator<GroupStats> getGroupStats(final EZImhotepSession session, final Map<Integer, GroupKey> groupKeys, final List<StatReference> statRefs, final long timeoutTS) throws ImhotepOutOfMemoryException {
if(groupKeys.isEmpty()) { // we don't have any parent groups probably because all docs were filtered out
return Collections.<GroupStats>emptyList().iterator();
}
final StatReference countStatRef = session.pushStat(countStat);
final long[] counts = getCounts(countStatRef);
final Int2ObjectMap<Int2LongMap> groupToPositionToStats = getPercentileStats(session, groupKeys, countStatRef, counts);
final List<GroupStats> result = Lists.newArrayList();
final int statCount = statRefs.size();
final int groupCount = session.getNumGroups();
// get values for the normal stats
final TIntObjectHashMap<double[]> statsResults = (statCount > 0) ? getGroupStatsValues(session, statRefs, groupCount) : null;
// combine normal stats with distinct counts
for (int groupNum = 1; groupNum < groupCount; groupNum++) {
final Int2LongMap groupPercentileData = groupToPositionToStats.get(groupNum);
double[] statsVals = statsResults != null ? statsResults.get(groupNum) : null;
double[] values = new double[statCount + fields.size()];
for(int i = 0, statsValsIndex = 0; i < values.length; i++) {
if(groupPercentileData != null && groupPercentileData.containsKey(i)) { // percentile value
values[i] = groupPercentileData.get(i);
} else if(statsVals != null && statsValsIndex < statsVals.length) {
values[i] = statsVals[statsValsIndex++]; // normal stat value available
} else {
values[i] = 0; // normal stat not in stats array
}
}
GroupKey groupKey = groupKeys.get(groupNum);
result.add(new GroupStats(groupKey, values));
}
return result.iterator();
}
示例7: testMultiSegmentReverseIterationIncompleteLiveSegment
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Test
public void testMultiSegmentReverseIterationIncompleteLiveSegment() throws Exception {
LeftIndexedPowerLawMultiSegmentBipartiteGraph leftIndexedPowerLawMultiSegmentBipartiteGraph =
new LeftIndexedPowerLawMultiSegmentBipartiteGraph(
3, 3, 5, 2, 2.0, 5, new IdentityEdgeTypeMask(), new NullStatsReceiver());
addEdges(leftIndexedPowerLawMultiSegmentBipartiteGraph);
/** One segment is dropped so the segments should have the following edges:
* Segment 0: Dropped
* Segment 1: (2, 21), (4, 42), (3, 31)
* Segment 2: (2, 22), (1, 13), (4, 43)
* Segment 3: (5, 11)
*/
Int2ObjectMap<LeftIndexedBipartiteGraphSegment> segments =
leftIndexedPowerLawMultiSegmentBipartiteGraph.getSegments();
LeftIndexedBipartiteGraphSegment segment1 = segments.get(1);
assertEquals(new LongArrayList(new long[]{21}),
new LongArrayList(segment1.getLeftNodeEdges(2)));
assertEquals(new LongArrayList(new long[]{31}),
new LongArrayList(segment1.getLeftNodeEdges(3)));
assertEquals(new LongArrayList(new long[]{42}),
new LongArrayList(segment1.getLeftNodeEdges(4)));
LeftIndexedBipartiteGraphSegment segment2 = segments.get(2);
assertEquals(new LongArrayList(new long[]{13}),
new LongArrayList(segment2.getLeftNodeEdges(1)));
assertEquals(new LongArrayList(new long[]{22}),
new LongArrayList(segment2.getLeftNodeEdges(2)));
assertEquals(new LongArrayList(new long[]{43}),
new LongArrayList(segment2.getLeftNodeEdges(4)));
LeftIndexedBipartiteGraphSegment segment3 = segments.get(3);
assertEquals(new LongArrayList(new long[]{11}),
new LongArrayList(segment3.getLeftNodeEdges(5)));
// Test that the iterator returns the correct edges after the first segment is dropped.
assertEquals(new LongArrayList(new long[]{13}),
new LongArrayList(leftIndexedPowerLawMultiSegmentBipartiteGraph.getLeftNodeEdges(1)));
// Test that the iterator returns the correct edges and in reverse order when the edges are in different segments.
assertEquals(new LongArrayList(new long[]{43, 42}),
new LongArrayList(leftIndexedPowerLawMultiSegmentBipartiteGraph.getLeftNodeEdges(4)));
}
示例8: testMultiSegmentReverseIterationCompleteLiveSegment
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Test
public void testMultiSegmentReverseIterationCompleteLiveSegment() throws Exception {
LeftIndexedPowerLawMultiSegmentBipartiteGraph leftIndexedPowerLawMultiSegmentBipartiteGraph =
new LeftIndexedPowerLawMultiSegmentBipartiteGraph(
4, 4, 2, 10, 2.0, 20, new IdentityEdgeTypeMask(), new NullStatsReceiver());
for (long leftNode = 1; leftNode <= 2; leftNode++) {
for (long i = 0; i < 10; i++) {
leftIndexedPowerLawMultiSegmentBipartiteGraph.addEdge(leftNode, leftNode*10 + i, (byte) 0);
}
}
/** One segment is dropped so the segments should have the following edges:
* Segment 0: Dropped
* Segment 1: (1, 14), (1, 15), (1, 16), (1, 17)
* Segment 2: (1, 18), (1, 19), (2, 20), (2, 21)
* Segment 3: (2, 22), (2, 23), (2, 24), (2, 25)
* Segment 4: (2, 26), (2, 27), (2, 28), (2, 29)
*/
Int2ObjectMap<LeftIndexedBipartiteGraphSegment> segments =
leftIndexedPowerLawMultiSegmentBipartiteGraph.getSegments();
LeftIndexedBipartiteGraphSegment segment1 = segments.get(1);
assertEquals(new LongArrayList(new long[]{14, 15, 16, 17}),
new LongArrayList(segment1.getLeftNodeEdges(1)));
LeftIndexedBipartiteGraphSegment segment2 = segments.get(2);
assertEquals(new LongArrayList(new long[]{18, 19}),
new LongArrayList(segment2.getLeftNodeEdges(1)));
assertEquals(new LongArrayList(new long[]{20, 21}),
new LongArrayList(segment2.getLeftNodeEdges(2)));
LeftIndexedBipartiteGraphSegment segment3 = segments.get(3);
assertEquals(new LongArrayList(new long[]{22, 23, 24, 25}),
new LongArrayList(segment3.getLeftNodeEdges(2)));
LeftIndexedBipartiteGraphSegment segment4 = segments.get(4);
assertEquals(new LongArrayList(new long[]{26, 27, 28, 29}),
new LongArrayList(segment4.getLeftNodeEdges(2)));
// Test that the iterator returns the correct edges and in reverse order when the edges are in different segments.
assertEquals(new LongArrayList(new long[]{26, 27, 28, 29, 22, 23, 24, 25, 20, 21}),
new LongArrayList(leftIndexedPowerLawMultiSegmentBipartiteGraph.getLeftNodeEdges(2)));
}
示例9: setup
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Override
public void setup(Context.OperatorContext context)
{
super.setup(context);
LOG.info("Done setting up super");
aggregatorRegistry.setup();
//Create prepared statements
schema = new DimensionalConfigurationSchema(eventSchema, aggregatorRegistry);
List<FieldsDescriptor> keyFDs = schema.getDimensionsDescriptorIDToKeyDescriptor();
for (int ddID = 0; ddID < keyFDs.size(); ddID++) {
LOG.info("ddID {}", ddID);
FieldsDescriptor keyFD = keyFDs.get(ddID);
Int2ObjectMap<FieldsDescriptor> aggIDToAggFD = schema
.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(ddID);
Map<Integer, PreparedStatement> aggIDToStatement = ddIDToAggIDToStatement.get(ddID);
if (aggIDToStatement == null) {
aggIDToStatement = Maps.newHashMap();
ddIDToAggIDToStatement.put(ddID, aggIDToStatement);
}
for (Map.Entry<String, String> aggTable : tableNames.get(ddID).entrySet()) {
int aggID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggTable.getKey());
LOG.info("aggID {}", aggID);
FieldsDescriptor aggFD = aggIDToAggFD.get(aggID);
List<String> keyNames = keyFD.getFieldList();
keyNames.remove(DimensionsDescriptor.DIMENSION_TIME_BUCKET);
LOG.info("List fields {}", keyNames);
List<String> aggregateNames = aggFD.getFieldList();
LOG.info("List fields {}", aggregateNames);
String tableName = aggTable.getValue();
String statementString = buildStatement(tableName, keyNames, aggregateNames);
try {
aggIDToStatement.put(aggID, store.getConnection().prepareStatement(statementString));
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}
}
}
示例10: setup
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Override
public void setup(Context.OperatorContext context)
{
super.setup(context);
LOG.info("Done setting up super");
aggregatorRegistry.setup();
//Create prepared statements
schema = new DimensionalConfigurationSchema(eventSchema,
aggregatorRegistry);
List<FieldsDescriptor> keyFDs = schema.getDimensionsDescriptorIDToKeyDescriptor();
for(int ddID = 0; ddID < keyFDs.size(); ddID ++) {
LOG.info("ddID {}", ddID);
FieldsDescriptor keyFD = keyFDs.get(ddID);
Int2ObjectMap<FieldsDescriptor> aggIDToAggFD = schema.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(ddID);
Map<Integer, PreparedStatement> aggIDToStatement = ddIDToAggIDToStatement.get(ddID);
if(aggIDToStatement == null) {
aggIDToStatement = Maps.newHashMap();
ddIDToAggIDToStatement.put(ddID, aggIDToStatement);
}
for(Map.Entry<String, String> aggTable: tableNames.get(ddID).entrySet()) {
int aggID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggTable.getKey());
LOG.info("aggID {}", aggID);
FieldsDescriptor aggFD = aggIDToAggFD.get(aggID);
List<String> keyNames = keyFD.getFieldList();
keyNames.remove(DimensionsDescriptor.DIMENSION_TIME_BUCKET);
List<String> aggregateNames = aggFD.getFieldList();
String tableName = aggTable.getValue();
String statementString = buildStatement(tableName, keyNames, aggregateNames);
try {
aggIDToStatement.put(aggID, store.getConnection().prepareStatement(statementString));
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}
}
}
示例11: removeDuplicatedNodes
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
public void removeDuplicatedNodes(Int2ObjectMap<List<Node>> borderPixelMap, int imageWidth) {
ObjectIterator<Int2ObjectMap.Entry<List<Node>>> it = borderPixelMap.int2ObjectEntrySet().iterator();
while (it.hasNext()) {
Int2ObjectMap.Entry<List<Node>> entry = it.next();
List<Node> nodes = entry.getValue();
if (nodes.size() > 1) {
Node refNode = nodes.get(0); // refNode
// explore duplicated nodes
for (int i=1; i<nodes.size(); i++) {
Node currentNode = nodes.get(i);
int edgeCount = currentNode.getEdgeCount();
for (int k=0; k<edgeCount; k++) {
Edge edge = currentNode.getEdgeAt(k);
Node neighNit = edge.getTarget();
int removedEdgeIndex = neighNit.removeEdge(currentNode);
assert(removedEdgeIndex >= 0);
Edge edgeToFirstNode = neighNit.findEdge(refNode);
if (edgeToFirstNode == null) {
// create an edge neighNit -> refNode
neighNit.addEdge(refNode, edge.getBoundary());
// create an edge refNode -> neighNit
refNode.addEdge(neighNit, edge.getBoundary());
}
}
currentNode.setExpired(true);
}
IntSet borderCells = AbstractSegmenter.generateBorderCells(refNode.getContour(), refNode.getId(), imageWidth);
IntIterator itCells = borderCells.iterator();
while (itCells.hasNext()) {
int gridId = itCells.nextInt();
List<Node> resultNodes = borderPixelMap.get(gridId);
if (resultNodes != null) {
resultNodes.clear();
resultNodes.add(refNode);
}
}
}
}
removeExpiredNodes();
}
示例12: constructStarTree
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private void constructStarTree(TreeNode node, int startDocId, int endDocId, int level) throws IOException {
if (level == _dimensionsSplitOrder.size()) {
return;
}
int splitDimensionId = _dimensionsSplitOrder.get(level);
LOGGER.debug("Building tree at level: {} from startDoc: {} endDocId: {} splitting on dimension id: {}", level,
startDocId, endDocId, splitDimensionId);
int numDocs = endDocId - startDocId;
Int2ObjectMap<IntPair> dimensionRangeMap;
try (StarTreeDataTable dataTable = new StarTreeDataTable(
new MMapBuffer(_dataFile, startDocId * _docSize, numDocs * _docSize, MMapMode.READ_ONLY), _dimensionSize,
_metricSize, startDocId, endDocId)) {
dimensionRangeMap = dataTable.groupOnDimension(startDocId, endDocId, splitDimensionId);
}
LOGGER.debug("Group stats:{}", dimensionRangeMap);
node._childDimensionId = splitDimensionId;
// Reserve one space for star node
Map<Integer, TreeNode> children = new HashMap<>(dimensionRangeMap.size() + 1);
node._children = children;
for (Int2ObjectMap.Entry<IntPair> entry : dimensionRangeMap.int2ObjectEntrySet()) {
int childDimensionValue = entry.getIntKey();
TreeNode child = new TreeNode();
_numNodes++;
children.put(childDimensionValue, child);
// The range pair value is the relative value to the start document id
IntPair range = dimensionRangeMap.get(childDimensionValue);
int childStartDocId = range.getLeft();
child._startDocId = childStartDocId;
int childEndDocId = range.getRight();
child._endDocId = childEndDocId;
if (childEndDocId - childStartDocId > _maxNumLeafRecords) {
constructStarTree(child, childStartDocId, childEndDocId, level + 1);
}
}
// Directly return if we don't need to create star-node
if (_skipStarNodeCreationDimensions != null && _skipStarNodeCreationDimensions.contains(splitDimensionId)) {
return;
}
// Create star node
TreeNode starChild = new TreeNode();
_numNodes++;
children.put(StarTreeNode.ALL, starChild);
starChild._dimensionId = splitDimensionId;
starChild._dimensionValue = StarTreeNode.ALL;
Iterator<Pair<DimensionBuffer, MetricBuffer>> iterator =
getUniqueCombinations(startDocId, endDocId, splitDimensionId);
int starChildStartDocId = _numRawDocs + _numAggregatedDocs;
while (iterator.hasNext()) {
Pair<DimensionBuffer, MetricBuffer> next = iterator.next();
DimensionBuffer dimensions = next.getLeft();
MetricBuffer metrics = next.getRight();
appendToAggBuffer(dimensions, metrics);
}
_dataOutputStream.flush();
int starChildEndDocId = _numRawDocs + _numAggregatedDocs;
starChild._startDocId = starChildStartDocId;
starChild._endDocId = starChildEndDocId;
if (starChildEndDocId - starChildStartDocId > _maxNumLeafRecords) {
constructStarTree(starChild, starChildStartDocId, starChildEndDocId, level + 1);
}
}