Skip to content

Commit

Permalink
- use JDK 22 to build MediathekView on github
Browse files Browse the repository at this point in the history
- optimize Lucene indexer and search by using modern Lucene features
- bump library versions
  • Loading branch information
derreisende77 committed Oct 26, 2024
1 parent e2b83c4 commit 028785f
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 176 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
- name: Set up JDK 22
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '21'
java-version: '22'
java-package: jdk
cache: 'maven'
- name: Build and test with Maven
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- **FEATURE:** Mittels `Ansicht/Filmstatistik anzeigen` können nun für die vorhandenen Sender Informationen bzgl. Anzahl der Filme und der Duplikate angezeigt werden. Es wird hier nur die gesamte Filmliste ohne jegliche Filter abzüglich Livestreams berücksichtigt, so dass es zu Abweichungen zur Anzeige in der Statuszeile kommen kann.
- **FEATURE:** Mit der Lucene-Suche können mittels des `duplicate`-Boolean Parameters Filmduplikate berücksichtigt werden.
- **FEATURE:** Via `Ansicht/Übersicht aller Duplikate anzeigen...` werden in einem Dialog per Sender alle vorhandenen Duplikate dargestellt zzgl. der zugeordneten Filme.

- **FEATURE:** Geschwindigkeitsoptimierungen für die moderne Suche.
# **14.1.0**
- JDK 21 wird nun mitgeliefert. Behebt primär Darstellungsfehler von Java Apps unter Windows.
- **macOS/Windows:** ffmpeg 7.0 ist nun enthalten.
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.language.version>21</jdk.language.version>
<kotlin.language.target>21</kotlin.language.target>
<kotlin.version>2.0.0</kotlin.version>
<jdk.language.version>22</jdk.language.version>
<kotlin.language.target>22</kotlin.language.target>
<kotlin.version>2.0.21</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>

<maven.compiler.source>${jdk.language.version}</maven.compiler.source>
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/mediathek/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,12 @@ private static void checkJVMSettings() {
}

if (!correctParameters) {
//show error dialog
logger.warn("Detected incorrect JVM parameters! Please modify your settings");
JOptionPane.showMessageDialog(null,getJvmErrorMessageString(), Konstanten.PROGRAMMNAME,
JOptionPane.WARNING_MESSAGE);
if (!Config.isDebugModeEnabled()) {
//show error dialog
JOptionPane.showMessageDialog(null, getJvmErrorMessageString(), Konstanten.PROGRAMMNAME,
JOptionPane.WARNING_MESSAGE);
}
}
}

Expand Down Expand Up @@ -500,33 +502,31 @@ public static void main(final String... args) {
migrateSeenHistory();
Daten.getInstance().launchHistoryDataLoading();
Daten.getInstance().loadBookMarkData();

removeLuceneIndexDirectory();
// enable modern search on demand
var useModernSearch = ApplicationConfiguration.getConfiguration()
.getBoolean(ApplicationConfiguration.APPLICATION_USE_MODERN_SEARCH, false);
if (useModernSearch)
Daten.getInstance().setListeFilmeNachBlackList(new IndexedFilmList());
else {
try {
checkModernSearchIndexRemoval();
} catch (IOException e) {
logger.error("Unable to delete lucene index path", e);
}
}

startGuiMode();
});
}

/**
* Remove modern search index when not in use.
* @throws IOException
*/
private static void checkModernSearchIndexRemoval() throws IOException {
private static void removeLuceneIndexDirectory() {
//when modern search is not in use, delete unused film index directory as a precaution
var indexPath = StandardLocations.getFilmIndexPath();
if (Files.exists(indexPath)) {
logger.info("Modern search not in use, deleting unnecessary index directory");
FileUtils.deletePathRecursively(indexPath);
try {
FileUtils.deletePathRecursively(indexPath);
}
catch (IOException e) {
logger.error("Failed to remove Lucene index directory", e);
}
}
}

Expand Down
33 changes: 3 additions & 30 deletions src/main/java/mediathek/daten/IndexedFilmList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,24 @@
import mediathek.config.StandardLocations;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.NRTCachingDirectory;
import org.apache.lucene.store.MMapDirectory;

public class IndexedFilmList extends ListeFilme {
private static final Logger logger = LogManager.getLogger();
private final StandardAnalyzer analyzer = new StandardAnalyzer();
private Directory luceneDirectory;
private IndexWriter writer;
private DirectoryReader reader;
private IndexSearcher indexSearcher;

public IndexedFilmList() {
try {
luceneDirectory = new NRTCachingDirectory(FSDirectory.open(StandardLocations.getFilmIndexPath()), 20.0, 100.0);
luceneDirectory = new MMapDirectory(StandardLocations.getFilmIndexPath());

IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer);
indexWriterConfig.setRAMBufferSizeMB(256d);
writer = new IndexWriter(luceneDirectory, indexWriterConfig);
} catch (Exception ex) {
logger.error("Creation of Lucene index failed!", ex);
logger.error("Creation of Lucene index directory failed!", ex);
}
}

public IndexSearcher getIndexSearcher() {
return indexSearcher;
}

public void setIndexSearcher(IndexSearcher indexSearcher) {
this.indexSearcher = indexSearcher;
}

public StandardAnalyzer getAnalyzer() {
return analyzer;
}

public IndexWriter getWriter() {
return writer;
}

public DirectoryReader getReader() {
return reader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import mediathek.gui.tabs.tab_film.searchfilters.FinalStageFilterNoPatternWithDescription;
import mediathek.gui.tabs.tab_film.searchfilters.FinalStagePatternFilter;
import mediathek.gui.tabs.tab_film.searchfilters.FinalStagePatternFilterWithDescription;
import mediathek.javafx.filterpanel.FilmLengthSlider;
import mediathek.javafx.filterpanel.FilterActionPanel;
import mediathek.tool.Filter;
import mediathek.tool.models.TModelFilm;
Expand All @@ -19,7 +18,6 @@
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class GuiFilmeModelHelper extends GuiModelHelper {
private TModelFilm filmModel;
Expand Down Expand Up @@ -73,33 +71,22 @@ private void performTableFiltering() {
if (filterActionPanel.isShowSubtitlesOnly()) {
stream = stream.filter(this::subtitleCheck);
}
if (!filterThema.isEmpty()) {
stream = stream.filter(film -> film.getThema().equalsIgnoreCase(filterThema));
}
if (maxLength < FilmLengthSlider.UNLIMITED_VALUE) {
stream = stream.filter(this::maxLengthCheck);
}
if (filterActionPanel.isShowUnseenOnly()) {
stream = stream.filter(this::seenCheck);
}
//perform min length filtering after all others may have reduced the available entries...
stream = stream.filter(this::minLengthCheck);

stream = applyCommonFilters(stream, filterThema);

//final stage filtering...
final boolean searchFieldEmpty = arrIrgendwo.length == 0;
if (!searchFieldEmpty) {
stream = stream.filter(createFinalStageFilter());
}

var list = stream.collect(Collectors.toList());
var list = stream.toList();
stream.close();

//adjust initial capacity
filmModel = new TModelFilm(list.size());
filmModel.addAll(list);

list.clear();

if (filterActionPanel.isShowUnseenOnly())
historyController.emptyMemoryCache();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.swing.table.TableModel;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

public abstract class GuiModelHelper {
protected SliderRange sliderRange;
Expand Down Expand Up @@ -36,6 +37,20 @@ protected boolean minLengthCheck(DatenFilm film) {
return filmLength >= sliderRange.minLengthInSeconds();
}

public Stream<DatenFilm> applyCommonFilters(Stream<DatenFilm> stream, final String filterThema) {
if (!filterThema.isEmpty()) {
stream = stream.filter(film -> film.getThema().equalsIgnoreCase(filterThema));
}
if (maxLength < FilmLengthSlider.UNLIMITED_VALUE) {
stream = stream.filter(this::maxLengthCheck);
}
if (filterActionPanel.isShowUnseenOnly()) {
stream = stream.filter(this::seenCheck);
}
//perform min length filtering after all others may have reduced the available entries...
return stream.filter(this::minLengthCheck);
}

protected boolean noFiltersAreSet() {
var filmLengthSlider = filterActionPanel.getFilmLengthSlider();

Expand Down
Loading

0 comments on commit 028785f

Please sign in to comment.