-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow passing `"auto"` as the `slices` parameter Signed-off-by: Thomas Farr <[email protected]> * Update CHANGELOG Signed-off-by: Thomas Farr <[email protected]> * Fix license header Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]> (cherry picked from commit cd4bd52)
- Loading branch information
1 parent
3fb0de3
commit 1867e9b
Showing
9 changed files
with
131 additions
and
133 deletions.
There are no files selected for viewing
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
95 changes: 0 additions & 95 deletions
95
src/OpenSearch.Client/CommonAbstractions/Infer/TrackTotalHits/TrackTotalHits.cs
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/OpenSearch.Client/CommonAbstractions/Infer/TrackTotalHits/TrackTotalHitsFormatter.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using OpenSearch.Net.Utf8Json; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
[JsonFormatter(typeof(SlicesFormatter))] | ||
public class Slices : Union<long, string> | ||
{ | ||
public Slices(long value) : base(value) { } | ||
|
||
public Slices(string value) : base(value) { } | ||
|
||
public static implicit operator Slices(long value) => new(value); | ||
public static implicit operator Slices(long? value) => value is { } v ? new Slices(v) : null; | ||
public static implicit operator Slices(string value) => value is { } v ? new Slices(value) : null; | ||
|
||
public override string ToString() => Tag switch | ||
{ | ||
0 => Item1.ToString(), | ||
1 => Item2, | ||
_ => null | ||
}; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/OpenSearch.Client/Document/Multiple/Slices/SlicesFormatter.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,31 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using OpenSearch.Net.Utf8Json; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
internal class SlicesFormatter : IJsonFormatter<Slices> | ||
{ | ||
private static readonly UnionFormatter<long, string> UnionFormatter = new(); | ||
|
||
public void Serialize(ref JsonWriter writer, Slices value, IJsonFormatterResolver formatterResolver) => | ||
UnionFormatter.Serialize(ref writer, value, formatterResolver); | ||
|
||
public Slices Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) | ||
{ | ||
var union = UnionFormatter.Deserialize(ref reader, formatterResolver); | ||
if (union == null) return null; | ||
|
||
return union.Tag switch | ||
{ | ||
0 => new Slices(union.Item1), | ||
1 => new Slices(union.Item2), | ||
_ => null | ||
}; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/OpenSearch.Client/Search/TrackTotalHits/TrackTotalHits.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,31 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using OpenSearch.Net.Utf8Json; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
[JsonFormatter(typeof(TrackTotalHitsFormatter))] | ||
public class TrackTotalHits : Union<bool, long> | ||
{ | ||
public TrackTotalHits(bool item) : base(item) { } | ||
|
||
public TrackTotalHits(long item) : base(item) { } | ||
|
||
public static implicit operator TrackTotalHits(bool trackTotalHits) => new(trackTotalHits); | ||
public static implicit operator TrackTotalHits(bool? trackTotalHits) => trackTotalHits is {} b ? new TrackTotalHits(b) : null; | ||
|
||
public static implicit operator TrackTotalHits(long trackTotalHitsUpTo) => new(trackTotalHitsUpTo); | ||
public static implicit operator TrackTotalHits(long? trackTotalHitsUpTo) => trackTotalHitsUpTo is {} l ? new TrackTotalHits(l) : null; | ||
|
||
public override string ToString() => Tag switch | ||
{ | ||
0 => Item1.ToString(), | ||
1 => Item2.ToString(), | ||
_ => null | ||
}; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/OpenSearch.Client/Search/TrackTotalHits/TrackTotalHitsFormatter.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,30 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using OpenSearch.Net.Utf8Json; | ||
|
||
namespace OpenSearch.Client; | ||
|
||
internal class TrackTotalHitsFormatter : IJsonFormatter<TrackTotalHits> | ||
{ | ||
private static readonly UnionFormatter<bool, long> UnionFormatter = new(); | ||
|
||
public void Serialize(ref JsonWriter writer, TrackTotalHits value, IJsonFormatterResolver formatterResolver) => | ||
UnionFormatter.Serialize(ref writer, value, formatterResolver); | ||
|
||
public TrackTotalHits Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) | ||
{ | ||
var union = UnionFormatter.Deserialize(ref reader, formatterResolver); | ||
if (union == null) return null; | ||
return union.Tag switch | ||
{ | ||
0 => new TrackTotalHits(union.Item1), | ||
1 => new TrackTotalHits(union.Item2), | ||
_ => null | ||
}; | ||
} | ||
} |