-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSHARP-3241: Zstandard compression key in the code must be kept in sy…
…nc with the spec.
- Loading branch information
1 parent
90bb172
commit b7362c2
Showing
10 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/MongoDB.Driver.Core/Core/Compression/CompressorTypeMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* Copyright 2020–present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace MongoDB.Driver.Core.Compression | ||
{ | ||
internal static class CompressorTypeMapper | ||
{ | ||
public static string ToServerName(CompressorType compressorType) | ||
{ | ||
switch (compressorType) | ||
{ | ||
case CompressorType.Noop: | ||
return "noop"; | ||
case CompressorType.Zlib: | ||
return "zlib"; | ||
case CompressorType.Snappy: | ||
return "snappy"; | ||
case CompressorType.ZStandard: | ||
return "zstd"; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(compressorType)); | ||
} | ||
} | ||
|
||
public static bool TryFromServerName(string serverName, out CompressorType compressorType) | ||
{ | ||
compressorType = default; | ||
switch (serverName.ToLowerInvariant()) | ||
{ | ||
case "noop": compressorType = CompressorType.Noop; break; | ||
case "zlib": compressorType = CompressorType.Zlib; break; | ||
case "snappy": compressorType = CompressorType.Snappy; break; | ||
case "zstd": compressorType = CompressorType.ZStandard; break; | ||
default: return false; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters