Release 1.1.0-preview 3 (#6)

Release roll-up snapshot of C#/C++ codebase at version 1.1.0-preview.
This release matches the current shipping nugets.
This commit is contained in:
Jason Hunter
2021-05-05 17:18:35 -07:00
committed by GitHub
parent c36b0adfe8
commit ce112dcdf1
643 changed files with 73408 additions and 20737 deletions

11
CODEOWNERS Normal file
View File

@@ -0,0 +1,11 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @invino4
# Order is important; the last matching pattern takes the most precedence
CODEOWNERS @invino4

View File

@@ -1,14 +1,13 @@
# Contributing
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

View File

@@ -1,3 +1,12 @@
# PLACEHOLDER
# Microsoft HybridRow
TODO: DANOBLE: Write README.md
This client library is an internal component of the Azure Cosmos DB SDK.
For more information, refer to https://azure.microsoft.com/services/cosmos-db/.
## Install via [Nuget.org](https://www.nuget.org/packages/Microsoft.HybridRow/)
`Install-Package Microsoft.HybridRow`
## Useful links
- [Release notes](https://github.com/microsoft/HybridRow/blob/master/changelog.md)

9
changelog.md Normal file
View File

@@ -0,0 +1,9 @@
Preview features are treated as a separate branch and will not be included in the official release until the feature is
ready. Each preview release lists all the additional features that are enabled.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### <a name="1.1.0-preview3"/> [1.1.0-preview3](https://www.nuget.org/packages/Microsoft.HybridRow/1.1.0-preview3) - 2021-03-30
- Initial snapshot of code with tools.

View File

@@ -1,20 +0,0 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRow.Json")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("CE1C4987-FC19-4887-9EB6-13508F8DA644")]

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{7047DD2A-14FA-445E-93B2-67EB98282C4D}</ProjectGuid>
<ShippingScope>External</ShippingScope>
<DisableCosmosDBRules>true</DisableCosmosDBRules>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\Build.props" />
<PropertyGroup>
<NugetPackBasePath>$(OutputRootDir)</NugetPackBasePath>
<NugetPackProperties>$(NugetPackProperties);ProductSemanticVersion=$(ProductSemanticVersion);VersionPrereleaseExtension=$(VersionPrereleaseExtension)</NugetPackProperties>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(DocDBRoot)\Cosmos\Core\Core\Microsoft.Azure.Cosmos.Core.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<Project>{B7621117-AEF3-4E10-928D-533AE893F379}</Project>
<Name>Microsoft.Azure.Cosmos.Core</Name>
</ProjectReference>
<ProjectReference Include="..\HybridRow\Microsoft.Azure.Cosmos.Serialization.HybridRow.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<Project>{490D42EE-1FEF-47CC-97E4-782A353B4D58}</Project>
<Name>Microsoft.Azure.Cosmos.Serialization.HybridRow</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(BuildExtensionsPath)\NoTarget.targets" />
</Project>

View File

@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>Microsoft.Azure.Cosmos.Serialization.HybridRow</id>
<version>1.0.0-preview</version>
<title>Microsoft.Azure.Cosmos.Serialization.HybridRow</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<licenseUrl>https://aka.ms/netcoregaeula</licenseUrl>
<projectUrl>https://github.com/Azure/azure-cosmos-dotnet-v3</projectUrl>
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Microsoft.Azure.Cosmos.Serialization.HybridRow</summary>
<description>This package supports the Microsoft Azure Cosmos Client and is not intended to be used directly from your code.</description>
<copyright>Copyright © Microsoft Corporation</copyright>
<tags>microsoft azure cosmos dotnetcore netcore netstandard</tags>
<dependencies>
<dependency id="System.Memory" version="4.5.1" />
<dependency id="Newtonsoft.Json" version="10.0.2" />
<dependency id="System.Runtime.CompilerServices.Unsafe" version="4.5.1" />
<dependency id="System.Threading.Tasks.Extensions" version="4.5.1" />
<dependency id="System.ValueTuple" version="4.5.0" />
</dependencies>
</metadata>
<files>
<file src="Product\Microsoft.Azure.Cosmos.Serialization.HybridRow\Microsoft.Azure.Cosmos.Serialization.HybridRow.dll" target="lib/netstandard2.0" />
<file src="Product\Microsoft.Azure.Cosmos.Core\Microsoft.Azure.Cosmos.Core.dll" target="lib/netstandard2.0" />
</files>
</package>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<ProjectGuid>{26A73F4A-AC9E-46AF-9445-286EE9EDA3EE}</ProjectGuid>
<OutputType>Library</OutputType>
<SigningType>Test</SigningType>
<RootNamespace>Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Perf</RootNamespace>
<AssemblyName>Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Perf</AssemblyName>
<TargetFramework>netcoreapp2.2</TargetFramework>
<EnforceTestOwnership>True</EnforceTestOwnership>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\build.props" />
<PropertyGroup>
<QTestType>MsTest_Latest</QTestType>
<QTestDotNetFramework>FrameworkCore20</QTestDotNetFramework>
<QTestDotNetCoreRuntimeArchitecture>X64</QTestDotNetCoreRuntimeArchitecture>
<QTestDirToDeploy>$(OutDir)</QTestDirToDeploy>
</PropertyGroup>
<ItemGroup>
<None Include="TestData\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(DocDBRoot)\Cosmos\Core\Core\Microsoft.Azure.Cosmos.Core.csproj" />
<ProjectReference Include="..\HybridRowGenerator\Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator.csproj" />
<ProjectReference Include="..\HybridRow\Microsoft.Azure.Cosmos.Serialization.HybridRow.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Profiler.Api" />
<PackageReference Include="Google.Protobuf" />
<PackageReference Include="Google.Protobuf.Tools" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.VisualStudio.TestPlatform" />
<PackageReference Include="MongoDB.Bson.Signed" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="System.ValueTuple" />
<PackageReference Include="VisualStudio.UnitTest.Corext" />
</ItemGroup>
<ItemGroup>
<None Update="HybridRowPerf.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,19 +0,0 @@
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Perf")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("26A73F4A-AC9E-46AF-9445-286EE9EDA3EE")]

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,51 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable SA1401 // Fields should be private
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
internal sealed class Address
{
public string Street;
public string City;
public string State;
public PostalCode PostalCode;
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is Address && this.Equals((Address)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Street != null ? this.Street.GetHashCode() : 0;
hashCode = (hashCode * 397) ^ (this.City != null ? this.City.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.State != null ? this.State.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.PostalCode != null ? this.PostalCode.GetHashCode() : 0);
return hashCode;
}
}
private bool Equals(Address other)
{
return string.Equals(this.Street, other.Street) &&
string.Equals(this.City, other.City) &&
string.Equals(this.State, other.State) &&
object.Equals(this.PostalCode, other.PostalCode);
}
}
}

View File

@@ -1,104 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
using Microsoft.Azure.Cosmos.Serialization.HybridRow.IO;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts;
internal static class AddressSerializer
{
public static Result Write(ref RowWriter writer, TypeArgument typeArg, Address obj)
{
Result r;
if (obj.Street != null)
{
r = writer.WriteString("street", obj.Street);
if (r != Result.Success)
{
return r;
}
}
if (obj.City != null)
{
r = writer.WriteString("city", obj.City);
if (r != Result.Success)
{
return r;
}
}
if (obj.State != null)
{
r = writer.WriteString("state", obj.State);
if (r != Result.Success)
{
return r;
}
}
if (obj.PostalCode != null)
{
r = writer.WriteScope("postal_code", PostalCodeSerializer.TypeArg, obj.PostalCode, PostalCodeSerializer.Write);
if (r != Result.Success)
{
return r;
}
}
return Result.Success;
}
public static Result Read(ref RowReader reader, out Address obj)
{
obj = new Address();
while (reader.Read())
{
Result r;
switch (reader.Path)
{
case "street":
r = reader.ReadString(out obj.Street);
if (r != Result.Success)
{
return r;
}
break;
case "city":
r = reader.ReadString(out obj.City);
if (r != Result.Success)
{
return r;
}
break;
case "state":
r = reader.ReadString(out obj.State);
if (r != Result.Success)
{
return r;
}
break;
case "postal_code":
r = reader.ReadScope(
obj,
(ref RowReader child, Address parent) =>
PostalCodeSerializer.Read(ref child, out parent.PostalCode));
if (r != Result.Success)
{
return r;
}
break;
}
}
return Result.Success;
}
}
}

View File

@@ -1,103 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable SA1401 // Fields should be private
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
using System;
using System.Collections.Generic;
using System.Linq;
internal sealed class Guest
{
public Guid Id;
public string FirstName;
public string LastName;
public string Title;
public ISet<string> Emails;
public IList<string> PhoneNumbers;
public IDictionary<string, Address> Addresses;
public string ConfirmNumber;
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is Guest && this.Equals((Guest)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Id.GetHashCode();
hashCode = (hashCode * 397) ^ (this.FirstName != null ? this.FirstName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.LastName != null ? this.LastName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Title != null ? this.Title.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Emails != null ? this.Emails.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.PhoneNumbers != null ? this.PhoneNumbers.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Addresses != null ? this.Addresses.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.ConfirmNumber != null ? this.ConfirmNumber.GetHashCode() : 0);
return hashCode;
}
}
private static bool DictionaryEquals<TKey, TValue>(IDictionary<TKey, TValue> left, IDictionary<TKey, TValue> right)
{
if (left == right)
{
return true;
}
if ((left == null) || (right == null))
{
return false;
}
if (left.Count != right.Count)
{
return false;
}
foreach (KeyValuePair<TKey, TValue> p in left)
{
TValue value;
if (!right.TryGetValue(p.Key, out value))
{
return false;
}
if (!p.Value.Equals(value))
{
return false;
}
}
return true;
}
private bool Equals(Guest other)
{
return this.Id.Equals(other.Id) &&
string.Equals(this.FirstName, other.FirstName) &&
string.Equals(this.LastName, other.LastName) &&
string.Equals(this.Title, other.Title) &&
string.Equals(this.ConfirmNumber, other.ConfirmNumber) &&
((this.Emails == other.Emails) ||
((this.Emails != null) && (other.Emails != null) && this.Emails.SetEquals(other.Emails))) &&
((this.PhoneNumbers == other.PhoneNumbers) ||
((this.PhoneNumbers != null) && (other.PhoneNumbers != null) && this.PhoneNumbers.SequenceEqual(other.PhoneNumbers))) &&
Guest.DictionaryEquals(this.Addresses, other.Addresses);
}
}
}

View File

@@ -1,51 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable SA1401 // Fields should be private
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
internal sealed class Hotel
{
public string Id;
public string Name;
public string Phone;
public Address Address;
public bool Equals(Hotel other)
{
return string.Equals(this.Id, other.Id) &&
string.Equals(this.Name, other.Name) &&
string.Equals(this.Phone, other.Phone) &&
object.Equals(this.Address, other.Address);
}
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is Hotel && this.Equals((Hotel)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Id?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (this.Name?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Phone?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Address?.GetHashCode() ?? 0);
return hashCode;
}
}
}
}

View File

@@ -1,42 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable SA1401 // Fields should be private
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
internal sealed class PostalCode
{
public int Zip;
public short? Plus4;
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is PostalCode && this.Equals((PostalCode)obj);
}
public override int GetHashCode()
{
unchecked
{
return (this.Zip * 397) ^ this.Plus4.GetHashCode();
}
}
private bool Equals(PostalCode other)
{
return this.Zip == other.Zip && this.Plus4 == other.Plus4;
}
}
}

View File

@@ -1,68 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable SA1401 // Fields should be private
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.CustomerSchema
{
using Microsoft.Azure.Cosmos.Serialization.HybridRow.IO;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts;
internal static class PostalCodeSerializer
{
public static TypeArgument TypeArg = new TypeArgument(LayoutType.UDT, new TypeArgumentList(new SchemaId(1)));
public static Result Write(ref RowWriter writer, TypeArgument typeArg, PostalCode obj)
{
Result r;
r = writer.WriteInt32("zip", obj.Zip);
if (r != Result.Success)
{
return r;
}
if (obj.Plus4.HasValue)
{
r = writer.WriteInt16("plus4", obj.Plus4.Value);
if (r != Result.Success)
{
return r;
}
}
return Result.Success;
}
public static Result Read(ref RowReader reader, out PostalCode obj)
{
obj = new PostalCode();
while (reader.Read())
{
Result r;
switch (reader.Path)
{
case "zip":
r = reader.ReadInt32(out obj.Zip);
if (r != Result.Success)
{
return r;
}
break;
case "plus4":
r = reader.ReadInt16(out short value);
if (r != Result.Success)
{
return r;
}
obj.Plus4 = value;
break;
}
}
return Result.Success;
}
}
}

View File

@@ -1,9 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
[assembly:
System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.LayoutRules",
"SA1515:Single-line comment should be preceded by blank line",
Justification = "Refactor")]

View File

@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<ProjectGuid>{DC93CAA3-9732-46D4-ACBF-D69EFC3F6511}</ProjectGuid>
<OutputType>Library</OutputType>
<SigningType>Test</SigningType>
<RootNamespace>Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit</RootNamespace>
<AssemblyName>Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit</AssemblyName>
<TargetFramework>netcoreapp2.2</TargetFramework>
<EnforceTestOwnership>True</EnforceTestOwnership>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\build.props" />
<PropertyGroup>
<QTestType>MsTest_Latest</QTestType>
<QTestDotNetFramework>FrameworkCore20</QTestDotNetFramework>
<QTestDotNetCoreRuntimeArchitecture>X64</QTestDotNetCoreRuntimeArchitecture>
<QTestDirToDeploy>$(OutDir)</QTestDirToDeploy>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.VisualStudio.TestPlatform" />
<PackageReference Include="VisualStudio.UnitTest.Corext" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Memory" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="System.ValueTuple" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HybridRow\Microsoft.Azure.Cosmos.Serialization.HybridRow.csproj" />
<ProjectReference Include="..\HybridRowGenerator\Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator.csproj" />
<ProjectReference Include="..\..\Core\Core\Microsoft.Azure.Cosmos.Core.csproj" />
<None Include="TestData\BatchApiSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\CoverageSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\CrossVersioningExpected.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\SchemaHashCoverageSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\TaggedApiSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\ReaderSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\TaggedApiSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\CrossVersioningSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\CustomerSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\MovieSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\NullableSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\TodoSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\TagSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\PerfCounterSchema.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -1,19 +0,0 @@
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("DC93CAA3-9732-46D4-ACBF-D69EFC3F6511")]

View File

@@ -1,413 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
// ReSharper disable StringLiteralTypo
// ReSharper disable IdentifierTypo
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Schemas;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
[DeploymentItem(TypedArrayUnitTests.SchemaFile, "TestData")]
public sealed class TypedArrayUnitTests
{
private const string SchemaFile = @"TestData\TagSchema.json";
private const int InitialRowSize = 2 * 1024 * 1024;
private Namespace counterSchema;
private LayoutResolver resolver;
private Layout layout;
[TestInitialize]
public void ParseNamespaceExample()
{
string json = File.ReadAllText(TypedArrayUnitTests.SchemaFile);
this.counterSchema = Namespace.Parse(json);
this.resolver = new LayoutResolverNamespace(this.counterSchema);
this.layout = this.resolver.Resolve(this.counterSchema.Schemas.Find(x => x.Name == "Tagged").SchemaId);
}
[TestMethod]
[Owner("jthunter")]
public void CreateTags()
{
RowBuffer row = new RowBuffer(TypedArrayUnitTests.InitialRowSize);
row.InitLayout(HybridRowVersion.V1, this.layout, this.resolver);
Tagged t1 = new Tagged
{
Title = "Thriller",
Tags = new List<string> { "classic", "Post-disco", "funk" },
Options = new List<int?> { 8, null, 9 },
Ratings = new List<List<double>>
{
new List<double> { 1.2, 3.0 },
new List<double> { 4.1, 5.7 },
new List<double> { 7.3, 8.12, 9.14 },
},
Similars = new List<SimilarMatch>
{
new SimilarMatch { Thumbprint = "TRABACN128F425B784", Score = 0.87173699999999998 },
new SimilarMatch { Thumbprint = "TRJYGLF12903CB4952", Score = 0.75105200000000005 },
new SimilarMatch { Thumbprint = "TRWJMMB128F429D550", Score = 0.50866100000000003 },
},
Priority = new List<Tuple<string, long>>
{
Tuple.Create("80's", 100L),
Tuple.Create("classics", 100L),
Tuple.Create("pop", 50L),
},
};
this.WriteTagged(ref row, ref RowCursor.Create(ref row, out RowCursor _), t1);
Tagged t2 = this.ReadTagged(ref row, ref RowCursor.Create(ref row, out RowCursor _));
Assert.AreEqual(t1, t2);
}
private void WriteTagged(ref RowBuffer row, ref RowCursor root, Tagged value)
{
Assert.IsTrue(this.layout.TryFind("title", out LayoutColumn c));
ResultAssert.IsSuccess(c.TypeAs<LayoutUtf8>().WriteVariable(ref row, ref root, c, value.Title));
if (value.Tags != null)
{
Assert.IsTrue(this.layout.TryFind("tags", out c));
root.Clone(out RowCursor tagsScope).Find(ref row, c.Path);
ResultAssert.IsSuccess(c.TypeAs<LayoutTypedArray>().WriteScope(ref row, ref tagsScope, c.TypeArgs, out tagsScope));
foreach (string item in value.Tags)
{
ResultAssert.IsSuccess(c.TypeArgs[0].Type.TypeAs<LayoutUtf8>().WriteSparse(ref row, ref tagsScope, item));
Assert.IsFalse(tagsScope.MoveNext(ref row));
}
}
if (value.Options != null)
{
Assert.IsTrue(this.layout.TryFind("options", out c));
root.Clone(out RowCursor optionsScope).Find(ref row, c.Path);
ResultAssert.IsSuccess(c.TypeAs<LayoutTypedArray>().WriteScope(ref row, ref optionsScope, c.TypeArgs, out optionsScope));
foreach (int? item in value.Options)
{
TypeArgument itemType = c.TypeArgs[0];
ResultAssert.IsSuccess(
itemType.Type.TypeAs<LayoutNullable>()
.WriteScope(ref row, ref optionsScope, itemType.TypeArgs, item.HasValue, out RowCursor nullableScope));
if (item.HasValue)
{
ResultAssert.IsSuccess(
itemType.TypeArgs[0].Type.TypeAs<LayoutInt32>().WriteSparse(ref row, ref nullableScope, item.Value));
}
Assert.IsFalse(optionsScope.MoveNext(ref row, ref nullableScope));
}
}
if (value.Ratings != null)
{
Assert.IsTrue(this.layout.TryFind("ratings", out c));
root.Clone(out RowCursor ratingsScope).Find(ref row, c.Path);
ResultAssert.IsSuccess(c.TypeAs<LayoutTypedArray>().WriteScope(ref row, ref ratingsScope, c.TypeArgs, out ratingsScope));
foreach (List<double> item in value.Ratings)
{
Assert.IsTrue(item != null);
TypeArgument innerType = c.TypeArgs[0];
LayoutTypedArray innerLayout = innerType.Type.TypeAs<LayoutTypedArray>();
ResultAssert.IsSuccess(innerLayout.WriteScope(ref row, ref ratingsScope, innerType.TypeArgs, out RowCursor innerScope));
foreach (double innerItem in item)
{
LayoutFloat64 itemLayout = innerType.TypeArgs[0].Type.TypeAs<LayoutFloat64>();
ResultAssert.IsSuccess(itemLayout.WriteSparse(ref row, ref innerScope, innerItem));
Assert.IsFalse(innerScope.MoveNext(ref row));
}
Assert.IsFalse(ratingsScope.MoveNext(ref row, ref innerScope));
}
}
if (value.Similars != null)
{
Assert.IsTrue(this.layout.TryFind("similars", out c));
root.Clone(out RowCursor similarsScope).Find(ref row, c.Path);
ResultAssert.IsSuccess(c.TypeAs<LayoutTypedArray>().WriteScope(ref row, ref similarsScope, c.TypeArgs, out similarsScope));
foreach (SimilarMatch item in value.Similars)
{
TypeArgument innerType = c.TypeArgs[0];
LayoutUDT innerLayout = innerType.Type.TypeAs<LayoutUDT>();
ResultAssert.IsSuccess(innerLayout.WriteScope(ref row, ref similarsScope, innerType.TypeArgs, out RowCursor matchScope));
TypedArrayUnitTests.WriteSimilarMatch(ref row, ref matchScope, innerType.TypeArgs, item);
Assert.IsFalse(similarsScope.MoveNext(ref row, ref matchScope));
}
}
if (value.Priority != null)
{
Assert.IsTrue(this.layout.TryFind("priority", out c));
root.Clone(out RowCursor priorityScope).Find(ref row, c.Path);
ResultAssert.IsSuccess(c.TypeAs<LayoutTypedArray>().WriteScope(ref row, ref priorityScope, c.TypeArgs, out priorityScope));
foreach (Tuple<string, long> item in value.Priority)
{
TypeArgument innerType = c.TypeArgs[0];
LayoutIndexedScope innerLayout = innerType.Type.TypeAs<LayoutIndexedScope>();
ResultAssert.IsSuccess(innerLayout.WriteScope(ref row, ref priorityScope, innerType.TypeArgs, out RowCursor tupleScope));
ResultAssert.IsSuccess(innerType.TypeArgs[0].Type.TypeAs<LayoutUtf8>().WriteSparse(ref row, ref tupleScope, item.Item1));
Assert.IsTrue(tupleScope.MoveNext(ref row));
ResultAssert.IsSuccess(innerType.TypeArgs[1].Type.TypeAs<LayoutInt64>().WriteSparse(ref row, ref tupleScope, item.Item2));
Assert.IsFalse(priorityScope.MoveNext(ref row, ref tupleScope));
}
}
}
private Tagged ReadTagged(ref RowBuffer row, ref RowCursor root)
{
Tagged value = new Tagged();
Assert.IsTrue(this.layout.TryFind("title", out LayoutColumn c));
ResultAssert.IsSuccess(c.TypeAs<LayoutUtf8>().ReadVariable(ref row, ref root, c, out value.Title));
Assert.IsTrue(this.layout.TryFind("tags", out c));
root.Clone(out RowCursor tagsScope).Find(ref row, c.Path);
if (c.TypeAs<LayoutTypedArray>().ReadScope(ref row, ref tagsScope, out tagsScope) == Result.Success)
{
value.Tags = new List<string>();
while (tagsScope.MoveNext(ref row))
{
ResultAssert.IsSuccess(c.TypeArgs[0].Type.TypeAs<LayoutUtf8>().ReadSparse(ref row, ref tagsScope, out string item));
value.Tags.Add(item);
}
}
Assert.IsTrue(this.layout.TryFind("options", out c));
root.Clone(out RowCursor optionsScope).Find(ref row, c.Path);
if (c.TypeAs<LayoutTypedArray>().ReadScope(ref row, ref optionsScope, out optionsScope) == Result.Success)
{
value.Options = new List<int?>();
while (optionsScope.MoveNext(ref row))
{
TypeArgument itemType = c.TypeArgs[0];
ResultAssert.IsSuccess(
itemType.Type.TypeAs<LayoutNullable>()
.ReadScope(ref row, ref optionsScope, out RowCursor nullableScope));
if (nullableScope.MoveNext(ref row))
{
ResultAssert.IsSuccess(LayoutNullable.HasValue(ref row, ref nullableScope));
ResultAssert.IsSuccess(
itemType.TypeArgs[0].Type.TypeAs<LayoutInt32>().ReadSparse(ref row, ref nullableScope, out int itemValue));
value.Options.Add(itemValue);
}
else
{
ResultAssert.NotFound(LayoutNullable.HasValue(ref row, ref nullableScope));
value.Options.Add(null);
}
}
}
Assert.IsTrue(this.layout.TryFind("ratings", out c));
root.Clone(out RowCursor ratingsScope).Find(ref row, c.Path);
if (c.TypeAs<LayoutTypedArray>().ReadScope(ref row, ref ratingsScope, out ratingsScope) == Result.Success)
{
value.Ratings = new List<List<double>>();
TypeArgument innerType = c.TypeArgs[0];
LayoutTypedArray innerLayout = innerType.Type.TypeAs<LayoutTypedArray>();
RowCursor innerScope = default;
while (ratingsScope.MoveNext(ref row, ref innerScope))
{
List<double> item = new List<double>();
ResultAssert.IsSuccess(innerLayout.ReadScope(ref row, ref ratingsScope, out innerScope));
while (innerScope.MoveNext(ref row))
{
LayoutFloat64 itemLayout = innerType.TypeArgs[0].Type.TypeAs<LayoutFloat64>();
ResultAssert.IsSuccess(itemLayout.ReadSparse(ref row, ref innerScope, out double innerItem));
item.Add(innerItem);
}
value.Ratings.Add(item);
}
}
Assert.IsTrue(this.layout.TryFind("similars", out c));
root.Clone(out RowCursor similarsScope).Find(ref row, c.Path);
if (c.TypeAs<LayoutTypedArray>().ReadScope(ref row, ref similarsScope, out similarsScope) == Result.Success)
{
value.Similars = new List<SimilarMatch>();
while (similarsScope.MoveNext(ref row))
{
TypeArgument innerType = c.TypeArgs[0];
LayoutUDT innerLayout = innerType.Type.TypeAs<LayoutUDT>();
ResultAssert.IsSuccess(innerLayout.ReadScope(ref row, ref similarsScope, out RowCursor matchScope));
SimilarMatch item = TypedArrayUnitTests.ReadSimilarMatch(ref row, ref matchScope);
value.Similars.Add(item);
}
}
Assert.IsTrue(this.layout.TryFind("priority", out c));
root.Clone(out RowCursor priorityScope).Find(ref row, c.Path);
if (c.TypeAs<LayoutTypedArray>().ReadScope(ref row, ref priorityScope, out priorityScope) == Result.Success)
{
value.Priority = new List<Tuple<string, long>>();
RowCursor tupleScope = default;
while (priorityScope.MoveNext(ref row, ref tupleScope))
{
TypeArgument innerType = c.TypeArgs[0];
LayoutIndexedScope innerLayout = innerType.Type.TypeAs<LayoutIndexedScope>();
ResultAssert.IsSuccess(innerLayout.ReadScope(ref row, ref priorityScope, out tupleScope));
Assert.IsTrue(tupleScope.MoveNext(ref row));
ResultAssert.IsSuccess(
innerType.TypeArgs[0].Type.TypeAs<LayoutUtf8>().ReadSparse(ref row, ref tupleScope, out string item1));
Assert.IsTrue(tupleScope.MoveNext(ref row));
ResultAssert.IsSuccess(
innerType.TypeArgs[1].Type.TypeAs<LayoutInt64>().ReadSparse(ref row, ref tupleScope, out long item2));
value.Priority.Add(Tuple.Create(item1, item2));
}
}
return value;
}
private static void WriteSimilarMatch(ref RowBuffer row, ref RowCursor matchScope, TypeArgumentList typeArgs, SimilarMatch m)
{
Layout matchLayout = row.Resolver.Resolve(typeArgs.SchemaId);
Assert.IsTrue(matchLayout.TryFind("thumbprint", out LayoutColumn c));
ResultAssert.IsSuccess(c.TypeAs<LayoutUtf8>().WriteFixed(ref row, ref matchScope, c, m.Thumbprint));
Assert.IsTrue(matchLayout.TryFind("score", out c));
ResultAssert.IsSuccess(c.TypeAs<LayoutFloat64>().WriteFixed(ref row, ref matchScope, c, m.Score));
}
private static SimilarMatch ReadSimilarMatch(ref RowBuffer row, ref RowCursor matchScope)
{
Layout matchLayout = matchScope.Layout;
SimilarMatch m = new SimilarMatch();
Assert.IsTrue(matchLayout.TryFind("thumbprint", out LayoutColumn c));
ResultAssert.IsSuccess(c.TypeAs<LayoutUtf8>().ReadFixed(ref row, ref matchScope, c, out m.Thumbprint));
Assert.IsTrue(matchLayout.TryFind("score", out c));
ResultAssert.IsSuccess(c.TypeAs<LayoutFloat64>().ReadFixed(ref row, ref matchScope, c, out m.Score));
return m;
}
[SuppressMessage("Microsoft.StyleCop.CSharp.OrderingRules", "SA1401", Justification = "Test types.")]
private sealed class Tagged
{
public string Title;
public List<string> Tags;
public List<int?> Options;
public List<List<double>> Ratings;
public List<SimilarMatch> Similars;
public List<Tuple<string, long>> Priority;
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is Tagged tagged && this.Equals(tagged);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Title?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (this.Tags?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Options?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Ratings?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Similars?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Priority?.GetHashCode() ?? 0);
return hashCode;
}
}
private static bool NestedSequenceEquals<T>(List<List<T>> left, List<List<T>> right)
{
if (left.Count != right.Count)
{
return false;
}
for (int i = 0; i < left.Count; i++)
{
if (!left[i].SequenceEqual(right[i]))
{
return false;
}
}
return true;
}
private bool Equals(Tagged other)
{
return string.Equals(this.Title, other.Title) &&
(object.ReferenceEquals(this.Tags, other.Tags) ||
((this.Tags != null) && (other.Tags != null) && this.Tags.SequenceEqual(other.Tags))) &&
(object.ReferenceEquals(this.Options, other.Options) ||
((this.Options != null) && (other.Options != null) && this.Options.SequenceEqual(other.Options))) &&
(object.ReferenceEquals(this.Ratings, other.Ratings) ||
((this.Ratings != null) && (other.Ratings != null) && Tagged.NestedSequenceEquals(this.Ratings, other.Ratings))) &&
(object.ReferenceEquals(this.Similars, other.Similars) ||
((this.Similars != null) && (other.Similars != null) && this.Similars.SequenceEqual(other.Similars))) &&
(object.ReferenceEquals(this.Priority, other.Priority) ||
((this.Priority != null) && (other.Priority != null) && this.Priority.SequenceEqual(other.Priority)));
}
}
[SuppressMessage("Microsoft.StyleCop.CSharp.OrderingRules", "SA1401", Justification = "Test types.")]
private sealed class SimilarMatch
{
public string Thumbprint;
public double Score;
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}
if (object.ReferenceEquals(this, obj))
{
return true;
}
return obj is SimilarMatch match && this.Equals(match);
}
public override int GetHashCode()
{
unchecked
{
return (this.Thumbprint.GetHashCode() * 397) ^ this.Score.GetHashCode();
}
}
private bool Equals(SimilarMatch other)
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
return this.Thumbprint == other.Thumbprint && this.Score == other.Score;
}
}
}
}

View File

@@ -1,27 +0,0 @@
System Schema are globally available HybridRow Schema definitions. This
document summarizes the available schema namespaces and their reserved SchemaId
allocated from the [System Schema](./SchemaId.md) address space.
[[_TOC_]]
# System Schema Catalog
The following are System Schema namespaces defined by the HybridRow runtime:
* [**Microsoft.Azure.Cosmos.HybridRow.RecordIO**](./RecordIO.md):
Defines types used in streaming record-oriented files containing HybridRows.
# SchemaId Reserved by the HybridRow Runtime
* $2147473648$ - RecordIO Segment
* $2147473649$ - RecordIO Record
* $2147473650$ - Empty Schema
# SchemaId Reserved by the Cosmos DB application
*These must be within [2145473647..2146473647]*
* $2145473647$ - HybridRow Query Response
* $2145473648$ - Batch API Operation
* $2145473649$ - Batch API Result
* $2145473650$ - Patch Request
* $2145473651$ - Patch Operation
* $2145473652$ - Json Schema

View File

@@ -1,61 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts
{
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.RecordIO;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Schemas;
public static class SystemSchema
{
/// <summary>
/// SchemaId of the empty schema. This schema has no defined cells but can accomodate
/// unschematized sparse content.
/// </summary>
public static readonly SchemaId EmptySchemaId = new SchemaId(2147473650);
/// <summary>SchemaId of HybridRow RecordIO Segments.</summary>
public static readonly SchemaId SegmentSchemaId = new SchemaId(2147473648);
/// <summary>SchemaId of HybridRow RecordIO Record Headers.</summary>
public static readonly SchemaId RecordSchemaId = new SchemaId(2147473649);
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Type is immutable.")]
public static readonly LayoutResolver LayoutResolver = SystemSchema.LoadSchema();
private static LayoutResolver LoadSchema()
{
string json = SystemSchema.GetEmbeddedResource(@"SystemSchemas\SystemSchema.json");
Namespace ns = Namespace.Parse(json);
LayoutResolverNamespace resolver = new LayoutResolverNamespace(ns);
return resolver;
}
private static string GetEmbeddedResource(string resourceName)
{
Assembly assembly = Assembly.GetAssembly(typeof(RecordIOFormatter));
resourceName = SystemSchema.FormatResourceName(assembly, resourceName);
using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
{
if (resourceStream == null)
{
return null;
}
using (StreamReader reader = new StreamReader(resourceStream))
{
return reader.ReadToEnd();
}
}
}
private static string FormatResourceName(Assembly assembly, string resourceName)
{
return assembly.GetName().Name + "." + resourceName.Replace(" ", "_").Replace("\\", ".").Replace("/", ".");
}
}
}

View File

@@ -1,26 +0,0 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRow")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("490D42EE-1FEF-47CC-97E4-782A353B4D58")]
// Allow tests to see internals.
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit" + AssemblyRef.TestPublicKey)]
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Perf" + AssemblyRef.TestPublicKey)]
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator" + AssemblyRef.TestPublicKey)]
[assembly: InternalsVisibleTo("Microsoft.Azure.Cosmos.Serialization.HybridRowStress" + AssemblyRef.TestPublicKey)]

View File

@@ -1,62 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.RecordIO
{
using Microsoft.Azure.Cosmos.Serialization.HybridRow.IO;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts;
public static class RecordSerializer
{
public static Result Write(ref RowWriter writer, TypeArgument typeArg, Record obj)
{
Result r;
r = writer.WriteInt32("length", obj.Length);
if (r != Result.Success)
{
return r;
}
r = writer.WriteUInt32("crc32", obj.Crc32);
if (r != Result.Success)
{
return r;
}
return Result.Success;
}
public static Result Read(ref RowReader reader, out Record obj)
{
obj = default;
while (reader.Read())
{
Result r;
// TODO: use Path tokens here.
switch (reader.Path.ToString())
{
case "length":
r = reader.ReadInt32(out obj.Length);
if (r != Result.Success)
{
return r;
}
break;
case "crc32":
r = reader.ReadUInt32(out obj.Crc32);
if (r != Result.Success)
{
return r;
}
break;
}
}
return Result.Success;
}
}
}

View File

@@ -1,103 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.RecordIO
{
using System;
using Microsoft.Azure.Cosmos.Core;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.IO;
using Microsoft.Azure.Cosmos.Serialization.HybridRow.Layouts;
public static class SegmentSerializer
{
public static Result Write(ref RowWriter writer, TypeArgument typeArg, Segment obj)
{
Result r;
if (obj.Comment != null)
{
r = writer.WriteString("comment", obj.Comment);
if (r != Result.Success)
{
return r;
}
}
if (obj.SDL != null)
{
r = writer.WriteString("sdl", obj.SDL);
if (r != Result.Success)
{
return r;
}
}
// Defer writing the length until all other fields of the segment header are written.
// The length is then computed based on the current size of the underlying RowBuffer.
// Because the length field is itself fixed, writing the length can never change the length.
int length = writer.Length;
r = writer.WriteInt32("length", length);
if (r != Result.Success)
{
return r;
}
Contract.Assert(length == writer.Length);
return Result.Success;
}
public static Result Read(Span<byte> span, LayoutResolver resolver, out Segment obj)
{
RowBuffer row = new RowBuffer(span, HybridRowVersion.V1, resolver);
RowReader reader = new RowReader(ref row);
return SegmentSerializer.Read(ref reader, out obj);
}
public static Result Read(ref RowReader reader, out Segment obj)
{
obj = default;
while (reader.Read())
{
Result r;
// TODO: use Path tokens here.
switch (reader.Path.ToString())
{
case "length":
r = reader.ReadInt32(out obj.Length);
if (r != Result.Success)
{
return r;
}
// If the RowBuffer isn't big enough to contain the rest of the header, then just
// return the length.
if (reader.Length < obj.Length)
{
return Result.Success;
}
break;
case "comment":
r = reader.ReadString(out obj.Comment);
if (r != Result.Success)
{
return r;
}
break;
case "sdl":
r = reader.ReadString(out obj.SDL);
if (r != Result.Success)
{
return r;
}
break;
}
}
return Result.Success;
}
}
}

View File

@@ -1,65 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable CA1716 // Identifiers should not match keywords
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Schemas
{
using System.Collections.Generic;
using Newtonsoft.Json;
[JsonObject]
public class Namespace
{
/// <summary>
/// The standard settings used by the JSON parser for interpreting <see cref="Namespace" />
/// documents.
/// </summary>
private static readonly JsonSerializerSettings NamespaceParseSettings = new JsonSerializerSettings()
{
CheckAdditionalContent = true,
};
/// <summary>The set of schemas that make up the <see cref="Namespace" />.</summary>
private List<Schema> schemas;
/// <summary>Initializes a new instance of the <see cref="Namespace" /> class.</summary>
public Namespace()
{
this.Schemas = new List<Schema>();
}
/// <summary>The version of the HybridRow Schema Definition Language used to encode this namespace.</summary>
[JsonProperty(PropertyName = "version")]
public SchemaLanguageVersion Version { get; set; }
/// <summary>The fully qualified identifier of the namespace.</summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>The set of schemas that make up the <see cref="Namespace" />.</summary>
/// <remarks>
/// Namespaces may consist of zero or more table schemas along with zero or more UDT schemas.
/// Table schemas can only reference UDT schemas defined in the same namespace. UDT schemas can
/// contain nested UDTs whose schemas are defined within the same namespace.
/// </remarks>
[JsonProperty(PropertyName = "schemas")]
public List<Schema> Schemas
{
get => this.schemas;
set => this.schemas = value ?? new List<Schema>();
}
/// <summary>Parse a JSON document and return a full namespace.</summary>
/// <param name="json">The JSON text to parse.</param>
/// <returns>A namespace containing a set of logical schemas.</returns>
public static Namespace Parse(string json)
{
Namespace ns = JsonConvert.DeserializeObject<Namespace>(json, Namespace.NamespaceParseSettings);
SchemaValidator.Validate(ns);
return ns;
}
}
}

View File

@@ -1,29 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Schemas
{
using Newtonsoft.Json;
/// <summary>A primitive property.</summary>
/// <remarks>
/// Primitive properties map to columns one-to-one. Primitive properties indicate how the
/// column should be represented within the row.
/// </remarks>
public class PrimitivePropertyType : PropertyType
{
/// <summary>The maximum allowable length in bytes.</summary>
/// <remarks>
/// This annotation is only valid for non-fixed length types. A value of 0 means the maximum
/// allowable length.
/// </remarks>
[JsonProperty(PropertyName = "length")]
[JsonConverter(typeof(StrictIntegerConverter))]
public int Length { get; set; }
/// <summary>Storage requirements of the property.</summary>
[JsonProperty(PropertyName = "storage")]
public StorageKind Storage { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,19 +0,0 @@
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRowCLI")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("F7D04E9B-4257-4D7E-9AAD-C743AEDBED04")]

View File

@@ -1,19 +0,0 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
namespace Microsoft.Azure.Cosmos.Serialization.HybridRowCLI
{
using System;
// TODO: this class should go away once we move to .NET Core 2.1.
internal static class StringExtensions
{
public static unsafe string AsString(this ReadOnlySpan<char> span)
{
fixed (char* p = span)
{
return new string(p, 0, span.Length);
}
}
}
}

View File

@@ -1,20 +0,0 @@
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("B3F04B26-800A-4097-95CE-EACECA9ACE23")]

View File

@@ -1,19 +0,0 @@
// <copyright file="AssemblyInfo.cs" company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Cosmos.Serialization.HybridRowStress")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2FED4096-A113-4946-85E2-36A1A94924C9")]

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<ProductRoot Condition=" '$(ProductRoot)'=='' ">$(MSBuildThisFileDirectory)</ProductRoot>
</PropertyGroup>
<Import Project="..\Build.props" />
<PropertyGroup>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>0</VersionPatch>
<ProductSemanticVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)-preview</ProductSemanticVersion>
<Version>$(ProductSemanticVersion)</Version>
<FileVersion>$(ProductSemanticVersion)</FileVersion>
<AssemblyVersion>$(ProductSemanticVersion)</AssemblyVersion>
</PropertyGroup>
</Project>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Build.props))\Build.props" />
<PropertyGroup>
<TraversalsSortValidation>true</TraversalsSortValidation>
</PropertyGroup>
<ItemGroup>
<ProjectFile Include="HybridRow.Json\Microsoft.Azure.Cosmos.Serialization.HybridRow.Json.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRow.Package\Microsoft.Azure.Cosmos.Serialization.HybridRow.Package.nuproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRow.Tests.Perf\Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Perf.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRow.Tests.Unit\Microsoft.Azure.Cosmos.Serialization.HybridRow.Tests.Unit.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRowCLI\Microsoft.Azure.Cosmos.Serialization.HybridRowCLI.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRowGenerator\Microsoft.Azure.Cosmos.Serialization.HybridRowGenerator.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRowStress\Microsoft.Azure.Cosmos.Serialization.HybridRowStress.csproj" IsRestoreNeeded="true" />
<ProjectFile Include="HybridRow\Microsoft.Azure.Cosmos.Serialization.HybridRow.csproj" IsRestoreNeeded="true" />
</ItemGroup>
<Import Project="$(BuildExtensionsPath)\Traversal.targets" />
</Project>

View File

@@ -1,25 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow;
public interface ISpanResizer<T> {
/**
* Resizes an existing a buffer.
* <typeparam name="T">The type of the elements of the memory.</typeparam>
*
* @param minimumLength The minimum required length (in elements) of the memory.
* @param buffer Optional existing memory to be copied to the new buffer. Ownership of <paramref
* name="buffer" /> is
* transferred as part of this call and it should not be used by the caller after this call
* completes.
* @return A new memory whose size is <em>at least as big</em> as <paramref name="minimumLength" />
* and containing the content of <paramref name="buffer" />.
*/
Span<T> Resize(int minimumLength);
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: Span<T> Resize(int minimumLength, Span<T> buffer = default);
Span<T> Resize(int minimumLength, Span<T> buffer);
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow;
public interface ISpanResizer<T> {
/**
* Resizes an existing a buffer.
* <typeparam name="T">The type of the elements of the memory.</typeparam>
*
* @param minimumLength The minimum required length (in elements) of the memory.
* @param buffer Optional existing memory to be copied to the new buffer. Ownership of <paramref
* name="buffer" /> is
* transferred as part of this call and it should not be used by the caller after this call
* completes.
* @return A new memory whose size is <em>at least as big</em> as <paramref name="minimumLength" />
* and containing the content of <paramref name="buffer" />.
*/
Span<T> Resize(int minimumLength);
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: Span<T> Resize(int minimumLength, Span<T> buffer = default);
Span<T> Resize(int minimumLength, Span<T> buffer);
}

View File

@@ -1,55 +1,55 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow;
import static com.google.common.base.Preconditions.checkArgument;
public final class MemorySpanResizer<T> implements ISpanResizer<T> {
private Memory<T> memory;
public MemorySpanResizer() {
this(0);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public MemorySpanResizer(int initialCapacity = 0)
public MemorySpanResizer(int initialCapacity) {
checkArgument(initialCapacity >= 0);
//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type parameters:
//ORIGINAL LINE: this.memory = initialCapacity == 0 ? default : new Memory<T>(new T[initialCapacity]);
this.memory = initialCapacity == 0 ? null : new Memory<T>((T[])new Object[initialCapacity]);
}
public Memory<T> getMemory() {
return this.memory;
}
/**
* <inheritdoc />
*/
public Span<T> Resize(int minimumLength) {
return Resize(minimumLength, null);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public Span<T> Resize(int minimumLength, Span<T> buffer = default)
public Span<T> Resize(int minimumLength, Span<T> buffer) {
if (this.memory.Length < minimumLength) {
//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type
// parameters:
//ORIGINAL LINE: this.memory = new Memory<T>(new T[Math.Max(minimumLength, buffer.Length)]);
this.memory = new Memory<T>((T[])new Object[Math.max(minimumLength, buffer.Length)]);
}
Span<T> next = this.memory.Span;
if (!buffer.IsEmpty && next.Slice(0, buffer.Length) != buffer) {
buffer.CopyTo(next);
}
return next;
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow;
import static com.google.common.base.Preconditions.checkArgument;
public final class MemorySpanResizer<T> implements ISpanResizer<T> {
private Memory<T> memory;
public MemorySpanResizer() {
this(0);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public MemorySpanResizer(int initialCapacity = 0)
public MemorySpanResizer(int initialCapacity) {
checkArgument(initialCapacity >= 0);
//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type parameters:
//ORIGINAL LINE: this.memory = initialCapacity == 0 ? default : new Memory<T>(new T[initialCapacity]);
this.memory = initialCapacity == 0 ? null : new Memory<T>((T[])new Object[initialCapacity]);
}
public Memory<T> getMemory() {
return this.memory;
}
/**
* <inheritdoc />
*/
public Span<T> Resize(int minimumLength) {
return Resize(minimumLength, null);
}
//C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above:
//ORIGINAL LINE: public Span<T> Resize(int minimumLength, Span<T> buffer = default)
public Span<T> Resize(int minimumLength, Span<T> buffer) {
if (this.memory.Length < minimumLength) {
//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type
// parameters:
//ORIGINAL LINE: this.memory = new Memory<T>(new T[Math.Max(minimumLength, buffer.Length)]);
this.memory = new Memory<T>((T[])new Object[Math.max(minimumLength, buffer.Length)]);
}
Span<T> next = this.memory.Span;
if (!buffer.IsEmpty && next.Slice(0, buffer.Length) != buffer) {
buffer.CopyTo(next);
}
return next;
}
}

View File

@@ -1,48 +1,48 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.layouts;
public class SamplingStringComparer implements IEqualityComparer<String> {
public static final SamplingStringComparer Default = new SamplingStringComparer();
public final boolean equals(String x, String y) {
checkArgument(x != null);
checkArgument(y != null);
return x.equals(y);
}
public final int hashCode(String obj) {
checkArgument(obj != null);
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash1 = 5381;
int hash1 = 5381;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash2 = hash1;
int hash2 = hash1;
final int numSamples = 4;
final int modulus = 13;
ReadOnlySpan<Character> utf16 = obj.AsSpan();
int max = Math.min(utf16.Length, numSamples);
for (int i = 0; i < max; i++) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint c = utf16[(i * modulus) % utf16.Length];
int c = utf16[(i * modulus) % utf16.Length];
if (i % 2 == 0) {
hash1 = ((hash1 << 5) + hash1) ^ c;
} else {
hash2 = ((hash2 << 5) + hash2) ^ c;
}
}
return hash1 + (hash2 * 1566083941);
}
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.layouts;
public class SamplingStringComparer implements IEqualityComparer<String> {
public static final SamplingStringComparer Default = new SamplingStringComparer();
public final boolean equals(String x, String y) {
checkArgument(x != null);
checkArgument(y != null);
return x.equals(y);
}
public final int hashCode(String obj) {
checkArgument(obj != null);
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash1 = 5381;
int hash1 = 5381;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash2 = hash1;
int hash2 = hash1;
final int numSamples = 4;
final int modulus = 13;
ReadOnlySpan<Character> utf16 = obj.AsSpan();
int max = Math.min(utf16.Length, numSamples);
for (int i = 0; i < max; i++) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint c = utf16[(i * modulus) % utf16.Length];
int c = utf16[(i * modulus) % utf16.Length];
if (i % 2 == 0) {
hash1 = ((hash1 << 5) + hash1) ^ c;
} else {
hash2 = ((hash2 << 5) + hash2) ^ c;
}
}
return hash1 + (hash2 * 1566083941);
}
}
}

View File

@@ -1,49 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.layouts;
public class SamplingUtf8StringComparer implements IEqualityComparer<Utf8String> {
public static final SamplingUtf8StringComparer Default = new SamplingUtf8StringComparer();
public final boolean equals(Utf8String x, Utf8String y) {
checkArgument(x != null);
checkArgument(y != null);
return x.Span.equals(y.Span);
}
public final int hashCode(Utf8String obj) {
checkArgument(obj != null);
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash1 = 5381;
int hash1 = 5381;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash2 = hash1;
int hash2 = hash1;
final int numSamples = 4;
final int modulus = 13;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: ReadOnlySpan<byte> utf8 = obj.Span.Span;
ReadOnlySpan<Byte> utf8 = obj.Span.Span;
int max = Math.min(utf8.Length, numSamples);
for (int i = 0; i < max; i++) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint c = utf8[(i * modulus) % utf8.Length];
int c = utf8[(i * modulus) % utf8.Length];
if (i % 2 == 0) {
hash1 = ((hash1 << 5) + hash1) ^ c;
} else {
hash2 = ((hash2 << 5) + hash2) ^ c;
}
}
return hash1 + (hash2 * 1566083941);
}
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.layouts;
public class SamplingUtf8StringComparer implements IEqualityComparer<Utf8String> {
public static final SamplingUtf8StringComparer Default = new SamplingUtf8StringComparer();
public final boolean equals(Utf8String x, Utf8String y) {
checkArgument(x != null);
checkArgument(y != null);
return x.Span.equals(y.Span);
}
public final int hashCode(Utf8String obj) {
checkArgument(obj != null);
// TODO: C# TO JAVA CONVERTER: There is no equivalent to an 'unchecked' block in Java:
unchecked
{
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash1 = 5381;
int hash1 = 5381;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint hash2 = hash1;
int hash2 = hash1;
final int numSamples = 4;
final int modulus = 13;
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: ReadOnlySpan<byte> utf8 = obj.Span.Span;
ReadOnlySpan<Byte> utf8 = obj.Span.Span;
int max = Math.min(utf8.Length, numSamples);
for (int i = 0; i < max; i++) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: uint c = utf8[(i * modulus) % utf8.Length];
int c = utf8[(i * modulus) % utf8.Length];
if (i % 2 == 0) {
hash1 = ((hash1 << 5) + hash1) ^ c;
} else {
hash2 = ((hash2 << 5) + hash2) ^ c;
}
}
return hash1 + (hash2 * 1566083941);
}
}
}

View File

@@ -1,84 +1,84 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
import Newtonsoft.Json.Converters.*;
import Newtonsoft.Json.Linq.*;
/**
* Helper class for parsing the polymorphic {@link PropertyType} subclasses from JSON.
*/
public class PropertySchemaConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return objectType.isAssignableFrom(PropertyType.class);
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
PropertyType p;
if (reader.TokenType != JsonToken.StartObject) {
throw new JsonSerializationException();
}
JObject propSchema = JObject.Load(reader);
TypeKind propType;
JToken value;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!propSchema.TryGetValue("type", out value)) {
throw new JsonSerializationException("Required \"type\" property missing.");
}
try (JsonReader typeReader = value.CreateReader()) {
typeReader.Read(); // Move to the start token
propType = TypeKind.forValue((new StringEnumConverter(true)).ReadJson(typeReader, TypeKind.class, null,
serializer));
}
switch (propType) {
case Array:
p = new ArrayPropertyType();
break;
case SET:
p = new SetPropertyType();
break;
case MAP:
p = new MapPropertyType();
break;
case Object:
p = new ObjectPropertyType();
break;
case Tuple:
p = new TuplePropertyType();
break;
case TAGGED:
p = new TaggedPropertyType();
break;
case Schema:
p = new UdtPropertyType();
break;
default:
p = new PrimitivePropertyType();
break;
}
serializer.Populate(propSchema.CreateReader(), p);
return p;
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
import Newtonsoft.Json.Converters.*;
import Newtonsoft.Json.Linq.*;
/**
* Helper class for parsing the polymorphic {@link PropertyType} subclasses from JSON.
*/
public class PropertySchemaConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return objectType.isAssignableFrom(PropertyType.class);
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
PropertyType p;
if (reader.TokenType != JsonToken.StartObject) {
throw new JsonSerializationException();
}
JObject propSchema = JObject.Load(reader);
TypeKind propType;
JToken value;
// TODO: C# TO JAVA CONVERTER: The following method call contained an unresolved 'out' keyword - these
// cannot be converted using the 'Out' helper class unless the method is within the code being modified:
if (!propSchema.TryGetValue("type", out value)) {
throw new JsonSerializationException("Required \"type\" property missing.");
}
try (JsonReader typeReader = value.CreateReader()) {
typeReader.Read(); // Move to the start token
propType = TypeKind.forValue((new StringEnumConverter(true)).ReadJson(typeReader, TypeKind.class, null,
serializer));
}
switch (propType) {
case Array:
p = new ArrayPropertyType();
break;
case SET:
p = new SetPropertyType();
break;
case MAP:
p = new MapPropertyType();
break;
case Object:
p = new ObjectPropertyType();
break;
case Tuple:
p = new TuplePropertyType();
break;
case TAGGED:
p = new TaggedPropertyType();
break;
case Schema:
p = new UdtPropertyType();
break;
default:
p = new PrimitivePropertyType();
break;
}
serializer.Populate(propSchema.CreateReader(), p);
return p;
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
}

View File

@@ -1,37 +1,37 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
public class StrictBooleanConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return objectType == Boolean.class;
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
switch (reader.TokenType) {
case JsonToken.Boolean:
return serializer.Deserialize(reader, objectType);
default:
throw new JsonSerializationException(String.format("Token \"%1$s\" of type %2$s was not a JSON bool",
reader.Value, reader.TokenType));
}
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value,
// JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
public class StrictBooleanConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return objectType == Boolean.class;
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
switch (reader.TokenType) {
case JsonToken.Boolean:
return serializer.Deserialize(reader, objectType);
default:
throw new JsonSerializationException(String.format("Token \"%1$s\" of type %2$s was not a JSON bool",
reader.Value, reader.TokenType));
}
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value,
// JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
}

View File

@@ -1,47 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
import java.math.BigInteger;
public class StrictIntegerConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return StrictIntegerConverter.IsIntegerType(objectType);
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
switch (reader.TokenType) {
case JsonToken.Integer:
return serializer.Deserialize(reader, objectType);
default:
throw new JsonSerializationException(String.format("Token \"%1$s\" of type %2$s was not a JSON " +
"integer", reader.Value, reader.TokenType));
}
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value,
// JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
private static boolean IsIntegerType(java.lang.Class type) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: if (type == typeof(long) || type == typeof(ulong) || type == typeof(int) || type == typeof
// (uint) || type == typeof(short) || type == typeof(ushort) || type == typeof(byte) || type == typeof(sbyte)
// || type == typeof(BigInteger))
return type == Long.class || type == Long.class || type == Integer.class || type == Integer.class || type == Short.class || type == Short.class || type == Byte.class || type == Byte.class || type == BigInteger.class;
}
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.cosmos.serialization.hybridrow.schemas;
import Newtonsoft.Json.*;
import java.math.BigInteger;
public class StrictIntegerConverter extends JsonConverter {
@Override
public boolean getCanWrite() {
return false;
}
@Override
public boolean CanConvert(java.lang.Class objectType) {
return StrictIntegerConverter.IsIntegerType(objectType);
}
@Override
public Object ReadJson(JsonReader reader, java.lang.Class objectType, Object existingValue,
JsonSerializer serializer) {
switch (reader.TokenType) {
case JsonToken.Integer:
return serializer.Deserialize(reader, objectType);
default:
throw new JsonSerializationException(String.format("Token \"%1$s\" of type %2$s was not a JSON " +
"integer", reader.Value, reader.TokenType));
}
}
// TODO: C# TO JAVA CONVERTER: Java annotations will not correspond to .NET attributes:
//ORIGINAL LINE: [ExcludeFromCodeCoverage] public override void WriteJson(JsonWriter writer, object value,
// JsonSerializer serializer)
@Override
public void WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) {
}
private static boolean IsIntegerType(java.lang.Class type) {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: if (type == typeof(long) || type == typeof(ulong) || type == typeof(int) || type == typeof
// (uint) || type == typeof(short) || type == typeof(ushort) || type == typeof(byte) || type == typeof(sbyte)
// || type == typeof(BigInteger))
return type == Long.class || type == Long.class || type == Integer.class || type == Integer.class || type == Short.class || type == Short.class || type == Byte.class || type == Byte.class || type == BigInteger.class;
}
}

Some files were not shown because too many files have changed in this diff Show More