Use an enum type for the 'should read fingerprint' flag, rather than a mysterious boolean

Fix tests.
This commit is contained in:
Daniel Patterson
2016-11-15 14:49:28 -08:00
parent 7b1131b982
commit 53ef2e2955
7 changed files with 58 additions and 47 deletions
+8 -12
View File
@@ -30,12 +30,8 @@ inline bool writeFingerprint(std::ostream &stream)
}
template <typename simple_type>
bool serializeVector(const std::string &filename, const std::vector<simple_type> &data)
bool serializeVector(std::ostream &stream, const std::vector<simple_type> &data)
{
std::ofstream stream(filename, std::ios::binary);
writeFingerprint(stream);
std::uint64_t count = data.size();
stream.write(reinterpret_cast<const char *>(&count), sizeof(count));
if (!data.empty())
@@ -44,13 +40,13 @@ bool serializeVector(const std::string &filename, const std::vector<simple_type>
}
template <typename simple_type>
bool serializeVector(std::ostream &stream, const std::vector<simple_type> &data)
bool serializeVector(const std::string &filename, const std::vector<simple_type> &data)
{
std::uint64_t count = data.size();
stream.write(reinterpret_cast<const char *>(&count), sizeof(count));
if (!data.empty())
stream.write(reinterpret_cast<const char *>(&data[0]), sizeof(simple_type) * count);
return static_cast<bool>(stream);
std::ofstream stream(filename, std::ios::binary);
writeFingerprint(stream);
return serializeVector(stream, data);
}
// serializes a vector of vectors into an adjacency array (creates a copy of the data internally)
@@ -116,7 +112,7 @@ void deserializeAdjacencyArray(const std::string &filename,
std::vector<std::uint32_t> &offsets,
std::vector<simple_type> &data)
{
storage::io::FileReader file(filename);
storage::io::FileReader file(filename, storage::io::FileReader::HasNoFingerprint);
file.DeserializeVector(offsets);
file.DeserializeVector(data);
+2 -1
View File
@@ -346,7 +346,8 @@ class StaticRTree
const CoordinateListT &coordinate_list)
: m_coordinate_list(coordinate_list)
{
storage::io::FileReader tree_node_file(node_file);
storage::io::FileReader tree_node_file(node_file,
storage::io::FileReader::HasNoFingerprint);
const auto tree_size = tree_node_file.ReadElementCount64();