Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap


    private final Int2IntOpenHashMap code2Pos;
    /** The current size of {{@link #queue}. */
    private int queueSize;
   
    public FrequencyCodec() {
      code2Pos = new Int2IntOpenHashMap();
      code2Pos.defaultReturnValue( -1 );
      queue = new int[ MAX_QUEUE_SIZE ];
      freq = new int[ MAX_QUEUE_SIZE ];
    }
View Full Code Here


    initDriver();
    Connection connection = DriverManager.getConnection( dbUri );
    Statement s = connection.createStatement();
    ResultSet rs = s.executeQuery( buildQuery( null ) );
   
    id2doc = new Int2IntOpenHashMap();
    id2doc.defaultReturnValue( -1 );
    final IntArrayList ids = new IntArrayList();
    int id;
    for( int i = 0; rs.next(); i++ ) {
      id = rs.getInt( 1 );
View Full Code Here

      occ[ i ] = index[ i ].maxCount > 0 ? new int[ index[ i ].maxCount ] : IntArrays.EMPTY_ARRAY;
      wordInPos[ i ] = new int[ Math.max( 0, index[ i ].properties.getInt( Index.PropertyKeys.MAXDOCSIZE ) ) ];
      indexReader[ i ] = index[ i ].getReader();
     
      if ( new File( basenameField + DiskBasedIndex.FREQUENCIES_EXTENSION ).exists() ) frequencies[ i ] = new InputBitStream( basenameField + DiskBasedIndex.FREQUENCIES_EXTENSION );
      termsInDoc[ i ] = new Int2IntOpenHashMap();
    }


    int currDoc = 0,
    // Term position in the current document.
View Full Code Here

  public SubDocumentFactory( DocumentFactory underlyingFactory, int... visibleField ) {
    this.underlyingFactory = underlyingFactory;
    this.visibleField = visibleField;
    for( int i = visibleField.length; i-- > 1; ) if ( visibleField[ i - 1 ] >= visibleField[ i ] ) throw new IllegalArgumentException( "Fields must be provided in increasing order" );
    // TODO: turn into an ArrayMap?
    field2Pos = new Int2IntOpenHashMap( visibleField.length, Hash.VERY_FAST_LOAD_FACTOR );
    for( int i = visibleField.length; i-- != 0; ) field2Pos.put( visibleField[ i ], i );
    field2Pos.defaultReturnValue( -1 );
  }
View Full Code Here

    long startTime;
    long duration;
    Random r = new Random();

    System.out.println("Benchmarking Int2IntOpenHashMap...");
    Int2IntOpenHashMap map = new Int2IntOpenHashMap();
    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(1000);
      boolean increment = r.nextBoolean();
      if ( increment ) {
View Full Code Here

    int[] ints = new int[size];

    long usedMemory1 = MemoryUsageUtils.getUsedMemory();

    System.out.println("Benchmarking Int2IntOpenHashMap...");
    Int2IntOpenHashMap map = new Int2IntOpenHashMap();

    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int k = r.nextInt(size);
      map.put(i, k);
      ints[i] = k;
    }
    duration = System.currentTimeMillis() - startTime;
    System.out.println(" Inserting " + size + " random entries: " + duration + " ms");

    startTime = System.currentTimeMillis();
    for (int i = 0; i < size; i++) {
      int v = map.get(i);

      if (v != ints[i])
        throw new RuntimeException("Values don't match!");
    }
    duration = System.currentTimeMillis() - startTime;
View Full Code Here

     * @param idx  Global index.
     */
    public void putIndex(int uidx, int iidx, int idx) {
        Int2IntMap imap = null;
        while (uidx >= mapping.size()) {
            imap = new Int2IntOpenHashMap();
            imap.defaultReturnValue(-1);
            mapping.add(imap);
        }
        if (imap == null) {
            imap = mapping.get(uidx);
View Full Code Here

   * Initialize the values of the vector. The default value is 0.0
   *
   * @param size the size of the vector
   */
  private void initialize(int size) {
    entries = new Int2IntOpenHashMap(size);
    entries.defaultReturnValue(0);
  }
View Full Code Here

        Map hm = null;
        switch (typeNum)
        {
        case RelevanceJSONConstants.TYPENUMBER_MAP_INT_INT:
          hm = new Int2IntOpenHashMap();
          for (int j = 0; j < keySize; j++)
          {
            if(isKeyValue)
              ((Int2IntOpenHashMap) hm).put(keysArrayList.getInt(j), valuesArrayList.getInt(j));
            else
View Full Code Here

public class FastUtilOomPut
{
    public static void main(String [] args)
    throws Exception
    {
        Int2IntOpenHashMap map = new Int2IntOpenHashMap(100, 1f);
        Field f = map.getClass().getDeclaredField("key");
        f.setAccessible(true);

        boolean hitOOM = false;
        for (int i = 0;; i++) {
            try {
                if (hitOOM) { System.out.println("put(" + i + ")"); }
                map.put(i,  i);
            } catch (OutOfMemoryError e) {
                hitOOM = true;
                System.out.println("OOM, map: " + map.size() + " " + ((int[])f.get(map)).length);
            }
        }
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.