Package org.terrier.structures

Examples of org.terrier.structures.DirectIndexInputStream


   */
  @Override
  protected void traverseDirectFile(TIntIntHashMap codesHashMap,
      TIntArrayList[][] tmpStorage) throws IOException {
    // scan the direct file
    DirectIndexInputStream directInputStream = (DirectIndexInputStream)index.getIndexStructureInputStream("direct");
    int[][] documentTerms = null;
    int p = 0; // a document counter;
    while ((documentTerms = directInputStream.getNextTerms()) != null) {
      p += directInputStream.getEntriesSkipped();
      // the two next vectors are used for reducing the number of
      // references
      int[] documentTerms0 = documentTerms[0];
      int[] termfreqs = documentTerms[1];
      int[] blockfreqs = documentTerms[fieldCount + 2];
      int[] blockids = documentTerms[fieldCount + 3];
     
      // scan the list of the j-th document's terms
      final int length = documentTerms0.length;
      int blockfreq;
      int blockidstart;
      int blockidend;
      for (int k = 0; k < length; k++) {
        // if the k-th term of the document is to be indexed in this
        // pass
        int codePairIndex = codesHashMap.get(documentTerms0[k]);

        if (codePairIndex > 0) {
          // need to decrease codePairIndex because it has been
          // already increased while storing in codesHashMap
          codePairIndex--;
          TIntArrayList[] tmpMatrix = tmpStorage[codePairIndex];

          tmpMatrix[0].add(p);
          tmpMatrix[1].add(termfreqs[k]);
          for(int fi= 0;fi<fieldCount;fi++)
          {
            tmpMatrix[2+fi].add(documentTerms[2+fi][k]);
          }
          blockfreq = blockfreqs[k];
          tmpMatrix[fieldCount+2].add(blockfreq);

          // computing the offsets in the
          // tmpMatrix[4] of the block ids
          blockidstart = 0;
          if (k > 0) {
            for (int l = 0; l < k; l++)
              blockidstart += blockfreqs[l];
          }
          blockidend = blockidstart + blockfreq;

          for (int l = blockidstart; l < blockidend; l++) {
            tmpMatrix[fieldCount+3].add(blockids[l]);
          }
        }
      }
      p++;
    }
    directInputStream.close();
  }
View Full Code Here


  
  protected void traverseDirectFile(TIntIntHashMap codesHashMap, TIntArrayList[][] tmpStorage)
    throws IOException
  {
    //scan the direct file
    DirectIndexInputStream directInputStream = (DirectIndexInputStream)index.getIndexStructureInputStream("direct");
    int[][] documentTerms = null;
    int p = 0; //a document counter;
    final boolean _useFieldInformation = this.useFieldInformation;
    while ((documentTerms = directInputStream.getNextTerms())
      != null) {
      p += directInputStream.getEntriesSkipped();
      //the two next vectors are used for reducing the number of references
      final int[] documentTerms0 = documentTerms[0];
      final int[] termfreqs = documentTerms[1];
      //int[] htmlscores = null;
      //if (useFieldInformation)
      //  htmlscores = documentTerms[2];

      //scan the list of the j-th document's terms
      final int length = documentTerms0.length;
     
      for (int k = 0; k < length; k++) {
        //if the k-th term of the document is to be indexed in this pass
        int codePairIndex = codesHashMap.get(documentTerms0[k]);

        if (codePairIndex > 0) {
          /* need to decrease codePairIndex because it has been already
           * increased while storing in codesHashMap */
          codePairIndex--;
          TIntArrayList[] tmpMatrix = tmpStorage[codePairIndex];

          tmpMatrix[0].add(p);
          tmpMatrix[1].add(termfreqs[k]);
          if (_useFieldInformation)
          {
            for(int fi = 0; fi < fieldCount; fi++)
              tmpMatrix[2+fi].add(documentTerms[fi+2][k]);
            //tmpMatrix[2].add(htmlscores[k]);
          }
        }
      }
      p++;
    }
    directInputStream.close();
  }
View Full Code Here

      {
        //logger.warn("Sorry, no direct index structure in index");
      }
      else
      {
      DirectIndexInputStream dirIndex = (DirectIndexInputStream)(i.getIndexStructureInputStream("direct"));
      dirIndex.print();
      dirIndex.close();
      i.close();
      }
    } else if (printinverted) {
      Index.setIndexLoadingProfileAsRetrieval(false);
      Index i = Index.createIndex();
View Full Code Here

TOP

Related Classes of org.terrier.structures.DirectIndexInputStream

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.