Cleanup Bolt debug messages
Reviewers: teon.banek, dgleich, msantl Reviewed By: msantl Subscribers: msantl, pullbot Differential Revision: https://phabricator.memgraph.io/D1414
This commit is contained in:
parent
ec93365b15
commit
67b7f480e3
@ -93,7 +93,6 @@ class ChunkedDecoderBuffer {
|
|||||||
size_t size = buffer_.size();
|
size_t size = buffer_.size();
|
||||||
|
|
||||||
if (size < 2) {
|
if (size < 2) {
|
||||||
DLOG(WARNING) << "Size < 2";
|
|
||||||
return ChunkState::Partial;
|
return ChunkState::Partial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +107,6 @@ class ChunkedDecoderBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size < chunk_size + 2) {
|
if (size < chunk_size + 2) {
|
||||||
DLOG(WARNING) << fmt::format(
|
|
||||||
"Chunk size is {} but only have {} data bytes.", chunk_size, size);
|
|
||||||
return ChunkState::Partial;
|
return ChunkState::Partial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +33,7 @@ class Decoder {
|
|||||||
bool ReadValue(DecodedValue *data) {
|
bool ReadValue(DecodedValue *data) {
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|
||||||
VLOG(20) << "[ReadValue] Start";
|
|
||||||
|
|
||||||
if (!buffer_.Read(&value, 1)) {
|
if (!buffer_.Read(&value, 1)) {
|
||||||
DLOG(WARNING) << "[ReadValue] Marker data missing!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +77,6 @@ class Decoder {
|
|||||||
// won't perform an additional signature read.
|
// won't perform an additional signature read.
|
||||||
uint8_t signature;
|
uint8_t signature;
|
||||||
if (!buffer_.Read(&signature, 1)) {
|
if (!buffer_.Read(&signature, 1)) {
|
||||||
DLOG(WARNING) << "[ReadVertex] Missing marker and/or signature data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (static_cast<Signature>(signature)) {
|
switch (static_cast<Signature>(signature)) {
|
||||||
@ -91,9 +87,6 @@ class Decoder {
|
|||||||
case Signature::Path:
|
case Signature::Path:
|
||||||
return ReadPath(data);
|
return ReadPath(data);
|
||||||
default:
|
default:
|
||||||
DLOG(WARNING) << "[ReadValue] Expected [node | unbounded_ege | "
|
|
||||||
"path] signature, received "
|
|
||||||
<< signature;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,11 +119,9 @@ class Decoder {
|
|||||||
*/
|
*/
|
||||||
bool ReadValue(DecodedValue *data, DecodedValue::Type type) {
|
bool ReadValue(DecodedValue *data, DecodedValue::Type type) {
|
||||||
if (!ReadValue(data)) {
|
if (!ReadValue(data)) {
|
||||||
DLOG(WARNING) << "[ReadValue] ReadValue call failed!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (data->type() != type) {
|
if (data->type() != type) {
|
||||||
DLOG(WARNING) << "[ReadValue] Decoded value has wrong type!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -148,16 +139,12 @@ class Decoder {
|
|||||||
bool ReadMessageHeader(Signature *signature, Marker *marker) {
|
bool ReadMessageHeader(Signature *signature, Marker *marker) {
|
||||||
uint8_t values[2];
|
uint8_t values[2];
|
||||||
|
|
||||||
VLOG(20) << "[ReadMessageHeader] Start";
|
|
||||||
|
|
||||||
if (!buffer_.Read(values, 2)) {
|
if (!buffer_.Read(values, 2)) {
|
||||||
DLOG(WARNING) << "[ReadMessageHeader] Marker data missing!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*marker = (Marker)values[0];
|
*marker = (Marker)values[0];
|
||||||
*signature = (Signature)values[1];
|
*signature = (Signature)values[1];
|
||||||
DLOG(WARNING) << "[ReadMessageHeader] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,15 +153,12 @@ class Decoder {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool ReadNull(const Marker &marker, DecodedValue *data) {
|
bool ReadNull(const Marker &marker, DecodedValue *data) {
|
||||||
VLOG(20) << "[ReadNull] Start";
|
|
||||||
DCHECK(marker == Marker::Null) << "Received invalid marker!";
|
DCHECK(marker == Marker::Null) << "Received invalid marker!";
|
||||||
*data = DecodedValue();
|
*data = DecodedValue();
|
||||||
VLOG(20) << "[ReadNull] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadBool(const Marker &marker, DecodedValue *data) {
|
bool ReadBool(const Marker &marker, DecodedValue *data) {
|
||||||
VLOG(20) << "[ReadBool] Start";
|
|
||||||
DCHECK(marker == Marker::False || marker == Marker::True)
|
DCHECK(marker == Marker::False || marker == Marker::True)
|
||||||
<< "Received invalid marker!";
|
<< "Received invalid marker!";
|
||||||
if (marker == Marker::False) {
|
if (marker == Marker::False) {
|
||||||
@ -182,156 +166,120 @@ class Decoder {
|
|||||||
} else {
|
} else {
|
||||||
*data = DecodedValue(true);
|
*data = DecodedValue(true);
|
||||||
}
|
}
|
||||||
VLOG(20) << "[ReadBool] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadInt(const Marker &marker, DecodedValue *data) {
|
bool ReadInt(const Marker &marker, DecodedValue *data) {
|
||||||
uint8_t value = utils::UnderlyingCast(marker);
|
uint8_t value = utils::UnderlyingCast(marker);
|
||||||
int64_t ret;
|
int64_t ret;
|
||||||
VLOG(20) << "[ReadInt] Start";
|
|
||||||
if (value >= 240 || value <= 127) {
|
if (value >= 240 || value <= 127) {
|
||||||
VLOG(20) << "[ReadInt] Found a TinyInt";
|
|
||||||
ret = value;
|
ret = value;
|
||||||
if (value >= 240) ret -= 256;
|
if (value >= 240) ret -= 256;
|
||||||
} else if (marker == Marker::Int8) {
|
} else if (marker == Marker::Int8) {
|
||||||
VLOG(20) << "[ReadInt] Found an Int8";
|
|
||||||
int8_t tmp;
|
int8_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadInt] Int8 missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = tmp;
|
ret = tmp;
|
||||||
} else if (marker == Marker::Int16) {
|
} else if (marker == Marker::Int16) {
|
||||||
VLOG(20) << "[ReadInt] Found an Int16";
|
|
||||||
int16_t tmp;
|
int16_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadInt] Int16 missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = utils::Bswap(tmp);
|
ret = utils::Bswap(tmp);
|
||||||
} else if (marker == Marker::Int32) {
|
} else if (marker == Marker::Int32) {
|
||||||
VLOG(20) << "[ReadInt] Found an Int32";
|
|
||||||
int32_t tmp;
|
int32_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadInt] Int32 missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = utils::Bswap(tmp);
|
ret = utils::Bswap(tmp);
|
||||||
} else if (marker == Marker::Int64) {
|
} else if (marker == Marker::Int64) {
|
||||||
VLOG(20) << "[ReadInt] Found an Int64";
|
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&ret), sizeof(ret))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&ret), sizeof(ret))) {
|
||||||
DLOG(WARNING) << "[ReadInt] Int64 missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = utils::Bswap(ret);
|
ret = utils::Bswap(ret);
|
||||||
} else {
|
} else {
|
||||||
DLOG(WARNING) << "[ReadInt] Received invalid marker "
|
|
||||||
<< utils::UnderlyingCast(marker);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*data = DecodedValue(ret);
|
*data = DecodedValue(ret);
|
||||||
VLOG(20) << "[ReadInt] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadDouble(const Marker marker, DecodedValue *data) {
|
bool ReadDouble(const Marker marker, DecodedValue *data) {
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
double ret;
|
double ret;
|
||||||
VLOG(20) << "[ReadDouble] Start";
|
|
||||||
DCHECK(marker == Marker::Float64) << "Received invalid marker!";
|
DCHECK(marker == Marker::Float64) << "Received invalid marker!";
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&value), sizeof(value))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&value), sizeof(value))) {
|
||||||
DLOG(WARNING) << "[ReadDouble] Missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
value = utils::Bswap(value);
|
value = utils::Bswap(value);
|
||||||
// cppcheck-suppress invalidPointerCast
|
// cppcheck-suppress invalidPointerCast
|
||||||
ret = *reinterpret_cast<double *>(&value);
|
ret = *reinterpret_cast<double *>(&value);
|
||||||
*data = DecodedValue(ret);
|
*data = DecodedValue(ret);
|
||||||
VLOG(20) << "[ReadDouble] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ReadTypeSize(const Marker &marker, const uint8_t type) {
|
int64_t ReadTypeSize(const Marker &marker, const uint8_t type) {
|
||||||
uint8_t value = utils::UnderlyingCast(marker);
|
uint8_t value = utils::UnderlyingCast(marker);
|
||||||
if ((value & 0xF0) == utils::UnderlyingCast(MarkerTiny[type])) {
|
if ((value & 0xF0) == utils::UnderlyingCast(MarkerTiny[type])) {
|
||||||
VLOG(20) << "[ReadTypeSize] Found a TinyType";
|
|
||||||
return value & 0x0F;
|
return value & 0x0F;
|
||||||
} else if (marker == Marker8[type]) {
|
} else if (marker == Marker8[type]) {
|
||||||
VLOG(20) << "[ReadTypeSize] Found a Type8";
|
|
||||||
uint8_t tmp;
|
uint8_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadTypeSize] Type8 missing data!";
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
} else if (marker == Marker16[type]) {
|
} else if (marker == Marker16[type]) {
|
||||||
VLOG(20) << "[ReadTypeSize] Found a Type16";
|
|
||||||
uint16_t tmp;
|
uint16_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadTypeSize] Type16 missing data!";
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tmp = utils::Bswap(tmp);
|
tmp = utils::Bswap(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
} else if (marker == Marker32[type]) {
|
} else if (marker == Marker32[type]) {
|
||||||
VLOG(20) << "[ReadTypeSize] Found a Type32";
|
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
if (!buffer_.Read(reinterpret_cast<uint8_t *>(&tmp), sizeof(tmp))) {
|
||||||
DLOG(WARNING) << "[ReadTypeSize] Type32 missing data!";
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tmp = utils::Bswap(tmp);
|
tmp = utils::Bswap(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
} else {
|
} else {
|
||||||
DLOG(WARNING) << "[ReadTypeSize] Received invalid marker "
|
|
||||||
<< utils::UnderlyingCast(marker);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadString(const Marker &marker, DecodedValue *data) {
|
bool ReadString(const Marker &marker, DecodedValue *data) {
|
||||||
VLOG(20) << "[ReadString] Start";
|
|
||||||
auto size = ReadTypeSize(marker, MarkerString);
|
auto size = ReadTypeSize(marker, MarkerString);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
DLOG(WARNING) << "[ReadString] Couldn't get size!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::unique_ptr<uint8_t[]> ret(new uint8_t[size]);
|
std::unique_ptr<uint8_t[]> ret(new uint8_t[size]);
|
||||||
if (!buffer_.Read(ret.get(), size)) {
|
if (!buffer_.Read(ret.get(), size)) {
|
||||||
DLOG(WARNING) << "[ReadString] Missing data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*data =
|
*data =
|
||||||
DecodedValue(std::string(reinterpret_cast<char *>(ret.get()), size));
|
DecodedValue(std::string(reinterpret_cast<char *>(ret.get()), size));
|
||||||
VLOG(20) << "[ReadString] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadList(const Marker &marker, DecodedValue *data) {
|
bool ReadList(const Marker &marker, DecodedValue *data) {
|
||||||
VLOG(20) << "[ReadList] Start";
|
|
||||||
auto size = ReadTypeSize(marker, MarkerList);
|
auto size = ReadTypeSize(marker, MarkerList);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
DLOG(WARNING) << "[ReadList] Couldn't get size!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<DecodedValue> ret(size);
|
std::vector<DecodedValue> ret(size);
|
||||||
for (int64_t i = 0; i < size; ++i) {
|
for (int64_t i = 0; i < size; ++i) {
|
||||||
if (!ReadValue(&ret[i])) {
|
if (!ReadValue(&ret[i])) {
|
||||||
DLOG(WARNING) << "[ReadList] Couldn't read element " << i;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*data = DecodedValue(ret);
|
*data = DecodedValue(ret);
|
||||||
VLOG(20) << "[ReadList] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadMap(const Marker &marker, DecodedValue *data) {
|
bool ReadMap(const Marker &marker, DecodedValue *data) {
|
||||||
VLOG(20) << "[ReadMap] Start";
|
|
||||||
auto size = ReadTypeSize(marker, MarkerMap);
|
auto size = ReadTypeSize(marker, MarkerMap);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
DLOG(WARNING) << "[ReadMap] Couldn't get size!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,29 +288,23 @@ class Decoder {
|
|||||||
std::map<std::string, DecodedValue> ret;
|
std::map<std::string, DecodedValue> ret;
|
||||||
for (int64_t i = 0; i < size; ++i) {
|
for (int64_t i = 0; i < size; ++i) {
|
||||||
if (!ReadValue(&dv)) {
|
if (!ReadValue(&dv)) {
|
||||||
DLOG(WARNING) << "[ReadMap] Couldn't read index " << i;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dv.type() != DecodedValue::Type::String) {
|
if (dv.type() != DecodedValue::Type::String) {
|
||||||
DLOG(WARNING) << "[ReadMap] Index " << i << " isn't a string!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
str = dv.ValueString();
|
str = dv.ValueString();
|
||||||
|
|
||||||
if (!ReadValue(&dv)) {
|
if (!ReadValue(&dv)) {
|
||||||
DLOG(WARNING) << "[ReadMap] Couldn't read element " << i;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret.insert(std::make_pair(str, dv));
|
ret.insert(std::make_pair(str, dv));
|
||||||
}
|
}
|
||||||
if (ret.size() != size) {
|
if (ret.size() != size) {
|
||||||
DLOG(WARNING)
|
|
||||||
<< "[ReadMap] The client sent multiple objects with same indexes!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = DecodedValue(ret);
|
*data = DecodedValue(ret);
|
||||||
VLOG(20) << "[ReadMap] Success";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,25 +312,20 @@ class Decoder {
|
|||||||
DecodedValue dv;
|
DecodedValue dv;
|
||||||
DecodedVertex vertex;
|
DecodedVertex vertex;
|
||||||
|
|
||||||
VLOG(20) << "[ReadVertex] Start";
|
|
||||||
|
|
||||||
// read ID
|
// read ID
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
||||||
DLOG(WARNING) << "[ReadVertex] Couldn't read ID!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vertex.id = dv.ValueInt();
|
vertex.id = dv.ValueInt();
|
||||||
|
|
||||||
// read labels
|
// read labels
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
||||||
DLOG(WARNING) << "[ReadVertex] Couldn't read labels!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto &labels = dv.ValueList();
|
auto &labels = dv.ValueList();
|
||||||
vertex.labels.resize(labels.size());
|
vertex.labels.resize(labels.size());
|
||||||
for (size_t i = 0; i < labels.size(); ++i) {
|
for (size_t i = 0; i < labels.size(); ++i) {
|
||||||
if (labels[i].type() != DecodedValue::Type::String) {
|
if (labels[i].type() != DecodedValue::Type::String) {
|
||||||
DLOG(WARNING) << "[ReadVertex] Label has wrong type!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vertex.labels[i] = labels[i].ValueString();
|
vertex.labels[i] = labels[i].ValueString();
|
||||||
@ -396,15 +333,12 @@ class Decoder {
|
|||||||
|
|
||||||
// read properties
|
// read properties
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
||||||
DLOG(WARNING) << "[ReadVertex] Couldn't read properties!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vertex.properties = dv.ValueMap();
|
vertex.properties = dv.ValueMap();
|
||||||
|
|
||||||
*data = DecodedValue(vertex);
|
*data = DecodedValue(vertex);
|
||||||
|
|
||||||
VLOG(20) << "[ReadVertex] Success";
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,63 +347,50 @@ class Decoder {
|
|||||||
DecodedValue dv;
|
DecodedValue dv;
|
||||||
DecodedEdge edge;
|
DecodedEdge edge;
|
||||||
|
|
||||||
VLOG(20) << "[ReadEdge] Start";
|
|
||||||
|
|
||||||
if (!buffer_.Read(&value, 1)) {
|
if (!buffer_.Read(&value, 1)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Missing marker and/or signature data!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check header
|
// check header
|
||||||
if (marker != Marker::TinyStruct5) {
|
if (marker != Marker::TinyStruct5) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Received invalid marker "
|
|
||||||
<< (uint64_t)utils::UnderlyingCast(marker);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (value != utils::UnderlyingCast(Signature::Relationship)) {
|
if (value != utils::UnderlyingCast(Signature::Relationship)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Received invalid signature " << value;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read ID
|
// read ID
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Couldn't read ID!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.id = dv.ValueInt();
|
edge.id = dv.ValueInt();
|
||||||
|
|
||||||
// read from
|
// read from
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Couldn't read from_id!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.from = dv.ValueInt();
|
edge.from = dv.ValueInt();
|
||||||
|
|
||||||
// read to
|
// read to
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Couldn't read to_id!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.to = dv.ValueInt();
|
edge.to = dv.ValueInt();
|
||||||
|
|
||||||
// read type
|
// read type
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::String)) {
|
if (!ReadValue(&dv, DecodedValue::Type::String)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Couldn't read type!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.type = dv.ValueString();
|
edge.type = dv.ValueString();
|
||||||
|
|
||||||
// read properties
|
// read properties
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
||||||
DLOG(WARNING) << "[ReadEdge] Couldn't read properties!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.properties = dv.ValueMap();
|
edge.properties = dv.ValueMap();
|
||||||
|
|
||||||
*data = DecodedValue(edge);
|
*data = DecodedValue(edge);
|
||||||
|
|
||||||
VLOG(20) << "[ReadEdge] Success";
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,33 +398,26 @@ class Decoder {
|
|||||||
DecodedValue dv;
|
DecodedValue dv;
|
||||||
DecodedUnboundedEdge edge;
|
DecodedUnboundedEdge edge;
|
||||||
|
|
||||||
VLOG(20) << "[ReadUnboundedEdge] Start";
|
|
||||||
|
|
||||||
// read ID
|
// read ID
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Int)) {
|
||||||
DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read ID!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.id = dv.ValueInt();
|
edge.id = dv.ValueInt();
|
||||||
|
|
||||||
// read type
|
// read type
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::String)) {
|
if (!ReadValue(&dv, DecodedValue::Type::String)) {
|
||||||
DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read type!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.type = dv.ValueString();
|
edge.type = dv.ValueString();
|
||||||
|
|
||||||
// read properties
|
// read properties
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
if (!ReadValue(&dv, DecodedValue::Type::Map)) {
|
||||||
DLOG(WARNING) << "[ReadUnboundedEdge] Couldn't read properties!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
edge.properties = dv.ValueMap();
|
edge.properties = dv.ValueMap();
|
||||||
|
|
||||||
*data = DecodedValue(edge);
|
*data = DecodedValue(edge);
|
||||||
|
|
||||||
VLOG(20) << "[ReadUnboundedEdge] Success";
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,17 +425,12 @@ class Decoder {
|
|||||||
DecodedValue dv;
|
DecodedValue dv;
|
||||||
DecodedPath path;
|
DecodedPath path;
|
||||||
|
|
||||||
VLOG(20) << "[ReadPath] Start";
|
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
||||||
DLOG(WARNING) << "[ReadPath] Couldn't read vertices!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const auto &vertex : dv.ValueList()) {
|
for (const auto &vertex : dv.ValueList()) {
|
||||||
if (vertex.type() != DecodedValue::Type::Vertex) {
|
if (vertex.type() != DecodedValue::Type::Vertex) {
|
||||||
DLOG(WARNING) << "[ReadPath] Received a '" << vertex.type()
|
|
||||||
<< "' element in the vertices list!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
path.vertices.emplace_back(vertex.ValueVertex());
|
path.vertices.emplace_back(vertex.ValueVertex());
|
||||||
@ -529,13 +438,10 @@ class Decoder {
|
|||||||
|
|
||||||
// edges
|
// edges
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
||||||
DLOG(WARNING) << "[ReadPath] Couldn't read edges!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const auto &edge : dv.ValueList()) {
|
for (const auto &edge : dv.ValueList()) {
|
||||||
if (edge.type() != DecodedValue::Type::UnboundedEdge) {
|
if (edge.type() != DecodedValue::Type::UnboundedEdge) {
|
||||||
DLOG(WARNING) << "[ReadPath] Received a '" << edge.type()
|
|
||||||
<< "' element in the edges list!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
path.edges.emplace_back(edge.ValueUnboundedEdge());
|
path.edges.emplace_back(edge.ValueUnboundedEdge());
|
||||||
@ -543,13 +449,10 @@ class Decoder {
|
|||||||
|
|
||||||
// indices
|
// indices
|
||||||
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
if (!ReadValue(&dv, DecodedValue::Type::List)) {
|
||||||
DLOG(WARNING) << "[ReadPath] Couldn't read indices!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const auto &index : dv.ValueList()) {
|
for (const auto &index : dv.ValueList()) {
|
||||||
if (index.type() != DecodedValue::Type::Int) {
|
if (index.type() != DecodedValue::Type::Int) {
|
||||||
DLOG(WARNING) << "[ReadPath] Received a '" << index.type()
|
|
||||||
<< "' element in the indices list (expected an int)!";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
path.indices.emplace_back(index.ValueInt());
|
path.indices.emplace_back(index.ValueInt());
|
||||||
@ -557,8 +460,6 @@ class Decoder {
|
|||||||
|
|
||||||
*data = DecodedValue(path);
|
*data = DecodedValue(path);
|
||||||
|
|
||||||
VLOG(20) << "[ReadPath] Success";
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -126,7 +126,6 @@ class ChunkedEncoderBuffer {
|
|||||||
// Flush the whole buffer.
|
// Flush the whole buffer.
|
||||||
if (!output_stream_.Write(buffer_.data() + offset_, size_ - offset_))
|
if (!output_stream_.Write(buffer_.data() + offset_, size_ - offset_))
|
||||||
return false;
|
return false;
|
||||||
DLOG(INFO) << "Flushed << " << size_ << " bytes.";
|
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
Clear();
|
Clear();
|
||||||
@ -150,7 +149,6 @@ class ChunkedEncoderBuffer {
|
|||||||
|
|
||||||
// Flush the first chunk
|
// Flush the first chunk
|
||||||
if (!output_stream_.Write(buffer_.data(), first_chunk_size_)) return false;
|
if (!output_stream_.Write(buffer_.data(), first_chunk_size_)) return false;
|
||||||
DLOG(INFO) << "Flushed << " << first_chunk_size_ << " bytes.";
|
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
// Here we use offset as a method of deleting from the front of the
|
// Here we use offset as a method of deleting from the front of the
|
||||||
|
@ -77,8 +77,6 @@ class Session {
|
|||||||
input_stream_.size());
|
input_stream_.size());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DLOG(WARNING) << fmt::format("Decoding handshake of size {}",
|
|
||||||
input_stream_.size());
|
|
||||||
state_ = StateHandshakeRun(*this);
|
state_ = StateHandshakeRun(*this);
|
||||||
if (UNLIKELY(state_ == State::Close)) {
|
if (UNLIKELY(state_ == State::Close)) {
|
||||||
ClientFailureInvalidData();
|
ClientFailureInvalidData();
|
||||||
@ -121,10 +119,6 @@ class Session {
|
|||||||
ClientFailureInvalidData();
|
ClientFailureInvalidData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG(INFO) << fmt::format("Input stream size: {}", input_stream_.size());
|
|
||||||
DLOG(INFO) << fmt::format("Decoder buffer size: {}",
|
|
||||||
decoder_buffer_.Size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,13 +21,10 @@ State StateErrorRun(TSession &session, State state) {
|
|||||||
Marker marker;
|
Marker marker;
|
||||||
Signature signature;
|
Signature signature;
|
||||||
if (!session.decoder_.ReadMessageHeader(&signature, &marker)) {
|
if (!session.decoder_.ReadMessageHeader(&signature, &marker)) {
|
||||||
DLOG(INFO) << "Missing header data!";
|
DLOG(WARNING) << "Missing header data!";
|
||||||
return State::Close;
|
return State::Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG(INFO) << fmt::format("Message signature is: 0x{:02X}",
|
|
||||||
utils::UnderlyingCast(signature));
|
|
||||||
|
|
||||||
// Clear the data buffer if it has any leftover data.
|
// Clear the data buffer if it has any leftover data.
|
||||||
session.encoder_buffer_.Clear();
|
session.encoder_buffer_.Clear();
|
||||||
|
|
||||||
|
@ -222,7 +222,6 @@ State HandleRun(TSession &session, State state, Marker marker) {
|
|||||||
// TODO: Get rid of duplications in PullAll/DiscardAll functions.
|
// TODO: Get rid of duplications in PullAll/DiscardAll functions.
|
||||||
template <typename Session>
|
template <typename Session>
|
||||||
State HandlePullAll(Session &session, State state, Marker marker) {
|
State HandlePullAll(Session &session, State state, Marker marker) {
|
||||||
DLOG(INFO) << "[PullAll]";
|
|
||||||
if (marker != Marker::TinyStruct) {
|
if (marker != Marker::TinyStruct) {
|
||||||
DLOG(WARNING) << fmt::format(
|
DLOG(WARNING) << fmt::format(
|
||||||
"Expected TinyStruct marker, but received 0x{:02X}!",
|
"Expected TinyStruct marker, but received 0x{:02X}!",
|
||||||
@ -246,7 +245,6 @@ State HandlePullAll(Session &session, State state, Marker marker) {
|
|||||||
|
|
||||||
template <typename Session>
|
template <typename Session>
|
||||||
State HandleDiscardAll(Session &session, State state, Marker marker) {
|
State HandleDiscardAll(Session &session, State state, Marker marker) {
|
||||||
DLOG(INFO) << "[DiscardAll]";
|
|
||||||
if (marker != Marker::TinyStruct) {
|
if (marker != Marker::TinyStruct) {
|
||||||
DLOG(WARNING) << fmt::format(
|
DLOG(WARNING) << fmt::format(
|
||||||
"Expected TinyStruct marker, but received 0x{:02X}!",
|
"Expected TinyStruct marker, but received 0x{:02X}!",
|
||||||
|
@ -20,7 +20,6 @@ template <typename Session>
|
|||||||
State StateInitRun(Session &session) {
|
State StateInitRun(Session &session) {
|
||||||
DCHECK(!session.encoder_buffer_.HasData())
|
DCHECK(!session.encoder_buffer_.HasData())
|
||||||
<< "There should be no data to write in this state";
|
<< "There should be no data to write in this state";
|
||||||
DLOG(INFO) << "Parsing message";
|
|
||||||
|
|
||||||
Marker marker;
|
Marker marker;
|
||||||
Signature signature;
|
Signature signature;
|
||||||
|
Loading…
Reference in New Issue
Block a user