Skip to content
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
16 changes: 8 additions & 8 deletions benchmarks/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,56 +173,56 @@ public class BulkIngest
public void Version7()
{
Stream.Position = 0;
_ = NestClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(Stream);
_ = NestClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(Stream);
}

[Benchmark]
public void Version8()
{
Stream.Position = 0;
_ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(Stream);
_ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(Stream);
}

// [Benchmark]
// public void Version8_String()
// {
// Stream.Position = 0;
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV2>(Stream);
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV2>(Stream);
// }

//[Benchmark]
//public void Version8_String_Converter()
//{
// Stream.Position = 0;
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3>(Stream);
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3>(Stream);
//}

//[Benchmark]
//public void Version8_String_ConverterWithBool()
//{
// Stream.Position = 0;
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3_BoolFlags>(Stream);
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3_BoolFlags>(Stream);
//}

//[Benchmark]
//public void Version8_String_ConverterWithSpan()
//{
// Stream.Position = 0;
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV3_Span>(Stream);
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV3_Span>(Stream);
//}

//[Benchmark]
//public void Version8_SourceWithoutUsingContext()
//{
// Stream.Position = 0;
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV4>(Stream);
// _ = AlphaClient.RequestResponseSerializer.Deserialize<Elastic.Clients.Elasticsearch.Cluster.HealthResponseV4>(Stream);
//}

//[Benchmark]
//public void Version8_SourceDirect()
//{
// Stream.Position = 0;
// _ = JsonSerializer.Deserialize(Stream, Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponseV4Context.Default.ClusterHealthResponseV4);
// _ = JsonSerializer.Deserialize(Stream, Elastic.Clients.Elasticsearch.Cluster.HealthResponseV4Context.Default.HealthResponseV4);
//}
}

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/Profiling/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

//var observer = bulkAll.Wait(TimeSpan.FromMinutes(1), n => { });

_ = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(stream);
_ = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(stream);

MemoryProfiler.ForceGc();

Expand All @@ -47,7 +47,7 @@

//observer = bulkAll.Wait(TimeSpan.FromMinutes(1), n => { });

var result = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.ClusterHealthResponse>(stream);
var result = await alphaClient.RequestResponseSerializer.DeserializeAsync<Elastic.Clients.Elasticsearch.Cluster.HealthResponse>(stream);

MemoryProfiler.GetSnapshot();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ private void ApplyPropertyOverrides(MemberInfo member, JsonProperty property)

private static void ApplyShouldSerializer(JsonProperty property)
{
if (property.PropertyType == typeof(QueryContainer))
property.ShouldSerialize = o => ShouldSerializeQueryContainer(o, property);
else if (property.PropertyType == typeof(IEnumerable<QueryContainer>))
property.ShouldSerialize = o => ShouldSerializeQueryContainers(o, property);
if (property.PropertyType == typeof(Query))
property.ShouldSerialize = o => ShouldSerializeQuery(o, property);
else if (property.PropertyType == typeof(IEnumerable<Query>))
property.ShouldSerialize = o => ShouldSerializeQuerys(o, property);
}

private static bool ShouldSerializeQueryContainer(object o, JsonProperty prop)
private static bool ShouldSerializeQuery(object o, JsonProperty prop)
{
if (o == null)
return false;
if (prop.ValueProvider.GetValue(o) is not QueryContainer q)
if (prop.ValueProvider.GetValue(o) is not Query q)
return false;
//return q.IsWritable;
return true;
}

private static bool ShouldSerializeQueryContainers(object o, JsonProperty prop)
private static bool ShouldSerializeQuerys(object o, JsonProperty prop)
{
if (o == null)
return false;
if (prop.ValueProvider.GetValue(o) is not IEnumerable<QueryContainer> q)
if (prop.ValueProvider.GetValue(o) is not IEnumerable<Query> q)
return false;

var queryContainers = q as QueryContainer[] ?? q.ToArray();
//return queryContainers.Any(qq => qq != null && ((QueryContainer)qq).IsWritable);
var queryContainers = q as Query[] ?? q.ToArray();
//return queryContainers.Any(qq => qq != null && ((Query)qq).IsWritable);
return queryContainers.Any(qq => qq != null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class HandleNestTypesOnSourceJsonConverter : JsonConverter
private static readonly HashSet<Type> NestTypesThatCanAppearInSource = new()
{
typeof(JoinField),
typeof(QueryContainer),
typeof(Query),
//typeof(CompletionField),
//typeof(Attachment),
typeof(LazyJson),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

namespace Elastic.Clients.Elasticsearch.AsyncSearch;

public partial class AsyncSearchSubmitRequest
public partial class SubmitAsyncSearchRequest
{
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
internal override void BeforeRequest() => TypedKeys = true;
}

public sealed partial class AsyncSearchSubmitRequestDescriptor
public sealed partial class SubmitAsyncSearchRequestDescriptor
{
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
public SubmitAsyncSearchRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));

internal override void BeforeRequest() => TypedKeys(true);
}

public sealed partial class AsyncSearchSubmitRequestDescriptor<TDocument>
public sealed partial class SubmitAsyncSearchRequestDescriptor<TDocument>
{
public AsyncSearchSubmitRequestDescriptor<TDocument> MatchAll()
public SubmitAsyncSearchRequestDescriptor<TDocument> MatchAll()
{
Query(new MatchAllQuery());
return Self;
Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Clients.Elasticsearch/Api/CountRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public CountRequestDescriptor Index(Indices indices)
return Self;
}

public CountRequestDescriptor Query(Func<QueryContainerDescriptor, QueryContainer> configure)
public CountRequestDescriptor Query(Func<QueryDescriptor, Query> configure)
{
var container = configure?.Invoke(new QueryContainerDescriptor());
var container = configure?.Invoke(new QueryDescriptor());
QueryValue = container;
return Self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Elastic.Clients.Elasticsearch.Eql;

public partial class GetEqlResponse<TEvent>
public partial class EqlGetResponse<TEvent>
{
private IReadOnlyCollection<HitsEvent<TEvent>> _events;
private IReadOnlyCollection<HitsSequence<TEvent>> _sequences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

namespace Elastic.Clients.Elasticsearch;

// TODO - Should be added as a rule to the descriptor generator
//public sealed partial class SourceRequestDescriptor<TDocument>
//{
// public SourceRequestDescriptor(TDocument documentWithId, IndexName index = null, Id id = null) : this(index ?? typeof(TDocument), id ?? Id.From(documentWithId)) => Doc
//}

public partial class SourceRequestDescriptor
public partial class GetSourceRequestDescriptor
{
/// <summary>
/// A shortcut into calling Index(typeof(TOther)).
/// </summary>
public SourceRequestDescriptor Index<TOther>()
public GetSourceRequestDescriptor Index<TOther>()
{
RouteValues.Required("index", (IndexName)typeof(TOther));
return Self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Elastic.Clients.Elasticsearch;

public partial class SourceResponse<TDocument> : ISelfDeserializable
public partial class GetSourceResponse<TDocument> : ISelfDeserializable
{
public TDocument Body { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

namespace Elastic.Clients.Elasticsearch.IndexManagement;

public partial class MappingResponse
public partial class GetMappingResponse
{
public IReadOnlyDictionary<IndexName, IndexMappingRecord> Indices => BackingDictionary;
}

public static class GetMappingResponseExtensions
{
public static TypeMapping GetMappingFor<T>(this MappingResponse response) => response.GetMappingFor(typeof(T));
public static TypeMapping GetMappingFor<T>(this GetMappingResponse response) => response.GetMappingFor(typeof(T));

public static TypeMapping GetMappingFor(this MappingResponse response, IndexName index)
public static TypeMapping GetMappingFor(this GetMappingResponse response, IndexName index)
{
if (index.IsNullOrEmpty())
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Elastic.Clients.Elasticsearch.Sql;

public partial class SqlGetAsyncResponse
public partial class GetAsyncResponse
{
[JsonInclude]
[JsonPropertyName("rows")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Elastic.Clients.Elasticsearch.Aggregations;
/// <summary>
/// Combines aggregations into a single list of aggregations.
/// </summary>
internal class AggregationCombinator : Aggregation
internal class AggregationCombinator : SearchAggregation
{
public AggregationCombinator(string name, Aggregation left, Aggregation right)
public AggregationCombinator(string name, SearchAggregation left, SearchAggregation right)
{
AddAggregation(left);
AddAggregation(right);
Expand All @@ -21,9 +21,9 @@ public AggregationCombinator(string name, Aggregation left, Aggregation right)

public override string? Name { get; internal set; }

internal List<Aggregation> Aggregations { get; } = new List<Aggregation>();
internal List<SearchAggregation> Aggregations { get; } = new List<SearchAggregation>();

private void AddAggregation(Aggregation agg)
private void AddAggregation(SearchAggregation agg)
{
switch (agg)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ namespace Elastic.Clients.Elasticsearch.Aggregations;
/// <summary>
/// Describes aggregations to execute as part of a search.
/// </summary>
public sealed class AggregationDictionary : IsADictionary<string, AggregationContainer>
public sealed class AggregationDictionary : IsADictionary<string, Aggregation>
{
public AggregationDictionary() { }

public AggregationDictionary(IDictionary<string, AggregationContainer> dictionary)
public AggregationDictionary(IDictionary<string, Aggregation> dictionary)
: base(dictionary.ToDictionary(kv => kv.Key, kv => kv.Value)) { } // Copy the existing dictionary rather then using the existing reference

public AggregationDictionary(Dictionary<string, AggregationContainer> dictionary)
public AggregationDictionary(Dictionary<string, Aggregation> dictionary)
: base(dictionary.ToDictionary(kv => kv.Key, kv => kv.Value)) { } // Copy the existing dictionary rather then using the existing reference

public static implicit operator AggregationDictionary(Dictionary<string, AggregationContainer> dictionary) =>
public static implicit operator AggregationDictionary(Dictionary<string, Aggregation> dictionary) =>
new(dictionary);

public static implicit operator AggregationDictionary(Aggregation aggregator)
public static implicit operator AggregationDictionary(SearchAggregation aggregator)
{
Aggregation b;
SearchAggregation b;
if (aggregator is AggregationCombinator combinator)
{
var dict = new AggregationDictionary();
Expand All @@ -49,9 +49,9 @@ public static implicit operator AggregationDictionary(Aggregation aggregator)
return new AggregationDictionary { { aggregator } };
}

public void Add(string key, AggregationContainer value) => BackingDictionary.Add(ValidateKey(key), value);
public void Add(string key, Aggregation value) => BackingDictionary.Add(ValidateKey(key), value);

public void Add(AggregationContainer value)
public void Add(Aggregation value)
{
if (value.Variant.Name.IsNullOrEmpty())
throw new ArgumentException($"{value.GetType().Name}.Name is not set!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
namespace Elastic.Clients.Elasticsearch.Aggregations;

// This is marked as internal for now, until we are ready to support plugin aggregations.
internal interface IAggregation
internal interface ISearchAggregation
{
string? Name { get; }
}

/// <summary>
/// Base class for all aggregations.
/// </summary>
public abstract class Aggregation : IAggregation
public abstract class SearchAggregation : ISearchAggregation
{
internal Aggregation() { }
internal SearchAggregation() { }

public abstract string? Name { get; internal set; }

//always evaluate to false so that each side of && equation is evaluated
public static bool operator false(Aggregation _) => false;
public static bool operator false(SearchAggregation _) => false;

//always evaluate to false so that each side of && equation is evaluated
public static bool operator true(Aggregation _) => false;
public static bool operator true(SearchAggregation _) => false;

public static Aggregation operator &(Aggregation left, Aggregation right) =>
public static SearchAggregation operator &(SearchAggregation left, SearchAggregation right) =>
new AggregationCombinator(null, left, right);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ internal static class Extensions
{
private static readonly ConcurrentDictionary<string, object> EnumCache = new();

//internal static bool NotWritable(this QueryContainer q) => q == null || !q.IsWritable;
//internal static bool NotWritable(this Query q) => q == null || !q.IsWritable;

//internal static bool NotWritable(this IEnumerable<QueryContainer> qs) => qs == null || qs.All(q => q.NotWritable());
//internal static bool NotWritable(this IEnumerable<Query> qs) => qs == null || qs.All(q => q.NotWritable());

internal static string ToEnumValue<T>(this T enumValue) where T : struct
{
Expand Down
Loading