Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.x] feat(): add support for DateOnly and TimeOnly #680 (#734) #735

Merged
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
1 change: 1 addition & 0 deletions .github/workflows/build_deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- uses: actions/cache@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/code-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
uses: actions/checkout@v4

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- name: Cache Nuget Packages
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration-yaml-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- uses: actions/cache@v4
with:
Expand Down Expand Up @@ -96,6 +97,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- uses: actions/cache@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- uses: actions/cache@v4
with:
Expand Down Expand Up @@ -86,6 +87,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x

- uses: actions/cache@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
Expand Down Expand Up @@ -67,6 +68,7 @@ jobs:
dotnet-version: |
5.0.x
6.0.x
8.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
### Added
- Added support for `MinScore` on `ScriptScoreQuery` ([#624](https://github.com/opensearch-project/opensearch-net/pull/624))
- Added support for serializing the `DateOnly` and `TimeOnly` types ([#734](https://github.com/opensearch-project/opensearch-net/pull/734))

### Dependencies
- Bumps `AWSSDK.Core` from 3.7.204.12 to 3.7.400
Expand Down Expand Up @@ -179,4 +180,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
[1.6.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.5.0...v1.6.0
[1.5.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.4.0...v1.5.0
[1.4.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0
[1.3.0]: https://github.com/opensearch-project/opensearch-net/compare/v1.2.0...v1.3.0
59 changes: 30 additions & 29 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ open Fake.IO.Globbing.Operators

module Main =

let private target name action = Targets.Target(name, Action(action))
let private target name action = Targets.Target(name, Action(action))
let private skip name = printfn "SKIPPED target '%s' evaluated not to run" name |> ignore
let private conditional name optional action = target name (if optional then action else (fun _ -> skip name))
let private conditional name optional action = target name (if optional then action else (fun _ -> skip name))
let private command name (dependencies: IEnumerable<string>) action = Targets.Target(name, dependencies, Action(action))
let private conditionalCommand name dependencies optional action = command name dependencies (if optional then action else (fun _ -> skip name))
let private conditionalCommand name dependencies optional action = command name dependencies (if optional then action else (fun _ -> skip name))

/// <summary>Sets command line environments indicating we are building from the command line</summary>
let setCommandLineEnvVars () =
Environment.setEnvironVar"OSC_COMMAND_LINE_BUILD" "1"

let sourceDir = Paths.TestsSource("Tests.Configuration");
let defaultYaml = Path.Combine(sourceDir, "tests.default.yaml");
let userYaml = Path.Combine(sourceDir, "tests.yaml");
Expand All @@ -56,59 +56,60 @@ module Main =
| (true, _) -> Environment.setEnvironVar "OSC_YAML_FILE" (Path.GetFullPath(userYaml))
| (_, true) -> Environment.setEnvironVar "OSC_YAML_FILE" (Path.GetFullPath(defaultYaml))
| _ -> failwithf "Expected to find a tests.default.yaml or tests.yaml in %s" sourceDir
let [<EntryPoint>] main args =


let [<EntryPoint>] main args =
async {
do! Async.SwitchToThreadPool ()

setCommandLineEnvVars ()

let parsed = Commandline.parse (args |> Array.toList)

let buildVersions = Versioning.BuildVersioning parsed
let artifactsVersion = Versioning.ArtifactsVersion buildVersions
Versioning.Validate parsed.Target buildVersions

let isCanary = parsed.Target = "canary";

Tests.SetTestEnvironmentVariables parsed

let testChain = ["clean"; "version"; "restore"; "full-build"; ]
let buildChain = ["test"; "inherit-doc" ]
let releaseChain =
[
[
"build";
"nuget-pack";
"nuget-pack-versioned";
// "nuget-pack-versioned";
"validate-artifacts";
"generate-release-notes"
]
let canaryChain = [ "version"; "release"; "test-nuget-package";]
// the following are expected to be called as targets directly
conditional "clean" (parsed.ReleaseBuild || parsed.Target = "clean") <| fun _ -> Build.Clean parsed

// the following are expected to be called as targets directly
conditional "clean" (parsed.ReleaseBuild || parsed.Target = "clean") <| fun _ -> Build.Clean parsed
target "version" <| fun _ -> printfn "Artifacts Version: %O" artifactsVersion
target "restore" Build.Restore

target "restore" Build.Restore
target "full-build" <| fun _ -> Build.Compile parsed artifactsVersion

//TEST
conditionalCommand "test" testChain (not parsed.SkipTests && not isCanary) <| fun _ -> Tests.RunUnitTests parsed

target "inherit-doc" <| InheritDoc.PatchInheritDocs

//BUILD
command "build" buildChain <| fun _ -> printfn "STARTING BUILD"

target "nuget-pack" <| fun _ -> Build.Pack artifactsVersion

conditional "nuget-pack-versioned" (isCanary) <| fun _ -> Build.VersionedPack artifactsVersion
// TODO: Re-enable once assembly-rewriter supports .NET 8.0
// conditional "nuget-pack-versioned" (isCanary) <| fun _ -> Build.VersionedPack artifactsVersion

conditional "generate-release-notes" (not isCanary) <| fun _ -> ReleaseNotes.GenerateNotes buildVersions

target "validate-artifacts" <| fun _ -> Versioning.ValidateArtifacts artifactsVersion

//RELEASE
command "release" releaseChain <| fun _ ->
let outputPath = match parsed.CommandArguments with | Commandline.SetVersion c -> c.OutputLocation | _ -> None
Expand All @@ -124,15 +125,15 @@ module Main =
printfn "Finished Release Build %O, output copied to: %s" artifactsVersion path

conditional "test-nuget-package" (not parsed.SkipTests) <| fun _ -> Tests.RunReleaseUnitTests artifactsVersion parsed

//CANARY
command "canary" canaryChain <| fun _ -> printfn "Finished Release Build %O" artifactsVersion

// ADDITIONAL COMMANDS

command "cluster" [ "restore"; "full-build" ] <| fun _ ->
ReposTooling.LaunchCluster parsed

command "codegen" [ ] <| fun _ ->
ReposTooling.GenerateApi parsed.RemainingArguments

Expand All @@ -145,5 +146,5 @@ module Main =

do! Targets.RunTargetsAndExitAsync([parsed.Target], (fun e -> e.GetType() = typeof<ProcExecException>)) |> Async.AwaitTask
} |> Async.RunSynchronously

0
10 changes: 5 additions & 5 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
"isRoot": true,
"tools": {
"assembly-rewriter": {
"version": "0.12.0",
"version": "0.13.0",
"commands": [
"assembly-rewriter"
]
},
"assembly-differ": {
"version": "0.13.0",
"version": "0.15.0",
"commands": [
"assembly-differ"
]
},
"nupkg-validator": {
"version": "0.4.0",
"version": "0.6.0",
"commands": [
"nupkg-validator"
]
},
"release-notes": {
"version": "0.3.1",
"version": "0.6.0",
"commands": [
"release-notes"
]
}
}
}
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.403",
"version": "8.0.107",
"rollForward": "latestFeature",
"allowPrerelease": false
},
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSearch.Net/Configuration/RequestMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal bool TryAddMetaData (string key, string value)
{
_metaDataItems ??= new Dictionary<string, string>();

#if NETSTANDARD2_1
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
return _metaDataItems.TryAdd(key, value);
#else
if (_metaDataItems.ContainsKey(key))
Expand All @@ -55,7 +55,7 @@ internal bool TryAddMetaData (string key, string value)
_metaDataItems.Add(key, value);
return true;
#endif
}
}

public IReadOnlyDictionary<string, string> Items => _metaDataItems ?? EmptyReadOnly<string, string>.Dictionary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private HttpMessageHandler CreateHandler(int key, RequestData requestData)
{
if (requestData == null) throw new ArgumentNullException(nameof(requestData));

#if NETSTANDARD2_1
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
var entry = _activeHandlers.GetOrAdd(key, (k, r) => _entryFactory(k, r), requestData).Value;
#else
var entry = _activeHandlers.GetOrAdd(key, (k) => _entryFactory(k, requestData)).Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ private static string GetNetCoreVersion()

private static bool TryGetVersionFromAssemblyPath(Assembly assembly, out string runtimeVersion)
{
#if NET6_0_OR_GREATER
var assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
#else
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
#endif
var netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void Reseed(IEnumerable<Node> nodes)
{
_readerWriter.EnterWriteLock();
var sortedNodes = SortNodes(nodesArray)
.DistinctBy(n => n.Uri)
.DistinctByInternal(n => n.Uri)
.ToList();

InternalNodes = sortedNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void Initialize(IEnumerable<Node> nodes, IDateTimeProvider dateTimeProvi
}

InternalNodes = SortNodes(nodesProvided)
.DistinctBy(n => n.Uri)
.DistinctByInternal(n => n.Uri)
.ToList();
LastUpdate = DateTimeProvider.Now();
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSearch.Net/Extensions/UtilExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal static void ThrowIfNull<T>(this T value, string name) where T : class

internal static bool IsNullOrEmpty(this string value) => string.IsNullOrEmpty(value);

internal static IEnumerable<T> DistinctBy<T, TKey>(this IEnumerable<T> items, Func<T, TKey> property) =>
internal static IEnumerable<T> DistinctByInternal<T, TKey>(this IEnumerable<T> items, Func<T, TKey> property) =>
items.GroupBy(property).Select(x => x.First());

internal static string ToTimeUnit(this TimeSpan timeSpan)
Expand Down
4 changes: 3 additions & 1 deletion src/OpenSearch.Net/OpenSearch.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461;net6.0;net8.0</TargetFrameworks>

<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

</PropertyGroup>


<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
Expand Down
6 changes: 3 additions & 3 deletions src/OpenSearch.Net/Providers/RecyclableMemoryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public int SafeRead(byte[] buffer, int offset, int count, ref int streamPosition
return amountRead;
}

#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
/// <summary>
/// Reads from the current position into the provided buffer
/// </summary>
Expand Down Expand Up @@ -649,7 +649,7 @@ public override void Write(byte[] buffer, int offset, int count)
_length = Math.Max(_position, _length);
}

#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
/// <summary>
/// Writes the buffer to the stream
/// </summary>
Expand Down Expand Up @@ -866,7 +866,7 @@ private int InternalRead(byte[] buffer, int offset, int count, int fromPosition)
return amountToCopy;
}

#if NETCOREAPP2_1 || NETSTANDARD2_1
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
private int InternalRead(Span<byte> buffer, int fromPosition)
{
if (_length - fromPosition <= 0) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public EventCounter(string blocks, RecyclableMemoryStreamManager.Events eventsWr
public void WriteMetric(long v) { }
}
#endif
#if !NETSTANDARD2_1
#if !NETSTANDARD2_1 && !NET6_0_OR_GREATER
internal class PollingCounter : IDisposable
{
// ReSharper disable UnusedParameter.Local
Expand Down
Loading
Loading