@@ -556,14 +556,14 @@ public void testIndexingPressure() throws Exception {
556
556
557
557
IndexingPressure .Coordinating coordinatingIndexingPressure = indexingPressure .getCoordinating ();
558
558
assertThat (coordinatingIndexingPressure , notNullValue ());
559
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc0Source ));
560
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc1Source ));
561
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc2Source ));
562
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc3Source ));
563
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc4Source ));
564
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc0UpdateSource ));
559
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc0Source ));
560
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc1Source ));
561
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc2Source ));
562
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc3Source ));
563
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc4Source ));
564
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc0UpdateSource ));
565
565
if (useLegacyFormat == false ) {
566
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc1UpdateSource ));
566
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc1UpdateSource ));
567
567
}
568
568
569
569
verify (coordinatingIndexingPressure , times (useLegacyFormat ? 6 : 7 )).increment (eq (0 ), longThat (l -> l > 0 ));
@@ -658,7 +658,7 @@ public void testIndexingPressureTripsOnInferenceRequestGeneration() throws Excep
658
658
659
659
IndexingPressure .Coordinating coordinatingIndexingPressure = indexingPressure .getCoordinating ();
660
660
assertThat (coordinatingIndexingPressure , notNullValue ());
661
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc1Source ));
661
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc1Source ));
662
662
verify (coordinatingIndexingPressure , times (1 )).increment (anyInt (), anyLong ());
663
663
664
664
// Verify that the coordinating indexing pressure is maintained through downstream action filters
@@ -697,7 +697,7 @@ public void testIndexingPressureTripsOnInferenceRequestGeneration() throws Excep
697
697
public void testIndexingPressureTripsOnInferenceResponseHandling () throws Exception {
698
698
final XContentBuilder doc1Source = IndexRequest .getXContentBuilder (XContentType .JSON , "sparse_field" , "bar" );
699
699
final InstrumentedIndexingPressure indexingPressure = new InstrumentedIndexingPressure (
700
- Settings .builder ().put (MAX_COORDINATING_BYTES .getKey (), (bytesUsed (doc1Source ) + 1 ) + "b" ).build ()
700
+ Settings .builder ().put (MAX_COORDINATING_BYTES .getKey (), (length (doc1Source ) + 1 ) + "b" ).build ()
701
701
);
702
702
703
703
final StaticModel sparseModel = StaticModel .createRandomInstance (TaskType .SPARSE_EMBEDDING );
@@ -738,7 +738,7 @@ public void testIndexingPressureTripsOnInferenceResponseHandling() throws Except
738
738
739
739
IndexingPressure .Coordinating coordinatingIndexingPressure = indexingPressure .getCoordinating ();
740
740
assertThat (coordinatingIndexingPressure , notNullValue ());
741
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc1Source ));
741
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc1Source ));
742
742
verify (coordinatingIndexingPressure ).increment (eq (0 ), longThat (l -> l > 0 ));
743
743
verify (coordinatingIndexingPressure , times (2 )).increment (anyInt (), anyLong ());
744
744
@@ -798,14 +798,14 @@ public void testIndexingPressurePartialFailure() throws Exception {
798
798
);
799
799
XContentBuilder builder = XContentFactory .jsonBuilder ();
800
800
semanticTextField .toXContent (builder , EMPTY_PARAMS );
801
- return bytesUsed (builder );
801
+ return length (builder );
802
802
};
803
803
804
804
final InstrumentedIndexingPressure indexingPressure = new InstrumentedIndexingPressure (
805
805
Settings .builder ()
806
806
.put (
807
807
MAX_COORDINATING_BYTES .getKey (),
808
- (bytesUsed (doc1Source ) + bytesUsed (doc2Source ) + estimateInferenceResultsBytes .apply (List .of ("bar" ), barEmbedding )
808
+ (length (doc1Source ) + length (doc2Source ) + estimateInferenceResultsBytes .apply (List .of ("bar" ), barEmbedding )
809
809
+ (estimateInferenceResultsBytes .apply (List .of ("bazzz" ), bazzzEmbedding ) / 2 )) + "b"
810
810
)
811
811
.build ()
@@ -847,8 +847,8 @@ public void testIndexingPressurePartialFailure() throws Exception {
847
847
848
848
IndexingPressure .Coordinating coordinatingIndexingPressure = indexingPressure .getCoordinating ();
849
849
assertThat (coordinatingIndexingPressure , notNullValue ());
850
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc1Source ));
851
- verify (coordinatingIndexingPressure ).increment (1 , bytesUsed (doc2Source ));
850
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc1Source ));
851
+ verify (coordinatingIndexingPressure ).increment (1 , length (doc2Source ));
852
852
verify (coordinatingIndexingPressure , times (2 )).increment (eq (0 ), longThat (l -> l > 0 ));
853
853
verify (coordinatingIndexingPressure , times (4 )).increment (anyInt (), anyLong ());
854
854
@@ -1053,8 +1053,8 @@ private static BulkItemRequest[] randomBulkItemRequest(
1053
1053
new BulkItemRequest (requestId , new IndexRequest ("index" ).source (expectedDocMap , requestContentType )) };
1054
1054
}
1055
1055
1056
- private static long bytesUsed (XContentBuilder builder ) {
1057
- return BytesReference .bytes (builder ).ramBytesUsed ();
1056
+ private static long length (XContentBuilder builder ) {
1057
+ return BytesReference .bytes (builder ).length ();
1058
1058
}
1059
1059
1060
1060
@ SuppressWarnings ({ "unchecked" })
0 commit comments