Compare commits

...

3 Commits

Author SHA1 Message Date
9b1872139d
docs: setup presentation 2024-03-22 11:01:03 +01:00
66a54d85cc
refactor: clean up 2024-03-22 10:59:35 +01:00
f080d00697
feat: don't search while typing 2024-03-22 10:59:13 +01:00
16 changed files with 2413 additions and 14 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@
bin/ bin/
compile_commands.json compile_commands.json
build-*/ build-*/
latex.out/
docs/folien/folien.pdf

View File

@ -22,6 +22,13 @@
qt6.full qt6.full
libGL libGL
# presentation
pandoc
texlive.combined.scheme-full
noto-fonts
latexrun
entr
# pre-commit # pre-commit
pre-commit pre-commit
commitizen commitizen

View File

@ -23,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
setupAlgorithmSelector(); setupAlgorithmSelector();
setupWordListSourceSelector(); setupWordListSourceSelector();
setupWordList(); setupWordList();
createSelectedFinder();
} }
MainWindow::~MainWindow() { delete ui; } MainWindow::~MainWindow() { delete ui; }
@ -79,8 +80,7 @@ void MainWindow::loadWordList(std::filesystem::path path) {
void MainWindow::search(const QString &search_term) { void MainWindow::search(const QString &search_term) {
if (search_term.isEmpty()) { if (search_term.isEmpty()) {
result_model_.setStringList(QStringList()); clearResults();
ui->mainStatusBar->clearMessage();
return; return;
} }
@ -99,6 +99,7 @@ void MainWindow::search(const QString &search_term) {
void MainWindow::createSelectedFinder() { void MainWindow::createSelectedFinder() {
auto selectedFinder = ui->searchAlgorithmSelector->currentIndex(); auto selectedFinder = ui->searchAlgorithmSelector->currentIndex();
Timer timer;
switch (selectedFinder) { switch (selectedFinder) {
case 0: case 0:
default: default:
@ -120,6 +121,12 @@ void MainWindow::createSelectedFinder() {
finder_ = std::make_unique<GroupedFinder>(word_list_); finder_ = std::make_unique<GroupedFinder>(word_list_);
break; break;
} }
timer.stop();
std::stringstream status_message;
status_message << "finder initialized in " << timer << ", "
<< word_list_.size() << " words loaded";
ui->mainStatusBar->showMessage(QString::fromStdString(status_message.str()));
} }
void MainWindow::showResults(const WordRefList &results) { void MainWindow::showResults(const WordRefList &results) {
@ -131,32 +138,37 @@ void MainWindow::showResults(const WordRefList &results) {
result_model_.setStringList(ui_results); result_model_.setStringList(ui_results);
} }
void MainWindow::clearResults() { result_model_.setStringList({}); }
void MainWindow::on_searchInput_textChanged(const QString &search_term) { void MainWindow::on_searchInput_textChanged(const QString &search_term) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor); // QGuiApplication::setOverrideCursor(Qt::WaitCursor);
search(search_term); // search(search_term);
QGuiApplication::restoreOverrideCursor(); // QGuiApplication::restoreOverrideCursor();
} }
void MainWindow::on_searchAlgorithmSelector_currentIndexChanged(int) { void MainWindow::on_searchAlgorithmSelector_currentIndexChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor); QGuiApplication::setOverrideCursor(Qt::WaitCursor);
clearResults();
createSelectedFinder(); createSelectedFinder();
search(ui->searchInput->displayText()); // search(ui->searchInput->displayText());
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }
void MainWindow::on_wordListSourceSelector_currentIndexChanged(int) { void MainWindow::on_wordListSourceSelector_currentIndexChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor); QGuiApplication::setOverrideCursor(Qt::WaitCursor);
clearResults();
setupWordList(); setupWordList();
createSelectedFinder(); createSelectedFinder();
search(ui->searchInput->displayText()); // search(ui->searchInput->displayText());
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }
void MainWindow::on_wordListSizeSelector_valueChanged(int) { void MainWindow::on_wordListSizeSelector_valueChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor); QGuiApplication::setOverrideCursor(Qt::WaitCursor);
clearResults();
setupWordList(); setupWordList();
createSelectedFinder(); createSelectedFinder();
search(ui->searchInput->displayText()); // search(ui->searchInput->displayText());
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }

View File

@ -37,6 +37,7 @@ private:
void search(const QString &search_term); void search(const QString &search_term);
void createSelectedFinder(); void createSelectedFinder();
void showResults(const WordRefList &results); void showResults(const WordRefList &results);
void clearResults();
private slots: private slots:
void on_searchInput_textChanged(const QString &search_term); void on_searchInput_textChanged(const QString &search_term);

34
docs/folien/analyse.tex Normal file
View File

@ -0,0 +1,34 @@
\begin{frame}{Analyse}
{\Large Anforderungen}
\vspace{0.5cm}
\begin{itemize}
\item Datenstruktur für Wortliste
\item Paralleler Such-Algorithmus
\item Abgeleitet: Optimierung der Such-Zeit
\end{itemize}
\end{frame}
\begin{frame}{Analyse}
{\Large Abgeleitete Aufgabenstellung}
\vspace{0.5cm}
\begin{minipage}{0.7\textwidth}
Aufteilung in zwei Blöcke:
\begin{block}{Anwendungs-Schicht (Layer 5 - 7)}
\begin{itemize}
\item Request/Reponse
\item Konkurrierender Zugriff
\item Session Handling
\end{itemize}
\end{block}
\begin{block}{Transport-Schicht (Layer 1 - 4)}
\begin{itemize}
\item Datenübertragung zwischen SG
\item Gleichzeitige Kommunikation
\end{itemize}
\end{block}
\end{minipage}
\end{frame}

14
docs/folien/aufgabe.tex Normal file
View File

@ -0,0 +1,14 @@
\begin{frame}{Aufgabe}
{\Large Entwicklung einer parallelen Suche in einer Liste mit Wörtern}
\vspace{0.5cm}
Es ist eine Datenstruktur in Form einer Liste (Vektor) mit unterschiedlichen Wörtern
gegeben. Ein Suchalgorithmus soll eine Liste mit Wörtern aus dieser Wortliste ermitteln,
deren erste Zeichen mit einem Suchstring übereinstimmen.
Der Algorithmus soll moderne Multi-Core-Prozessoren ausnutzen, die Suche also auf
möglichst viele Cores verteilen.
\end{frame}

5
docs/folien/danke.tex Normal file
View File

@ -0,0 +1,5 @@
\begin{frame}
\begin{center}
\huge Vielen Dank
\end{center}
\end{frame}

51
docs/folien/folien.tex Normal file
View File

@ -0,0 +1,51 @@
\documentclass[aspectratio=169]{beamer}
\title{Fallstudie Wortliste}
\author{Michael Mandl}
\date[v0.1 | 25.03.2024]{25.03.2024}
\usepackage[sfdefault]{noto}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{fontawesome}
\definecolor{vector_red}{RGB}{183, 0, 50}
\definecolor{vector_grey}{RGB}{234, 236, 237}
\usetheme{Boadilla}
\setbeamercolor*{palette primary}{fg=white,bg=vector_red}
\setbeamercolor*{palette secondary}{fg=black,bg=vector_grey}
\setbeamercolor*{palette tertiary}{fg=black,bg=vector_grey}
\setbeamercolor*{palette quaternary}{fg=black,bg=vector_grey}
\setbeamercolor{titlelike}{fg=white, bg=vector_red}
\setbeamercolor{frametitle}{bg=vector_red,fg=white}
\setbeamertemplate{itemize item}[triangle]
\setbeamertemplate{itemize subitem}[circle]
\setbeamercolor{itemize item}{fg=vector_red}
\setbeamercolor{itemize subitem}{fg=vector_red}
\setbeamercolor{itemize subsubitem}{fg=vector_red}
\setbeamercolor{description item}{fg=vector_red}
\setbeamercolor{block title}{fg=white, bg=vector_red}
\setbeamercolor{block body}{fg=black, bg=vector_grey}
\setbeamertemplate{navigation symbols}{}
\setbeamersize
{
text margin left=2cm,
text margin right=2cm
}
\begin{document}
\frame[plain]{\titlepage}
\include{aufgabe}
\include{analyse}
\include{danke}
\end{document}

BIN
docs/folien/insert_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/folien/insert_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/folien/insert_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
docs/folien/insert_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

3
docs/folien/watch_and_build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
find . -name "*.tex" -o -name "*.png" | entr latexrun folien.tex

2270
docs/input.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -7,7 +7,7 @@
class Bucket { class Bucket {
private: private:
std::map<const char, WordRefList> groups_; std::map<char, WordRefList> directory_;
public: public:
void insert(const WordList &word_list, size_t first_index, size_t last_index); void insert(const WordList &word_list, size_t first_index, size_t last_index);

View File

@ -6,20 +6,20 @@
void Bucket::insert(const WordList &word_list, size_t first_index, void Bucket::insert(const WordList &word_list, size_t first_index,
size_t last_index) { size_t last_index) {
for (size_t index = first_index; index < last_index; ++index) { for (auto index = first_index; index < last_index; ++index) {
const auto &current_word = word_list[index]; const auto &current_word = word_list[index];
groups_[current_word.front()].push_back(&current_word); directory_[current_word.front()].push_back(&current_word);
} }
} }
WordRefList Bucket::find_prefix(std::string_view search_term) const { WordRefList Bucket::find_prefix(std::string_view search_term) const {
auto group_it = groups_.find(search_term.front()); auto directory_it = directory_.find(search_term.front());
if (group_it == groups_.cend()) { if (directory_it == directory_.cend()) {
return {}; return {};
} }
WordRefList result; WordRefList result;
for (const auto *word : group_it->second) { for (const auto *word : directory_it->second) {
if (word->starts_with(search_term)) { if (word->starts_with(search_term)) {
result.push_back(word); result.push_back(word);
} }