Examples of LongOpenHashSet


Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    public void testItemItemRecommender3() {
        List<ScoredId> recs = recommender.recommend(1, null);
        assertTrue(recs.isEmpty());


        LongOpenHashSet candidates = new LongOpenHashSet();
        candidates.add(6);
        candidates.add(7);
        candidates.add(8);
        candidates.add(9);
        recs = recommender.recommend(1, candidates);
        assertThat(recs, hasSize(0));

        recs = recommender.recommend(2, null);
        assertThat(Lists.transform(recs, ScoredIds.idFunction()),
                   contains(9L));

        candidates.clear();
        candidates.add(7);
        candidates.add(8);
        candidates.add(9);
        recs = recommender.recommend(2, candidates);
        assertThat(Lists.transform(recs, ScoredIds.idFunction()),
                   contains(9L));

        candidates.add(6);
        candidates.remove(9);
        recs = recommender.recommend(2, candidates);
        assertThat(recs, hasSize(0));

        recs = recommender.recommend(5, null);
        assertThat(Lists.transform(recs, ScoredIds.idFunction()),
                   containsInAnyOrder(9L, 7L, 6L));

        candidates.clear();
        candidates.add(6);
        candidates.add(7);
        recs = recommender.recommend(5, candidates);
        assertThat(Lists.transform(recs, ScoredIds.idFunction()),
                   containsInAnyOrder(6L, 7L));

        candidates.clear();
        candidates.add(6);
        candidates.add(9);
        recs = recommender.recommend(5, candidates);
        assertThat(Lists.transform(recs, ScoredIds.idFunction()),
                   containsInAnyOrder(6L, 9L));
    }
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

      System.exit(-1);
    }

    String collectionPath = cmdline.getOptionValue(COLLECTION_OPTION);

    LongOpenHashSet tweetids = new LongOpenHashSet();
    File tweetidsFile = new File(cmdline.getOptionValue(ID_OPTION));
    if (!tweetidsFile.exists()) {
      System.err.println("Error: " + tweetidsFile + " does not exist!");
      System.exit(-1);
    }
    LOG.info("Reading tweetids from " + tweetidsFile);

    FileInputStream fin = new FileInputStream(tweetidsFile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));

    String s;
    while ((s = br.readLine()) != null) {
      tweetids.add(Long.parseLong(s));
    }
    br.close();
    fin.close();
    LOG.info("Read " + tweetids.size() + " tweetids.");

    File file = new File(collectionPath);
    if (!file.exists()) {
      System.err.println("Error: " + file + " does not exist!");
      System.exit(-1);
    }

    PrintStream out = new PrintStream(System.out, true, "UTF-8");
    StatusStream stream = new JsonStatusCorpusReader(file);
    Status status;
    while ((status = stream.next()) != null) {
      if (tweetids.contains(status.getId())) {
        out.println(status.getJsonObject().toString());
      }
    }
    stream.close();
    out.close();
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

      System.exit(-1);
    }

    String collectionPath = cmdline.getOptionValue(COLLECTION_OPTION);

    LongOpenHashSet tweetids = new LongOpenHashSet();
    File tweetidsFile = new File(cmdline.getOptionValue(ID_OPTION));
    if (!tweetidsFile.exists()) {
      System.err.println("Error: " + tweetidsFile + " does not exist!");
      System.exit(-1);
    }
    LOG.info("Reading tweetids from " + tweetidsFile);

    FileInputStream fin = new FileInputStream(tweetidsFile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));

    String s;
    while ((s = br.readLine()) != null) {
      tweetids.add(Long.parseLong(s));
    }
    br.close();
    fin.close();
    LOG.info("Read " + tweetids.size() + " tweetids.");

    File file = new File(collectionPath);
    if (!file.exists()) {
      System.err.println("Error: " + file + " does not exist!");
      System.exit(-1);
    }

    LongOpenHashSet seen = new LongOpenHashSet();
    TreeMap<Long, String> tweets = Maps.newTreeMap();

    PrintStream out = new PrintStream(System.out, true, "UTF-8");
    StatusStream stream = new JsonStatusCorpusReader(file);
    Status status;
    int cnt = 0;
    while ((status = stream.next()) != null) {
      if (!tweetids.contains(status.getId())) {
        LOG.error("tweetid " + status.getId() + " doesn't belong in collection");
        continue;
      }
      if (seen.contains(status.getId())) {
        LOG.error("tweetid " + status.getId() + " already seen!");
        continue;
      }

      tweets.put(status.getId(), status.getJsonObject().toString());
      seen.add(status.getId());
      cnt++;
    }
    LOG.info("total of " + cnt + " tweets in subcollection.");

    for ( Map.Entry<Long, String> entry : tweets.entrySet()){
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    if ( indexIterator != null && index.length == 1 && ( documentIterator instanceof AbstractIntersectionDocumentIterator || indexIterator.length < MAX_FLAT_DISJUNCTS ) ) {
      /* This code is a flat, simplified duplication of what a CounterSetupVisitor would do. It is here just for efficiency. */
      numberOfPairs = 0;
      /* Find duplicate terms. We score unique pairs term/index with nonzero frequency, as the standard method would do. */
      final LongOpenHashSet alreadySeen = new LongOpenHashSet();

      for( int i = indexIterator.length; i-- != 0; )
        if ( indexIterator[ i ].frequency() != 0 && alreadySeen.add( indexIterator[ i ].termNumber() ) ) numberOfPairs++;

      if ( numberOfPairs == indexIterator.length ) flatIndexIterator = indexIterator;
      else {
        /* We must compact the array, eliminating zero-frequency iterators. */
        flatIndexIterator = new IndexIterator[ numberOfPairs ];
        alreadySeen.clear();
        for( int i = 0, p = 0; i != indexIterator.length; i++ )
          if ( indexIterator[ i ].frequency() != 0 &&  alreadySeen.add( indexIterator[ i ].termNumber() ) ) flatIndexIterator[ p++ ] = indexIterator[ i ];
      }

      if ( flatIndexIterator.length != 0 ) {
        // Some caching of frequently-used values
        k1TimesBDividedByAverageDocumentSize = k1 * b * flatIndexIterator[ 0 ].index().numberOfDocuments / flatIndexIterator[ 0 ].index().numberOfOccurrences;
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    if ( indexIterator != null && index.length == 1 && ( documentIterator instanceof AbstractIntersectionDocumentIterator || indexIterator.length < MAX_FLAT_DISJUNCTS ) ) {
      /* This code is a flat, simplified duplication of what a CounterSetupVisitor would do. It is here just for efficiency. */
      numberOfPairs = 0;
      /* Find duplicate terms. We score unique pairs term/index with nonzero frequency, as the standard method would do. */
      final LongOpenHashSet alreadySeen = new LongOpenHashSet();

      for( int i = indexIterator.length; i-- != 0; )
        if ( indexIterator[ i ].frequency() != 0 && alreadySeen.add( indexIterator[ i ].termNumber() ) ) numberOfPairs++;

      if ( numberOfPairs == indexIterator.length ) flatIndexIterator = indexIterator;
      else {
        /* We must compact the array, eliminating zero-frequency iterators. */
        flatIndexIterator = new IndexIterator[ numberOfPairs ];
        alreadySeen.clear();
        for( int i = 0, p = 0; i != indexIterator.length; i++ )
          if ( indexIterator[ i ].frequency() != 0 &&  alreadySeen.add( indexIterator[ i ].termNumber() ) ) flatIndexIterator[ p++ ] = indexIterator[ i ];
      }

      if ( flatIndexIterator.length != 0 ) {
        // Some caching of frequently-used values
        k1TimesBDividedByAverageDocumentSize = k1 * b * flatIndexIterator[ 0 ].index().numberOfDocuments / flatIndexIterator[ 0 ].index().numberOfOccurrences;
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    /**
     * Constructor
     * @param capacity Capacity
     */
    public BasicLongOpenHashSet(int capacity) {
      set = new LongOpenHashSet(capacity);
    }
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    EdgeIterables.initialize(this, edges);
  }

  @Override
  public void initialize(int capacity) {
    neighbors = new LongOpenHashSet(capacity);
  }
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

    neighbors = new LongOpenHashSet(capacity);
  }

  @Override
  public void initialize() {
    neighbors = new LongOpenHashSet();
  }
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

  }
 
  @Override
  public boolean containsAny(Object set)
  {
    LongOpenHashSet setLong = (LongOpenHashSet)set;
    for(int i=0; i< this._length; i++)
      if( setLong.contains(((TermLongList) _mTermList).getPrimitiveValue(_buf[i])) )
        return true;
             
    return false;
  }
View Full Code Here

Examples of it.unimi.dsi.fastutil.longs.LongOpenHashSet

   
  }

  @Override
  public LongOpenHashSet map(int[] docId, int docIdCount, long[] uids, FieldAccessor accessor, FacetCountAccessor facetCountAccessor) {
    LongOpenHashSet hashSet = new LongOpenHashSet(docIdCount);
    for (int i =0; i < docIdCount; i++) {
      hashSet.add(accessor.getLong(column, docId[i]));
    }
   
    return hashSet;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.