类org.apache.lucene.index.ImpactsEnum源码实例Demo

下面列出了怎么用org.apache.lucene.index.ImpactsEnum的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lucene-solr   文件: Lucene84PostingsReader.java
@Override
public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException {
  if (state.docFreq <= BLOCK_SIZE) {
    // no skip data
    return new SlowImpactsEnum(postings(fieldInfo, state, null, flags));
  }

  final boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
  final boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  final boolean indexHasPayloads = fieldInfo.hasPayloads();

  if (indexHasPositions == false || PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {
    return new BlockImpactsDocsEnum(fieldInfo, (IntBlockTermState) state);
  }

  if (indexHasPositions &&
      PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) &&
      (indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
      (indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
    return new BlockImpactsPostingsEnum(fieldInfo, (IntBlockTermState) state);
  }

  return new BlockImpactsEverythingEnum(fieldInfo, (IntBlockTermState) state, flags);
}
 
源代码2 项目: lucene-solr   文件: PhraseQuery.java
public PostingsAndFreq(PostingsEnum postings, ImpactsEnum impacts, int position, Term... terms) {
  this.postings = postings;
  this.impacts = impacts;
  this.position = position;
  nTerms = terms==null ? 0 : terms.length;
  if (nTerms>0) {
    if (terms.length==1) {
      this.terms = terms;
    } else {
      Term[] terms2 = new Term[terms.length];
      System.arraycopy(terms, 0, terms2, 0, terms.length);
      Arrays.sort(terms2);
      this.terms = terms2;
    }
  } else {
    this.terms = null;
  }
}
 
源代码3 项目: lucene-solr   文件: ExactPhraseMatcher.java
ExactPhraseMatcher(PhraseQuery.PostingsAndFreq[] postings, ScoreMode scoreMode, SimScorer scorer, float matchCost) {
  super(matchCost);

  final DocIdSetIterator approximation = ConjunctionDISI.intersectIterators(Arrays.stream(postings).map(p -> p.postings).collect(Collectors.toList()));
  final ImpactsSource impactsSource = mergeImpacts(Arrays.stream(postings).map(p -> p.impacts).toArray(ImpactsEnum[]::new));

  if (scoreMode == ScoreMode.TOP_SCORES) {
    this.approximation = this.impactsApproximation = new ImpactsDISI(approximation, impactsSource, scorer);
  } else {
    this.approximation = approximation;
    this.impactsApproximation = new ImpactsDISI(approximation, impactsSource, scorer);
  }

  List<PostingsAndPosition> postingsAndPositions = new ArrayList<>();
  for(PhraseQuery.PostingsAndFreq posting : postings) {
    postingsAndPositions.add(new PostingsAndPosition(posting.postings, posting.position));
  }
  this.postings = postingsAndPositions.toArray(new PostingsAndPosition[postingsAndPositions.size()]);
}
 
源代码4 项目: lucene-solr   文件: Lucene50PostingsReader.java
@Override
public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException {
  if (state.docFreq <= BLOCK_SIZE || version < Lucene50PostingsFormat.VERSION_IMPACT_SKIP_DATA) {
    // no skip data
    return new SlowImpactsEnum(postings(fieldInfo, state, null, flags));
  }

  final boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
  final boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  final boolean indexHasPayloads = fieldInfo.hasPayloads();

  if (indexHasPositions &&
      PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) &&
      (indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
      (indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
    return new BlockImpactsPostingsEnum(fieldInfo, (IntBlockTermState) state);
  }

  return new BlockImpactsEverythingEnum(fieldInfo, (IntBlockTermState) state, flags);
}
 
源代码5 项目: lucene-solr   文件: OrdsSegmentTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  assert !eof;
  //if (DEBUG) {
  //System.out.println("BTTR.docs seg=" + segment);
  //}
  currentFrame.decodeMetaData();
  //if (DEBUG) {
  //System.out.println("  state=" + currentFrame.state);
  //}
  return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.state, flags);
}
 
源代码6 项目: lucene-solr   文件: SegmentTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  assert !eof;
  //if (DEBUG) {
  //System.out.println("BTTR.docs seg=" + segment);
  //}
  currentFrame.decodeMetaData();
  //if (DEBUG) {
  //System.out.println("  state=" + currentFrame.state);
  //}
  return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.state, flags);
}
 
源代码7 项目: lucene-solr   文件: TermScorer.java
/**
 * Construct a {@link TermScorer} that will use impacts to skip blocks of
 * non-competitive documents.
 */
TermScorer(Weight weight, ImpactsEnum impactsEnum, LeafSimScorer docScorer) {
  super(weight);
  postingsEnum = this.impactsEnum = impactsEnum;
  impactsDisi = new ImpactsDISI(impactsEnum, impactsEnum, docScorer.getSimScorer());
  iterator = impactsDisi;
  this.docScorer = docScorer;
}
 
源代码8 项目: lucene-solr   文件: PhraseQuery.java
public PostingsAndFreq(PostingsEnum postings, ImpactsEnum impacts, int position, List<Term> terms) {
  this.postings = postings;
  this.impacts = impacts;
  this.position = position;
  nTerms = terms == null ? 0 : terms.size();
  if (nTerms > 0) {
    Term[] terms2 = terms.toArray(new Term[0]);
    if (nTerms > 1) {
      Arrays.sort(terms2);
    }
    this.terms = terms2;
  } else {
    this.terms = null;
  }
}
 
源代码9 项目: querqy   文件: TermScorer.java
/**
 * Construct a {@link org.apache.lucene.search.TermScorer} that will use impacts to skip blocks of
 * non-competitive documents.
 */
TermScorer(Weight weight, ImpactsEnum impactsEnum, LeafSimScorer docScorer) {
    super(weight);
    postingsEnum = this.impactsEnum = impactsEnum;
    impactsDisi = new ImpactsDISI(impactsEnum, impactsEnum, docScorer.getSimScorer());
    iterator = impactsDisi;
    this.docScorer = docScorer;
}
 
@Override
public ImpactsEnum impacts(int flags) throws IOException {
    return delegate.impacts(flags);
}
 
源代码11 项目: lucene-solr   文件: FSTTermsReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  decodeMetaData();
  return postingsReader.impacts(fieldInfo, state, flags);
}
 
源代码12 项目: lucene-solr   文件: DirectPostingsFormat.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return new SlowImpactsEnum(postings(null, flags));
}
 
源代码13 项目: lucene-solr   文件: DirectPostingsFormat.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return new SlowImpactsEnum(postings(null, flags));
}
 
源代码14 项目: lucene-solr   文件: OrdsIntersectTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  currentFrame.decodeMetaData();
  return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.termState, flags);
}
 
源代码15 项目: lucene-solr   文件: BlockTermsReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  decodeMetaData();
  return postingsReader.impacts(fieldInfo, state, flags);
}
 
源代码16 项目: lucene-solr   文件: SimpleTextTermVectorsReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return new SlowImpactsEnum(postings(null, PostingsEnum.FREQS));
}
 
源代码17 项目: lucene-solr   文件: SimpleTextFieldsReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return new SlowImpactsEnum(postings(null, flags));
}
 
源代码18 项目: lucene-solr   文件: BloomFilteringPostingsFormat.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return delegate().impacts(flags);
}
 
源代码19 项目: lucene-solr   文件: BlockReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  readTermStateIfNotRead();
  return postingsReader.impacts(fieldMetadata.getFieldInfo(), termState, flags);
}
 
源代码20 项目: lucene-solr   文件: STMergingTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) {
  throw new UnsupportedOperationException();
}
 
源代码21 项目: lucene-solr   文件: IDVersionSegmentTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  // Only one posting, the slow impl is fine
  // We could make this throw UOE but then CheckIndex is angry
  return new SlowImpactsEnum(postings(null, flags));
}
 
源代码22 项目: lucene-solr   文件: IDVersionPostingsReader.java
@Override
public ImpactsEnum impacts(FieldInfo fieldInfo, BlockTermState state, int flags) throws IOException {
  throw new UnsupportedOperationException("Should never be called, IDVersionSegmentTermsEnum implements impacts directly");
}
 
源代码23 项目: lucene-solr   文件: RAMOnlyPostingsFormat.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return new SlowImpactsEnum(postings(null, PostingsEnum.FREQS));
}
 
源代码24 项目: lucene-solr   文件: DocValuesConsumer.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  throw new UnsupportedOperationException();
}
 
源代码25 项目: lucene-solr   文件: Lucene80DocValuesProducer.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  throw new UnsupportedOperationException();
}
 
源代码26 项目: lucene-solr   文件: IntersectTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  currentFrame.decodeMetaData();
  return fr.parent.postingsReader.impacts(fr.fieldInfo, currentFrame.termState, flags);
}
 
源代码27 项目: lucene-solr   文件: CompressingTermVectorsReader.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  final PostingsEnum delegate = postings(null, PostingsEnum.FREQS);
  return new SlowImpactsEnum(delegate);
}
 
源代码28 项目: lucene-solr   文件: FuzzyTermsEnum.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return actualEnum.impacts(flags);
}
 
源代码29 项目: lucene-solr   文件: TestSynonymQuery.java
public void testMergeImpacts() throws IOException {
  DummyImpactsEnum impacts1 = new DummyImpactsEnum();
  impacts1.reset(42,
      new Impact[][] {
        new Impact[] { new Impact(3, 10), new Impact(5, 12), new Impact(8, 13) },
        new Impact[] { new Impact(5, 11), new Impact(8, 13),  new Impact(12, 14) }
      },
      new int[] {
          110,
          945
      });
  DummyImpactsEnum impacts2 = new DummyImpactsEnum();
  impacts2.reset(45,
      new Impact[][] {
        new Impact[] { new Impact(2, 10), new Impact(6, 13) },
        new Impact[] { new Impact(3, 9), new Impact(5, 11), new Impact(7, 13) }
      },
      new int[] {
          90,
          1000
      });

  ImpactsSource mergedImpacts = SynonymQuery.mergeImpacts(new ImpactsEnum[] { impacts1, impacts2 }, new float[] { 1f, 1f });
  assertEquals(
      new Impact[][] {
        new Impact[] { new Impact(5, 10), new Impact(7, 12), new Impact(14, 13) },
        new Impact[] { new Impact(Integer.MAX_VALUE, 1) }
      },
      new int[] {
          90,
          1000
      },
      mergedImpacts.getImpacts());

  ImpactsSource mergedBoostedImpacts = SynonymQuery.mergeImpacts(new ImpactsEnum[] { impacts1, impacts2 }, new float[] { 0.3f, 0.9f });
  assertEquals(
      new Impact[][] {
          new Impact[] { new Impact(3, 10), new Impact(4, 12), new Impact(9, 13) },
          new Impact[] { new Impact(Integer.MAX_VALUE, 1) }
      },
      new int[] {
          90,
          1000
      },
      mergedBoostedImpacts.getImpacts());

  // docID is > the first doIdUpTo of impacts1
  impacts2.reset(112,
      new Impact[][] {
        new Impact[] { new Impact(2, 10), new Impact(6, 13) },
        new Impact[] { new Impact(3, 9), new Impact(5, 11), new Impact(7, 13) }
      },
      new int[] {
          150,
          1000
      });
  assertEquals(
      new Impact[][] {
        new Impact[] { new Impact(3, 10), new Impact(5, 12), new Impact(8, 13) }, // same as impacts1
        new Impact[] { new Impact(3, 9), new Impact(10, 11), new Impact(15, 13), new Impact(19, 14) }
      },
      new int[] {
          110,
          945
      },
      mergedImpacts.getImpacts());

  assertEquals(
      new Impact[][] {
          new Impact[] { new Impact(1, 10), new Impact(2, 12), new Impact(3, 13) }, // same as impacts1*boost
          new Impact[] { new Impact(3, 9), new Impact(7, 11), new Impact(10, 13), new Impact(11, 14) }
      },
      new int[] {
          110,
          945
      },
      mergedBoostedImpacts.getImpacts());
}
 
源代码30 项目: lucene-solr   文件: DocTermOrds.java
@Override
public ImpactsEnum impacts(int flags) throws IOException {
  return termsEnum.impacts(flags);
}
 
 类所在包
 同包方法