NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_mpi_csvresources.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef BE_MPI_CSVRESOURCES_H_
12#define BE_MPI_CSVRESOURCES_H_
13
14#include <random>
15#include <string>
16#include <vector>
17#include <utility>
18
19#include <be_memory_autoarray.h>
20#include <be_mpi_resources.h>
21
22namespace BiometricEvaluation
23{
24 namespace MPI
25 {
26 class CSVResources : public Resources
27 {
28 public:
30 static const std::string INPUTCSVPROPERTY;
32 static const std::string CHUNKSIZEPROPERTY;
34 static const std::string USEBUFFERPROPERTY;
36 static const std::string RANDOMIZEPROPERTY;
38 static const std::string RANDOMSEEDPROPERTY;
40 static const std::string DELIMITERPROPERTY;
42 static const std::string TRIMPROPERTY;
43
44 static std::vector<std::string>
46
47 static std::vector<std::string>
49
51 const std::string &propertiesFileName);
53
54 uint32_t
56 const;
57
68 bool
70 const;
71
81 bool
83 const;
84
93 uint64_t
95 const;
96
98 std::string
100 const;
101
119 std::pair<uint64_t, std::string>
121
132 uint64_t
134 const;
135
146 std::mt19937_64::result_type
148 const;
149
150 private:
164 void
165 openCSV();
166
167 std::pair<uint64_t, std::string>
168 readLine(
169 bool randomize);
170
171 uint32_t _chunkSize;
172
174 uint64_t _numLines;
176 uint64_t _remainingLines;
177
179 std::string _csvPath;
181 std::shared_ptr<std::ifstream> _csvStream;
182
184 bool _trimWhitespace;
186 bool _useBuffer;
188 Memory::uint8Array _csvBuffer;
190 bool _randomizeLines;
192 std::vector<std::pair<uint64_t, std::string>>
193 _randomizedLines;
195 std::mt19937_64 _rng;
197 std::mt19937_64::result_type _rngSeed;
199 uint64_t _offset;
200
202 std::string _delimiter;
203 };
204 }
205}
206
207#endif /* BE_MPI_CSVRESOURCES_H_ */
208
static const std::string INPUTCSVPROPERTY
Text file to read.
bool useBuffer() const
Obtain whether or not the entire CSV was read into memory at construction.
std::pair< uint64_t, std::string > readLine()
Obtain the next line from a buffer of file stream.
CSVResources(const std::string &propertiesFileName)
static const std::string TRIMPROPERTY
Trim whitespace from lines read.
static const std::string CHUNKSIZEPROPERTY
Number of lines sent in succession.
bool randomizeLines() const
If using buffer, whether or not to randomize how lines from the buffer are iterated.
uint64_t getNumLines() const
Obtain number of lines of input.
static const std::string USEBUFFERPROPERTY
Read file into buffer first, or read from file.
static const std::string RANDOMIZEPROPERTY
Randomly iterate buffer.
std::mt19937_64::result_type getRandomSeed() const
Obtain the seed used to shuffle lines.
static const std::string RANDOMSEEDPROPERTY
Seed for randomization.
static const std::string DELIMITERPROPERTY
Delimiter to tokenize sent lines.
static std::vector< std::string > getOptionalProperties()
uint64_t getNumRemainingLines() const
Obtain the number of lines that have not yet been read from readLine() by a Distributor.
static std::vector< std::string > getRequiredProperties()
A class to represent a set of resources needed by an MPI program.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...