From c8f790dd31412d4b8eddbb343e5406b9b2bfa726 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Fri, 28 Jul 2023 11:54:30 -0700 Subject: [PATCH] Fixing java doc comments. --- .../execution/StreamingQueryPlan.java | 7 +- .../pagination/CanPaginateVisitor.java | 25 +-- .../sql/expression/ExpressionNodeVisitor.java | 13 +- .../sql/expression/NamedExpression.java | 5 +- .../sql/expression/ReferenceExpression.java | 36 +++-- .../aggregation/AggregatorFunction.java | 11 +- .../expression/datetime/DateTimeFunction.java | 144 ++++++++++++------ .../arthmetic/ArithmeticFunction.java | 12 +- .../arthmetic/MathematicalFunction.java | 47 ++++-- .../predicate/BinaryPredicateOperator.java | 58 +++++-- .../predicate/UnaryPredicateOperator.java | 11 +- .../sql/expression/span/SpanExpression.java | 12 +- .../sql/expression/text/TextFunction.java | 22 ++- .../window/WindowFunctionExpression.java | 20 +-- .../window/frame/PeerRowsWindowFrame.java | 19 ++- .../expression/window/frame/WindowFrame.java | 15 +- 16 files changed, 319 insertions(+), 138 deletions(-) diff --git a/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java b/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java index 52348319c8..0ab95101ad 100644 --- a/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java +++ b/core/src/main/java/org/opensearch/sql/executor/execution/StreamingQueryPlan.java @@ -72,8 +72,11 @@ interface ExecutionStrategy { } /** - * execute task with fixed interval. if task run time < interval, trigger next task on next - * interval. if task run time >= interval, trigger next task immediately. + *
+   * execute task with fixed interval.
+   * if task run time < interval, trigger next task on next interval.
+   * if task run time >= interval, trigger next task immediately.
+   * 
*/ @RequiredArgsConstructor public static class IntervalTriggerExecution implements ExecutionStrategy { diff --git a/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java b/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java index c7ae350245..3ab32e77c2 100644 --- a/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java +++ b/core/src/main/java/org/opensearch/sql/executor/pagination/CanPaginateVisitor.java @@ -41,16 +41,21 @@ import org.opensearch.sql.expression.function.BuiltinFunctionName; /** - * Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache. If - * - *
plan.accept(new CanPaginateVisitor(...))
- * - * returns true, then PaginatedPlanCache.convertToCursor will succeed. Otherwise, it will - * fail. The purpose of this visitor is to activate legacy engine fallback mechanism. Currently, V2 - * engine does not support queries with: - aggregation (GROUP BY clause or aggregation functions - * like min/max) - in memory aggregation (window function) - LIMIT/OFFSET clause(s) - without FROM - * clause - JOIN - a subquery V2 also requires that the table being queried should be an OpenSearch - * index. See PaginatedPlanCache.canConvertToCursor for usage. + *
+ * Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache.
+ * If 
plan.accept(new CanPaginateVisitor(...))
returns true, + * then PaginatedPlanCache.convertToCursor will succeed. Otherwise, it will fail. + * The purpose of this visitor is to activate legacy engine fallback mechanism. + * Currently, V2 engine does not support queries with: + * - aggregation (GROUP BY clause or aggregation functions like min/max) + * - in memory aggregation (window function) + * - LIMIT/OFFSET clause(s) + * - without FROM clause + * - JOIN + * - a subquery + * V2 also requires that the table being queried should be an OpenSearch index. + * See PaginatedPlanCache.canConvertToCursor for usage. + *
*/ public class CanPaginateVisitor extends AbstractNodeVisitor { diff --git a/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java b/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java index 1f11f0805b..0c00b89e9b 100644 --- a/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java +++ b/core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java @@ -81,11 +81,14 @@ public T visitNamedAggregator(NamedAggregator node, C context) { return visitChildren(node, context); } - /** - * Call visitFunction() by default rather than visitChildren(). This makes CASE/WHEN able to be - * handled: 1) by visitFunction() if not overwritten: ex. FilterQueryBuilder 2) by - * visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer - */ + /** + * Call visitFunction() by default rather than visitChildren(). + * This makes CASE/WHEN able to be handled: + * *
    + * *
  1. by visitFunction() if not overwritten: ex. FilterQueryBuilder
  2. + * *
  3. by visitCase/When() otherwise if any special logic: ex. ExprReferenceOptimizer
  4. + * *
+ */ public T visitCase(CaseClause node, C context) { return visitFunction(node, context); } diff --git a/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java b/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java index febd468e72..03118311a9 100644 --- a/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java +++ b/core/src/main/java/org/opensearch/sql/expression/NamedExpression.java @@ -15,8 +15,9 @@ import org.opensearch.sql.expression.env.Environment; /** - * Named expression that represents expression with name. Please see more details in associated - * unresolved expression operator {@link org.opensearch.sql.ast.expression.Alias}. + * Named expression that represents expression with name.
+ * Please see more details in associated unresolved expression operator
+ * {@link org.opensearch.sql.ast.expression.Alias}. */ @AllArgsConstructor @EqualsAndHashCode diff --git a/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java b/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java index 67a916a786..cfb87940b4 100644 --- a/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java +++ b/core/src/main/java/org/opensearch/sql/expression/ReferenceExpression.java @@ -61,21 +61,39 @@ public String toString() { } /** - * Resolve the ExprValue from {@link ExprTupleValue} using paths. Considering the following sample - * data. { "name": "bob smith" "project.year": 1990, "project": { "year": "2020" } "address": { - * "state": "WA", "city": "seattle", "project.year": 1990 } "address.local": { "state": "WA", } } - * The paths could be 1. top level, e.g. "name", which will be resolved as "bob smith" 2. multiple - * paths, e.g. "name.address.state", which will be resolved as "WA" 3. special case, the "." is - * the path separator, but it is possible that the path include ".", for handling this use case, - * we define the resolve rule as bellow, e.g. "project.year" is resolved as 1990 instead of 2020. - * Note. This logic only applied top level none object field. e.g. "address.local.state" been - * resolved to Missing. but "address.project.year" could been resolved as 1990. + *
+   * Resolve the ExprValue from {@link ExprTupleValue} using paths.
+   * Considering the following sample data.
+   * {
+   *   "name": "bob smith"
+   *   "project.year": 1990,
+   *   "project": {
+   *     "year": "2020"
+   *   }
+   *   "address": {
+   *     "state": "WA",
+   *     "city": "seattle",
+   *     "project.year": 1990
+   *   }
+   *   "address.local": {
+   *     "state": "WA",
+   *   }
+   * }
+   * The paths could be
+   * 1. top level, e.g. "name", which will be resolved as "bob smith"
+   * 2. multiple paths, e.g. "name.address.state", which will be resolved as "WA"
+   * 3. special case, the "." is the path separator, but it is possible that the path include
+   * ".", for handling this use case, we define the resolve rule as bellow, e.g. "project.year" is
+   * resolved as 1990 instead of 2020. Note. This logic only applied top level none object field.
+   * e.g. "address.local.state" been resolved to Missing. but "address.project.year" could been
+   * resolved as 1990.
    *
    * 

Resolve Rule 1. Resolve the full name by combine the paths("x"."y"."z") as whole ("x.y.z"). * 2. Resolve the path recursively through ExprValue. * * @param value {@link ExprTupleValue}. * @return {@link ExprTupleValue}. + *

*/ public ExprValue resolve(ExprTupleValue value) { return resolve(value, paths); diff --git a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java index 944bb7b50f..62b9256cfd 100644 --- a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunction.java @@ -34,9 +34,14 @@ import org.opensearch.sql.expression.function.FunctionSignature; /** - * The definition of aggregator function avg, Accepts two numbers and produces a number. sum, - * Accepts two numbers and produces a number. max, Accepts two numbers and produces a number. min, - * Accepts two numbers and produces a number. count, Accepts two numbers and produces a number. + *
+ * The definition of aggregator function
+ * avg, Accepts two numbers and produces a number.
+ * sum, Accepts two numbers and produces a number.
+ * max, Accepts two numbers and produces a number.
+ * min, Accepts two numbers and produces a number.
+ * count, Accepts two numbers and produces a number.
+ * 
*/ @UtilityClass public class AggregatorFunction { diff --git a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java index 84c670cb1c..3549b231a4 100644 --- a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java @@ -98,8 +98,9 @@ import org.opensearch.sql.utils.DateTimeUtils; /** - * The definition of date and time functions. 1) have the clear interface for function define. 2) - * the implementation should rely on ExprValue. + * The definition of date and time functions. + * 1) have the clear interface for function define. + * 2) the implementation should rely on ExprValue. */ @UtilityClass @SuppressWarnings("unchecked") @@ -325,12 +326,17 @@ private FunctionResolver current_date() { } /** - * A common signature for `date_add` and `date_sub`. Specify a start date and add/subtract a - * temporal amount to/from the date. The return type depends on the date type and the interval - * unit. Detailed supported signatures: (DATE/DATETIME/TIMESTAMP/TIME, INTERVAL) -> DATETIME MySQL - * has these signatures too (DATE, INTERVAL) -> DATE // when interval has no time part (TIME, - * INTERVAL) -> TIME // when interval has no date part (STRING, INTERVAL) -> STRING // when - * argument has date or datetime string, // result has date or datetime depending on interval type + *
+   * A common signature for `date_add` and `date_sub`.
+   * Specify a start date and add/subtract a temporal amount to/from the date.
+   * The return type depends on the date type and the interval unit. Detailed supported signatures:
+   * (DATE/DATETIME/TIMESTAMP/TIME, INTERVAL) -> DATETIME
+   * MySQL has these signatures too
+   * (DATE, INTERVAL) -> DATE                                     // when interval has no time part
+   * (TIME, INTERVAL) -> TIME                                     // when interval has no date part
+   * (STRING, INTERVAL) -> STRING         // when argument has date or datetime string,
+   *                                      // result has date or datetime depending on interval type
+   * 
*/ private Stream> get_date_add_date_sub_signatures( SerializableTriFunction function) { @@ -344,8 +350,12 @@ private FunctionResolver current_date() { } /** - * A common signature for `adddate` and `subdate`. Adds/subtracts an integer number of days - * to/from the first argument. (DATE, LONG) -> DATE (TIME/DATETIME/TIMESTAMP, LONG) -> DATETIME + *
+   * A common signature for `adddate` and `subdate`.
+   * Adds/subtracts an integer number of days to/from the first argument.
+   * (DATE, LONG) -> DATE
+   * (TIME/DATETIME/TIMESTAMP, LONG) -> DATETIME
+   * 
*/ private Stream> get_adddate_subdate_signatures( SerializableTriFunction function) { @@ -367,11 +377,15 @@ private DefaultFunctionResolver adddate() { } /** - * Adds expr2 to expr1 and returns the result. (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME - * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME TODO: MySQL has these - * signatures too (STRING, STRING/TIME) -> STRING // second arg - string with time only (x, - * STRING) -> NULL // second arg - string with timestamp (x, STRING/DATE) -> x // second arg - - * string with date only + *
+   * Adds expr2 to expr1 and returns the result.
+   * (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
+   * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME
+   * TODO: MySQL has these signatures too
+   * (STRING, STRING/TIME) -> STRING               // second arg - string with time only
+   * (x, STRING) -> NULL                           // second arg - string with timestamp
+   * (x, STRING/DATE) -> x                         // second arg - string with date only
+   * 
*/ private DefaultFunctionResolver addtime() { return define( @@ -444,8 +458,12 @@ private DefaultFunctionResolver addtime() { } /** - * Converts date/time from a specified timezone to another specified timezone. The supported - * signatures: (DATETIME, STRING, STRING) -> DATETIME (STRING, STRING, STRING) -> DATETIME + *
+   * Converts date/time from a specified timezone to another specified timezone.
+   * The supported signatures:
+   * (DATETIME, STRING, STRING) -> DATETIME
+   * (STRING, STRING, STRING) -> DATETIME
+   * 
*/ private DefaultFunctionResolver convert_tz() { return define( @@ -465,8 +483,11 @@ private DefaultFunctionResolver convert_tz() { } /** - * Extracts the date part of a date and time value. Also to construct a date type. The supported - * signatures: STRING/DATE/DATETIME/TIMESTAMP -> DATE + *
+   * Extracts the date part of a date and time value.
+   * Also to construct a date type. The supported signatures:
+   * STRING/DATE/DATETIME/TIMESTAMP -> DATE
+   * 
*/ private DefaultFunctionResolver date() { return define( @@ -555,8 +576,12 @@ private DefaultFunctionResolver datediff() { } /** - * Specify a datetime with time zone field and a time zone to convert to. Returns a local date - * time. (STRING, STRING) -> DATETIME (STRING) -> DATETIME + *
+   * Specify a datetime with time zone field and a time zone to convert to.
+   * Returns a local date time.
+   * (STRING, STRING) -> DATETIME
+   * (STRING) -> DATETIME
+   * 
*/ private FunctionResolver datetime() { return define( @@ -847,11 +872,15 @@ private DefaultFunctionResolver subdate() { } /** - * Subtracts expr2 from expr1 and returns the result. (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME - * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME TODO: MySQL has these - * signatures too (STRING, STRING/TIME) -> STRING // second arg - string with time only (x, - * STRING) -> NULL // second arg - string with timestamp (x, STRING/DATE) -> x // second arg - - * string with date only + *
+   * Subtracts expr2 from expr1 and returns the result.
+   * (TIME, TIME/DATE/DATETIME/TIMESTAMP) -> TIME
+   * (DATE/DATETIME/TIMESTAMP, TIME/DATE/DATETIME/TIMESTAMP) -> DATETIME
+   * TODO: MySQL has these signatures too
+   * (STRING, STRING/TIME) -> STRING               // second arg - string with time only
+   * (x, STRING) -> NULL                           // second arg - string with timestamp
+   * (x, STRING/DATE) -> x                         // second arg - string with date only
+   * 
*/ private DefaultFunctionResolver subtime() { return define( @@ -954,11 +983,17 @@ private DefaultFunctionResolver time() { } /** - * Returns different between two times as a time. (TIME, TIME) -> TIME MySQL has these signatures - * too (DATE, DATE) -> TIME // result is > 24 hours (DATETIME, DATETIME) -> TIME // result is > 24 - * hours (TIMESTAMP, TIMESTAMP) -> TIME // result is > 24 hours (x, x) -> NULL // when args have - * different types (STRING, STRING) -> TIME // argument strings contain same types only (STRING, - * STRING) -> NULL // argument strings are different types + *
+   * Returns different between two times as a time.
+   * (TIME, TIME) -> TIME
+   * MySQL has these signatures too
+   * (DATE, DATE) -> TIME                      // result is > 24 hours
+   * (DATETIME, DATETIME) -> TIME              // result is > 24 hours
+   * (TIMESTAMP, TIMESTAMP) -> TIME            // result is > 24 hours
+   * (x, x) -> NULL                            // when args have different types
+   * (STRING, STRING) -> TIME                  // argument strings contain same types only
+   * (STRING, STRING) -> NULL                  // argument strings are different types
+   * 
*/ private DefaultFunctionResolver timediff() { return define( @@ -979,11 +1014,14 @@ private DefaultFunctionResolver time_to_sec() { } /** - * Extracts the timestamp of a date and time value. Input strings may contain a timestamp only in - * format 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]' STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP - * STRING/DATE/TIME/DATETIME/TIMESTAMP, STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP All types - * are converted to TIMESTAMP actually before the function call - it is responsibility of the - * automatic cast mechanism defined in `ExprCoreType` and performed by `TypeCastOperator`. + *
+   * Extracts the timestamp of a date and time value.
+   * Input strings may contain a timestamp only in format 'yyyy-MM-dd HH:mm:ss[.SSSSSSSSS]'
+   * STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP
+   * STRING/DATE/TIME/DATETIME/TIMESTAMP, STRING/DATE/TIME/DATETIME/TIMESTAMP -> TIMESTAMP
+   * All types are converted to TIMESTAMP actually before the function call - it is responsibility
+   * of the automatic cast mechanism defined in `ExprCoreType` and performed by `TypeCastOperator`.
+   * 
*/ private DefaultFunctionResolver timestamp() { return define( @@ -1221,9 +1259,15 @@ private DefaultFunctionResolver yearweek() { } /** - * Formats date according to format specifier. First argument is date, second is format. Detailed - * supported signatures: (STRING, STRING) -> STRING (DATE, STRING) -> STRING (DATETIME, STRING) -> - * STRING (TIME, STRING) -> STRING (TIMESTAMP, STRING) -> STRING + *
+   * Formats date according to format specifier. First argument is date, second is format.
+   * Detailed supported signatures:
+   * (STRING, STRING) -> STRING
+   * (DATE, STRING) -> STRING
+   * (DATETIME, STRING) -> STRING
+   * (TIME, STRING) -> STRING
+   * (TIMESTAMP, STRING) -> STRING
+   * 
*/ private DefaultFunctionResolver date_format() { return define( @@ -1302,9 +1346,15 @@ private ExprValue exprDateApplyInterval( } /** - * Formats date according to format specifier. First argument is time, second is format. Detailed - * supported signatures: (STRING, STRING) -> STRING (DATE, STRING) -> STRING (DATETIME, STRING) -> - * STRING (TIME, STRING) -> STRING (TIMESTAMP, STRING) -> STRING + *
+   * Formats date according to format specifier. First argument is time, second is format.
+   * Detailed supported signatures:
+   * (STRING, STRING) -> STRING
+   * (DATE, STRING) -> STRING
+   * (DATETIME, STRING) -> STRING
+   * (TIME, STRING) -> STRING
+   * (TIMESTAMP, STRING) -> STRING
+   * 
*/ private DefaultFunctionResolver time_format() { return define( @@ -1683,14 +1733,18 @@ private ExprValue exprLastDayToday(Clock clock) { } /** + *
    * Following MySQL, function receives arguments of type double and rounds them before use.
-   * Furthermore: - zero year interpreted as 2000 - negative year is not accepted - @dayOfYear
-   * should be greater than 1 - if @dayOfYear is greater than 365/366, calculation goes to the next
-   * year(s)
+   * Furthermore:
+   *  - zero year interpreted as 2000
+   *  - negative year is not accepted
+   *  - @dayOfYear should be greater than 1
+   *  - if @dayOfYear is greater than 365/366, calculation goes to the next year(s)
    *
    * @param yearExpr year
    * @param dayOfYearExp day of the @year, starting from 1
    * @return Date - ExprDateValue object with LocalDate
+   * 
*/ private ExprValue exprMakeDate(ExprValue yearExpr, ExprValue dayOfYearExp) { var year = Math.round(yearExpr.doubleValue()); diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java index 3969b5310e..d58181b0a7 100644 --- a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java @@ -29,10 +29,14 @@ import org.opensearch.sql.expression.function.FunctionName; /** - * The definition of arithmetic function add, Accepts two numbers and produces a number. subtract, - * Accepts two numbers and produces a number. multiply, Accepts two numbers and produces a number. - * divide, Accepts two numbers and produces a number. module, Accepts two numbers and produces a - * number. + *
+ * The definition of arithmetic function
+ * add, Accepts two numbers and produces a number.
+ * subtract, Accepts two numbers and produces a number.
+ * multiply, Accepts two numbers and produces a number.
+ * divide, Accepts two numbers and produces a number.
+ * module, Accepts two numbers and produces a number.
+ * 
*/ @UtilityClass public class ArithmeticFunction { diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java index 21a348504e..6c1971638c 100644 --- a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java @@ -151,9 +151,13 @@ private static DefaultFunctionResolver ceiling() { } /** - * Definition of conv(x, a, b) function. Convert number x from base a to base b The supported - * signature of floor function is (STRING, INTEGER, INTEGER) -> STRING (INTEGER, INTEGER, INTEGER) - * -> STRING + *
+   * Definition of conv(x, a, b) function.
+   * Convert number x from base a to base b
+   * The supported signature of floor function is
+   * (STRING, INTEGER, INTEGER) -> STRING
+   * (INTEGER, INTEGER, INTEGER) -> STRING
+   * 
*/ private static DefaultFunctionResolver conv() { return define( @@ -396,9 +400,15 @@ private static DefaultFunctionResolver pi() { } /** - * Definition of pow(x, y)/power(x, y) function. Calculate the value of x raised to the power of y - * The supported signature of pow/power function is (INTEGER, INTEGER) -> DOUBLE (LONG, LONG) -> - * DOUBLE (FLOAT, FLOAT) -> DOUBLE (DOUBLE, DOUBLE) -> DOUBLE + *
+   * Definition of pow(x, y)/power(x, y) function.
+   * Calculate the value of x raised to the power of y
+   * The supported signature of pow/power function is
+   * (INTEGER, INTEGER) -> DOUBLE
+   * (LONG, LONG) -> DOUBLE
+   * (FLOAT, FLOAT) -> DOUBLE
+   * (DOUBLE, DOUBLE) -> DOUBLE
+   * 
*/ private static DefaultFunctionResolver pow() { return define(BuiltinFunctionName.POW.getName(), powerFunctionImpl()); @@ -478,10 +488,15 @@ private static DefaultFunctionResolver rint() { } /** - * Definition of round(x)/round(x, d) function. Rounds the argument x to d decimal places, d - * defaults to 0 if not specified. The supported signature of round function is (x: INTEGER [, y: - * INTEGER]) -> INTEGER (x: LONG [, y: INTEGER]) -> LONG (x: FLOAT [, y: INTEGER]) -> FLOAT (x: - * DOUBLE [, y: INTEGER]) -> DOUBLE + *
+   * Definition of round(x)/round(x, d) function.
+   * Rounds the argument x to d decimal places, d defaults to 0 if not specified.
+   * The supported signature of round function is
+   * (x: INTEGER [, y: INTEGER]) -> INTEGER
+   * (x: LONG [, y: INTEGER]) -> LONG
+   * (x: FLOAT [, y: INTEGER]) -> FLOAT
+   * (x: DOUBLE [, y: INTEGER]) -> DOUBLE
+   * 
*/ private static DefaultFunctionResolver round() { return define( @@ -613,9 +628,15 @@ private static DefaultFunctionResolver cbrt() { } /** - * Definition of truncate(x, d) function. Returns the number x, truncated to d decimal places The - * supported signature of round function is (x: INTEGER, y: INTEGER) -> LONG (x: LONG, y: INTEGER) - * -> LONG (x: FLOAT, y: INTEGER) -> DOUBLE (x: DOUBLE, y: INTEGER) -> DOUBLE + *
+   * Definition of truncate(x, d) function.
+   * Returns the number x, truncated to d decimal places
+   * The supported signature of round function is
+   * (x: INTEGER, y: INTEGER) -> LONG
+   * (x: LONG, y: INTEGER) -> LONG
+   * (x: FLOAT, y: INTEGER) -> DOUBLE
+   * (x: DOUBLE, y: INTEGER) -> DOUBLE
+   * 
*/ private static DefaultFunctionResolver truncate() { return define( diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java index 042a4f3ad4..e88afb09b9 100644 --- a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java +++ b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperator.java @@ -29,10 +29,13 @@ import org.opensearch.sql.utils.OperatorUtils; /** - * The definition of binary predicate function and, Accepts two Boolean values and produces a - * Boolean. or, Accepts two Boolean values and produces a Boolean. xor, Accepts two Boolean values - * and produces a Boolean. equalTo, Compare the left expression and right expression and produces a - * Boolean. + *
+ * The definition of binary predicate function
+ * and, Accepts two Boolean values and produces a Boolean.
+ * or,  Accepts two Boolean values and produces a Boolean.
+ * xor, Accepts two Boolean values and produces a Boolean.
+ * equalTo, Compare the left expression and right expression and produces a Boolean.
+ * 
*/ @UtilityClass public class BinaryPredicateOperator { @@ -57,9 +60,20 @@ public static void register(BuiltinFunctionRepository repository) { } /** - * The and logic. A B A AND B TRUE TRUE TRUE TRUE FALSE FALSE TRUE NULL NULL TRUE MISSING MISSING - * FALSE FALSE FALSE FALSE NULL FALSE FALSE MISSING FALSE NULL NULL NULL NULL MISSING MISSING + *
+   * The and logic.
+   * A       B       A AND B
+   * TRUE    TRUE    TRUE
+   * TRUE    FALSE   FALSE
+   * TRUE    NULL    NULL
+   * TRUE    MISSING MISSING
+   * FALSE   FALSE   FALSE
+   * FALSE   NULL    FALSE
+   * FALSE   MISSING FALSE
+   * NULL    NULL    NULL
+   * NULL    MISSING MISSING
    * MISSING MISSING MISSING
+   * 
*/ private static Table andTable = new ImmutableTable.Builder() @@ -76,9 +90,20 @@ public static void register(BuiltinFunctionRepository repository) { .build(); /** - * The or logic. A B A AND B TRUE TRUE TRUE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE FALSE - * FALSE FALSE FALSE NULL NULL FALSE MISSING MISSING NULL NULL NULL NULL MISSING NULL MISSING - * MISSING MISSING + *
+   * The or logic.
+   * A       B       A AND B
+   * TRUE    TRUE    TRUE
+   * TRUE    FALSE   TRUE
+   * TRUE    NULL    TRUE
+   * TRUE    MISSING TRUE
+   * FALSE   FALSE   FALSE
+   * FALSE   NULL    NULL
+   * FALSE   MISSING MISSING
+   * NULL    NULL    NULL
+   * NULL    MISSING NULL
+   * MISSING MISSING MISSING
+   * 
*/ private static Table orTable = new ImmutableTable.Builder() @@ -95,9 +120,20 @@ public static void register(BuiltinFunctionRepository repository) { .build(); /** - * The xor logic. A B A AND B TRUE TRUE FALSE TRUE FALSE TRUE TRUE NULL TRUE TRUE MISSING TRUE - * FALSE FALSE FALSE FALSE NULL NULL FALSE MISSING MISSING NULL NULL NULL NULL MISSING NULL + *
+   * The xor logic.
+   * A       B       A AND B
+   * TRUE    TRUE    FALSE
+   * TRUE    FALSE   TRUE
+   * TRUE    NULL    TRUE
+   * TRUE    MISSING TRUE
+   * FALSE   FALSE   FALSE
+   * FALSE   NULL    NULL
+   * FALSE   MISSING MISSING
+   * NULL    NULL    NULL
+   * NULL    MISSING NULL
    * MISSING MISSING MISSING
+   * 
    */
   private static Table xorTable =
       new ImmutableTable.Builder()
diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
index dbea762ae1..2bc5b1bde2 100644
--- a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
+++ b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/UnaryPredicateOperator.java
@@ -48,7 +48,16 @@ private static DefaultFunctionResolver not() {
         FunctionDSL.impl(UnaryPredicateOperator::not, BOOLEAN, BOOLEAN));
   }
 
-  /** The not logic. A NOT A TRUE FALSE FALSE TRUE NULL NULL MISSING MISSING */
+  /**
+   * 
+   * The not logic.
+   * A       NOT A
+   * TRUE    FALSE
+   * FALSE   TRUE
+   * NULL    NULL
+   * MISSING MISSING
+   * 
+ */ public ExprValue not(ExprValue v) { if (v.isMissing() || v.isNull()) { return v; diff --git a/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java b/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java index a4db50944c..ea35c47ea7 100644 --- a/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java +++ b/core/src/main/java/org/opensearch/sql/expression/span/SpanExpression.java @@ -39,9 +39,15 @@ public ExprValue valueOf(Environment valueEnv) { } /** - * Return type follows the following table. FIELD VALUE RETURN_TYPE int/long integer int/long - * (field type) int/long double double float/double integer float/double (field type) float/double - * double float/double (field type) other any field type + *
+   * Return type follows the following table.
+   *  FIELD         VALUE     RETURN_TYPE
+   *  int/long      integer   int/long (field type)
+   *  int/long      double    double
+   *  float/double  integer   float/double (field type)
+   *  float/double  double    float/double (field type)
+   *  other         any       field type
+   * 
*/ @Override public ExprType type() { diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java index 1ba5854596..54d62ade64 100644 --- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java @@ -34,8 +34,11 @@ import org.opensearch.sql.expression.function.SerializableTriFunction; /** - * The definition of text functions. 1) have the clear interface for function define. 2) the - * implementation should rely on ExprValue. + *
+ * The definition of text functions.
+ * 1) have the clear interface for function define.
+ * 2) the implementation should rely on ExprValue.
+ * 
*/ @UtilityClass public class TextFunction { @@ -262,11 +265,16 @@ private DefaultFunctionResolver ascii() { } /** - * LOCATE(substr, str) returns the position of the first occurrence of substring substr in string - * str. LOCATE(substr, str, pos) returns the position of the first occurrence of substring substr - * in string str, starting at position pos. Returns 0 if substr is not in str. Returns NULL if any - * argument is NULL. Supports following signature: (STRING, STRING) -> INTEGER (STRING, STRING, - * INTEGER) -> INTEGER + *
+   * LOCATE(substr, str) returns the position of the first occurrence of substring substr
+   * in string str. LOCATE(substr, str, pos) returns the position of the first occurrence
+   * of substring substr in string str, starting at position pos.
+   * Returns 0 if substr is not in str.
+   * Returns NULL if any argument is NULL.
+   * Supports following signature:
+   * (STRING, STRING) -> INTEGER
+   * (STRING, STRING, INTEGER) -> INTEGER
+   * 
*/ private DefaultFunctionResolver locate() { return define( diff --git a/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java b/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java index f323494307..1b8d6beb70 100644 --- a/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java +++ b/core/src/main/java/org/opensearch/sql/expression/window/WindowFunctionExpression.java @@ -11,14 +11,16 @@ /** Window function abstraction. */ public interface WindowFunctionExpression extends Expression { - /** - * Create specific window frame based on window definition and what's current window function. For - * now two types of cumulative window frame is returned: 1. Ranking window functions: ignore frame - * definition and always operates on previous and current row. 2. Aggregate window functions: - * frame partition into peers and sliding window is not supported. - * - * @param definition window definition - * @return window frame - */ +/** + * Create specific window frame based on window definition and what's current window function. + * For now two types of cumulative window frame is returned: + *
    + *
  1. Ranking window functions: ignore frame definition and always operates on previous and current row.
  2. + *
  3. Aggregate window functions: frame partition into peers and sliding window is not supported
  4. + *
+ * + * @param definition window definition + * @return window frame + */ WindowFrame createWindowFrame(WindowDefinition definition); } diff --git a/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java b/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java index 0ec2042b1e..2c430ec7ed 100644 --- a/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java +++ b/core/src/main/java/org/opensearch/sql/expression/window/frame/PeerRowsWindowFrame.java @@ -72,14 +72,17 @@ public ExprValue current() { return peers.get(position); } - /** - * Preload all peer rows if last peer rows done. Note that when no more data in peeking iterator, - * there must be rows in frame (hasNext()=true), so no need to check it.hasNext() in this method. - * Load until: 1. Different peer found (row with different sort key) 2. Or new partition (row with - * different partition key) 3. Or no more rows - * - * @param it rows iterator - */ +/** + * Preload all peer rows if last peer rows done. Note that when no more data in peeking iterator, + * there must be rows in frame (hasNext()=true), so no need to check it.hasNext() in this method.
+ * Load until:
+ *
    + *
  1. Different peer found (row with different sort key)
  2. + *
  3. Or new partition (row with different partition key)
  4. + *
  5. Or no more rows
  6. + *
+ * @param TYPE_EQUAL rows iterator + */ @Override public void load(PeekingIterator it) { if (hasNext()) { diff --git a/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java b/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java index 85bc937969..0160240f34 100644 --- a/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java +++ b/core/src/main/java/org/opensearch/sql/expression/window/frame/WindowFrame.java @@ -13,12 +13,15 @@ import org.opensearch.sql.expression.env.Environment; /** - * Window frame that represents a subset of a window which is all data accessible to the window - * function when calculation. Basically there are 3 types of window frame: 1) Entire window frame - * that holds all data of the window 2) Cumulative window frame that accumulates one row by another - * 3) Sliding window frame that maintains a sliding window of fixed size Note that which type of - * window frame is used is determined by both window function itself and frame definition in a - * window definition. + * Window frame that represents a subset of a window which is all data accessible to + * the window function when calculation. Basically there are 3 types of window frame: + *
    + *
  1. Entire window frame that holds all data of the window
  2. + *
  3. Cumulative window frame that accumulates one row by another
  4. + *
  5. Sliding window frame that maintains a sliding window of fixed size
  6. + *
+ * Note that which type of window frame is used is determined by both window function itself + * and frame definition in a window definition. */ public interface WindowFrame extends Environment, Iterator> {