Currently, the aggregations framework uses instanceof operations in many places to figure out what type of values we are getting. For example:
if (indexFieldData instanceof IndexOrdinalsFieldData) {
dataSource = new ValuesSource.Bytes.WithOrdinals.FieldData((IndexOrdinalsFieldData) indexFieldData);
} else {
dataSource = new ValuesSource.Bytes.FieldData(indexFieldData);
}
(
|
if (indexFieldData instanceof IndexOrdinalsFieldData) { |
|
dataSource = new ValuesSource.Bytes.WithOrdinals.FieldData((IndexOrdinalsFieldData) indexFieldData); |
|
} else { |
|
dataSource = new ValuesSource.Bytes.FieldData(indexFieldData); |
|
} |
)
As part of our effort to get away from hard coding type information in the core aggregations framework, we'd like to explore replacing these with predicates on the Field Data classes. For example, the above case could use a hasOrdinals() predicate instead of the instanceof check.
Currently, the aggregations framework uses
instanceofoperations in many places to figure out what type of values we are getting. For example:(
elasticsearch/server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfig.java
Lines 353 to 357 in 4a66cfc
As part of our effort to get away from hard coding type information in the core aggregations framework, we'd like to explore replacing these with predicates on the Field Data classes. For example, the above case could use a
hasOrdinals()predicate instead of theinstanceofcheck.