当前位置: 首页>>代码示例>>Java>>正文


Java Int2ObjectMap.put方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2ObjectMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java Int2ObjectMap.put方法的具体用法?Java Int2ObjectMap.put怎么用?Java Int2ObjectMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.ints.Int2ObjectMap的用法示例。


在下文中一共展示了Int2ObjectMap.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replayTrain

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private void replayTrain(@Nonnull final ByteBuffer buf) {
    final int itemI = buf.getInt();
    final int knnSize = buf.getInt();

    final Int2ObjectMap<Int2FloatMap> knnItems = new Int2ObjectOpenHashMap<>(1024);
    final IntSet pairItems = new IntOpenHashSet();
    for (int i = 0; i < knnSize; i++) {
        int user = buf.getInt();
        int ruSize = buf.getInt();
        Int2FloatMap ru = new Int2FloatOpenHashMap(ruSize);
        ru.defaultReturnValue(0.f);

        for (int j = 0; j < ruSize; j++) {
            int itemK = buf.getInt();
            pairItems.add(itemK);
            float ruk = buf.getFloat();
            ru.put(itemK, ruk);
        }
        knnItems.put(user, ru);
    }

    for (int itemJ : pairItems) {
        train(itemI, knnItems, itemJ);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:SlimUDTF.java

示例2: kNNentries

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
        @Nonnull final MapObjectInspector knnItemsOI,
        @Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
        @Nonnull final MapObjectInspector knnItemsValueOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
        @Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
    if (knnItems == null) {
        knnItems = new Int2ObjectOpenHashMap<>(1024);
    } else {
        knnItems.clear();
    }

    int numElementOfKNNItems = 0;
    for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
        int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
        Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
            knnItemsValueKeyOI, knnItemsValueValueOI);
        knnItems.put(user, ru);
        numElementOfKNNItems += ru.size();
    }

    nnzKNNi.setValue(numElementOfKNNItems);
    return knnItems;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:SlimUDTF.java

示例3: buildNonCompositeAggregatorIDMap

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
protected void buildNonCompositeAggregatorIDMap(String aggregatorName, FieldsDescriptor inputDescriptor,
    IntArrayList aggIDList, Int2ObjectMap<FieldsDescriptor> inputMap, Int2ObjectMap<FieldsDescriptor> outputMap)
{
  IncrementalAggregator incrementalAggregator = aggregatorRegistry.getNameToIncrementalAggregator().get(
      aggregatorName);
  //don't need to build OTF aggregate
  if (incrementalAggregator == null) {
    return;
  }
  int aggregatorID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggregatorName);
  mergeAggregatorID(aggIDList, aggregatorID);
  inputMap.put(aggregatorID, inputDescriptor);
  outputMap.put(aggregatorID,
      AggregatorUtils.getOutputFieldsDescriptor(inputDescriptor,
      incrementalAggregator));
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:DimensionalConfigurationSchema.java

示例4: testRemoveUselessNodes

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
@Test
public void testRemoveUselessNodes() {
    int imageWidth = 10;
    int imageHeight = 10;
    int tileLeftX = 0;
    int tileTopY = 0;
    int tileSizeX = 3;
    int tileSizeY = 3;
    int tileMargin = 1;

    Graph graph = checkGraph(imageWidth);

    ProcessingTile tile = AbstractTileSegmenter.buildTile(tileLeftX, tileTopY, tileSizeX, tileSizeY, tileMargin, imageWidth, imageHeight);

    Int2ObjectMap<Node> borderNodes = new Int2ObjectLinkedOpenHashMap<Node>(1);
    Node node = graph.getNodeAt(0);
    borderNodes.put(node.getId(), node);
    graph.removeUselessNodes(borderNodes, tile);

    assertEquals(1, graph.getNodeCount());
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:22,代码来源:GraphTest.java

示例5: groupOnDimension

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
/**
 * Group all documents based on a dimension's value.
 *
 * @param startDocId Start document id of the range to be grouped
 * @param endDocId End document id (exclusive) of the range to be grouped
 * @param dimensionId Index of the dimension to group on
 * @return Map from dimension value to a pair of start docId and end docId (exclusive)
 */
public Int2ObjectMap<IntPair> groupOnDimension(int startDocId, int endDocId, int dimensionId) {
  int startDocIdOffset = startDocId - _startDocId;
  int endDocIdOffset = endDocId - _startDocId;
  Int2ObjectMap<IntPair> rangeMap = new Int2ObjectLinkedOpenHashMap<>();
  int dimensionOffset = dimensionId * V1Constants.Numbers.INTEGER_SIZE;
  int currentValue = _dataBuffer.getInt(startDocIdOffset * _docSize + dimensionOffset);
  int groupStartDocId = startDocId;
  for (int i = startDocIdOffset + 1; i < endDocIdOffset; i++) {
    int value = _dataBuffer.getInt(i * _docSize + dimensionOffset);
    if (value != currentValue) {
      int groupEndDocId = i + _startDocId;
      rangeMap.put(currentValue, new IntPair(groupStartDocId, groupEndDocId));
      currentValue = value;
      groupStartDocId = groupEndDocId;
    }
  }
  rangeMap.put(currentValue, new IntPair(groupStartDocId, endDocId));
  return rangeMap;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:28,代码来源:StarTreeDataTable.java

示例6: deserialize

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
public static InventorySnapshot deserialize(List<DataView> itemDataViews) {
    final ObjectSerializer<LanternItemStack> itemStackSerializer = ObjectSerializerRegistry.get().get(LanternItemStack.class).get();
    final Int2ObjectMap<ItemStackSnapshot> itemsByIndex = new Int2ObjectOpenHashMap<>();
    for (DataView itemDataView : itemDataViews) {
        final int slot = itemDataView.getByte(SLOT).get() & 0xff;
        final ItemStackSnapshot itemStackSnapshot = itemStackSerializer.deserialize(itemDataView).createSnapshot();
        itemsByIndex.put(slot, itemStackSnapshot);
    }
    return InventorySnapshot.ofRawMap(itemsByIndex);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:InventorySnapshotSerializer.java

示例7: 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;

}
 
开发者ID:jankotek,项目名称:talk-save-java-memory,代码行数:14,代码来源:SpecializedMaps.java

示例8: 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);
//        }

    }
 
开发者ID:besil,项目名称:Neo4jSNA,代码行数:34,代码来源:LouvainTest.java

示例9: buildFeatureIndexMap

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
private static Int2ObjectMap<String> buildFeatureIndexMap(String[] featuresFromModelFile) {
    Int2ObjectMap<String> result = new Int2ObjectOpenHashMap<>(featuresFromModelFile.length);
    for (int i = 0; i < featuresFromModelFile.length; i++) {
        result.put(i, featuresFromModelFile[i]);
    }
    return result;
}
 
开发者ID:staples-sparx,项目名称:Sequoia,代码行数:8,代码来源:ScikitGBMParser.java

示例10: execute

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
/**
   * Computes the LHS
   *
   * @param maximalSets    The set of the complements of maximal sets (see Phase 2 for further information)
   * @param nrOfAttributes The number attributes in the whole relation
   * @return {@code Int2ObjectMap<List<OpenBitSet>>} (key: dependent attribute, value: set of all lefthand sides)
   */
  public Int2ObjectMap<List<OpenBitSet>> execute(List<CMAX_SET> maximalSets, int nrOfAttributes) {

      if (this.timeMesurement) {
          this.startTime();
      }

      Int2ObjectMap<List<OpenBitSet>> lhs = new Int2ObjectOpenHashMap<List<OpenBitSet>>();

/* 1: for all attributes A in R do */
      for (int attribute = 0; attribute < nrOfAttributes; attribute++) {

	/* 2: i:=1 */
          // int i = 1;

	/* 3: Li:={B | B in X, X in cmax(dep(r),A)} */
          Set<OpenBitSet> Li = new HashSet<OpenBitSet>();
          CMAX_SET correctSet = this.generateFirstLevelAndFindCorrectSet(maximalSets, attribute, Li);

          List<List<OpenBitSet>> lhs_a = new LinkedList<List<OpenBitSet>>();

	/* 4: while Li != ø do */
          while (!Li.isEmpty()) {

		/*
               * 5: LHSi[A]:={l in Li | l intersect X != ø, for all X in cmax(dep(r),A)}
		 */
              List<OpenBitSet> lhs_i = findLHS(Li, correctSet);

		/* 6: Li:=Li/LHSi[A] */
              Li.removeAll(lhs_i);

		/*
               * 7: Li+1:={l' | |l'|=i+1 and for all l subset l' | |l|=i, l in Li}
		 */
              /*
		 * The generation of the next level is, as mentioned in the paper, done with the Apriori gen-function from the
		 * following paper: "Fast algorithms for mining association rules in large databases." - Rakesh Agrawal,
		 * Ramakrishnan Srikant
		 */
              Li = this.generateNextLevel(Li);

		/* 8: i:=i+1 */
              // i++;
              lhs_a.add(lhs_i);
          }

	/* 9: lhs(dep(r),A):= union LHSi[A] */
          if (!lhs.containsKey(attribute)) {
              lhs.put(attribute, new LinkedList<OpenBitSet>());
          }
          for (List<OpenBitSet> lhs_ia : lhs_a) {
              lhs.get(attribute).addAll(lhs_ia);
          }
      }

      if (this.timeMesurement) {
          this.stopTime();
      }

      return lhs;
  }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:69,代码来源:LeftHandSideGenerator.java

示例11: addNewSegment

import it.unimi.dsi.fastutil.ints.Int2ObjectMap; //导入方法依赖的package包/类
/**
 * Note that some readers might still access the oldest segment for a while -- we do NOT interrupt
 * readers accessing the old segment. The expected behavior is that after a while though, none of
 * them will reference it anymore (once their computation finishes) and the JVM can then
 * garbage-collect it. This lagging reading behavior is what makes it hard to explicitly recycle
 * the already allocated memory so we need memory for k+1 segments (where k is the number of
 * segments we'll maintain).
 *
 * @param numEdgesInLiveSegment          is the number of edges in the current live segment
 * @param numEdgesInNonLiveSegmentsMap   contains a map from segment id to number of edges in it
 * @param statsReceiver                  is where the stats are updated
 * @param bipartiteGraphSegmentProvider  provides the new segment to be added
 * @return the live segment that was added
 */
public T addNewSegment(
    int numEdgesInLiveSegment,
    Int2IntMap numEdgesInNonLiveSegmentsMap,
    StatsReceiver statsReceiver,
    BipartiteGraphSegmentProvider<T> bipartiteGraphSegmentProvider
) {
  final Int2ObjectMap<T> segments =
      new Int2ObjectOpenHashMap<T>(multiSegmentReaderAccessibleInfo.getSegments());
  numEdgesInNonLiveSegmentsMap.put(liveSegmentId, numEdgesInLiveSegment);
  int oldestSegmentId = multiSegmentReaderAccessibleInfo.oldestSegmentId;
  // remove a segment if we're at the limit
  if (multiSegmentReaderAccessibleInfo.getSegments().size() == maxNumSegments) {
    segments.remove(oldestSegmentId);
    numEdgesInNonLiveSegmentsMap.remove(oldestSegmentId);
    LOG.info("Removed segment " + oldestSegmentId);
    oldestSegmentId++;
  } else {
    statsReceiver.counter("numSegments").incr();
  }
  int newLiveSegmentId =  multiSegmentReaderAccessibleInfo.liveSegmentId + 1;
  // add a new segment
  T liveSegment =
      bipartiteGraphSegmentProvider.generateNewSegment(newLiveSegmentId, maxNumEdgesPerSegment);
  segments.put(newLiveSegmentId, liveSegment);
  // now make the switch for the readers -- this is immediately published and visible!
  multiSegmentReaderAccessibleInfo = new MultiSegmentReaderAccessibleInfo<T>(
          segments, oldestSegmentId, newLiveSegmentId);

  // flush the write
  liveSegmentId = newLiveSegmentId;

  numEdgesInNonLiveSegments = 0;
  for (int segmentEdgeCount : numEdgesInNonLiveSegmentsMap.values()) {
    numEdgesInNonLiveSegments += segmentEdgeCount;
  }
  LOG.info("Total number of edges in graph = " + numEdgesInNonLiveSegments);
  LOG.info("Created a new segment: oldestSegmentId = " + oldestSegmentId
      + ", and liveSegmentId = " + liveSegmentId);

  return liveSegment;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:56,代码来源:MultiSegmentReaderAccessibleInfoProvider.java


注:本文中的it.unimi.dsi.fastutil.ints.Int2ObjectMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。