Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp json fix by returning empty string #131

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dbms/src/Storages/Transaction/Codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ inline UInt64 DecodeVarUInt(size_t & cursor, const String & raw_value)
throw Exception("Wrong format. (DecodeVarUInt)", ErrorCodes::LOGICAL_ERROR);
}

inline UInt32 decodeUInt32(size_t & cursor, const String & raw_value)
ilovesoup marked this conversation as resolved.
Show resolved Hide resolved
{
UInt32 res = *(reinterpret_cast<const UInt32 *>(raw_value.data() + cursor));
cursor += 4;

return res;
}


inline String DecodeJson(size_t &cursor, const String &raw_value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

raw_value[cursor++]; // JSON Root element type
decodeUInt32(cursor, raw_value); // elementCount
size_t size = decodeUInt32(cursor, raw_value);
cursor += (size < 8 ? 0 : (size - 8));

return String();
}

inline Int64 DecodeVarInt(size_t & cursor, const String & raw_value)
{
UInt64 v = DecodeVarUInt(cursor, raw_value);
Expand All @@ -116,6 +134,7 @@ inline String DecodeCompactBytes(size_t & cursor, const String & raw_value)
return res;
}


inline Int8 getWords(PrecType prec, ScaleType scale)
{
Int8 scale_word = scale / 9 + (scale % 9 > 0);
Expand Down Expand Up @@ -236,6 +255,8 @@ inline Field DecodeDatum(size_t & cursor, const String & raw_value)
throw Exception("Not implented yet. DecodeDatum: CodecFlagDuration", ErrorCodes::LOGICAL_ERROR);
case TiDB::CodecFlagDecimal:
return DecodeDecimal(cursor, raw_value);
case TiDB::CodecFlagJson:
return DecodeJson(cursor, raw_value);
default:
throw Exception("Unknown Type:" + std::to_string(raw_value[cursor - 1]), ErrorCodes::LOGICAL_ERROR);
}
Expand Down