Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ void WriteRawJsonValue(
int valueOffset,
JsonBinaryEncoding.UniformArrayInfo externalArrayInfo,
bool isFieldName,
IJsonReadOnlyStringDictionary jsonStringDictionary = null);
IJsonStringDictionary jsonStringDictionary = null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Azure.Cosmos.Json
#else
internal
#endif
interface IJsonReadOnlyStringDictionary : IEquatable<IJsonReadOnlyStringDictionary>
interface IJsonStringDictionary : IEquatable<IJsonStringDictionary>
{
bool TryGetString(int stringId, out UtfAllString value);

Expand Down
24 changes: 12 additions & 12 deletions Microsoft.Azure.Cosmos/src/Json/JsonBinaryEncoding.Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ internal static partial class JsonBinaryEncoding
public static string GetStringValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
// First retrieve the string length
GetStringValue(buffer, stringToken, jsonStringDictionary, destinationBuffer: Span<byte>.Empty, out int valueLength);
Expand All @@ -190,7 +190,7 @@ public static string GetStringValue(
public static Utf8Span GetUtf8SpanValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
return Utf8Span.UnsafeFromUtf8BytesNoValidation(GetUtf8MemoryValue(buffer, stringToken, jsonStringDictionary).Span);
}
Expand All @@ -199,15 +199,15 @@ public static Utf8Span GetUtf8SpanValue(
public static Utf8String GetUtf8StringValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
return Utf8String.UnsafeFromUtf8BytesNoValidation(GetUtf8MemoryValue(buffer, stringToken, jsonStringDictionary));
}

public static bool TryGetBufferedStringValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out Utf8Memory value)
{
if (stringToken.IsEmpty)
Expand Down Expand Up @@ -240,7 +240,7 @@ public static bool TryGetBufferedStringValue(

public static bool TryGetDictionaryEncodedStringValue(
ReadOnlySpan<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out UtfAllString value)
{
return TryGetEncodedStringValue(
Expand All @@ -252,7 +252,7 @@ public static bool TryGetDictionaryEncodedStringValue(
private static ReadOnlyMemory<byte> GetUtf8MemoryValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
byte typeMarker = stringToken.Span[0];

Expand Down Expand Up @@ -284,7 +284,7 @@ private static ReadOnlyMemory<byte> GetUtf8MemoryValue(
private static void GetStringValue(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
Span<byte> destinationBuffer,
out int valueLength)
{
Expand Down Expand Up @@ -336,7 +336,7 @@ private static void GetStringValue(
/// <returns>Encoded String Value</returns>
private static bool TryGetEncodedStringValue(
ReadOnlySpan<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out UtfAllString value)
{
if (JsonBinaryEncoding.TryGetEncodedSystemStringValue(stringToken, out value))
Expand Down Expand Up @@ -388,7 +388,7 @@ private static bool TryGetEncodedSystemStringValue(
/// <returns>Whether or not the Encoded User String Value was found</returns>
private static bool TryGetEncodedUserStringValue(
ReadOnlySpan<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out UtfAllString encodedUserStringValue)
{
if ((jsonStringDictionary == null)
Expand Down Expand Up @@ -440,7 +440,7 @@ private static bool TryGetUserStringId(ReadOnlySpan<byte> stringToken, out int u
private static bool TryGetBufferedLengthPrefixedString(
ReadOnlyMemory<byte> buffer,
ReadOnlyMemory<byte> stringToken,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out Utf8Memory value)
{
ReadOnlySpan<byte> stringTokenSpan = stringToken.Span;
Expand Down Expand Up @@ -568,7 +568,7 @@ private static bool TryGetBufferedLengthPrefixedString(
/// <returns>Whether or not the type marker was found.</returns>
public static bool TryGetEncodedStringTypeMarker(
Utf8Span utf8Span,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out MultiByteTypeMarker multiByteTypeMarker)
{
if (JsonBinaryEncoding.TryGetEncodedSystemStringTypeMarker(utf8Span, out multiByteTypeMarker))
Expand Down Expand Up @@ -617,7 +617,7 @@ private static bool TryGetEncodedSystemStringTypeMarker(
/// <returns>Whether or not the Encoded User String Type Marker was found.</returns>
private static bool TryGetEncodedUserStringTypeMarker(
Utf8Span utf8Span,
IJsonReadOnlyStringDictionary jsonStringDictionary,
IJsonStringDictionary jsonStringDictionary,
out MultiByteTypeMarker multiByteTypeMarker)
{
if (jsonStringDictionary == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract partial class JsonNavigator : IJsonNavigator
private sealed class JsonBinaryNavigator : JsonNavigator
{
private readonly ReadOnlyMemory<byte> rootBuffer;
private readonly IJsonReadOnlyStringDictionary jsonStringDictionary;
private readonly IJsonStringDictionary jsonStringDictionary;
private readonly IJsonNavigatorNode rootNode;

/// <summary>
Expand All @@ -36,7 +36,7 @@ private sealed class JsonBinaryNavigator : JsonNavigator
/// <param name="jsonStringDictionary">The JSON string dictionary.</param>
public JsonBinaryNavigator(
ReadOnlyMemory<byte> buffer,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
if (buffer.Length < 2)
{
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Json/JsonNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected JsonNavigator()
/// <returns>A concrete JsonNavigator that can navigate the supplied buffer.</returns>
public static IJsonNavigator Create(
ReadOnlyMemory<byte> buffer,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
if (buffer.IsEmpty)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private sealed class JsonBinaryReader : JsonReader, ITypedJsonReader
/// <summary>
/// Dictionary used for user string encoding.
/// </summary>
private readonly IJsonReadOnlyStringDictionary jsonStringDictionary;
private readonly IJsonStringDictionary jsonStringDictionary;

/// <summary>
/// For binary there is no end of token marker in the actual binary, but the JsonReader interface still needs to surface ObjectEndToken and ArrayEndToken.
Expand All @@ -191,15 +191,15 @@ private sealed class JsonBinaryReader : JsonReader, ITypedJsonReader

public JsonBinaryReader(
ReadOnlyMemory<byte> buffer,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
: this(buffer, indexToStartFrom: null, jsonStringDictionary: jsonStringDictionary)
{
}

internal JsonBinaryReader(
ReadOnlyMemory<byte> rootBuffer,
int? indexToStartFrom = null,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
if (rootBuffer.IsEmpty)
{
Expand Down
6 changes: 3 additions & 3 deletions Microsoft.Azure.Cosmos/src/Json/JsonReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected JsonReader()
/// <param name="buffer">The byte array (with format marker) to read from.</param>
/// <param name="jsonStringDictionary">The dictionary to use for user string encoding.</param>
/// <returns>A concrete JsonReader that can read the supplied byte array.</returns>
public static IJsonReader Create(ReadOnlyMemory<byte> buffer, IJsonReadOnlyStringDictionary jsonStringDictionary = null)
public static IJsonReader Create(ReadOnlyMemory<byte> buffer, IJsonStringDictionary jsonStringDictionary = null)
{
if (buffer.IsEmpty)
{
Expand All @@ -70,7 +70,7 @@ public static IJsonReader Create(ReadOnlyMemory<byte> buffer, IJsonReadOnlyStrin
public static IJsonReader Create(
JsonSerializationFormat jsonSerializationFormat,
ReadOnlyMemory<byte> buffer,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
if (buffer.IsEmpty)
{
Expand All @@ -89,7 +89,7 @@ public static IJsonReader Create(
internal static IJsonReader CreateBinaryFromOffset(
ReadOnlyMemory<byte> buffer,
int offset,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
return new JsonBinaryReader(buffer, offset, jsonStringDictionary);
}
Expand Down
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos/src/Json/JsonStringDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.Azure.Cosmos.Json
#else
internal
#endif
sealed class JsonStringDictionary : IJsonReadOnlyStringDictionary, IEquatable<JsonStringDictionary>
sealed class JsonStringDictionary : IJsonStringDictionary, IEquatable<JsonStringDictionary>
{
public static readonly int MaxDictionarySize =
TypeMarker.UserString1ByteLengthMax - TypeMarker.UserString1ByteLengthMin + ((TypeMarker.UserString2ByteLengthMax - TypeMarker.UserString2ByteLengthMin) * 0xFF);
Expand Down Expand Up @@ -96,7 +96,7 @@ public bool Equals(JsonStringDictionary other)
return this.checksum == other.checksum;
}

public bool Equals(IJsonReadOnlyStringDictionary other)
public bool Equals(IJsonStringDictionary other)
{
if (other == null)
{
Expand Down
10 changes: 5 additions & 5 deletions Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private enum RawValueType : byte
/// <summary>
/// The string dictionary used for user string encoding.
/// </summary>
private readonly IJsonReadOnlyStringDictionary jsonStringDictionary;
private readonly IJsonStringDictionary jsonStringDictionary;

private readonly List<SharedStringValue> sharedStrings;

Expand All @@ -302,7 +302,7 @@ public JsonBinaryWriter(
bool enableNumberArrays,
bool enableUint64Values,
bool enableEncodedStrings = true,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
this.enableNumberArrays = enableNumberArrays;
this.enableUInt64Values = enableUint64Values;
Expand Down Expand Up @@ -1615,7 +1615,7 @@ public void WriteRawJsonValue(
int valueOffset,
UniformArrayInfo externalArrayInfo,
bool isFieldName,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
this.ForceRewriteRawJsonValue(rootBuffer, valueOffset, externalArrayInfo, isFieldName, jsonStringDictionary);
}
Expand All @@ -1625,7 +1625,7 @@ private void ForceRewriteRawJsonValue(
int valueOffset,
UniformArrayInfo externalArrayInfo,
bool isFieldName,
IJsonReadOnlyStringDictionary jsonStringDictionary)
IJsonStringDictionary jsonStringDictionary)
{
ReadOnlyMemory<byte> rawJsonValue = rootBuffer.Slice(valueOffset);
byte typeMarker = rawJsonValue.Span[0];
Expand Down Expand Up @@ -1804,7 +1804,7 @@ private void ForceRewriteRawJsonValue(
}
}

private void WriteRawStringValue(RawValueType rawValueType, ReadOnlyMemory<byte> buffer, bool isFieldName, IJsonReadOnlyStringDictionary jsonStringDictionary)
private void WriteRawStringValue(RawValueType rawValueType, ReadOnlyMemory<byte> buffer, bool isFieldName, IJsonStringDictionary jsonStringDictionary)
{
Utf8Span rawStringValue;
switch (rawValueType)
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Json/JsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static IJsonWriter Create(
JsonSerializationFormat jsonSerializationFormat,
JsonWriteOptions writeOptions = JsonWriteOptions.None,
int initialCapacity = 256,
IJsonReadOnlyStringDictionary jsonStringDictionary = null)
IJsonStringDictionary jsonStringDictionary = null)
{
return jsonSerializationFormat switch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private CuratedDocsPayload(
string name,
ReadOnlyMemory<byte> text,
ReadOnlyMemory<byte> binary,
(ReadOnlyMemory<byte> binary, IJsonReadOnlyStringDictionary dictionary) binaryWithDictionaryEncoding)
(ReadOnlyMemory<byte> binary, IJsonStringDictionary dictionary) binaryWithDictionaryEncoding)
{
this.Name = name;
this.Text = text;
Expand All @@ -122,7 +122,7 @@ private CuratedDocsPayload(
public string Name { get; }
public ReadOnlyMemory<byte> Text { get; }
public ReadOnlyMemory<byte> Binary { get; }
internal (ReadOnlyMemory<byte> binary, IJsonReadOnlyStringDictionary dictionary) BinaryWithDictionaryEncoding { get; }
internal (ReadOnlyMemory<byte> binary, IJsonStringDictionary dictionary) BinaryWithDictionaryEncoding { get; }

public static CuratedDocsPayload CreateFromCuratedDocs(string name)
{
Expand All @@ -139,7 +139,7 @@ public static CuratedDocsPayload CreateFromCuratedDocs(string name)

ReadOnlyMemory<byte> text = Encoding.UTF8.GetBytes(json);
ReadOnlyMemory<byte> binary = JsonTestUtils.ConvertTextToBinary(json);
ReadOnlyMemory<byte> dictionaryEncodedBinary = JsonTestUtils.ConvertTextToBinary(json, out IJsonReadOnlyStringDictionary jsonStringDictionary);
ReadOnlyMemory<byte> dictionaryEncodedBinary = JsonTestUtils.ConvertTextToBinary(json, out IJsonStringDictionary jsonStringDictionary);

return new CuratedDocsPayload(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private readonly struct Payload
private Payload(
ReadOnlyMemory<byte> text,
ReadOnlyMemory<byte> binary,
(ReadOnlyMemory<byte> binary, IJsonReadOnlyStringDictionary dictionary) binaryWithDictionaryEncoding)
(ReadOnlyMemory<byte> binary, IJsonStringDictionary dictionary) binaryWithDictionaryEncoding)
{
this.Text = text;
this.Binary = binary;
Expand All @@ -104,13 +104,13 @@ private Payload(

public ReadOnlyMemory<byte> Text { get; }
public ReadOnlyMemory<byte> Binary { get; }
public (ReadOnlyMemory<byte> binary, IJsonReadOnlyStringDictionary dictionary) BinaryWithDictionaryEncoding { get; }
public (ReadOnlyMemory<byte> binary, IJsonStringDictionary dictionary) BinaryWithDictionaryEncoding { get; }

public static Payload Create(string json)
{
ReadOnlyMemory<byte> text = Encoding.UTF8.GetBytes(json);
ReadOnlyMemory<byte> binary = JsonTestUtils.ConvertTextToBinary(json);
ReadOnlyMemory<byte> dictionaryEncodedBinary = JsonTestUtils.ConvertTextToBinary(json, out IJsonReadOnlyStringDictionary jsonStringDictionary);
ReadOnlyMemory<byte> dictionaryEncodedBinary = JsonTestUtils.ConvertTextToBinary(json, out IJsonStringDictionary jsonStringDictionary);

return new Payload(
text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private static void VerifyNavigator(
IJsonNavigator binaryNavigator = JsonNavigator.Create(binaryInput);

// Test binary + empty user string dictionary
IJsonReadOnlyStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string>());
IJsonStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string>());
byte[] binaryWithEmptyUserStringEncodingInput = JsonTestUtils.ConvertTextToBinary(input, jsonStringDictionary);
Assert.IsTrue(binaryWithEmptyUserStringEncodingInput.SequenceEqual(binaryInput), "Binary data should be the same with empty readonly JSON dictionary.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,7 @@ public void SimpleObjectTest()

this.VerifyReader(input, expectedTokens);
this.VerifyReader(binaryInput, expectedTokens);
IJsonReadOnlyStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string> { "GlossDiv", "title" });
IJsonStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string> { "GlossDiv", "title" });
this.VerifyReader(binaryInputWithEncoding, expectedTokens, jsonStringDictionary);
}

Expand Down Expand Up @@ -2570,7 +2570,7 @@ public void AllPrimitivesObjectTest()
this.VerifyReader(input, expectedTokens);
this.VerifyReader(binaryInput, expectedTokens);

IJsonReadOnlyStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string> { "double", "string", "boolean", "null", "datetime", "spatialPoint", "text" });
IJsonStringDictionary jsonStringDictionary = new JsonStringDictionary(new List<string> { "double", "string", "boolean", "null", "datetime", "spatialPoint", "text" });
this.VerifyReader(binaryInputWithEncoding, expectedTokens, jsonStringDictionary);
}

Expand Down Expand Up @@ -3213,7 +3213,7 @@ private void VerifyReader(string input, JsonToken[] expectedTokens, Exception ex
expectedException);
}

private void VerifyReader(ReadOnlyMemory<byte> input, JsonToken[] expectedTokens, IJsonReadOnlyStringDictionary jsonStringDictionary = null, Exception expectedException = null)
private void VerifyReader(ReadOnlyMemory<byte> input, JsonToken[] expectedTokens, IJsonStringDictionary jsonStringDictionary = null, Exception expectedException = null)
{
// Test binary reader created with the array API
this.VerifyReader(() => JsonReader.Create(input, jsonStringDictionary), expectedTokens, expectedException);
Expand Down
Loading