Skip to content

Commit 8189993

Browse files
committed
Add postingsInMemoryBytes to testShardFieldStats
1 parent 3292e00 commit 8189993

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,7 @@ public void testShardFieldStats() throws IOException {
18821882
assertThat(stats.numSegments(), equalTo(0));
18831883
assertThat(stats.totalFields(), equalTo(0));
18841884
assertThat(stats.fieldUsages(), equalTo(0L));
1885+
assertThat(stats.postingsInMemoryBytes(), equalTo(0L));
18851886
// index some documents
18861887
int numDocs = between(1, 10);
18871888
for (int i = 0; i < numDocs; i++) {
@@ -1901,6 +1902,9 @@ public void testShardFieldStats() throws IOException {
19011902
// _id(term), _source(0), _version(dv), _primary_term(dv), _seq_no(point,dv), f1(postings,norms),
19021903
// f1.keyword(term,dv), f2(postings,norms), f2.keyword(term,dv),
19031904
assertThat(stats.fieldUsages(), equalTo(13L));
1905+
// _id: 8, f1: 3, f1.keyword: 3, f2: 3, f2.keyword: 3
1906+
// (8 + 3 + 3 + 3 + 3) * 2 = 40
1907+
assertThat(stats.postingsInMemoryBytes(), equalTo(40L));
19041908
// don't re-compute on refresh without change
19051909
if (randomBoolean()) {
19061910
shard.refresh("test");
@@ -1948,13 +1952,20 @@ public void testShardFieldStats() throws IOException {
19481952
assertThat(stats.totalFields(), equalTo(21));
19491953
// first segment: 13, second segment: 13 + f3(postings,norms) + f3.keyword(term,dv), and __soft_deletes to previous segment
19501954
assertThat(stats.fieldUsages(), equalTo(31L));
1955+
// segment 1: 40 (see above)
1956+
// segment 2: _id: 8, f1: 3, f1.keyword: 3, f2: 3, f2.keyword: 3, f3: 6, f3.keyword: 6
1957+
// (8 + 3 + 3 + 3 + 3 + 6 + 6) * 2 q= 64
1958+
// 40 + 64 = 104
1959+
assertThat(stats.postingsInMemoryBytes(), equalTo(104L));
19511960
shard.forceMerge(new ForceMergeRequest().maxNumSegments(1).flush(true));
19521961
stats = shard.getShardFieldStats();
19531962
assertThat(stats.numSegments(), equalTo(1));
19541963
assertThat(stats.totalFields(), equalTo(12));
19551964
// _id(term), _source(0), _version(dv), _primary_term(dv), _seq_no(point,dv), f1(postings,norms),
19561965
// f1.keyword(term,dv), f2(postings,norms), f2.keyword(term,dv), f3(postings,norms), f3.keyword(term,dv), __soft_deletes
19571966
assertThat(stats.fieldUsages(), equalTo(18L));
1967+
// max(segment1: 40, segment2: 64) = 64
1968+
assertThat(stats.postingsInMemoryBytes(), equalTo(64L));
19581969
closeShards(shard);
19591970
}
19601971

0 commit comments

Comments
 (0)