forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Refactor Literals serialization method
Since other classes besides intervals can be serialized as part of the Cursor, the getNamedWritables method should be moved from Intervals to a more generic class Literals. Relates to elastic#39973
- Loading branch information
Showing
3 changed files
with
40 additions
and
15 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
36 changes: 36 additions & 0 deletions
36
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/literal/Literals.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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.sql.expression.literal; | ||
|
||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* Utility class for common literal-related functions | ||
*/ | ||
public final class Literals { | ||
|
||
private Literals() { | ||
|
||
} | ||
|
||
/** | ||
* All custom types that are not serializable by default can be be serialized as a part of Cursor (i.e as constant in ConstantProcessor) | ||
* should implement NamedWriteables interface and register their de-serialization methods here. | ||
*/ | ||
public static Collection<? extends NamedWriteableRegistry.Entry> getNamedWriteables() { | ||
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>(); | ||
|
||
entries.add(new NamedWriteableRegistry.Entry(IntervalDayTime.class, IntervalDayTime.NAME, IntervalDayTime::new)); | ||
entries.add(new NamedWriteableRegistry.Entry(IntervalYearMonth.class, IntervalYearMonth.NAME, IntervalYearMonth::new)); | ||
|
||
return entries; | ||
} | ||
} |
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