Package ivory.core.data.index

Examples of ivory.core.data.index.PostingsReader


        OutputCollector<IntWritable, HMapIFW> output, Reporter reporter) throws IOException {

      sLogger.debug(mCollectionDocCount);
      postings.setCollectionDocumentCount(mCollectionDocCount);

      PostingsReader reader1 = postings.getPostingsReader();

      if (reader1.getNumberOfPostings() > dfCut)
        return;

      // set per postings list
      mModel.setDF(reader1.getNumberOfPostings());

      // performing PCP
      while (reader1.nextPosting(e1)) {

        // Here's a hidden dependency: How we do the blocking depends on
        // how the postings are sorted. If the postings are sorted in
        // ascending docno, then we can break out of the loop after
        // we've gone past the block bounds (as in code below).
        // Otherwise (say, if postings are sorted by tf), we have to go
        // through all postings.
        // -- Jimmy, 2008/09/03
        //

        if (e1.getDocno() < mBlockStart)
          continue;
        if (e1.getDocno() >= mBlockEnd)
          break;

        HMapIFW map = new HMapIFW();

        sLogger.debug(key + ": " + e1);

        PostingsReader reader2 = postings.getPostingsReader();

        while (reader2.nextPosting(e2)) {

          sLogger.debug(key + ": " + e1 + ", " + e2);

          if (e1.getDocno() == e2.getDocno())
            continue;
View Full Code Here


    return collectionSize;
  }

  public PostingsReader getPostingsReader(Expression exp) {
    //LOG.info("**getPostingsReader("+exp+")");;
    PostingsReader postingsReader = null;
    try {
      if (exp.getType().equals(Expression.Type.OD)) {
        int gapSize = exp.getWindow();
        String[] terms = exp.getTerms();

        List<PostingsReader> readers = new ArrayList<PostingsReader>();
        for (int i = 0; i < terms.length; i++) {
          PostingsReader reader = constructPostingsReader(terms[i]);
          if(reader != null)
            readers.add(reader);
        }

        postingsReader = new ProximityPostingsReaderOrderedWindow(readers.toArray(new PostingsReader[0]), gapSize);
      } else if (exp.getType().equals(Expression.Type.UW)) {
        int windowSize = exp.getWindow();
        String[] terms = exp.getTerms();

        List<PostingsReader> readers = new ArrayList<PostingsReader>();
        for (int i = 0; i < terms.length; i++) {
          PostingsReader reader = constructPostingsReader(terms[i]);
          if(reader != null)
            readers.add(reader);
        }

        postingsReader = new ProximityPostingsReaderUnorderedWindow(readers.toArray(new PostingsReader[0]), windowSize);
View Full Code Here

    return postingsReader;
  }

  protected PostingsReader constructPostingsReader(String expression) throws Exception {
    //LOG.info("**constructPostingsReader("+expression+")");
    PostingsReader reader = null;

    if (mPostingsReaderCache != null) {
      reader = mPostingsReaderCache.get(expression);
    }

View Full Code Here

  public void writeCollectionAverageDocumentLength(float n) { FSProperty.writeFloat(fs, appendPath(indexPath, "property.CollectionAverageDocumentLength"), n); }

  private static void testTerm(RetrievalEnvironment env, String term) {
    long startTime = System.currentTimeMillis();

    PostingsReader reader = null;
    Posting p = new Posting();
    int df = 0;
    String termOrig = term;
    String termTokenized = env.tokenize(termOrig)[0];

    LOG.info("term=" + termOrig + ", tokenized=" + termTokenized);
    reader = env.getPostingsReader(new Expression(termTokenized));
    df = reader.getNumberOfPostings();
    LOG.info("First ten postings: ");
    for (int i = 0; i < (df < 10 ? df : 10); i++) {
      reader.nextPosting(p);
      System.out.print(p);
    }

    System.out.println("\n");
View Full Code Here

    assertEquals(3, postings2.getDf());
    assertEquals(8, postings2.getCf());

    Posting posting = new Posting();

    PostingsReader reader = postings2.getPostingsReader();

    int arr[] = null;

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(13, posting.getDocno());
    assertEquals(5, posting.getScore());
    assertEquals(1, arr[0]);
    assertEquals(4, arr[1]);
    assertEquals(5, arr[2]);
    assertEquals(10, arr[3]);
    assertEquals(23, arr[4]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(14, posting.getDocno());
    assertEquals(2, posting.getScore());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getScore());
    assertEquals(1, arr[0]);
  }
View Full Code Here

    assertEquals(3, postings2.getDf());
    assertEquals(8, postings2.getCf());

    Posting posting = new Posting();

    PostingsReader reader = postings2.getPostingsReader();

    int arr[] = null;

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(13, posting.getDocno());
    assertEquals(5, posting.getScore());
    assertEquals(1, arr[0]);
    assertEquals(4, arr[1]);
    assertEquals(5, arr[2]);
    assertEquals(10, arr[3]);
    assertEquals(23, arr[4]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(14, posting.getDocno());
    assertEquals(2, posting.getScore());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getScore());
    assertEquals(1, arr[0]);

    // Set new tf and cf.
    postings2.setDf(6);
    postings2.setCf(16);

    // Verify tf and cf.
    assertEquals(6, postings2.getDf());
    assertEquals(16, postings2.getCf());

    reader = postings2.getPostingsReader();
    arr = null;

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(13, posting.getDocno());
    assertEquals(5, posting.getScore());
    assertEquals(1, arr[0]);
    assertEquals(4, arr[1]);
    assertEquals(5, arr[2]);
    assertEquals(10, arr[3]);
    assertEquals(23, arr[4]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(14, posting.getDocno());
    assertEquals(2, posting.getScore());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getScore());
    assertEquals(1, arr[0]);

    PostingsListDocSortedPositional postings3 =
        PostingsListDocSortedPositional.create(postings2.serialize());
    postings3.setCollectionDocumentCount(20);

    // Verify tf and cf.
    assertEquals(6, postings2.getDf());
    assertEquals(16, postings2.getCf());

    reader = postings2.getPostingsReader();
    arr = null;

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(13, posting.getDocno());
    assertEquals(5, posting.getScore());
    assertEquals(1, arr[0]);
    assertEquals(4, arr[1]);
    assertEquals(5, arr[2]);
    assertEquals(10, arr[3]);
    assertEquals(23, arr[4]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(14, posting.getDocno());
    assertEquals(2, posting.getScore());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getScore());
    assertEquals(1, arr[0]);
  }
View Full Code Here

    // Now merge and test.
    Posting p = new Posting();

    PostingsListDocSortedPositional merged;
    PostingsReader mergedReader;

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings1b, postings2b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(7, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(11, p.getDocno());
    assertEquals(4, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(14, p.getDocno());
    assertEquals(2, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(19, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(24, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(25, p.getDocno());
    assertEquals(2, p.getScore());

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings2b, postings1b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(7, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(11, p.getDocno());
    assertEquals(4, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(14, p.getDocno());
    assertEquals(2, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(19, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(24, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(25, p.getDocno());
    assertEquals(2, p.getScore());
  }
View Full Code Here

    // Now merge and test.
    Posting p = new Posting();

    PostingsListDocSortedPositional merged;
    PostingsReader mergedReader;

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings1b, postings2b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(2, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings2b, postings1b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(2, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());
  }
View Full Code Here

    // Now merge and test.
    Posting p = new Posting();

    PostingsListDocSortedPositional merged;
    PostingsReader mergedReader;

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings1b, postings2b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(5, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(11, p.getDocno());
    assertEquals(4, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(19, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(25, p.getDocno());
    assertEquals(2, p.getScore());

    merged = PostingsListDocSortedPositional.create(PostingsListDocSortedPositional.merge(
        postings2b, postings1b, 30).serialize());

    merged.setCollectionDocumentCount(30);
    mergedReader = merged.getPostingsReader();

    assertEquals(5, merged.getNumberOfPostings());
    mergedReader.nextPosting(p);
    assertEquals(2, p.getDocno());
    assertEquals(3, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(11, p.getDocno());
    assertEquals(4, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(19, p.getDocno());
    assertEquals(1, p.getScore());

    mergedReader.nextPosting(p);
    assertEquals(25, p.getDocno());
    assertEquals(2, p.getScore());
  }
View Full Code Here

    return collectionSize;
  }

  public PostingsReader getPostingsReader(Expression exp) {
    //LOG.info("**getPostingsReader("+exp+")");;
    PostingsReader postingsReader = null;
    try {
      if (exp.getType().equals(Expression.Type.OD)) {
        int gapSize = exp.getWindow();
        String[] terms = exp.getTerms();

        List<PostingsReader> readers = new ArrayList<PostingsReader>();
        for (int i = 0; i < terms.length; i++) {
          PostingsReader reader = constructPostingsReader(terms[i]);
          if(reader != null)
            readers.add(reader);
        }

        postingsReader = new ProximityPostingsReaderOrderedWindow(readers.toArray(new PostingsReader[0]), gapSize);
      } else if (exp.getType().equals(Expression.Type.UW)) {
        int windowSize = exp.getWindow();
        String[] terms = exp.getTerms();

        List<PostingsReader> readers = new ArrayList<PostingsReader>();
        for (int i = 0; i < terms.length; i++) {
          PostingsReader reader = constructPostingsReader(terms[i]);
          if(reader != null)
            readers.add(reader);
        }

        postingsReader = new ProximityPostingsReaderUnorderedWindow(readers.toArray(new PostingsReader[0]), windowSize);
View Full Code Here

TOP

Related Classes of ivory.core.data.index.PostingsReader

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.