DBGenerator.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2014 Carlos Aguilar Melchor, Joris Barrier, Marc-Olivier Killijian
  2. * This file is part of XPIR.
  3. *
  4. * XPIR is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * XPIR is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with XPIR. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef DEF_DBGEN
  18. #define DEF_DBGEN
  19. #include "DBHandler.hpp"
  20. #include <cstring>
  21. #include <random>
  22. #include <omp.h>
  23. class DBGenerator : public DBHandler
  24. {
  25. private:
  26. std::vector <std::string> file_list; // the output file list
  27. public:
  28. DBGenerator(uint64_t nbStreams, uint64_t streamBytesize, bool silent);
  29. ~DBGenerator();
  30. std::string getCatalog(const bool typeOfCatalog);
  31. uint64_t getNbStream();
  32. uint64_t getmaxFileBytesize();
  33. std::ifstream* openStream(uint64_t streamNb, uint64_t requested_offset);
  34. uint64_t readStream(std::ifstream* s, char * buf, uint64_t size);
  35. void readAggregatedStream(uint64_t streamNb, uint64_t alpha, uint64_t offset, uint64_t bytes_per_file, char* rawBits);
  36. void closeStream(std::ifstream* s);
  37. private:
  38. std::mt19937_64 random_engine; // Fixed seed of 0
  39. std::uniform_int_distribution<> random_distribution;
  40. uint64_t maxFileBytesize;
  41. uint64_t nbFiles;
  42. };
  43. #endif //DEF_CATALOGMAKER