Skip to content

Commit fcfe498

Browse files
committed
More code gen!
1 parent f0ec92a commit fcfe498

File tree

431 files changed

+7952
-94973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+7952
-94973
lines changed

Elasticsearch.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Profiling", "benchmarks\Pro
2929
EndProject
3030
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D9FFF81B-26F3-4A26-9605-E3D22382E9A5}"
3131
ProjectSection(SolutionItems) = preProject
32+
.dockerignore = .dockerignore
33+
.editorconfig = .editorconfig
34+
.gitattributes = .gitattributes
35+
.gitignore = .gitignore
36+
build.bat = build.bat
37+
build.sh = build.sh
38+
contributing.md = contributing.md
39+
Directory.Build.props = Directory.Build.props
40+
Directory.Build.targets = Directory.Build.targets
41+
dotnet-tools.json = dotnet-tools.json
3242
global.json = global.json
43+
issue_template.md = issue_template.md
44+
license.txt = license.txt
45+
nuget.config = nuget.config
46+
readme.md = readme.md
3347
EndProjectSection
3448
EndProject
3549
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Clients.Elasticsearch", "src\Elastic.Clients.Elasticsearch\Elastic.Clients.Elasticsearch.csproj", "{F8A7E60C-0C48-4D76-AF7F-7881DF5A263D}"

benchmarks/Profiling/Program.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
using JetBrains.Profiler.Api;
2-
using Elastic.Clients.Elasticsearch;
3-
using Elastic.Clients.Elasticsearch.IndexManagement;
1+
//using JetBrains.Profiler.Api;
2+
//using Elastic.Clients.Elasticsearch;
3+
//using Elastic.Clients.Elasticsearch.IndexManagement;
44

5-
var req1 = new Elastic.Clients.Elasticsearch.IndexManagement.DeleteRequest("test");
5+
//var req1 = new Elastic.Clients.Elasticsearch.IndexManagement.DeleteRequest("test");
66

7-
//var list = new List<IndexName>();
8-
//IEnumerable<IndexName> items = new IndexName[] { "a", "b" };
7+
////var list = new List<IndexName>();
8+
////IEnumerable<IndexName> items = new IndexName[] { "a", "b" };
99

10-
MemoryProfiler.ForceGc();
10+
//MemoryProfiler.ForceGc();
1111

12-
MemoryProfiler.CollectAllocations(true);
12+
//MemoryProfiler.CollectAllocations(true);
1313

14-
MemoryProfiler.GetSnapshot();
14+
//MemoryProfiler.GetSnapshot();
1515

16-
//var req = new DeleteRequest("test");
16+
////var req = new DeleteRequest("test");
1717

18-
//var i = Indices.Parse("test");
18+
////var i = Indices.Parse("test");
1919

20-
var i = Indices.Single("test");
20+
//var i = Indices.Single("test");
2121

22-
MemoryProfiler.GetSnapshot();
22+
//MemoryProfiler.GetSnapshot();
2323

24-
//if (req.AllowNoIndices.HasValue)
25-
//{
24+
////if (req.AllowNoIndices.HasValue)
25+
////{
2626

27-
//}
27+
////}
2828

29-
_ = i.ToString();
29+
//_ = i.ToString();
3030

31-
MemoryProfiler.CollectAllocations(false);
31+
//MemoryProfiler.CollectAllocations(false);
3232

33-
//var source = new IndexName[] { "index-01", "index-02" };
33+
////var source = new IndexName[] { "index-01", "index-02" };
3434

35-
//var indices = new Indices(source);
36-
//var indicesList = new IndicesList(source);
35+
////var indices = new Indices(source);
36+
////var indicesList = new IndicesList(source);
3737

38-
//MemoryProfiler.CollectAllocations(true);
38+
////MemoryProfiler.CollectAllocations(true);
3939

40-
//MemoryProfiler.GetSnapshot();
40+
////MemoryProfiler.GetSnapshot();
4141

42-
//var indices2 = new Indices(source);
42+
////var indices2 = new Indices(source);
4343

44-
//MemoryProfiler.GetSnapshot();
44+
////MemoryProfiler.GetSnapshot();
4545

46-
//var indicesList2 = new IndicesList(source);
46+
////var indicesList2 = new IndicesList(source);
4747

48-
//MemoryProfiler.GetSnapshot();
48+
////MemoryProfiler.GetSnapshot();
4949

50-
//MemoryProfiler.CollectAllocations(false);
50+
////MemoryProfiler.CollectAllocations(false);
5151

52-
//// Ensure no GC between snapshots
53-
//_ = indices2.Values.Count;
54-
//_ = indicesList2.Values.Count;
52+
////// Ensure no GC between snapshots
53+
////_ = indices2.Values.Count;
54+
////_ = indicesList2.Values.Count;

src/Elastic.Clients.Elasticsearch/.editorconfig

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
using System;
2-
using System.IO;
3-
using System.Text.Json;
4-
using System.Text.Json.Serialization;
5-
using Elastic.Transport;
6-
7-
namespace Elastic.Clients.Elasticsearch
8-
{
9-
public partial interface IIndexRequest<TDocument> : ICustomJsonWriter
10-
{
11-
TDocument Document { get; set; } // TODO - This should be generated based on the spec
12-
Id? Id { get; }
13-
}
14-
15-
public partial class IndexRequest<TDocument> : ICustomJsonWriter
16-
{
17-
protected override HttpMethod? DynamicHttpMethod => GetHttpMethod(this);
18-
19-
[JsonIgnore] public TDocument Document { get; set; }
20-
21-
[JsonIgnore] Id? IIndexRequest<TDocument>.Id => Self.RouteValues.Get<Id>("id");
22-
23-
void ICustomJsonWriter.WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer)
24-
{
25-
// TODO: Review perf
26-
using var ms = new MemoryStream();
27-
sourceSerializer.Serialize(Document, ms); // TODO - This needs to camelCase
28-
ms.Position = 0;
29-
using var
30-
document = JsonDocument
31-
.Parse(ms); // This is not super efficient but a variant on the suggestion at https://github.com/dotnet/runtime/issues/1784#issuecomment-608331125
32-
document.RootElement.WriteTo(writer);
33-
34-
// Perhaps can be improved in .NET 6/ updated system.text.json - https://github.com/dotnet/runtime/pull/53212
35-
}
36-
37-
internal static HttpMethod GetHttpMethod(IIndexRequest<TDocument> request) =>
38-
request.Id?.Value is not null || request.RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST;
39-
//request.Id?.StringOrLongValue != null || request.RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST;
40-
}
41-
42-
public partial class IndexDescriptor<TDocument>
43-
{
44-
public void WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer) =>
45-
throw new NotImplementedException();
46-
47-
Id? IIndexRequest<TDocument>.Id => Self.RouteValues.Get<Id>("id");
48-
49-
TDocument IIndexRequest<TDocument>.Document { get; set; }
50-
}
51-
}
1+
//using System;
2+
//using System.IO;
3+
//using System.Text.Json;
4+
//using System.Text.Json.Serialization;
5+
//using Elastic.Transport;
6+
7+
//namespace Elastic.Clients.Elasticsearch
8+
//{
9+
// public partial interface IIndexRequest<TDocument> : ICustomJsonWriter
10+
// {
11+
// TDocument Document { get; set; } // TODO - This should be generated based on the spec
12+
// Id? Id { get; }
13+
// }
14+
15+
// public partial class IndexRequest<TDocument> : ICustomJsonWriter
16+
// {
17+
// protected override HttpMethod? DynamicHttpMethod => GetHttpMethod(this);
18+
19+
// [JsonIgnore] public TDocument Document { get; set; }
20+
21+
// [JsonIgnore] Id? IIndexRequest<TDocument>.Id => Self.RouteValues.Get<Id>("id");
22+
23+
// void ICustomJsonWriter.WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer)
24+
// {
25+
// // TODO: Review perf
26+
// using var ms = new MemoryStream();
27+
// sourceSerializer.Serialize(Document, ms); // TODO - This needs to camelCase
28+
// ms.Position = 0;
29+
// using var
30+
// document = JsonDocument
31+
// .Parse(ms); // This is not super efficient but a variant on the suggestion at https://github.com/dotnet/runtime/issues/1784#issuecomment-608331125
32+
// document.RootElement.WriteTo(writer);
33+
34+
// // Perhaps can be improved in .NET 6/ updated system.text.json - https://github.com/dotnet/runtime/pull/53212
35+
// }
36+
37+
// internal static HttpMethod GetHttpMethod(IIndexRequest<TDocument> request) =>
38+
// request.Id?.Value is not null || request.RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST;
39+
// //request.Id?.StringOrLongValue != null || request.RouteValues.ContainsId ? HttpMethod.PUT : HttpMethod.POST;
40+
// }
41+
42+
// public partial class IndexDescriptor<TDocument>
43+
// {
44+
// public void WriteJson(Utf8JsonWriter writer, Serializer sourceSerializer) =>
45+
// throw new NotImplementedException();
46+
47+
// Id? IIndexRequest<TDocument>.Id => Self.RouteValues.Get<Id>("id");
48+
49+
// TDocument IIndexRequest<TDocument>.Document { get; set; }
50+
// }
51+
//}

src/Elastic.Clients.Elasticsearch/Client/ElasticClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Elastic.Clients.Elasticsearch;
77

88
/// <inheritdoc />
9-
public partial class ElasticClient : IElasticClient
9+
public partial class ElasticClient
1010
{
1111
private readonly ITransport<IElasticsearchClientSettings> _transport;
1212

@@ -127,7 +127,7 @@ internal Task<TResponse> DoRequestAsync<TRequest, TResponse>(
127127
//}
128128

129129
var postData =
130-
request.CanBeEmpty && request.IsEmpty || request.HttpMethod == HttpMethod.GET ||
130+
/*request.CanBeEmpty && request.IsEmpty || */request.HttpMethod == HttpMethod.GET ||
131131
request.HttpMethod == HttpMethod.HEAD || !request.SupportsBody
132132
? null
133133
: PostData.Serializable(request);

src/Elastic.Clients.Elasticsearch/Common/IndexName.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@
66

77
namespace Elastic.Clients.Elasticsearch
88
{
9+
public readonly struct SearchQuery
10+
{
11+
private readonly int? _intValue;
12+
private readonly string _stringValue;
13+
//private readonly bool? _boolValue;
14+
15+
private SearchQuery(int value)
16+
{
17+
_intValue = value;
18+
_stringValue = null;
19+
//_boolValue = null;
20+
}
21+
22+
private SearchQuery(string value)
23+
{
24+
_intValue = null;
25+
_stringValue = value;
26+
//_boolValue = null;
27+
}
28+
29+
public static SearchQuery String(string value) => new SearchQuery(value);
30+
public static SearchQuery Integer(int value) => new SearchQuery(value);
31+
}
32+
933
[DebuggerDisplay("{DebugDisplay,nq}")]
1034
public class IndexName : IEquatable<IndexName>, IUrlParameter
1135
{

src/Elastic.Clients.Elasticsearch/Common/Infer/DataStreamName/DataStreamNames.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
namespace Elastic.Clients.Elasticsearch
1010
{
11-
public partial class DataStreamNames
12-
{
13-
// This is temporary
14-
public DataStreamNames(IEnumerable<DataStreamName> names) => _dataStreamNameList.AddRange(names);
11+
//public partial class DataStreamNames
12+
//{
13+
// // This is temporary
14+
// public DataStreamNames(IEnumerable<DataStreamName> names) => _dataStreamNameList.AddRange(names);
1515

16-
public string GetString(ITransportConfiguration settings) => throw new NotImplementedException();
17-
}
16+
// public string GetString(ITransportConfiguration settings) => throw new NotImplementedException();
17+
//}
1818
}

0 commit comments

Comments
 (0)