Package org.terrier.structures

Examples of org.terrier.structures.MetaIndex


      }
     
     
      final Iterator<DocumentIndexEntry> docidInput1 = (Iterator<DocumentIndexEntry>)srcIndex1.getIndexStructureInputStream("document");
      final PostingIndexInputStream dfInput1 = (PostingIndexInputStream)srcIndex1.getIndexStructureInputStream("direct");
      final MetaIndex metaInput1 = srcIndex1.getMetaIndex();
     
      int sourceDocid = 0;
      //traversing the direct index, without any change
      while(docidInput1.hasNext())
      {
        BitIndexPointer pointerDF = emptyPointer;
        DocumentIndexEntry die = docidInput1.next();
        if (die.getDocumentLength() > 0)
        {
          pointerDF = dfOutput.writePostings(dfInput1.next());
        }
        die.setBitIndexPointer(pointerDF);
        docidOutput.addEntryToBuffer(die);
        metaBuilder.writeDocumentEntry(metaInput1.getAllItems(sourceDocid));
        sourceDocid++;
      }
      dfInput1.close();
      metaInput1.close();
      IndexUtil.close(docidInput1);
      final Iterator<DocumentIndexEntry> docidInput2 = (Iterator<DocumentIndexEntry>)srcIndex2.getIndexStructureInputStream("document");
      final PostingIndexInputStream dfInput2 = (PostingIndexInputStream)srcIndex2.getIndexStructureInputStream("direct");
      final MetaIndex metaInput2 = srcIndex2.getMetaIndex();
     
      sourceDocid = 0;
      while (docidInput2.hasNext())
      {
        DocumentIndexEntry die = docidInput2.next();
     
        BitIndexPointer pointerDF = emptyPointer;
        if (die.getDocumentLength() > 0)
        {
          final IterablePosting postings = dfInput2.next();
         
          List<Posting> postingList = new ArrayList<Posting>();
          while(postings.next() != IterablePosting.EOL)
          {
            final Posting p = postings.asWritablePosting();
            p.setId(termcodeHashmap.get(postings.getId()));
            postingList.add(p);
          }
          Collections.sort(postingList, new PostingIdComparator());
          pointerDF = dfOutput.writePostings(postingList.iterator());
        }
        die.setBitIndexPointer(pointerDF);
        docidOutput.addEntryToBuffer(die);
        metaBuilder.writeDocumentEntry(metaInput2.getAllItems(sourceDocid));
        sourceDocid++;
      }
      dfInput2.close();
      IndexUtil.close(docidInput2);
      metaInput2.close();
     
      metaBuilder.close();
      dfOutput.close();
      docidOutput.finishedCollections();
      docidOutput.close();
View Full Code Here


   * Render the given resultset into the tblResults.
   * @param rs The result set to render
   */
  private void renderResults(ResultSet rs) throws Exception {
    Vector<String> HeaderRow = new Vector<String>(5);
    MetaIndex meta = diskIndex.getMetaIndex();
    HeaderRow.add(" ");
    HeaderRow.add("File Type");
    HeaderRow.add("Filename");
    HeaderRow.add("Directory");
    HeaderRow.add("Score");
    System.err.println("INFO: RenderResults "+rs.getExactResultSize()+" "+rs.getResultSize());
    int ResultsSize = rs.getResultSize();
    int[] docids = rs.getDocids();
    double[] scores = rs.getScores();
    Vector<Vector<String>> rows = new Vector<Vector<String>>(ResultsSize);
    for (int i = 0; i < ResultsSize; i++) {
      Vector<String> thisRow = new Vector<String>(5);
      thisRow.add("" + (i + 1));
      String f = meta.getItem("filename", docids[i]);
      System.err.println("INFO: RenderResults "+f);
      //String f = (String) fileList.get(docids[i]);
      if (f == null)
        continue;
      int dotIndex = f.lastIndexOf('.');
View Full Code Here

    Index index = !fieldsExpected ?
        Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, ApplicationSetup.TERRIER_INDEX_PREFIX)
        : Index.createIndex(ApplicationSetup.TERRIER_INDEX_PATH, "fields");
    assertNotNull(index);
   
    MetaIndex meta = index.getMetaIndex();
    assertNotNull(meta);
    assertEquals("doc1", index.getMetaIndex().getItem("filename", 0));
    assertEquals("doc2", index.getMetaIndex().getItem("filename", 1));
   
    IterablePosting ip = null;
View Full Code Here

    //check docid is as large as expected
    assertEquals("Metaindex as stream didnt have expected number of entries", docnos.length -1, docid);
    IndexUtil.close(iMi);
   
    //check random access
    MetaIndex mi = index.getMetaIndex();
    assertNotNull("Failed to get a metaindex", mi);
    final int numberOfDocuments = index.getCollectionStatistics().getNumberOfDocuments();
    for(docid = 0; docid < numberOfDocuments; docid++)
    {
      assertEquals("Normal lookup: Document name for document "+ docid + " was not correct", docnos[docid], mi.getItem("docno", docid));
      assertEquals("Reverse lookup: Document id not correct for docno "+ docnos[docid], docid, mi.getDocument("docno", docnos[docid]));
    }
   
   
    //check methods that take more than one docid at once
    int[] docids = new int[docnos.length];
    for(int i=0;i< docids.length;i++)
      docids[i] = docids.length -i -1;
   
    final String[] retrdocnos = mi.getItems("docno", docids);
    assertEquals(docids.length -1, docids[0]);
    assertEquals(retrdocnos.length, docnos.length);
    for(int i=0; i< docids.length; i++)
      assertEquals(docnos[docids[i]], retrdocnos[i]);
   
    docids = new int[docnos.length];
    for(int i=0;i< docids.length;i++)
      docids[i] = docids.length -i -1;
   
    final String[][] retrdocnosA = mi.getItems(new String[]{"docno"}, docids);
    assertEquals(retrdocnosA.length, docnos.length);
    assertEquals(docids.length -1, docids[0]);
    for(int i=0; i< docids.length; i++)
      assertEquals(docnos[docids[i]], retrdocnosA[i][0]);
   
View Full Code Here

TOP

Related Classes of org.terrier.structures.MetaIndex

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.