Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Update getHNSWPaths to use SegmentReader to get directory path (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazanec15 committed Oct 20, 2020
1 parent e663da4 commit 924a131
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SegmentInfo;
import org.apache.lucene.index.SegmentReader;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.FilterDirectory;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardPath;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -103,9 +106,10 @@ public List<String> getHNSWPaths(IndexReader indexReader) throws IOException {
List<String> hnswFiles = new ArrayList<>();
for (LeafReaderContext leafReaderContext : indexReader.leaves()) {
SegmentReader reader = (SegmentReader) FilterLeafReader.unwrap(leafReaderContext.reader());
Path shardPath = ((FSDirectory) FilterDirectory.unwrap(reader.directory())).getDirectory();
hnswFiles.addAll(reader.getSegmentInfo().files().stream()
.filter(fileName -> fileName.endsWith(getHNSWFileExtension(reader.getSegmentInfo().info)))
.map(fileName -> shardPath().resolveIndex().resolve(fileName).toString())
.map(fileName -> shardPath.resolve(fileName).toString())
.filter(Objects::nonNull)
.collect(Collectors.toList()));
}
Expand Down

0 comments on commit 924a131

Please sign in to comment.