|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq.Expressions; |
| 4 | +using System.Runtime.Serialization; |
| 5 | +using Elasticsearch.Net.Utf8Json; |
| 6 | + |
| 7 | +namespace Nest |
| 8 | +{ |
| 9 | + [MapsApi("ml.estimate_model_memory.json")] |
| 10 | + [ReadAs(typeof(EstimateModelMemoryRequest))] |
| 11 | + public partial interface IEstimateModelMemoryRequest |
| 12 | + { |
| 13 | + /// <summary> |
| 14 | + /// For a list of the properties that you can specify in the analysis_config component of the body |
| 15 | + /// of this API, see analysis_config. |
| 16 | + /// </summary> |
| 17 | + [DataMember(Name ="analysis_config")] |
| 18 | + IAnalysisConfig AnalysisConfig { get; set; } |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Estimates of the cardinality that will be observed for fields over the whole time period that |
| 22 | + /// the job analyzes data. To produce a good answer, values must be provided for fields referenced |
| 23 | + /// in the by_field_name, over_field_name and partition_field_name of any detectors. It does not matter |
| 24 | + /// if values are provided for other fields. If no detectors have a by_field_name, over_field_name or |
| 25 | + /// partition_field_name then overall_cardinality can be omitted from the request. |
| 26 | + /// </summary> |
| 27 | + [DataMember(Name = "overall_cardinality")] |
| 28 | + IOverallCardinality OverallCardinality { get; set; } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Estimates of the highest cardinality in a single bucket that will be observed for influencer |
| 32 | + /// fields over the time period that the job analyzes data. To produce a good answer, values must |
| 33 | + /// be provided for all influencer fields. It does not matter if values are provided for fields |
| 34 | + /// that are not listed as influencers. If there are no influencers then max_bucket_cardinality |
| 35 | + /// can be omitted from the request. |
| 36 | + /// </summary> |
| 37 | + [DataMember(Name = "max_bucket_cardinality")] |
| 38 | + IMaxBucketCardinality MaxBucketCardinality { get; set; } |
| 39 | + } |
| 40 | + |
| 41 | + public partial class EstimateModelMemoryRequest |
| 42 | + { |
| 43 | + /// <inheritdoc /> |
| 44 | + public IAnalysisConfig AnalysisConfig { get; set; } |
| 45 | + |
| 46 | + /// <inheritdoc /> |
| 47 | + public IOverallCardinality OverallCardinality { get; set; } |
| 48 | + |
| 49 | + /// <inheritdoc /> |
| 50 | + public IMaxBucketCardinality MaxBucketCardinality { get; set; } |
| 51 | + } |
| 52 | + |
| 53 | + public partial class EstimateModelMemoryDescriptor<TDocument> where TDocument : class |
| 54 | + { |
| 55 | + IAnalysisConfig IEstimateModelMemoryRequest.AnalysisConfig { get; set; } |
| 56 | + IOverallCardinality IEstimateModelMemoryRequest.OverallCardinality { get; set; } |
| 57 | + IMaxBucketCardinality IEstimateModelMemoryRequest.MaxBucketCardinality { get; set; } |
| 58 | + |
| 59 | + /// <inheritdoc /> |
| 60 | + public EstimateModelMemoryDescriptor<TDocument> AnalysisConfig(Func<AnalysisConfigDescriptor<TDocument>, IAnalysisConfig> selector) => |
| 61 | + Assign(selector, (a, v) => a.AnalysisConfig = v?.Invoke(new AnalysisConfigDescriptor<TDocument>())); |
| 62 | + |
| 63 | + /// <inheritdoc /> |
| 64 | + public EstimateModelMemoryDescriptor<TDocument> OverallCardinality(Func<OverallCardinalityDescriptor<TDocument>, IPromise<IOverallCardinality>> analyzerSelector) => |
| 65 | + Assign(analyzerSelector, (a, v) => a.OverallCardinality = v?.Invoke(new OverallCardinalityDescriptor<TDocument>())?.Value); |
| 66 | + |
| 67 | + /// <inheritdoc /> |
| 68 | + public EstimateModelMemoryDescriptor<TDocument> MaxBucketCardinality(Func<MaxBucketCardinalityDescriptor<TDocument>, IPromise<IMaxBucketCardinality>> analyzerSelector) => |
| 69 | + Assign(analyzerSelector, (a, v) => a.MaxBucketCardinality = v?.Invoke(new MaxBucketCardinalityDescriptor<TDocument>())?.Value); |
| 70 | + } |
| 71 | + |
| 72 | + [JsonFormatter(typeof(VerbatimDictionaryKeysFormatter<OverallCardinality, IOverallCardinality, Field, long>))] |
| 73 | + public interface IOverallCardinality : IIsADictionary<Field, long> { } |
| 74 | + |
| 75 | + public class OverallCardinality : IsADictionaryBase<Field, long>, IOverallCardinality |
| 76 | + { |
| 77 | + public OverallCardinality() { } |
| 78 | + |
| 79 | + public OverallCardinality(IDictionary<Field, long> container) : base(container) { } |
| 80 | + |
| 81 | + public void Add(Field field, long cardinality) => BackingDictionary.Add(field, cardinality); |
| 82 | + } |
| 83 | + |
| 84 | + public class OverallCardinality<T> : OverallCardinality where T : class |
| 85 | + { |
| 86 | + public void Add<TValue>(Expression<Func<T, TValue>> field, long cardinality) => BackingDictionary.Add(field, cardinality); |
| 87 | + } |
| 88 | + |
| 89 | + public class OverallCardinalityDescriptor<T> : IsADictionaryDescriptorBase<OverallCardinalityDescriptor<T>, IOverallCardinality, Field, long> where T : class |
| 90 | + { |
| 91 | + public OverallCardinalityDescriptor() : base(new OverallCardinality()) { } |
| 92 | + |
| 93 | + public OverallCardinalityDescriptor<T> Field(Field field, long cardinality) => Assign(field, cardinality); |
| 94 | + |
| 95 | + public OverallCardinalityDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> field, long cardinality) => Assign(field, cardinality); |
| 96 | + } |
| 97 | + |
| 98 | + [JsonFormatter(typeof(VerbatimDictionaryKeysFormatter<MaxBucketCardinality, IMaxBucketCardinality, Field, long>))] |
| 99 | + public interface IMaxBucketCardinality : IIsADictionary<Field, long> { } |
| 100 | + |
| 101 | + public class MaxBucketCardinality : IsADictionaryBase<Field, long>, IMaxBucketCardinality |
| 102 | + { |
| 103 | + public MaxBucketCardinality() { } |
| 104 | + |
| 105 | + public MaxBucketCardinality(IDictionary<Field, long> container) : base(container) { } |
| 106 | + |
| 107 | + public MaxBucketCardinality(Dictionary<Field, long> container) : base(container) { } |
| 108 | + |
| 109 | + public void Add(Field field, long cardinality) => BackingDictionary.Add(field, cardinality); |
| 110 | + } |
| 111 | + |
| 112 | + public class MaxBucketCardinality<T> : MaxBucketCardinality where T : class |
| 113 | + { |
| 114 | + public void Add<TValue>(Expression<Func<T, TValue>> field, long cardinality) => BackingDictionary.Add(field, cardinality); |
| 115 | + } |
| 116 | + |
| 117 | + public class MaxBucketCardinalityDescriptor<T> : IsADictionaryDescriptorBase<MaxBucketCardinalityDescriptor<T>, IMaxBucketCardinality, Field, long> where T : class |
| 118 | + { |
| 119 | + public MaxBucketCardinalityDescriptor() : base(new MaxBucketCardinality()) { } |
| 120 | + |
| 121 | + public MaxBucketCardinalityDescriptor<T> Field(Field field, long cardinality) => Assign(field, cardinality); |
| 122 | + |
| 123 | + public MaxBucketCardinalityDescriptor<T> Field<TValue>(Expression<Func<T, TValue>> field, long cardinality) => Assign(field, cardinality); |
| 124 | + } |
| 125 | +} |
0 commit comments