Package ivory.core.data.index

Examples of ivory.core.data.index.PostingsReader


    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

      // The current concept.
      String concept = vocab[conceptID].getKey();

      // Get df and cf information for the concept.
      PostingsReader reader = env.getPostingsReader(new Expression(concept));
      if (reader == null) {
        continue;
      }
      PostingsList list = reader.getPostingsList();
      int df = list.getDf();
      long cf = list.getCf();
      env.clearPostingsReaderCache();

      // Construct concept evidence.
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.getTf());
    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.getTf());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getTf());
    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.getTf());
    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.getTf());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getTf());
    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.getTf());
    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.getTf());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getTf());
    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.getTf());
    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.getTf());
    assertEquals(2, arr[0]);
    assertEquals(23, arr[1]);

    reader.nextPosting(posting);
    arr = reader.getPositions();
    assertEquals(24, posting.getDocno());
    assertEquals(1, posting.getTf());
    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.getTf());

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

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

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

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

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

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

    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.getTf());

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

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

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

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

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

    mergedReader.nextPosting(p);
    assertEquals(25, p.getDocno());
    assertEquals(2, p.getTf());
  }
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.getTf());

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

    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.getTf());

    mergedReader.nextPosting(p);
    assertEquals(13, p.getDocno());
    assertEquals(5, p.getTf());
  }
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.