File indexing completed on 2024-04-28 15:39:59
0001 /* SPDX-FileCopyrightText: 2018 Robert Krawitz <rlk@alum.mit.edu> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef OPTIMIZEDFILELIST_H 0007 #define OPTIMIZEDFILELIST_H 0008 #include <kpabase/FileNameList.h> 0009 0010 #include <QMap> 0011 #include <QSet> 0012 #include <QString> 0013 #include <QStringList> 0014 0015 namespace DB 0016 { 0017 typedef QSet<QString> StringSet; 0018 typedef QMap<QString, StringSet> DirMap; 0019 // Key is MD5 hash of the (opaque) contents of f_fsid 0020 typedef QMap<QString, QStringList> FSMap; 0021 0022 /** 0023 * Provide a list of files optimized by filesystem. 0024 * File names are interleaved across all filesystems 0025 * with files belonging to them. 0026 * 0027 * In other words, you can put in a list of files, and get 0028 * back a list that is optimized for read performance. 0029 */ 0030 class OptimizedFileList 0031 { 0032 public: 0033 explicit OptimizedFileList(const DB::FileNameList &files); 0034 explicit OptimizedFileList(const QStringList &files); 0035 QStringList optimizedFiles() const; 0036 DB::FileNameList optimizedDbFiles() const; 0037 0038 private: 0039 OptimizedFileList(); 0040 void optimizeFiles() const; 0041 const QStringList m_fileList; 0042 mutable QStringList m_optimizedList; 0043 mutable bool m_haveOptimizedFiles; 0044 mutable FSMap m_fsMap; 0045 static QString getDirName(const QString &); 0046 }; 0047 0048 } 0049 0050 #endif /* OPTIMIZEDFILELIST_H */ 0051 0052 // vi:expandtab:tabstop=4 shiftwidth=4: