Query: Adds new system strings in JsonBinaryEncoding, replacing 1-byte user strings (#3400)
Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
This commit is contained in:
Родитель
b54e01de47
Коммит
9140890d78
|
@ -21,13 +21,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
|
@ -36,13 +36,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
Number, Number, Number, Number, Number, Number, Number, Number,
|
||||
Number, Number, Number, Number, Number, Number, Number, Number,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
String, String, String, String, String, String, String, String,
|
||||
String, String, String, String, String, String, String, String,
|
||||
String, String, String, String, String, String, String, String,
|
||||
String, String, String, String, String, String, String, String,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
String, String, String, String, String, String, String, String,
|
||||
String, String, String, String, String, String, String, String,
|
||||
String, String, String, String, String, String, String, String,
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
NotStr, NotStr, NotStr, NotStr, NotStr, NotStr, NotStr, NotStr,
|
||||
NotStr, NotStr, NotStr, NotStr, NotStr, NotStr, NotStr, NotStr,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
SystemStrings.Strings[0].Utf8String.Length, SystemStrings.Strings[1].Utf8String.Length,
|
||||
SystemStrings.Strings[2].Utf8String.Length, SystemStrings.Strings[3].Utf8String.Length,
|
||||
SystemStrings.Strings[4].Utf8String.Length, SystemStrings.Strings[5].Utf8String.Length,
|
||||
|
@ -54,12 +54,22 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
SystemStrings.Strings[26].Utf8String.Length, SystemStrings.Strings[27].Utf8String.Length,
|
||||
SystemStrings.Strings[28].Utf8String.Length, SystemStrings.Strings[29].Utf8String.Length,
|
||||
SystemStrings.Strings[30].Utf8String.Length, SystemStrings.Strings[31].Utf8String.Length,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1,
|
||||
UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1,
|
||||
UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1,
|
||||
UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1, UsrStr1,
|
||||
SystemStrings.Strings[32].Utf8String.Length, SystemStrings.Strings[33].Utf8String.Length,
|
||||
SystemStrings.Strings[34].Utf8String.Length, SystemStrings.Strings[35].Utf8String.Length,
|
||||
SystemStrings.Strings[36].Utf8String.Length, SystemStrings.Strings[37].Utf8String.Length,
|
||||
SystemStrings.Strings[38].Utf8String.Length, SystemStrings.Strings[39].Utf8String.Length,
|
||||
SystemStrings.Strings[40].Utf8String.Length, SystemStrings.Strings[41].Utf8String.Length,
|
||||
SystemStrings.Strings[42].Utf8String.Length, SystemStrings.Strings[43].Utf8String.Length,
|
||||
SystemStrings.Strings[44].Utf8String.Length, SystemStrings.Strings[45].Utf8String.Length,
|
||||
SystemStrings.Strings[46].Utf8String.Length, SystemStrings.Strings[47].Utf8String.Length,
|
||||
SystemStrings.Strings[48].Utf8String.Length, SystemStrings.Strings[49].Utf8String.Length,
|
||||
SystemStrings.Strings[50].Utf8String.Length, SystemStrings.Strings[51].Utf8String.Length,
|
||||
SystemStrings.Strings[52].Utf8String.Length, SystemStrings.Strings[53].Utf8String.Length,
|
||||
SystemStrings.Strings[54].Utf8String.Length, SystemStrings.Strings[55].Utf8String.Length,
|
||||
SystemStrings.Strings[56].Utf8String.Length, SystemStrings.Strings[57].Utf8String.Length,
|
||||
SystemStrings.Strings[58].Utf8String.Length, SystemStrings.Strings[59].Utf8String.Length,
|
||||
SystemStrings.Strings[60].Utf8String.Length, SystemStrings.Strings[61].Utf8String.Length,
|
||||
SystemStrings.Strings[62].Utf8String.Length, SystemStrings.Strings[63].Utf8String.Length,
|
||||
|
||||
// Encoded 2-byte user string (8 values)
|
||||
UsrStr2, UsrStr2, UsrStr2, UsrStr2, UsrStr2, UsrStr2, UsrStr2, UsrStr2,
|
||||
|
|
|
@ -38,13 +38,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false,
|
||||
|
||||
// Encoded 0-byte system string (32 values)
|
||||
// Encoded 0-byte system string (64 values)
|
||||
true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true,
|
||||
|
||||
// Encoded true-byte user string (32 values)
|
||||
true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true,
|
||||
|
@ -386,29 +384,14 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return false;
|
||||
}
|
||||
|
||||
if (JsonBinaryEncoding.TypeMarker.IsOneByteEncodedUserString(typeMarker))
|
||||
// JsonBinaryEncoding.TypeMarker.IsTwoByteEncodedUserString(typeMarker) must be true
|
||||
if (stringToken.Length < 2)
|
||||
{
|
||||
if (stringToken.Length < 1)
|
||||
{
|
||||
userStringId = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
userStringId = typeMarker - JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin;
|
||||
userStringId = default;
|
||||
return false;
|
||||
}
|
||||
else //// JsonBinaryEncoding.TypeMarker.IsTwoByteEncodedUserString(typeMarker)
|
||||
{
|
||||
if (stringToken.Length < 2)
|
||||
{
|
||||
userStringId = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
const byte OneByteCount = JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMax - JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin;
|
||||
userStringId = OneByteCount
|
||||
+ stringToken[1]
|
||||
+ ((stringToken[0] - JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin) * 0xFF);
|
||||
}
|
||||
userStringId = stringToken[1] + ((stringToken[0] - JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin) * 0xFF);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
// This is auto-generated code. Modify: JsonBinaryEncoding.SystemStrings.tt: 54
|
||||
// This is auto-generated code. Modify: JsonBinaryEncoding.SystemStrings.tt: 86
|
||||
|
||||
namespace Microsoft.Azure.Cosmos.Json
|
||||
{
|
||||
|
@ -51,6 +51,38 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
UtfAllString.Create("Feature"),
|
||||
UtfAllString.Create("FeatureCollection"),
|
||||
UtfAllString.Create("_id"),
|
||||
UtfAllString.Create("$id"),
|
||||
UtfAllString.Create("$pk"),
|
||||
UtfAllString.Create("_isEdge"),
|
||||
UtfAllString.Create("_partitionKey"),
|
||||
UtfAllString.Create("_type"),
|
||||
UtfAllString.Create("_value"),
|
||||
UtfAllString.Create("data"),
|
||||
UtfAllString.Create("Data"),
|
||||
UtfAllString.Create("entity"),
|
||||
UtfAllString.Create("isDeleted"),
|
||||
UtfAllString.Create("IsDeleted"),
|
||||
UtfAllString.Create("key"),
|
||||
UtfAllString.Create("Key"),
|
||||
UtfAllString.Create("Location"),
|
||||
UtfAllString.Create("partition"),
|
||||
UtfAllString.Create("partition_id"),
|
||||
UtfAllString.Create("partitionKey"),
|
||||
UtfAllString.Create("PartitionKey"),
|
||||
UtfAllString.Create("pk"),
|
||||
UtfAllString.Create("state"),
|
||||
UtfAllString.Create("State"),
|
||||
UtfAllString.Create("status"),
|
||||
UtfAllString.Create("Status"),
|
||||
UtfAllString.Create("subscriptionId"),
|
||||
UtfAllString.Create("SubscriptionId"),
|
||||
UtfAllString.Create("tenantId"),
|
||||
UtfAllString.Create("TenantId"),
|
||||
UtfAllString.Create("timestamp"),
|
||||
UtfAllString.Create("Timestamp"),
|
||||
UtfAllString.Create("ttl"),
|
||||
UtfAllString.Create("userId"),
|
||||
UtfAllString.Create("UserId"),
|
||||
}.ToImmutableArray();
|
||||
|
||||
public static int? GetSystemStringId(Utf8Span buffer)
|
||||
|
@ -61,11 +93,15 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
3 => GetSystemStringIdLength3(buffer.Span),
|
||||
4 => GetSystemStringIdLength4(buffer.Span),
|
||||
5 => GetSystemStringIdLength5(buffer.Span),
|
||||
6 => GetSystemStringIdLength6(buffer.Span),
|
||||
7 => GetSystemStringIdLength7(buffer.Span),
|
||||
8 => GetSystemStringIdLength8(buffer.Span),
|
||||
9 => GetSystemStringIdLength9(buffer.Span),
|
||||
10 => GetSystemStringIdLength10(buffer.Span),
|
||||
11 => GetSystemStringIdLength11(buffer.Span),
|
||||
12 => GetSystemStringIdLength12(buffer.Span),
|
||||
13 => GetSystemStringIdLength13(buffer.Span),
|
||||
14 => GetSystemStringIdLength14(buffer.Span),
|
||||
15 => GetSystemStringIdLength15(buffer.Span),
|
||||
17 => GetSystemStringIdLength17(buffer.Span),
|
||||
18 => GetSystemStringIdLength18(buffer.Span),
|
||||
|
@ -95,6 +131,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 12;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[50].Utf8String.Span.Span))
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength3(ReadOnlySpan<byte> buffer)
|
||||
|
@ -114,6 +155,31 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 31;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[32].Utf8String.Span.Span))
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[33].Utf8String.Span.Span))
|
||||
{
|
||||
return 33;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[43].Utf8String.Span.Span))
|
||||
{
|
||||
return 43;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[44].Utf8String.Span.Span))
|
||||
{
|
||||
return 44;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[61].Utf8String.Span.Span))
|
||||
{
|
||||
return 61;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength4(ReadOnlySpan<byte> buffer)
|
||||
|
@ -148,6 +214,16 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 27;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[38].Utf8String.Span.Span))
|
||||
{
|
||||
return 38;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[39].Utf8String.Span.Span))
|
||||
{
|
||||
return 39;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength5(ReadOnlySpan<byte> buffer)
|
||||
|
@ -182,6 +258,55 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 28;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[36].Utf8String.Span.Span))
|
||||
{
|
||||
return 36;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[51].Utf8String.Span.Span))
|
||||
{
|
||||
return 51;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[52].Utf8String.Span.Span))
|
||||
{
|
||||
return 52;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength6(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
if (buffer.SequenceEqual(Strings[37].Utf8String.Span.Span))
|
||||
{
|
||||
return 37;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[40].Utf8String.Span.Span))
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[53].Utf8String.Span.Span))
|
||||
{
|
||||
return 53;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[54].Utf8String.Span.Span))
|
||||
{
|
||||
return 54;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[62].Utf8String.Span.Span))
|
||||
{
|
||||
return 62;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[63].Utf8String.Span.Span))
|
||||
{
|
||||
return 63;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength7(ReadOnlySpan<byte> buffer)
|
||||
|
@ -196,6 +321,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 29;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[34].Utf8String.Span.Span))
|
||||
{
|
||||
return 34;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength8(ReadOnlySpan<byte> buffer)
|
||||
|
@ -205,6 +335,50 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 10;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[45].Utf8String.Span.Span))
|
||||
{
|
||||
return 45;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[57].Utf8String.Span.Span))
|
||||
{
|
||||
return 57;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[58].Utf8String.Span.Span))
|
||||
{
|
||||
return 58;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength9(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
if (buffer.SequenceEqual(Strings[41].Utf8String.Span.Span))
|
||||
{
|
||||
return 41;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[42].Utf8String.Span.Span))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[46].Utf8String.Span.Span))
|
||||
{
|
||||
return 46;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[59].Utf8String.Span.Span))
|
||||
{
|
||||
return 59;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[60].Utf8String.Span.Span))
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength10(ReadOnlySpan<byte> buffer)
|
||||
|
@ -252,6 +426,44 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return 20;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[47].Utf8String.Span.Span))
|
||||
{
|
||||
return 47;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[48].Utf8String.Span.Span))
|
||||
{
|
||||
return 48;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[49].Utf8String.Span.Span))
|
||||
{
|
||||
return 49;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength13(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
if (buffer.SequenceEqual(Strings[35].Utf8String.Span.Span))
|
||||
{
|
||||
return 35;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength14(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
if (buffer.SequenceEqual(Strings[55].Utf8String.Span.Span))
|
||||
{
|
||||
return 55;
|
||||
}
|
||||
|
||||
if (buffer.SequenceEqual(Strings[56].Utf8String.Span.Span))
|
||||
{
|
||||
return 56;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private static int? GetSystemStringIdLength15(ReadOnlySpan<byte> buffer)
|
||||
|
|
|
@ -43,6 +43,38 @@ string[] systemStrings = new string[]
|
|||
"Feature",
|
||||
"FeatureCollection",
|
||||
"_id",
|
||||
"$id",
|
||||
"$pk",
|
||||
"_isEdge",
|
||||
"_partitionKey",
|
||||
"_type",
|
||||
"_value",
|
||||
"data",
|
||||
"Data",
|
||||
"entity",
|
||||
"isDeleted",
|
||||
"IsDeleted",
|
||||
"key",
|
||||
"Key",
|
||||
"Location",
|
||||
"partition",
|
||||
"partition_id",
|
||||
"partitionKey",
|
||||
"PartitionKey",
|
||||
"pk",
|
||||
"state",
|
||||
"State",
|
||||
"status",
|
||||
"Status",
|
||||
"subscriptionId",
|
||||
"SubscriptionId",
|
||||
"tenantId",
|
||||
"TenantId",
|
||||
"timestamp",
|
||||
"Timestamp",
|
||||
"ttl",
|
||||
"userId",
|
||||
"UserId",
|
||||
};
|
||||
|
||||
int[] distinctStringLengths = systemStrings.Select(x => x.Length).Distinct().OrderBy(x => x).ToArray();
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
public const byte LiteralIntMax = LiteralIntMin + 32;
|
||||
#endregion
|
||||
|
||||
#region [0x20, 0x40): Encoded 1-byte system string (32 values)
|
||||
#region [0x20, 0x60): Encoded 1-byte system string (64 values)
|
||||
/// <summary>
|
||||
/// The first type marker for a system string whose value can be encoded in a 1 byte type marker.
|
||||
/// </summary>
|
||||
|
@ -36,26 +36,14 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
/// <summary>
|
||||
/// The last type marker for a system string whose value can be encoded in a 1 byte type marker.
|
||||
/// </summary>
|
||||
public const byte SystemString1ByteLengthMax = SystemString1ByteLengthMin + 32;
|
||||
#endregion
|
||||
|
||||
#region [0x40, 0x60): Encoded 1-byte user string (32 values)
|
||||
/// <summary>
|
||||
/// The first type marker for a user string whose value can be encoded in a 1 byte type marker.
|
||||
/// </summary>
|
||||
public const byte UserString1ByteLengthMin = SystemString1ByteLengthMax;
|
||||
|
||||
/// <summary>
|
||||
/// The last type marker for a user string whose value can be encoded in a 1 byte type marker.
|
||||
/// </summary>
|
||||
public const byte UserString1ByteLengthMax = UserString1ByteLengthMin + 32;
|
||||
public const byte SystemString1ByteLengthMax = SystemString1ByteLengthMin + 64;
|
||||
#endregion
|
||||
|
||||
#region [0x60, 0x68): 2-byte user string (8 values)
|
||||
/// <summary>
|
||||
/// The first type marker for a system string whose value can be encoded in a 2 byte type marker.
|
||||
/// </summary>
|
||||
public const byte UserString2ByteLengthMin = UserString1ByteLengthMax;
|
||||
public const byte UserString2ByteLengthMin = SystemString1ByteLengthMax;
|
||||
|
||||
/// <summary>
|
||||
/// The last type marker for a system string whose value can be encoded in a 2 byte type marker.
|
||||
|
@ -467,17 +455,6 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
return InRange(typeMarker, SystemString1ByteLengthMin, SystemString1ByteLengthMax);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether a typeMarker is for a one byte encoded user string.
|
||||
/// </summary>
|
||||
/// <param name="typeMarker">The input type marker.</param>
|
||||
/// <returns>Whether the typeMarker is for a one byte encoded user string.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsOneByteEncodedUserString(byte typeMarker)
|
||||
{
|
||||
return InRange(typeMarker, UserString1ByteLengthMin, UserString1ByteLengthMax);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether a typeMarker is for a two byte encoded user string.
|
||||
/// </summary>
|
||||
|
@ -497,7 +474,7 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsUserString(byte typeMarker)
|
||||
{
|
||||
return IsOneByteEncodedUserString(typeMarker) || IsTwoByteEncodedUserString(typeMarker);
|
||||
return IsTwoByteEncodedUserString(typeMarker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -508,7 +485,7 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsOneByteEncodedString(byte typeMarker)
|
||||
{
|
||||
return InRange(typeMarker, SystemString1ByteLengthMin, UserString1ByteLengthMax);
|
||||
return InRange(typeMarker, SystemString1ByteLengthMin, SystemString1ByteLengthMax);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -43,13 +43,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
|
|
|
@ -26,13 +26,11 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number,
|
||||
JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number, JsonTokenType.Number,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String, JsonTokenType.String,
|
||||
|
|
|
@ -81,17 +81,15 @@ namespace Microsoft.Azure.Cosmos.Json
|
|||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
|
||||
// Encoded 1-byte system string (32 values)
|
||||
// Encoded 1-byte system string (64 values)
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token, RawValueType.Token,
|
||||
|
||||
// Encoded 1-byte user string (32 values)
|
||||
RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr,
|
||||
RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr,
|
||||
RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr,
|
||||
RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr,
|
||||
|
||||
// Encoded 2-byte user string (8 values)
|
||||
RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr, RawValueType.StrUsr,
|
||||
|
|
|
@ -2281,9 +2281,9 @@ namespace Microsoft.Azure.Cosmos.Tests.Json
|
|||
|
||||
List<byte[]> elements = new List<byte[]>
|
||||
{
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 0 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.LiteralIntMin + 10 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 1) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 1 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "example glossary".Length), 101, 120, 97, 109, 112, 108, 101, 32, 103, 108, 111, 115, 115, 97, 114, 121 }
|
||||
};
|
||||
byte[] elementsBytes = elements.SelectMany(x => x).ToArray();
|
||||
|
@ -2405,25 +2405,25 @@ namespace Microsoft.Azure.Cosmos.Tests.Json
|
|||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.SystemString1ByteLengthMin + 12) },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "7029d079-4016-4436-b7da-36c0bae54ff6".Length), 55, 48, 50, 57, 100, 48, 55, 57, 45, 52, 48, 49, 54, 45, 52, 52, 51, 54, 45, 98, 55, 100, 97, 45, 51, 54, 99, 48, 98, 97, 101, 53, 52, 102, 102, 54 },
|
||||
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 0 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.NumberDouble, 0x98, 0x8B, 0x30, 0xE3, 0xCB, 0x45, 0xC8, 0x3F },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 1) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 1 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.NumberInt32, 0x19, 0xDF, 0xB6, 0xB0 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 2) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 2 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "XCPCFXPHHF".Length), 88, 67, 80, 67, 70, 88, 80, 72, 72, 70 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 3) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 3 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.True },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 4) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 4 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.Null },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 5) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 5 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "2526-07-11T18:18:16.4520716".Length), 50, 53, 50, 54, 45, 48, 55, 45, 49, 49, 84, 49, 56, 58, 49, 56, 58, 49, 54, 46, 52, 53, 50, 48, 55, 49, 54 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 6) }
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 6 }
|
||||
};
|
||||
|
||||
List<byte[]> innerObjectElements = new List<byte[]>
|
||||
|
@ -2447,7 +2447,7 @@ namespace Microsoft.Azure.Cosmos.Tests.Json
|
|||
elements.Add(new byte[] { JsonBinaryEncoding.TypeMarker.Object1ByteLength, (byte)innerObjectElementsBytes.Length });
|
||||
elements.Add(innerObjectElementsBytes);
|
||||
|
||||
elements.Add(new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 7) });
|
||||
elements.Add(new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 7 });
|
||||
elements.Add(new byte[] { JsonBinaryEncoding.TypeMarker.String1ByteLength, (byte)"tiger diamond newbrunswick snowleopard chocolate dog snowleopard turtle cat sapphire peach sapphire vancouver white chocolate horse diamond lion superlongcolourname ruby".Length, 116, 105, 103, 101, 114, 32, 100, 105, 97, 109, 111, 110, 100, 32, 110, 101, 119, 98, 114, 117, 110, 115, 119, 105, 99, 107, 32, 115, 110, 111, 119, 108, 101, 111, 112, 97, 114, 100, 32, 99, 104, 111, 99, 111, 108, 97, 116, 101, 32, 100, 111, 103, 32, 115, 110, 111, 119, 108, 101, 111, 112, 97, 114, 100, 32, 116, 117, 114, 116, 108, 101, 32, 99, 97, 116, 32, 115, 97, 112, 112, 104, 105, 114, 101, 32, 112, 101, 97, 99, 104, 32, 115, 97, 112, 112, 104, 105, 114, 101, 32, 118, 97, 110, 99, 111, 117, 118, 101, 114, 32, 119, 104, 105, 116, 101, 32, 99, 104, 111, 99, 111, 108, 97, 116, 101, 32, 104, 111, 114, 115, 101, 32, 100, 105, 97, 109, 111, 110, 100, 32, 108, 105, 111, 110, 32, 115, 117, 112, 101, 114, 108, 111, 110, 103, 99, 111, 108, 111, 117, 114, 110, 97, 109, 101, 32, 114, 117, 98, 121 });
|
||||
|
||||
byte[] elementsBytes = elements.SelectMany(x => x).ToArray();
|
||||
|
|
|
@ -2194,9 +2194,9 @@
|
|||
|
||||
List<byte[]> elements = new List<byte[]>
|
||||
{
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 0 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.LiteralIntMin + 10 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 1) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 1 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "example glossary".Length), 101, 120, 97, 109, 112, 108, 101, 32, 103, 108, 111, 115, 115, 97, 114, 121 }
|
||||
};
|
||||
byte[] elementsBytes = elements.SelectMany(x => x).ToArray();
|
||||
|
@ -2325,25 +2325,25 @@
|
|||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.SystemString1ByteLengthMin + 12) },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.LowercaseGuidString, 0x07, 0x92, 0x0D, 0x97, 0x04, 0x61, 0x44, 0x63, 0x7B, 0xAD, 0x63, 0x0C, 0xAB, 0x5E, 0xF4, 0x6F },
|
||||
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 0 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.NumberDouble, 0x98, 0x8B, 0x30, 0xE3, 0xCB, 0x45, 0xC8, 0x3F },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 1) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 1 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.NumberInt32, 0x19, 0xDF, 0xB6, 0xB0 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 2) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 2 },
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.EncodedStringLengthMin + "XCPCFXPHHF".Length), 88, 67, 80, 67, 70, 88, 80, 72, 72, 70 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 3) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 3 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.True },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 4) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 4 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.Null },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 5) },
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 5 },
|
||||
new byte[] { JsonBinaryEncoding.TypeMarker.CompressedDateTimeString, 0x1B, 0x63, 0x73, 0x1C, 0xC8, 0x22, 0x2E, 0xB9, 0x92, 0x2B, 0xD7, 0x65, 0x13, 0x28, 0x07 },
|
||||
|
||||
new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 6) }
|
||||
new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 6 }
|
||||
};
|
||||
|
||||
List<byte[]> innerObjectElements = new List<byte[]>
|
||||
|
@ -2367,7 +2367,7 @@
|
|||
elements.Add(new byte[] { JsonBinaryEncoding.TypeMarker.Object1ByteLength, (byte)innerObjectElementsBytes.Length });
|
||||
elements.Add(innerObjectElementsBytes);
|
||||
|
||||
elements.Add(new byte[] { (byte)(JsonBinaryEncoding.TypeMarker.UserString1ByteLengthMin + 7) });
|
||||
elements.Add(new byte[] { (byte)JsonBinaryEncoding.TypeMarker.UserString2ByteLengthMin, 7 });
|
||||
elements.Add(new byte[] { JsonBinaryEncoding.TypeMarker.Packed7BitStringLength1, (byte)"tiger diamond newbrunswick snowleopard chocolate dog snowleopard turtle cat sapphire peach sapphire vancouver white chocolate horse diamond lion superlongcolourname ruby".Length, 0xF4, 0xF4, 0xB9, 0x2C, 0x07, 0x91, 0xD3, 0xE1, 0xF6, 0xDB, 0x4D, 0x06, 0xB9, 0xCB, 0x77, 0xB1, 0xBC, 0xEE, 0x9E, 0xDF, 0xD3, 0xE3, 0x35, 0x68, 0xEE, 0x7E, 0xDF, 0xD9, 0xE5, 0x37, 0x3C, 0x2C, 0x27, 0x83, 0xC6, 0xE8, 0xF7, 0xF8, 0xCD, 0x0E, 0xD3, 0xCB, 0x20, 0xF2, 0xFB, 0x0C, 0x9A, 0xBB, 0xDF, 0x77, 0x76, 0xF9, 0x0D, 0x0F, 0xCB, 0xC9, 0x20, 0x7A, 0x5D, 0x4E, 0x67, 0x97, 0x41, 0xE3, 0x30, 0x1D, 0x34, 0x0F, 0xC3, 0xE1, 0xE8, 0xB4, 0xBC, 0x0C, 0x82, 0x97, 0xC3, 0x63, 0x34, 0x68, 0x1E, 0x86, 0xC3, 0xD1, 0x69, 0x79, 0x19, 0x64, 0x0F, 0xBB, 0xC7, 0xEF, 0xBA, 0xBD, 0x2C, 0x07, 0xDD, 0xD1, 0x69, 0x7A, 0x19, 0x34, 0x46, 0xBF, 0xC7, 0x6F, 0x76, 0x98, 0x5E, 0x06, 0xA1, 0xDF, 0xF2, 0x79, 0x19, 0x44, 0x4E, 0x87, 0xDB, 0x6F, 0x37, 0x19, 0xC4, 0x4E, 0xBF, 0xDD, 0xA0, 0x79, 0x1D, 0x5E, 0x96, 0xB3, 0xDF, 0xEE, 0xF3, 0xF8, 0xCD, 0x7E, 0xD7, 0xE5, 0xEE, 0x70, 0xBB, 0x0C, 0x92, 0xD7, 0xC5, 0x79 });
|
||||
|
||||
byte[] elementsBytes = elements.SelectMany(x => x).ToArray();
|
||||
|
|
Загрузка…
Ссылка в новой задаче