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


Java Object2IntMap.put方法代码示例

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


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

示例1: changeReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
public void changeReads(final Map<GATKSAMRecord, GATKSAMRecord> readRealignments) {
    final int sampleCount = samples.sampleCount();
    for (int s = 0; s < sampleCount; s++) {
        final GATKSAMRecord[] sampleReads = readsBySampleIndex[s];
        final Object2IntMap<GATKSAMRecord> readIndex = readIndexBySampleIndex[s];
        final int sampleReadCount = sampleReads.length;
        for (int r = 0; r < sampleReadCount; r++) {
            final GATKSAMRecord read = sampleReads[r];
            final GATKSAMRecord replacement = readRealignments.get(read);
            if (replacement == null)
                continue;
            sampleReads[r] = replacement;
            if (readIndex != null) {
                readIndex.remove(read);
                readIndex.put(replacement, r);
            }
        }
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:20,代码来源:ReadLikelihoods.java

示例2: calculateTermFreq

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
/**
 * Calculates a vector of attributes from a list of tokens
 * 
 * @param tokens the input tokens 
 * @param prefix the prefix of each vector attribute
 * @return an Object2IntMap object mapping the attributes to their values
 */		
public static Object2IntMap<String> calculateTermFreq(List<String> tokens, String prefix, boolean freqWeights) {
	Object2IntMap<String> termFreq = new Object2IntOpenHashMap<String>();

	// Traverse the strings and increments the counter when the token was
	// already seen before
	for (String token : tokens) {
		// add frequency weights if the flat is set
		if(freqWeights)
			termFreq.put(prefix+token, termFreq.getInt(prefix+token) + 1);
		// otherwise, just consider boolean weights
		else{
			if(!termFreq.containsKey(token))
				termFreq.put(prefix+token, 1);
		}
	}

	return termFreq;
}
 
开发者ID:felipebravom,项目名称:AffectiveTweets,代码行数:26,代码来源:Utils.java

示例3: arrangeTargets

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
/**
 * Rearrange the targets so that they are in a particular order.
 * @return a new collection.
 * @throws IllegalArgumentException if any of the following is true:
 * <ul>
 *     <li>{@code targetsInOrder} is {@code null},</li>
 *     <li>is empty,</li>
 *     <li>it contains {@code null},</li>
 *     <li>contains any target not present in this collection.</li>
 * </ul>
 */
public ReadCountCollection arrangeTargets(final List<Target> targetsInOrder) {
    Utils.nonNull(targetsInOrder);
    Utils.nonEmpty(targetsInOrder, "the input targets list cannot be empty");
    final RealMatrix counts = new Array2DRowRealMatrix(targetsInOrder.size(), columnNames.size());
    final Object2IntMap<Target> targetToIndex = new Object2IntOpenHashMap<>(targets.size());
    for (int i = 0; i < targets.size(); i++) {
        targetToIndex.put(targets.get(i), i);
    }
    for (int i = 0; i < targetsInOrder.size(); i++) {
        final Target target = targetsInOrder.get(i);
        Utils.validateArg(targetToIndex.containsKey(target), () -> String.format("target '%s' is not present in the collection", target.getName()));
        counts.setRow(i, this.counts.getRow(targetToIndex.getInt(target)));
    }
    return new ReadCountCollection(new ArrayList<>(targetsInOrder), columnNames, counts, false);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:27,代码来源:ReadCountCollection.java

示例4: changeReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
public void changeReads(final Map<GATKRead, GATKRead> readRealignments) {
    final int sampleCount = samples.numberOfSamples();
    for (int s = 0; s < sampleCount; s++) {
        final GATKRead[] sampleReads = readsBySampleIndex[s];
        final Object2IntMap<GATKRead> readIndex = readIndexBySampleIndex[s];
        final int sampleReadCount = sampleReads.length;
        for (int r = 0; r < sampleReadCount; r++) {
            final GATKRead read = sampleReads[r];
            final GATKRead replacement = readRealignments.get(read);
            if (replacement == null) {
                continue;
            }
            sampleReads[r] = replacement;
            if (readIndex != null) {
                readIndex.remove(read);
                readIndex.put(replacement, r);
            }
        }
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:21,代码来源:ReadLikelihoods.java

示例5: appendReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
private void appendReads(final List<GATKRead> newSampleReads, final int sampleIndex,
                         final int sampleReadCount, final int newSampleReadCount) {
    final GATKRead[] sampleReads = readsBySampleIndex[sampleIndex] =
            Arrays.copyOf(readsBySampleIndex[sampleIndex], newSampleReadCount);

    int nextReadIndex = sampleReadCount;
    final Object2IntMap<GATKRead> sampleReadIndex = readIndexBySampleIndex[sampleIndex];
    for (final GATKRead newRead : newSampleReads) {
        //    if (sampleReadIndex.containsKey(newRead)) // might be worth handle this without exception (ignore the read?) but in practice should never be the case.
        //        throw new IllegalArgumentException("you cannot add reads that are already in read-likelihood collection");
        if (sampleReadIndex != null ) {
            sampleReadIndex.put(newRead, nextReadIndex);
        }
        sampleReads[nextReadIndex++] = newRead;
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:17,代码来源:ReadLikelihoods.java

示例6: add

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
private <T> boolean add(Object2IntMap<T> map, T item) {
  if (!map.containsKey(item)) {
    map.put(item, NOT_SET);
    return true;
  }
  return false;
}
 
开发者ID:inferjay,项目名称:r8,代码行数:8,代码来源:FileWriter.java

示例7: appendReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
private void appendReads(final List<GATKSAMRecord> newSampleReads, final int sampleIndex,
                         final int sampleReadCount, final int newSampleReadCount) {
    final GATKSAMRecord[] sampleReads = readsBySampleIndex[sampleIndex] =
            Arrays.copyOf(readsBySampleIndex[sampleIndex], newSampleReadCount);

    int nextReadIndex = sampleReadCount;
    final Object2IntMap<GATKSAMRecord> sampleReadIndex = readIndexBySampleIndex[sampleIndex];
    for (final GATKSAMRecord newRead : newSampleReads) {
        //    if (sampleReadIndex.containsKey(newRead)) // might be worth handle this without exception (ignore the read?) but in practice should never be the case.
        //        throw new IllegalArgumentException("you cannot add reads that are already in read-likelihood collection");
        if (sampleReadIndex != null) sampleReadIndex.put(newRead, nextReadIndex);
        sampleReads[nextReadIndex++] = newRead;
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:15,代码来源:ReadLikelihoods.java

示例8: initWithSlots

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
void initWithSlots(List<AbstractMutableInventory> children, List<? extends AbstractSlot> slots,
        @Nullable List<? extends AbstractSlot> prioritizedSlots) {
    this.children = children;
    final Object2IntMap<AbstractSlot> slotsToIndex = new Object2IntOpenHashMap<>();
    slotsToIndex.defaultReturnValue(INVALID_INDEX);
    int index = 0;
    for (AbstractSlot slot : slots) {
        slotsToIndex.put(slot, index++);
    }
    this.slots = ImmutableList.copyOf(slots);
    this.slotsToIndex = Object2IntMaps.unmodifiable(slotsToIndex);
    this.prioritizedSlots = prioritizedSlots != null ? ImmutableList.copyOf(prioritizedSlots) : null;
    init();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:AbstractOrderedInventory.java

示例9: testEquivalentPairs

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
@Test(dataProvider = "equivalentPairs")
public void testEquivalentPairs(
    final SymmetricImmutablePair<String> lhs,
    final SymmetricImmutablePair<String> rhs) {

  assertThat(lhs).isEqualByComparingTo(lhs);
  assertThat(rhs).isEqualByComparingTo(rhs);
  assertThat(lhs).isEqualByComparingTo(rhs);
  assertThat(rhs).isEqualByComparingTo(lhs);

  assertThat(lhs).isEqualTo(lhs);
  assertThat(rhs).isEqualTo(rhs);
  assertThat(lhs).isEqualTo(rhs);
  assertThat(rhs).isEqualTo(lhs);

  assertThat(lhs.hashCode()).isEqualTo(rhs.hashCode());

  Object2IntMap<SymmetricImmutablePair<String>> map;

  map = new Object2IntOpenHashMap<>(2);

  map.put(lhs, 1);
  assertThat(map).containsEntry(lhs, 1);
  assertThat(map).containsEntry(rhs, 1);

  map.put(rhs, 2);
  assertThat(map).containsEntry(rhs, 2);
  assertThat(map).containsEntry(lhs, 2);

  map = new Object2IntRBTreeMap<>();

  map.put(lhs, 1);
  assertThat(map).containsEntry(lhs, 1);
  assertThat(map).containsEntry(rhs, 1);

  map.put(rhs, 2);
  assertThat(map).containsEntry(rhs, 2);
  assertThat(map).containsEntry(lhs, 2);
}
 
开发者ID:universal-automata,项目名称:liblevenshtein-java,代码行数:40,代码来源:SymmetricImmutablePairTest.java

示例10: updateFlushThresholdForSegmentMetadata

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
void updateFlushThresholdForSegmentMetadata(LLCRealtimeSegmentZKMetadata segmentZKMetadata,
    ZNRecord partitionAssignment, int tableFlushSize) {
  // If config does not have a flush threshold, use the default.
  if (tableFlushSize < 1) {
    tableFlushSize = KafkaHighLevelStreamProviderConfig.getDefaultMaxRealtimeRowsCount();
  }

  // Gather list of instances for this partition
  Object2IntMap<String> partitionCountForInstance = new Object2IntLinkedOpenHashMap<>();
  String segmentPartitionId = new LLCSegmentName(segmentZKMetadata.getSegmentName()).getPartitionRange();
  for (String instanceName : partitionAssignment.getListField(segmentPartitionId)) {
    partitionCountForInstance.put(instanceName, 0);
  }

  // Find the maximum number of partitions served for each instance that is serving this segment
  int maxPartitionCountPerInstance = 1;
  for (Map.Entry<String, List<String>> partitionAndInstanceList : partitionAssignment.getListFields().entrySet()) {
    for (String instance : partitionAndInstanceList.getValue()) {
      if (partitionCountForInstance.containsKey(instance)) {
        int partitionCountForThisInstance = partitionCountForInstance.getInt(instance);
        partitionCountForThisInstance++;
        partitionCountForInstance.put(instance, partitionCountForThisInstance);

        if (maxPartitionCountPerInstance < partitionCountForThisInstance) {
          maxPartitionCountPerInstance = partitionCountForThisInstance;
        }
      }
    }
  }

  // Configure the segment size flush limit based on the maximum number of partitions allocated to a replica
  int segmentFlushSize = (int) (((float) tableFlushSize) / maxPartitionCountPerInstance);
  segmentZKMetadata.setSizeThresholdToFlushSegment(segmentFlushSize);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:35,代码来源:PinotLLCRealtimeSegmentManager.java

示例11: getKeyForValue

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private int getKeyForValue(String value) {
  Object2IntMap<String> map = (Object2IntMap<String>) _groupKeyMap;
  int groupId = map.getInt(value);
  if (groupId == INVALID_ID) {
    groupId = _numGroupKeys;
    map.put(value, _numGroupKeys++);
  }
  return groupId;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:11,代码来源:NoDictionarySingleColumnGroupKeyGenerator.java

示例12: removeSampleReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
private void removeSampleReads(final int sampleIndex, final Collection<GATKSAMRecord> readsToRemove, final int alleleCount) {
    final GATKSAMRecord[] sampleReads = readsBySampleIndex[sampleIndex];
    final int sampleReadCount = sampleReads.length;

    final Object2IntMap<GATKSAMRecord> indexByRead = readIndexBySampleIndex(sampleIndex);
    // Count how many we are going to remove, which ones (indexes) and remove entry from the read-index map.
    final boolean[] removeIndex = new boolean[sampleReadCount];
    int removeCount = 0; // captures the number of deletions.
    int firstDeleted = sampleReadCount;    // captures the first position that was deleted.

    final Iterator<GATKSAMRecord> readsToRemoveIterator = readsToRemove.iterator();
    while (readsToRemoveIterator.hasNext()) {
        final GATKSAMRecord read = readsToRemoveIterator.next();
        if (indexByRead.containsKey(read)) {
            final int index = indexByRead.getInt(read);
            if (firstDeleted > index)
                firstDeleted = index;
            removeCount++;
            removeIndex[index] = true;
            readsToRemoveIterator.remove();
            indexByRead.remove(read);
        }
    }

    // Nothing to remove we just finish here.
    if (removeCount == 0)
        return;

    final int newSampleReadCount = sampleReadCount - removeCount;

    // Now we skim out the removed reads from the read array.
    final GATKSAMRecord[] oldSampleReads = readsBySampleIndex[sampleIndex];
    final GATKSAMRecord[] newSampleReads = new GATKSAMRecord[newSampleReadCount];

    System.arraycopy(oldSampleReads, 0, newSampleReads, 0, firstDeleted);
    Utils.skimArray(oldSampleReads, firstDeleted, newSampleReads, firstDeleted, removeIndex, firstDeleted);

    // Update the indices for the extant reads from the first deletion onwards.
    for (int r = firstDeleted; r < newSampleReadCount; r++) {
        indexByRead.put(newSampleReads[r], r);
    }

    // Then we skim out the likelihoods of the removed reads.
    final double[][] oldSampleValues = valuesBySampleIndex[sampleIndex];
    final double[][] newSampleValues = new double[alleleCount][newSampleReadCount];
    for (int a = 0; a < alleleCount; a++) {
        System.arraycopy(oldSampleValues[a], 0, newSampleValues[a], 0, firstDeleted);
        Utils.skimArray(oldSampleValues[a], firstDeleted, newSampleValues[a], firstDeleted, removeIndex, firstDeleted);
    }
    valuesBySampleIndex[sampleIndex] = newSampleValues;
    readsBySampleIndex[sampleIndex] = newSampleReads;
    readListBySampleIndex[sampleIndex] = null; // reset the unmodifiable list.
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:54,代码来源:ReadLikelihoods.java

示例13: create

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
@Override
public FreqKList create(ITable data) {
    data.getColumns(this.schema);
    Hash.Strategy<BaseRowSnapshot> hs = new Hash.Strategy<BaseRowSnapshot>() {
        @Override
        public int hashCode(BaseRowSnapshot brs) {
            if (brs instanceof VirtualRowSnapshot) {
                return brs.hashCode();
            } else if (brs instanceof RowSnapshot) {
                return brs.computeHashCode(ExactFreqSketch.this.schema);
            } else throw new RuntimeException("Uknown type encountered");
        }

        @Override
        public boolean equals(BaseRowSnapshot brs1, @Nullable BaseRowSnapshot brs2) {
            // brs2 is null because the hashmap explicitly calls with null
            // even if null cannot be a key.
            if (brs2 == null)
                return brs1 == null;
            return brs1.compareForEquality(brs2, ExactFreqSketch.this.schema);
        }
    };

    Object2IntMap<BaseRowSnapshot> hMap = new
            Object2IntOpenCustomHashMap<BaseRowSnapshot>(hs);
    this.rssList.forEach(rss -> hMap.put(rss, 0));
    IRowIterator rowIt = data.getRowIterator();
    int i = rowIt.getNextRow();
    VirtualRowSnapshot vrs = new VirtualRowSnapshot(data, this.schema);
    while (i != -1) {
        vrs.setRow(i);
        if (hMap.containsKey(vrs)) {
            int count = hMap.getInt(vrs);
            hMap.put(vrs, count + 1);
        }
        i = rowIt.getNextRow();
    }
    Object2IntOpenHashMap<RowSnapshot> hm = new Object2IntOpenHashMap<RowSnapshot>(this.rssList.size());
    this.rssList.forEach(rss -> hm.put(rss, hMap.getInt(rss)));
    return new FreqKList(data.getNumOfRows(), this.epsilon, hm);
}
 
开发者ID:vmware,项目名称:hillview,代码行数:42,代码来源:ExactFreqSketch.java

示例14: VRSTest2

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
@Test
public void VRSTest2() {
    ITable data = TestTables.testRepTable();
    Schema schema = data.getSchema();
    Hash.Strategy<BaseRowSnapshot> hs = new Hash.Strategy<BaseRowSnapshot>() {
        @Override
        public int hashCode(BaseRowSnapshot brs) {
            if (brs instanceof VirtualRowSnapshot) {
                return brs.hashCode();
            } else if (brs instanceof RowSnapshot) {
                return brs.computeHashCode(schema);
            } else
                throw new RuntimeException("Uknown type encountered");
        }

        @Override
        public boolean equals(BaseRowSnapshot brs1, @Nullable BaseRowSnapshot brs2) {
            // brs2 is null because the hashmap explicitly calls with null
            // even if null cannot be a key.
            if (brs2 == null)
                return brs1 == null;
            return brs1.compareForEquality(brs2, schema);
        }
    };
    Object2IntMap<BaseRowSnapshot> hMap = new
            Object2IntOpenCustomHashMap<BaseRowSnapshot>(hs);
    for (int i = 0; i < 2; i++ ) {
        BaseRowSnapshot rs = new RowSnapshot(data, i);
        hMap.put(rs, 0);
    }
    VirtualRowSnapshot vrs = new VirtualRowSnapshot(data);
    IRowIterator rowIt = data.getRowIterator();
    vrs.setRow(0);
    if (hMap.containsKey(vrs)) {
        System.out.println("A hit!\n");
        int count = hMap.getInt(vrs);
        hMap.put(vrs, count + 1);
    } else {
        throw new RuntimeException("Not found");
    }
}
 
开发者ID:vmware,项目名称:hillview,代码行数:42,代码来源:VirtualRowSnapshotTest.java

示例15: removeSampleReads

import it.unimi.dsi.fastutil.objects.Object2IntMap; //导入方法依赖的package包/类
public void removeSampleReads(final int sampleIndex, final Collection<GATKRead> readsToRemove, final int alleleCount) {
    final GATKRead[] sampleReads = readsBySampleIndex[sampleIndex];
    final int sampleReadCount = sampleReads.length;

    final Object2IntMap<GATKRead> indexByRead = readIndexBySampleIndex(sampleIndex);
    // Count how many we are going to remove, which ones (indexes) and remove entry from the read-index map.
    final boolean[] removeIndex = new boolean[sampleReadCount];
    int removeCount = 0; // captures the number of deletions.
    int firstDeleted = sampleReadCount;    // captures the first position that was deleted.

    final Iterator<GATKRead> readsToRemoveIterator = readsToRemove.iterator();
    while (readsToRemoveIterator.hasNext()) {
        final GATKRead read = readsToRemoveIterator.next();
        if (indexByRead.containsKey(read)) {
            final int index = indexByRead.getInt(read);
            if (firstDeleted > index) {
                firstDeleted = index;
            }
            removeCount++;
            removeIndex[index] = true;
            readsToRemoveIterator.remove();
            indexByRead.remove(read);
        }
    }

    // Nothing to remove we just finish here.
    if (removeCount == 0) {
        return;
    }

    final int newSampleReadCount = sampleReadCount - removeCount;

    // Now we skim out the removed reads from the read array.
    final GATKRead[] oldSampleReads = readsBySampleIndex[sampleIndex];
    final GATKRead[] newSampleReads = new GATKRead[newSampleReadCount];

    System.arraycopy(oldSampleReads,0,newSampleReads,0,firstDeleted);
    Utils.skimArray(oldSampleReads,firstDeleted, newSampleReads, firstDeleted, removeIndex, firstDeleted);

    // Update the indices for the extant reads from the first deletion onwards.
    for (int r = firstDeleted; r < newSampleReadCount; r++) {
        indexByRead.put(newSampleReads[r], r);
    }

    // Then we skim out the likelihoods of the removed reads.
    final double[][] oldSampleValues = valuesBySampleIndex[sampleIndex];
    final double[][] newSampleValues = new double[alleleCount][newSampleReadCount];
    for (int a = 0; a < alleleCount; a++) {
        System.arraycopy(oldSampleValues[a],0,newSampleValues[a],0,firstDeleted);
        Utils.skimArray(oldSampleValues[a], firstDeleted, newSampleValues[a], firstDeleted, removeIndex, firstDeleted);
    }
    valuesBySampleIndex[sampleIndex] = newSampleValues;
    readsBySampleIndex[sampleIndex] = newSampleReads;
    readListBySampleIndex[sampleIndex] = null; // reset the unmodifiable list.
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:56,代码来源:ReadLikelihoods.java


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