forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Estimate segment field usages (elastic#112760) (elastic#112777)
We have introduced a new memory estimation method in serverless, based on the number of segments and the fields within them. This new approach works well overall, but it still falls short in cases where most fields are used more than once - for example, in both doc_values and postings, or doc_values and points. This change exposes the total usage of fields in segments, allowing us to adjust the memory estimate for these cases.
- Loading branch information
Showing
5 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
server/src/main/java/org/elasticsearch/index/codec/FieldInfosWithUsages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.index.codec; | ||
|
||
import org.apache.lucene.index.DocValuesType; | ||
import org.apache.lucene.index.FieldInfo; | ||
import org.apache.lucene.index.FieldInfos; | ||
import org.apache.lucene.index.IndexOptions; | ||
|
||
public class FieldInfosWithUsages extends FieldInfos { | ||
private final int totalUsages; | ||
|
||
public FieldInfosWithUsages(FieldInfo[] infos) { | ||
super(infos); | ||
this.totalUsages = computeUsages(infos); | ||
} | ||
|
||
public static int computeUsages(FieldInfo[] infos) { | ||
int usages = 0; | ||
for (FieldInfo fi : infos) { | ||
if (fi.getIndexOptions() != IndexOptions.NONE) { | ||
usages++; | ||
} | ||
if (fi.hasNorms()) { | ||
usages++; | ||
} | ||
if (fi.getDocValuesType() != DocValuesType.NONE) { | ||
usages++; | ||
} | ||
if (fi.getPointDimensionCount() > 0) { | ||
usages++; | ||
} | ||
if (fi.getVectorDimension() > 0) { | ||
usages++; | ||
} | ||
} | ||
return usages; | ||
} | ||
|
||
public int getTotalUsages() { | ||
return totalUsages; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters