Skip to content

Commit

Permalink
Revert "Statically init typeActionMap in `OpenSearchExprValueFactor…
Browse files Browse the repository at this point in the history
…y`. (#310) (opensearch-project#1897)"

This reverts commit c8d42a7.
  • Loading branch information
MitchellGale committed Jul 27, 2023
1 parent b2d4872 commit 03127d0
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void extendTypeMapping(Map<String, OpenSearchDataType> typeMapping) {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

private static final Map<ExprType, BiFunction<Content, ExprType, ExprValue>> typeActionMap =
private final Map<ExprType, BiFunction<Content, ExprType, ExprValue>> typeActionMap =
new ImmutableMap.Builder<ExprType, BiFunction<Content, ExprType, ExprValue>>()
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Integer),
(c, dt) -> new ExprIntegerValue(c.intValue()))
Expand All @@ -126,12 +126,10 @@ public void extendTypeMapping(Map<String, OpenSearchDataType> typeMapping) {
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Boolean),
(c, dt) -> ExprBooleanValue.of(c.booleanValue()))
//Handles the creation of DATE, TIME & DATETIME
.put(OpenSearchDateType.of(TIME), OpenSearchExprValueFactory::createOpenSearchDateType)
.put(OpenSearchDateType.of(DATE), OpenSearchExprValueFactory::createOpenSearchDateType)
.put(OpenSearchDateType.of(TIMESTAMP),
OpenSearchExprValueFactory::createOpenSearchDateType)
.put(OpenSearchDateType.of(DATETIME),
OpenSearchExprValueFactory::createOpenSearchDateType)
.put(OpenSearchDateType.of(TIME), this::createOpenSearchDateType)
.put(OpenSearchDateType.of(DATE), this::createOpenSearchDateType)
.put(OpenSearchDateType.of(TIMESTAMP), this::createOpenSearchDateType)
.put(OpenSearchDateType.of(DATETIME), this::createOpenSearchDateType)
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Ip),
(c, dt) -> new OpenSearchExprIpValue(c.stringValue()))
.put(OpenSearchDataType.of(OpenSearchDataType.MappingType.GeoPoint),
Expand Down Expand Up @@ -224,7 +222,7 @@ private Optional<ExprType> type(String field) {
* @param dataType - field data type
* @return Parsed value
*/
private static ExprValue parseDateTimeString(String value, OpenSearchDateType dataType) {
private ExprValue parseDateTimeString(String value, OpenSearchDateType dataType) {
List<DateFormatter> formatters = dataType.getAllNamedFormatters();
formatters.addAll(dataType.getAllCustomFormatters());
ExprCoreType returnFormat = (ExprCoreType) dataType.getExprType();
Expand Down Expand Up @@ -264,7 +262,7 @@ private static ExprValue parseDateTimeString(String value, OpenSearchDateType da
"Construct %s from \"%s\" failed, unsupported format.", returnFormat, value));
}

private static ExprValue createOpenSearchDateType(Content value, ExprType type) {
private ExprValue createOpenSearchDateType(Content value, ExprType type) {
OpenSearchDateType dt = (OpenSearchDateType) type;
ExprType returnFormat = dt.getExprType();

Expand Down

0 comments on commit 03127d0

Please sign in to comment.