Skip to content

Commit

Permalink
Fixed javadoc formatting in AggregateFunction.java AstDSL.java Functi…
Browse files Browse the repository at this point in the history
…on.java QualifiedName.java

Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Jul 31, 2023
1 parent 5609956 commit d4ad388
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 59 deletions.
82 changes: 45 additions & 37 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.dsl;

import java.util.Arrays;
Expand Down Expand Up @@ -62,7 +63,9 @@
import org.opensearch.sql.ast.tree.UnresolvedPlan;
import org.opensearch.sql.ast.tree.Values;

/** Class of static methods to create specific node instances. */
/**
* Class of static methods to create specific node instances.
*/
@UtilityClass
public class AstDSL {

Expand Down Expand Up @@ -129,9 +132,8 @@ public static UnresolvedPlan rename(UnresolvedPlan input, Map... maps) {

/**
* Initialize Values node by rows of literals.
*
* @param values rows in which each row is a list of literal values
* @return Values node
* @param values rows in which each row is a list of literal values
* @return Values node
*/
@SafeVarargs
public UnresolvedPlan values(List<Literal>... values) {
Expand Down Expand Up @@ -247,19 +249,27 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
}

/**
* CASE WHEN search_condition THEN result_expr [WHEN search_condition THEN result_expr] ... [ELSE
* result_expr] END
* CASE<br>
* WHEN search_condition THEN result_expr<br>
* [WHEN search_condition THEN result_expr] ...<br>
* [ELSE result_expr]<br>
* END
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, When... whenClauses) {
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
When... whenClauses) {
return caseWhen(null, elseClause, whenClauses);
}

/**
* CASE case_value_expr WHEN compare_expr THEN result_expr [WHEN compare_expr THEN result_expr]
* ... [ELSE result_expr] END
* CASE case_value_expr<br>
* WHEN compare_expr THEN result_expr<br>
* [WHEN compare_expr THEN result_expr] ...<br>
* [ELSE result_expr]<br>
* END
*/
public UnresolvedExpression caseWhen(
UnresolvedExpression caseValueExpr, UnresolvedExpression elseClause, When... whenClauses) {
public UnresolvedExpression caseWhen(UnresolvedExpression caseValueExpr,
UnresolvedExpression elseClause,
When... whenClauses) {
return new Case(caseValueExpr, Arrays.asList(whenClauses), elseClause);
}

Expand All @@ -271,20 +281,19 @@ public When when(UnresolvedExpression condition, UnresolvedExpression result) {
return new When(condition, result);
}

public UnresolvedExpression highlight(
UnresolvedExpression fieldName, java.util.Map<String, Literal> arguments) {
public UnresolvedExpression highlight(UnresolvedExpression fieldName,
java.util.Map<String, Literal> arguments) {
return new HighlightFunction(fieldName, arguments);
}

public UnresolvedExpression score(
UnresolvedExpression relevanceQuery, Literal relevanceFieldWeight) {
public UnresolvedExpression score(UnresolvedExpression relevanceQuery,
Literal relevanceFieldWeight) {
return new ScoreFunction(relevanceQuery, relevanceFieldWeight);
}

public UnresolvedExpression window(
UnresolvedExpression function,
List<UnresolvedExpression> partitionByList,
List<Pair<SortOption, UnresolvedExpression>> sortList) {
public UnresolvedExpression window(UnresolvedExpression function,
List<UnresolvedExpression> partitionByList,
List<Pair<SortOption, UnresolvedExpression>> sortList) {
return new WindowFunction(function, partitionByList, sortList);
}

Expand Down Expand Up @@ -319,10 +328,9 @@ public static UnresolvedExpression compare(
return new Compare(operator, left, right);
}

public static UnresolvedExpression between(
UnresolvedExpression value,
UnresolvedExpression lowerBound,
UnresolvedExpression upperBound) {
public static UnresolvedExpression between(UnresolvedExpression value,
UnresolvedExpression lowerBound,
UnresolvedExpression upperBound) {
return new Between(value, lowerBound, upperBound);
}

Expand Down Expand Up @@ -390,7 +398,9 @@ public static List<Argument> defaultFieldsArgs() {
return exprList(argument("exclude", booleanLiteral(false)));
}

/** Default Stats Command Args. */
/**
* Default Stats Command Args.
*/
public static List<Argument> defaultStatsArgs() {
return exprList(
argument("partitions", intLiteral(1)),
Expand All @@ -399,7 +409,9 @@ public static List<Argument> defaultStatsArgs() {
argument("dedupsplit", booleanLiteral(false)));
}

/** Default Dedup Command Args. */
/**
* Default Dedup Command Args.
*/
public static List<Argument> defaultDedupArgs() {
return exprList(
argument("number", intLiteral(1)),
Expand Down Expand Up @@ -435,12 +447,9 @@ public static List<Argument> defaultTopArgs() {
return exprList(argument("noOfResults", intLiteral(10)));
}

public static RareTopN rareTopN(
UnresolvedPlan input,
CommandType commandType,
List<Argument> noOfResults,
List<UnresolvedExpression> groupList,
Field... fields) {
public static RareTopN rareTopN(UnresolvedPlan input, CommandType commandType,
List<Argument> noOfResults, List<UnresolvedExpression> groupList,
Field... fields) {
return new RareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupList)
.attach(input);
}
Expand All @@ -449,12 +458,11 @@ public static Limit limit(UnresolvedPlan input, Integer limit, Integer offset) {
return new Limit(limit, offset).attach(input);
}

public static Parse parse(
UnresolvedPlan input,
ParseMethod parseMethod,
UnresolvedExpression sourceField,
Literal pattern,
java.util.Map<String, Literal> arguments) {
public static Parse parse(UnresolvedPlan input, ParseMethod parseMethod,
UnresolvedExpression sourceField,
Literal pattern,
java.util.Map<String, Literal> arguments) {
return new Parse(parseMethod, sourceField, pattern, arguments, input);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Collections;
Expand All @@ -16,8 +17,8 @@
import org.opensearch.sql.common.utils.StringUtils;

/**
* Expression node of aggregate functions. Params include aggregate function name (AVG, SUM, MAX
* etc.) and the field to aggregate.
* Expression node of aggregate functions.<br>
* Params include aggregate function name (AVG, SUM, MAX etc.) and the field to aggregate.
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand All @@ -26,16 +27,13 @@ public class AggregateFunction extends UnresolvedExpression {
private final String funcName;
private final UnresolvedExpression field;
private final List<UnresolvedExpression> argList;

@Setter
@Accessors(fluent = true)
private UnresolvedExpression condition;

private Boolean distinct = false;

/**
* Constructor.
*
* @param funcName function name.
* @param field {@link UnresolvedExpression}.
*/
Expand All @@ -47,7 +45,6 @@ public AggregateFunction(String funcName, UnresolvedExpression field) {

/**
* Constructor.
*
* @param funcName function name.
* @param field {@link UnresolvedExpression}.
* @param distinct whether distinct field is specified or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import java.util.Collections;
Expand All @@ -13,9 +14,10 @@
import lombok.RequiredArgsConstructor;
import org.opensearch.sql.ast.AbstractNodeVisitor;


/**
* Expression node of scalar function. Params include function name (@funcName) and function
* arguments (@funcArgs)
* Expression node of scalar function.<br>
* Params include function name (@funcName) and function arguments (@funcArgs)
*/
@Getter
@EqualsAndHashCode(callSuper = false)
Expand All @@ -36,8 +38,9 @@ public <R, C> R accept(AbstractNodeVisitor<R, C> nodeVisitor, C context) {

@Override
public String toString() {
return String.format(
"%s(%s)",
funcName, funcArgs.stream().map(Object::toString).collect(Collectors.joining(", ")));
return String.format("%s(%s)", funcName,
funcArgs.stream()
.map(Object::toString)
.collect(Collectors.joining(", ")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import static java.util.Objects.requireNonNull;
Expand All @@ -28,7 +29,9 @@ public QualifiedName(String name) {
this.parts = Collections.singletonList(name);
}

/** QualifiedName Constructor. */
/**
* QualifiedName Constructor.
*/
public QualifiedName(Iterable<String> parts) {
List<String> partsList = StreamSupport.stream(parts.spliterator(), false).collect(toList());
if (partsList.isEmpty()) {
Expand All @@ -37,7 +40,9 @@ public QualifiedName(Iterable<String> parts) {
this.parts = partsList;
}

/** Construct {@link QualifiedName} from list of string. */
/**
* Construct {@link QualifiedName} from list of string.
*/
public static QualifiedName of(String first, String... rest) {
requireNonNull(first);
ArrayList<String> parts = new ArrayList<>();
Expand All @@ -50,7 +55,9 @@ public static QualifiedName of(Iterable<String> parts) {
return new QualifiedName(parts);
}

/** Get Prefix of {@link QualifiedName}. */
/**
* Get Prefix of {@link QualifiedName}.
*/
public Optional<QualifiedName> getPrefix() {
if (parts.size() == 1) {
return Optional.empty();
Expand All @@ -64,8 +71,7 @@ public String getSuffix() {

/**
* Get first part of the qualified name.
*
* @return first part
* @return first part
*/
public Optional<String> first() {
if (parts.size() == 1) {
Expand All @@ -75,12 +81,17 @@ public Optional<String> first() {
}

/**
* Get rest parts of the qualified name. Assume that there must be remaining parts so caller is
* responsible for the check (first() or size() must be called first). For example: {@code
* QualifiedName name = ... Optional<String> first = name.first(); if (first.isPresent()) {
* name.rest() ... } }
*
* @return rest part(s)
* Get rest parts of the qualified name. Assume that there must be remaining parts
* so caller is responsible for the check (first() or size() must be called first).<br>
* For example:<br>
* {@code<br>
* &ensp; QualifiedName name = ...<br>
* &ensp; Optional<String> first = name.first();<br>
* &ensp; if (first.isPresent()) {<br>
* &emsp; name.rest() ...<br>
* &ensp; }<br>
* }
* @return rest part(s)
*/
public QualifiedName rest() {
return QualifiedName.of(parts.subList(1, parts.size()));
Expand Down

0 comments on commit d4ad388

Please sign in to comment.