Query saver store fix for big endian systems.

This commit is contained in:
Lev Dragunov 2015-08-25 20:04:41 +03:00 committed by Alex Zolotarev
parent 64c1eb8feb
commit eca1b5c650

View file

@ -5,6 +5,7 @@
#include "coding/base64.hpp"
#include "coding/reader.hpp"
#include "coding/writer.hpp"
#include "coding/write_to_sink.hpp"
#include "base/logging.hpp"
@ -19,7 +20,7 @@ bool ReadLength(ReaderSource<MemReader> & reader, TLength & length)
{
if (reader.Size() < kLengthTypeSize)
return false;
reader.Read(&length, kLengthTypeSize);
length = ReadPrimitiveFromSource<TLength>(reader);
return true;
}
} // namespace
@ -59,11 +60,11 @@ void QuerySaver::Serialize(string & data) const
vector<uint8_t> rawData;
MemWriter<vector<uint8_t>> writer(rawData);
TLength size = m_topQueries.size();
writer.Write(&size, kLengthTypeSize);
WriteToSink(writer, size);
for (auto const & query : m_topQueries)
{
size = query.size();
writer.Write(&size, kLengthTypeSize);
WriteToSink(writer, size);
writer.Write(query.c_str(), size);
}
data = base64::Encode(string(rawData.begin(), rawData.end()));