You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by 80152403 <80...@qq.com.INVALID> on 2021/08/05 10:01:54 UTC

回复:Question for SoftDeletesRetentionMergePolicy#numDeletesToMerge

I am sorry, the picture did not upload successfully, the code is here:


org.apache.lucene.index.SoftDeletesRetentionMergePolicy#numDeletesToMerge
public int numDeletesToMerge(SegmentCommitInfo info, int delCount, IOSupplier<CodecReader&gt; readerSupplier) throws IOException {
  final int numDeletesToMerge = super.numDeletesToMerge(info, delCount, readerSupplier);
  if (numDeletesToMerge != 0 &amp;&amp; info.getSoftDelCount() &gt; 0) {
    final CodecReader reader = readerSupplier.get();
    if (reader.getLiveDocs() != null) {
      BooleanQuery.Builder builder = new BooleanQuery.Builder();
      builder.add(new DocValuesFieldExistsQuery(field), BooleanClause.Occur.FILTER);
      builder.add(retentionQuerySupplier.get(), BooleanClause.Occur.FILTER);
      Scorer scorer = getScorer(builder.build(), FilterCodecReader.wrapLiveDocs(reader, null, reader.maxDoc()));
      if (scorer != null) {
        DocIdSetIterator iterator = scorer.iterator();
        Bits liveDocs = reader.getLiveDocs();
        int numDeletedDocs = reader.numDeletedDocs();
        while (iterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
          if (liveDocs.get(iterator.docID()) == false) {
            numDeletedDocs--;
          }
        }
        return numDeletedDocs;
      }
    }
  }




------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "zhangchao-so"                                                                                    <80152403@qq.com&gt;;
发送时间:&nbsp;2021年7月22日(星期四) 晚上9:10
收件人:&nbsp;"dev"<dev@lucene.apache.org&gt;;

主题:&nbsp;Question  for  SoftDeletesRetentionMergePolicy#numDeletesToMerge



Hi,all 

I have a question for SoftDeletesRetentionMergePolicy#numDeletesToMerge funcation, the &nbsp;highlight line:

liveDocs.get(iterator.docID()

It always seems to return false, I added a log when it returned true in elasticsearch 7.x(softdelete enable), then It ran for several hours with doc update operation, it never return true


I understand a doc which has a SOFT_DELETE docvalue,it always has a zero value in liveDocs, so i understand that there is no need to judge in LiveDoc. I don't know if it is correct?


Looking forward to your reply. Thank a lot!