Skip to content

Commit 999cdcb

Browse files
docs(core): add javadoc, excluding Expression (#778)
This change adds missing Javadoc to address build warnings in all classes except for io.substrait.expression.Expression. Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent 44f792b commit 999cdcb

17 files changed

Lines changed: 278 additions & 0 deletions

core/src/main/java/io/substrait/expression/EnumArg.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
*/
1515
@Value.Immutable
1616
public interface EnumArg extends FunctionArg {
17+
/** Constant representing an unspecified enum argument with no value. */
1718
EnumArg UNSPECIFIED_ENUM_ARG = builder().value(Optional.empty()).build();
1819

20+
/**
21+
* Returns the enum option value.
22+
*
23+
* @return the option value, if present
24+
*/
1925
Optional<String> value();
2026

2127
@Override
@@ -25,6 +31,15 @@ default <R, C extends VisitationContext, E extends Throwable> R accept(
2531
return fnArgVisitor.visitEnumArg(fnDef, argIdx, this, context);
2632
}
2733

34+
/**
35+
* Creates an EnumArg with the specified option value, validating it against the enum argument
36+
* definition.
37+
*
38+
* @param enumArg the enum argument definition
39+
* @param option the option value to use
40+
* @return a new EnumArg instance
41+
* @throws IllegalArgumentException if the option is not valid for the enum argument
42+
*/
2843
static EnumArg of(SimpleExtension.EnumArgument enumArg, String option) {
2944
if (!enumArg.options().contains(option)) {
3045
throw new IllegalArgumentException(
@@ -33,10 +48,21 @@ static EnumArg of(SimpleExtension.EnumArgument enumArg, String option) {
3348
return builder().value(Optional.of(option)).build();
3449
}
3550

51+
/**
52+
* Creates an EnumArg with the specified value without validation.
53+
*
54+
* @param value the enum value
55+
* @return a new EnumArg instance
56+
*/
3657
static EnumArg of(String value) {
3758
return builder().value(Optional.of(value)).build();
3859
}
3960

61+
/**
62+
* Creates a new builder for constructing an EnumArg.
63+
*
64+
* @return a new builder instance
65+
*/
4066
static ImmutableEnumArg.Builder builder() {
4167
return ImmutableEnumArg.builder();
4268
}

core/src/main/java/io/substrait/expression/FunctionArg.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
*/
1818
public interface FunctionArg {
1919

20+
/**
21+
* Accepts a visitor for this function argument.
22+
*
23+
* @param <R> the return type
24+
* @param <C> the visitation context type
25+
* @param <E> the exception type that may be thrown
26+
* @param fnDef the function definition
27+
* @param argIdx the argument index
28+
* @param fnArgVisitor the visitor
29+
* @param context the visitation context
30+
* @return the result of the visit
31+
* @throws E if the visit fails
32+
*/
2033
<R, C extends VisitationContext, E extends Throwable> R accept(
2134
SimpleExtension.Function fnDef, int argIdx, FuncArgVisitor<R, C, E> fnArgVisitor, C context)
2235
throws E;

core/src/main/java/io/substrait/extension/AbstractExtensionLookup.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22

33
import java.util.Map;
44

5+
/**
6+
* Abstract base class for {@link ExtensionLookup} implementations that use maps to resolve
7+
* extension references to their corresponding function and type anchors.
8+
*/
59
public abstract class AbstractExtensionLookup implements ExtensionLookup {
10+
/** Map of function reference IDs to their corresponding function anchors. */
611
protected final Map<Integer, SimpleExtension.FunctionAnchor> functionAnchorMap;
12+
13+
/** Map of type reference IDs to their corresponding type anchors. */
714
protected final Map<Integer, SimpleExtension.TypeAnchor> typeAnchorMap;
815

16+
/**
17+
* Constructs an AbstractExtensionLookup with the provided anchor maps.
18+
*
19+
* @param functionAnchorMap map of function reference IDs to function anchors
20+
* @param typeAnchorMap map of type reference IDs to type anchors
21+
*/
922
public AbstractExtensionLookup(
1023
Map<Integer, SimpleExtension.FunctionAnchor> functionAnchorMap,
1124
Map<Integer, SimpleExtension.TypeAnchor> typeAnchorMap) {

core/src/main/java/io/substrait/extension/ExtensionLookup.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,42 @@
66
* functions or types.
77
*/
88
public interface ExtensionLookup {
9+
/**
10+
* Resolves a scalar function reference to its corresponding function variant.
11+
*
12+
* @param reference the function reference ID
13+
* @param extensions the extension collection to search
14+
* @return the scalar function variant
15+
*/
916
SimpleExtension.ScalarFunctionVariant getScalarFunction(
1017
int reference, SimpleExtension.ExtensionCollection extensions);
1118

19+
/**
20+
* Resolves a window function reference to its corresponding function variant.
21+
*
22+
* @param reference the function reference ID
23+
* @param extensions the extension collection to search
24+
* @return the window function variant
25+
*/
1226
SimpleExtension.WindowFunctionVariant getWindowFunction(
1327
int reference, SimpleExtension.ExtensionCollection extensions);
1428

29+
/**
30+
* Resolves an aggregate function reference to its corresponding function variant.
31+
*
32+
* @param reference the function reference ID
33+
* @param extensions the extension collection to search
34+
* @return the aggregate function variant
35+
*/
1536
SimpleExtension.AggregateFunctionVariant getAggregateFunction(
1637
int reference, SimpleExtension.ExtensionCollection extensions);
1738

39+
/**
40+
* Resolves a type reference to its corresponding type.
41+
*
42+
* @param reference the type reference ID
43+
* @param extensions the extension collection to search
44+
* @return the type
45+
*/
1846
SimpleExtension.Type getType(int reference, SimpleExtension.ExtensionCollection extensions);
1947
}

core/src/main/java/io/substrait/relation/AbstractReadRel.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,32 @@
55
import io.substrait.type.Type;
66
import java.util.Optional;
77

8+
/**
9+
* Abstract base class for read relations that scan data from various sources. Provides common
10+
* functionality for schema definition and filtering.
11+
*/
812
public abstract class AbstractReadRel extends ZeroInputRel implements HasExtension {
913

14+
/**
15+
* Returns the initial schema of the data being read.
16+
*
17+
* @return the named struct defining the schema
18+
*/
1019
public abstract NamedStruct getInitialSchema();
1120

21+
/**
22+
* Returns an optional filter expression that must be applied during the read.
23+
*
24+
* @return the filter expression, if present
25+
*/
1226
public abstract Optional<Expression> getFilter();
1327

28+
/**
29+
* Returns an optional best-effort filter to apply during the read. If the source doesn't support
30+
* all operations, this filter may not be applied.
31+
*
32+
* @return the best-effort filter expression, if present
33+
*/
1434
public abstract Optional<Expression> getBestEffortFilter();
1535

1636
// TODO:

core/src/main/java/io/substrait/relation/AbstractRel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import io.substrait.util.Util;
55
import java.util.function.Supplier;
66

7+
/**
8+
* Abstract base class for relations that provides common functionality for deriving and caching
9+
* record types with optional remapping.
10+
*/
711
public abstract class AbstractRel implements Rel {
812

913
private Supplier<Type.Struct> recordType =
@@ -13,6 +17,11 @@ public abstract class AbstractRel implements Rel {
1317
return getRemap().map(r -> r.remap(s)).orElse(s);
1418
});
1519

20+
/**
21+
* Derives the record type for this relation before any remapping is applied.
22+
*
23+
* @return the derived record type
24+
*/
1625
protected abstract Type.Struct deriveRecordType();
1726

1827
@Override

core/src/main/java/io/substrait/relation/AbstractRelVisitor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,23 @@
1010
import io.substrait.relation.physical.SingleBucketExchange;
1111
import io.substrait.util.VisitationContext;
1212

13+
/**
14+
* Abstract base class for relation visitors that provides default implementations delegating all
15+
* visit methods to a fallback method.
16+
*
17+
* @param <O> the return type of visit methods
18+
* @param <C> the visitation context type
19+
* @param <E> the exception type that may be thrown
20+
*/
1321
public abstract class AbstractRelVisitor<O, C extends VisitationContext, E extends Exception>
1422
implements RelVisitor<O, C, E> {
23+
/**
24+
* Fallback method called by default implementations of all visit methods.
25+
*
26+
* @param rel the relation to visit
27+
* @param context the visitation context
28+
* @return the result of the visit
29+
*/
1530
public abstract O visitFallback(Rel rel, C context);
1631

1732
@Override

core/src/main/java/io/substrait/relation/Aggregate.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@
1212
import java.util.stream.Stream;
1313
import org.immutables.value.Value;
1414

15+
/**
16+
* Represents an aggregate relation that groups input rows and computes aggregate functions.
17+
* Supports multiple grouping sets and measures.
18+
*/
1519
@Value.Immutable
1620
public abstract class Aggregate extends SingleInputRel implements HasExtension {
1721

22+
/**
23+
* Returns the list of grouping sets for this aggregate.
24+
*
25+
* @return list of grouping sets
26+
*/
1827
public abstract List<Grouping> getGroupings();
1928

29+
/**
30+
* Returns the list of aggregate measures to compute.
31+
*
32+
* @return list of measures
33+
*/
2034
public abstract List<Measure> getMeasures();
2135

2236
@Override
@@ -71,26 +85,58 @@ public <O, C extends VisitationContext, E extends Exception> O accept(
7185
return visitor.visit(this, context);
7286
}
7387

88+
/** Represents a grouping set - a set of expressions to group by. */
7489
@Value.Immutable
7590
public abstract static class Grouping {
91+
/**
92+
* Returns the list of expressions in this grouping set.
93+
*
94+
* @return list of grouping expressions
95+
*/
7696
public abstract List<Expression> getExpressions();
7797

98+
/**
99+
* Creates a new builder for constructing a Grouping.
100+
*
101+
* @return a new builder instance
102+
*/
78103
public static ImmutableGrouping.Builder builder() {
79104
return ImmutableGrouping.builder();
80105
}
81106
}
82107

108+
/** Represents an aggregate measure - an aggregate function to compute. */
83109
@Value.Immutable
84110
public abstract static class Measure {
111+
/**
112+
* Returns the aggregate function invocation for this measure.
113+
*
114+
* @return the aggregate function
115+
*/
85116
public abstract AggregateFunctionInvocation getFunction();
86117

118+
/**
119+
* Returns an optional filter to apply before computing the aggregate.
120+
*
121+
* @return the pre-measure filter, if present
122+
*/
87123
public abstract Optional<Expression> getPreMeasureFilter();
88124

125+
/**
126+
* Creates a new builder for constructing a Measure.
127+
*
128+
* @return a new builder instance
129+
*/
89130
public static ImmutableMeasure.Builder builder() {
90131
return ImmutableMeasure.builder();
91132
}
92133
}
93134

135+
/**
136+
* Creates a new builder for constructing an Aggregate relation.
137+
*
138+
* @return a new builder instance
139+
*/
94140
public static ImmutableAggregate.Builder builder() {
95141
return ImmutableAggregate.builder();
96142
}

core/src/main/java/io/substrait/relation/AggregateFunctionProtoConverter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@ public class AggregateFunctionProtoConverter {
2222
private final TypeProtoConverter typeProtoConverter;
2323
private final ExtensionCollector functionCollector;
2424

25+
/**
26+
* Constructs a converter with the specified extension collector.
27+
*
28+
* @param functionCollector the extension collector for tracking function references
29+
*/
2530
public AggregateFunctionProtoConverter(ExtensionCollector functionCollector) {
2631
this.functionCollector = functionCollector;
2732
this.exprProtoConverter = new ExpressionProtoConverter(functionCollector, null);
2833
this.typeProtoConverter = new TypeProtoConverter(functionCollector);
2934
}
3035

36+
/**
37+
* Converts an aggregate measure to its protobuf representation.
38+
*
39+
* @param measure the aggregate measure to convert
40+
* @return the protobuf aggregate function
41+
*/
3142
public AggregateFunction toProto(Aggregate.Measure measure) {
3243
FunctionArg.FuncArgVisitor<FunctionArgument, EmptyVisitationContext, RuntimeException>
3344
argVisitor = FunctionArg.toProto(typeProtoConverter, exprProtoConverter);

core/src/main/java/io/substrait/relation/BiRel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6+
/** Abstract base class for binary relations that have exactly two input relations. */
67
public abstract class BiRel extends AbstractRel {
78

9+
/**
10+
* Returns the left input relation.
11+
*
12+
* @return the left input
13+
*/
814
public abstract Rel getLeft();
915

16+
/**
17+
* Returns the right input relation.
18+
*
19+
* @return the right input
20+
*/
1021
public abstract Rel getRight();
1122

1223
@Override

0 commit comments

Comments
 (0)