@@ -102,30 +102,92 @@ public int hashCode() {
102102 }
103103 }
104104
105- public static final InferenceFeatureSetUsage EMPTY = new InferenceFeatureSetUsage (List .of ());
105+ public static class SemanticTextStats implements ToXContentObject , Writeable {
106+ private final Long totalFieldCount ;
107+ private final Long indexCount ;
108+ private final Long denseFieldCount ;
109+ private final Long sparseFieldCount ;
110+ private final Long denseInferenceIdCount ;
111+ private final Long sparseInferenceIdCount ;
112+
113+ public SemanticTextStats (
114+ Long totalFieldCount ,
115+ Long indexCount ,
116+ Long sparseFieldCount ,
117+ Long denseFieldCount ,
118+ Long denseInferenceIdCount ,
119+ Long sparseInferenceIdCount
120+ ) {
121+ this .totalFieldCount = totalFieldCount ;
122+ this .indexCount = indexCount ;
123+ this .sparseFieldCount = sparseFieldCount ;
124+ this .denseFieldCount = denseFieldCount ;
125+ this .denseInferenceIdCount = denseInferenceIdCount ;
126+ this .sparseInferenceIdCount = sparseInferenceIdCount ;
127+ }
128+
129+ public SemanticTextStats (StreamInput in ) throws IOException {
130+ this .totalFieldCount = in .readLong ();
131+ this .indexCount = in .readLong ();
132+ this .denseFieldCount = in .readLong ();
133+ this .denseInferenceIdCount = in .readLong ();
134+ this .sparseInferenceIdCount = in .readLong ();
135+ this .sparseFieldCount = in .readLong ();
136+ }
137+
138+ @ Override
139+ public void writeTo (StreamOutput out ) throws IOException {
140+ out .writeLong (totalFieldCount );
141+ out .writeLong (indexCount );
142+ out .writeLong (denseFieldCount );
143+ out .writeLong (denseInferenceIdCount );
144+ out .writeLong (sparseInferenceIdCount );
145+ out .writeLong (sparseFieldCount );
146+ }
147+
148+ @ Override
149+ public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
150+ builder .startObject ();
151+ builder .field ("total_fields" , totalFieldCount );
152+ builder .field ("indices" , indexCount );
153+ builder .field ("dense_fields" , denseFieldCount );
154+ builder .field ("dense_inference_ids" , denseInferenceIdCount );
155+ builder .field ("sparse_fields" , sparseFieldCount );
156+ builder .field ("sparse_inference_ids" , sparseInferenceIdCount );
157+ builder .endObject ();
158+ return builder ;
159+ }
160+ }
161+
162+ public static final InferenceFeatureSetUsage EMPTY = new InferenceFeatureSetUsage (List .of (), null );
106163
107164 private final Collection <ModelStats > modelStats ;
165+ private final SemanticTextStats semanticTextStats ;
108166
109- public InferenceFeatureSetUsage (Collection <ModelStats > modelStats ) {
167+ public InferenceFeatureSetUsage (Collection <ModelStats > modelStats , SemanticTextStats semanticTextStats ) {
110168 super (XPackField .INFERENCE , true , true );
111169 this .modelStats = modelStats ;
170+ this .semanticTextStats = semanticTextStats ;
112171 }
113172
114173 public InferenceFeatureSetUsage (StreamInput in ) throws IOException {
115174 super (in );
116175 this .modelStats = in .readCollectionAsList (ModelStats ::new );
176+ this .semanticTextStats = new SemanticTextStats (in );
117177 }
118178
119179 @ Override
120180 protected void innerXContent (XContentBuilder builder , Params params ) throws IOException {
121181 super .innerXContent (builder , params );
122182 builder .xContentList ("models" , modelStats );
183+ builder .field ("semantic_text" , semanticTextStats );
123184 }
124185
125186 @ Override
126187 public void writeTo (StreamOutput out ) throws IOException {
127188 super .writeTo (out );
128189 out .writeCollection (modelStats );
190+ semanticTextStats .writeTo (out );
129191 }
130192
131193 @ Override
@@ -137,11 +199,11 @@ public TransportVersion getMinimalSupportedVersion() {
137199 public boolean equals (Object o ) {
138200 if (o == null || getClass () != o .getClass ()) return false ;
139201 InferenceFeatureSetUsage that = (InferenceFeatureSetUsage ) o ;
140- return Objects .equals (modelStats , that .modelStats );
202+ return Objects .equals (modelStats , that .modelStats ) && Objects . equals ( semanticTextStats , that . semanticTextStats ) ;
141203 }
142204
143205 @ Override
144206 public int hashCode () {
145- return Objects .hashCode (modelStats );
207+ return Objects .hash (modelStats , semanticTextStats );
146208 }
147209}
0 commit comments