org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap Java Examples

The following examples show how to use org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleColumnTimestampAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Timestamp findCommonValue(List data)
{
    ObjectIntHashMap<Timestamp> counts = new ObjectIntHashMap(data.size());
    TimestampAttribute attr = (TimestampAttribute) this;

    for(int i=0;i<data.size();i++)
    {
        Timestamp t = attr.timestampValueOf(data.get(i));
        if (t != null)
        {
            counts.addToValue(t, 1);
        }
    }

    MaxProc procedure = new MaxProc();
    counts.forEachKeyValue(procedure);
    if (procedure.maxCount > data.size() >> 4)
    {
        return procedure.max;
    }
    return null;
}
 
Example #2
Source File: CachedPostingListCounter.java    From vespa with Apache License 2.0 6 votes vote down vote up
public CachedPostingListCounter rebuildCache() {
    MinMaxPriorityQueue<Entry> mostExpensive = MinMaxPriorityQueue
            .maximumSize(32).expectedSize(32).create();
    synchronized (this) {
        for (ObjectLongPair<int[]> p : frequency.keyValuesView()) {
            mostExpensive.add(new Entry(p.getOne(), p.getTwo()));
        }
    }
    ObjectIntHashMap<int[]> postingListMapping = new ObjectIntHashMap<>();
    int[] bitVector = new int[nDocuments];
    int length = mostExpensive.size();
    for (int i = 0; i < length; i++) {
        Entry e = mostExpensive.removeFirst();
        int[] docIds = e.docIds;
        postingListMapping.put(docIds, i);
        for (int docId : docIds) {
            bitVector[docId] |= (1 << i);
        }
    }
    return new CachedPostingListCounter(postingListMapping, bitVector);
}
 
Example #3
Source File: AggregateDataConfig.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void setNameToPositionMap(ObjectIntMap<String> map)
{
    this.nameToPositionMap = new ObjectIntHashMap(map.size());
    map.forEachKeyValue(new ObjectIntProcedure<String>()
    {
        @Override
        public void value(String each, int parameter)
        {
            nameToPositionMap.put(each, parameter);
        }
    });
}
 
Example #4
Source File: GsObjectIntMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ], i );
    for ( int i = 0; i < m_keys2.length; ++i )
        m_map.put( m_keys2[ i ], i );
    return m_map.size();
}
 
Example #5
Source File: GsObjectIntMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length / 2 + 1 );
    int add = 0, remove = 0;
    while ( add < m_keys.length )
    {
        m_map.put( m_keys[ add ], add );
        ++add;
        m_map.put( m_keys[ add ], add );
        ++add;
        m_map.remove( m_keys[ remove++ ] );
    }
    return m_map.size();
}
 
Example #6
Source File: ALSServingModel.java    From oryx with Apache License 2.0 5 votes vote down vote up
/**
 * @return mapping of item IDs to count of users that have interacted with that item
 */
public Map<String,Integer> getItemCounts() {
  ObjectIntHashMap<String> counts = ObjectIntHashMap.newMap();
  try (AutoLock al = knownItemsLock.autoReadLock()) {
    knownItems.values().forEach(ids -> {
      synchronized (ids) {
        ids.forEach(id -> counts.addToValue(id, 1));
      }
    });
  }
  // No way to get Java map from primitive map directly (?)
  Map<String,Integer> javaCounts = new HashMap<>(counts.size());
  counts.forEachKeyValue(javaCounts::put);
  return javaCounts;
}
 
Example #7
Source File: PartitionedFeatureVectors.java    From oryx with Apache License 2.0 5 votes vote down vote up
public PartitionedFeatureVectors(int numPartitions,
                                 ExecutorService executor,
                                 ToIntBiFunction<String,float[]> partitioner) {
  Preconditions.checkArgument(numPartitions > 0);
  Objects.requireNonNull(executor);
  Objects.requireNonNull(partitioner);
  partitions = new FeatureVectorsPartition[numPartitions];
  for (int i = 0; i < numPartitions; i++) {
    partitions[i] = new FeatureVectorsPartition();
  }
  partitionMap = ObjectIntHashMap.newMap();
  partitionMapLock = new AutoReadWriteLock();
  this.partitioner = partitioner;
  this.executor = executor;
}
 
Example #8
Source File: CachedPostingListCounter.java    From vespa with Apache License 2.0 4 votes vote down vote up
public CachedPostingListCounter(int nDocuments) {
    this.nDocuments = nDocuments;
    this.postingListMapping = new ObjectIntHashMap<>();
    this.bitVector = new int[0];
}
 
Example #9
Source File: CachedPostingListCounter.java    From vespa with Apache License 2.0 4 votes vote down vote up
private CachedPostingListCounter(ObjectIntHashMap<int[]> postingListMapping, int[] bitVector) {
    this.nDocuments = bitVector.length;
    this.postingListMapping = postingListMapping;
    this.bitVector = bitVector;
}
 
Example #10
Source File: CachedPostingListCounter.java    From vespa with Apache License 2.0 4 votes vote down vote up
ObjectIntHashMap<int[]> getPostingListMapping() {
    return postingListMapping;
}
 
Example #11
Source File: GsObjectIntMapTest.java    From hashmapTest with The Unlicense 4 votes vote down vote up
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
    super.setup(keys, fillFactor, oneFailureOutOf);
    m_map = new ObjectIntHashMap<>( keys.length );
    for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key + 1 : key), key );
}