content: package org.apache.lucene.search;
  
  import java.io.IOException;
  
  /*
   *    // references(P) - set of papers that are in the reference list of P
   *    see: http://labs.adsabs.harvard.edu/trac/ads-invenio/ticket/221
   */
  public class SecondOrderCollectorCitesRAM extends AbstractSecondOrderCollector {
  
      private final SolrCacheWrapper cache;
  
      public SecondOrderCollectorCitesRAM(SolrCacheWrapper cache) {
          super();
          assert cache != null;
          this.cache = cache;
      }
  
  
      @Override
      public void collect(int doc) throws IOException {
          int[] citations = cache.getLuceneDocIds(doc + docBase);
          if (citations == null) {
              return;
          }
          float s = scorer.score();
          for (int docid : citations) {
              if (docid == -1)
                  continue;
              hits.add(new CollectorDoc(docid, s, citations.length));
          }
  
      }
  
  
      @Override
      public String toString() {
          return this.getClass().getSimpleName() + "(cache:" + cache.toString() + ")";
      }
  
      /**
       * Returns a hash code value for this object.
       */
      public int hashCode() {
          return 2938572 ^ cache.hashCode();
      }
  
  
      @Override
      public ScoreMode scoreMode() {
          return ScoreMode.COMPLETE;
      }
  
  
      @Override
      public SecondOrderCollector copy() {
          return new SecondOrderCollectorCitesRAM(cache);
      }
  }
  