File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
server/src/main/java/org/elasticsearch Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 8787import java .util .Arrays ;
8888import java .util .Collection ;
8989import java .util .Collections ;
90+ import java .util .HashSet ;
9091import java .util .List ;
9192import java .util .Map ;
9293import java .util .Objects ;
94+ import java .util .Set ;
95+ import java .util .stream .Collectors ;
9396
9497public class Lucene {
9598
@@ -128,6 +131,14 @@ public static Iterable<String> files(SegmentInfos infos) throws IOException {
128131 return Iterables .flatten (list );
129132 }
130133
134+ /**
135+ * Returns the additional files that the {@param current} index commit introduces compared to the {@param previous} one.
136+ */
137+ public static Set <String > additionalFileNames (IndexCommit previous , IndexCommit current ) throws IOException {
138+ final Set <String > previousFiles = previous != null ? new HashSet <>(previous .getFileNames ()) : Set .of ();
139+ return current .getFileNames ().stream ().filter (f -> previousFiles .contains (f ) == false ).collect (Collectors .toUnmodifiableSet ());
140+ }
141+
131142 /**
132143 * Returns the number of documents in the index referenced by this {@link SegmentInfos}
133144 */
Original file line number Diff line number Diff line change 3030import java .util .Set ;
3131import java .util .function .LongSupplier ;
3232
33+ import static org .elasticsearch .common .lucene .Lucene .additionalFileNames ;
3334import static org .elasticsearch .index .engine .ElasticsearchIndexDeletionPolicy .CommitsListener .listOfNewFileNames ;
3435
3536/**
@@ -131,7 +132,7 @@ public void onCommit(List<? extends IndexCommit> commits) throws IOException {
131132 assert assertSafeCommitUnchanged (safeCommit );
132133 if (commitsListener != null ) {
133134 if (newCommit != null ) {
134- final Set <String > additionalFiles = listOfNewFileNames (previousLastCommit , newCommit );
135+ final Set <String > additionalFiles = additionalFileNames (previousLastCommit , newCommit );
135136 commitsListener .onNewAcquiredCommit (newCommit , additionalFiles );
136137 }
137138 if (deletedCommits != null ) {
Original file line number Diff line number Diff line change @@ -48,10 +48,5 @@ public interface CommitsListener {
4848 void onNewAcquiredCommit (IndexCommit commit , Set <String > additionalFiles );
4949
5050 void onDeletedCommit (IndexCommit commit );
51-
52- static Set <String > listOfNewFileNames (IndexCommit previous , IndexCommit current ) throws IOException {
53- final Set <String > previousFiles = previous != null ? new HashSet <>(previous .getFileNames ()) : Set .of ();
54- return current .getFileNames ().stream ().filter (f -> previousFiles .contains (f ) == false ).collect (Collectors .toUnmodifiableSet ());
55- }
5651 }
5752}
You can’t perform that action at this time.
0 commit comments