-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebuild version map when opening internal engine (#43202)
With this change, we will rebuild the live version map and local checkpoint using documents (including soft-deleted) from the safe commit when opening an internal engine. This allows us to safely prune away _id of all soft-deleted documents as the version map is always in-sync with the Lucene index. Relates #40741 Supersedes #42979
- v8.17.2
- v8.17.1
- v8.17.0
- v8.16.4
- v8.16.3
- v8.16.2
- v8.16.1
- v8.16.0
- v8.15.5
- v8.15.4
- v8.15.3
- v8.15.2
- v8.15.1
- v8.15.0
- v8.14.3
- v8.14.2
- v8.14.1
- v8.14.0
- v8.13.4
- v8.13.3
- v8.13.2
- v8.13.1
- v8.13.0
- v8.12.2
- v8.12.1
- v8.12.0
- v8.11.4
- v8.11.3
- v8.11.2
- v8.11.1
- v8.11.0
- v8.10.4
- v8.10.3
- v8.10.2
- v8.10.1
- v8.10.0
- v8.9.2
- v8.9.1
- v8.9.0
- v8.8.2
- v8.8.1
- v8.8.0
- v8.7.1
- v8.7.0
- v8.6.2
- v8.6.1
- v8.6.0
- v8.5.3
- v8.5.2
- v8.5.1
- v8.5.0
- v8.4.3
- v8.4.2
- v8.4.1
- v8.4.0
- v8.3.3
- v8.3.2
- v8.3.1
- v8.3.0
- v8.2.3
- v8.2.2
- v8.2.1
- v8.2.0
- v8.1.3
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.1
- v8.0.0
- v8.0.0-rc2
- v8.0.0-rc1
- v8.0.0-beta1
- v8.0.0-alpha2
- v8.0.0-alpha1
Showing
9 changed files
with
348 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
server/src/main/java/org/elasticsearch/index/engine/CombinedDocValues.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.index.engine; | ||
|
||
import org.apache.lucene.index.LeafReader; | ||
import org.apache.lucene.index.NumericDocValues; | ||
import org.elasticsearch.index.mapper.SeqNoFieldMapper; | ||
import org.elasticsearch.index.mapper.SourceFieldMapper; | ||
import org.elasticsearch.index.mapper.VersionFieldMapper; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
final class CombinedDocValues { | ||
private final NumericDocValues versionDV; | ||
private final NumericDocValues seqNoDV; | ||
private final NumericDocValues primaryTermDV; | ||
private final NumericDocValues tombstoneDV; | ||
private final NumericDocValues recoverySource; | ||
|
||
CombinedDocValues(LeafReader leafReader) throws IOException { | ||
this.versionDV = Objects.requireNonNull(leafReader.getNumericDocValues(VersionFieldMapper.NAME), "VersionDV is missing"); | ||
this.seqNoDV = Objects.requireNonNull(leafReader.getNumericDocValues(SeqNoFieldMapper.NAME), "SeqNoDV is missing"); | ||
this.primaryTermDV = Objects.requireNonNull( | ||
leafReader.getNumericDocValues(SeqNoFieldMapper.PRIMARY_TERM_NAME), "PrimaryTermDV is missing"); | ||
this.tombstoneDV = leafReader.getNumericDocValues(SeqNoFieldMapper.TOMBSTONE_NAME); | ||
this.recoverySource = leafReader.getNumericDocValues(SourceFieldMapper.RECOVERY_SOURCE_NAME); | ||
} | ||
|
||
long docVersion(int segmentDocId) throws IOException { | ||
assert versionDV.docID() < segmentDocId; | ||
if (versionDV.advanceExact(segmentDocId) == false) { | ||
throw new IllegalStateException("DocValues for field [" + VersionFieldMapper.NAME + "] is not found"); | ||
} | ||
return versionDV.longValue(); | ||
} | ||
|
||
long docSeqNo(int segmentDocId) throws IOException { | ||
assert seqNoDV.docID() < segmentDocId; | ||
if (seqNoDV.advanceExact(segmentDocId) == false) { | ||
throw new IllegalStateException("DocValues for field [" + SeqNoFieldMapper.NAME + "] is not found"); | ||
} | ||
return seqNoDV.longValue(); | ||
} | ||
|
||
long docPrimaryTerm(int segmentDocId) throws IOException { | ||
if (primaryTermDV == null) { | ||
return -1L; | ||
} | ||
assert primaryTermDV.docID() < segmentDocId; | ||
// Use -1 for docs which don't have primary term. The caller considers those docs as nested docs. | ||
if (primaryTermDV.advanceExact(segmentDocId) == false) { | ||
return -1; | ||
} | ||
return primaryTermDV.longValue(); | ||
} | ||
|
||
boolean isTombstone(int segmentDocId) throws IOException { | ||
if (tombstoneDV == null) { | ||
return false; | ||
} | ||
assert tombstoneDV.docID() < segmentDocId; | ||
return tombstoneDV.advanceExact(segmentDocId) && tombstoneDV.longValue() > 0; | ||
} | ||
|
||
boolean hasRecoverySource(int segmentDocId) throws IOException { | ||
if (recoverySource == null) { | ||
return false; | ||
} | ||
assert recoverySource.docID() < segmentDocId; | ||
return recoverySource.advanceExact(segmentDocId); | ||
} | ||
} |
Oops, something went wrong.