Package org.terrier.structures

Examples of org.terrier.structures.DirectInvertedDocidOnlyOuptutStream


     
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      NullOutputStream nos = new NullOutputStream();
      BitOutputStream bo_null = new BitOutputStream(nos);
      DirectInvertedDocidOnlyOuptutStream dios = new DirectInvertedDocidOnlyOuptutStream(bo_null);
      BitOutputStream bo = new BitOutputStream(baos);
      if (initial_bitoffset > 0)
        bo.writeBinary(initial_bitoffset, 0);
      int docid = 0;
      while((line = br.readLine())!= null)
      {
        String[] parts = line.split("\\s+");
        for(String p : parts)
          ids.add(Integer.parseInt(p));
        int[] _tmp = ids.toNativeArray();
        byteOffset = bo.getByteOffset();
        bitOffset = bo.getBitOffset();
        BitFilePosition bp = new FilePosition(byteOffset, bitOffset);
        startOffsets.add(bp);
        //System.err.println(_tmp.length + "@{"+byteOffset+","+bitOffset+"}");
       
        List<Posting> postingList = new ArrayList<Posting>();
        IterablePosting ip = new ArrayOfIdsIterablePosting(_tmp);
        while(ip.next() != IterablePosting.EOL)
        {
          postingList.add(ip.asWritablePosting());
        }
        BitIndexPointer diosPointer = dios.writePostings(postingList.iterator());
       
        IDS.add(_tmp);
        ids.clear();
        int previous = -1;
        for(int i : _tmp)
View Full Code Here


  {
    String path = ApplicationSetup.TERRIER_INDEX_PATH;
    String prefix = ApplicationSetup.TERRIER_INDEX_PREFIX;

    Index index = Index.createNewIndex(path, prefix);
    DirectInvertedDocidOnlyOuptutStream dios = new DirectInvertedDocidOnlyOuptutStream(path + '/'+ prefix + ".direct.bf");
    //FSArrayFile<BitIndexPointer>
    DocumentIndexBuilder dib = new DocumentIndexBuilder(index, "document");
    BitIndexPointer p;
    for(int[] list : postings)
    {
      final int doclen = StaTools.sum(list);
      p = dios.writePostings(new ArrayOfIdsIterablePosting(list));
      DocumentIndexEntry die = new BasicDocumentIndexEntry(doclen, p);
      dib.addEntryToBuffer(die);
    }
    dios.close();
    dib.finishedCollections();
    index.addIndexStructure(
        "direct",
        "org.terrier.structures.DirectIndex",
        "org.terrier.structures.Index,java.lang.String,java.lang.Class",
View Full Code Here

TOP

Related Classes of org.terrier.structures.DirectInvertedDocidOnlyOuptutStream

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.