Skip to content

Commit e399724

Browse files
l46kokcopybara-github
authored andcommitted
Remove deprecated builder methods for accepting unknown attribute patterns
PiperOrigin-RevId: 766801310
1 parent 7515167 commit e399724

File tree

4 files changed

+71
-129
lines changed

4 files changed

+71
-129
lines changed

runtime/src/main/java/dev/cel/runtime/async/AsyncProgramImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.google.common.util.concurrent.ListeningExecutorService;
3030
import javax.annotation.concurrent.ThreadSafe;
3131
import dev.cel.runtime.CelAttribute;
32-
import dev.cel.runtime.CelAttributePattern;
3332
import dev.cel.runtime.CelEvaluationException;
3433
import dev.cel.runtime.CelRuntime.Program;
3534
import dev.cel.runtime.CelUnknownSet;
@@ -60,17 +59,14 @@ final class AsyncProgramImpl implements CelAsyncRuntime.AsyncProgram {
6059
private final UnknownContext startingUnknownContext;
6160
private final Program program;
6261
private final ListeningExecutorService executor;
63-
private final ImmutableMap<CelAttributePattern, CelUnknownAttributeValueResolver> resolvers;
6462

6563
AsyncProgramImpl(
6664
Program program,
6765
ListeningExecutorService executor,
68-
ImmutableMap<CelAttributePattern, CelUnknownAttributeValueResolver> resolvers,
6966
int maxEvaluateIterations,
7067
UnknownContext startingUnknownContext) {
7168
this.program = program;
7269
this.executor = executor;
73-
this.resolvers = resolvers;
7470
this.maxEvaluateIterations = maxEvaluateIterations;
7571
// The following is populated from CelAsyncRuntime. The impl is immutable, thus safe to reuse as
7672
// a starting context.
@@ -86,12 +82,6 @@ private Optional<CelUnknownAttributeValueResolver> lookupResolver(
8682
}
8783
}
8884

89-
for (Map.Entry<CelAttributePattern, CelUnknownAttributeValueResolver> entry :
90-
resolvers.entrySet()) {
91-
if (entry.getKey().isPartialMatch(attribute)) {
92-
return Optional.of(entry.getValue());
93-
}
94-
}
9585
return Optional.empty();
9686
}
9787

runtime/src/main/java/dev/cel/runtime/async/CelAsyncRuntimeBuilder.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
package dev.cel.runtime.async;
1515

1616
import com.google.errorprone.annotations.CanIgnoreReturnValue;
17-
import dev.cel.runtime.CelAttributePattern;
1817
import dev.cel.runtime.CelRuntime;
19-
import dev.cel.runtime.async.CelAsyncRuntime.AsyncProgram;
2018
import java.util.concurrent.ExecutorService;
2119

2220
/** Builder interface for {@link CelAsyncRuntime}. */
@@ -27,27 +25,6 @@ public interface CelAsyncRuntimeBuilder {
2725
@CanIgnoreReturnValue
2826
CelAsyncRuntimeBuilder setRuntime(CelRuntime runtime);
2927

30-
/**
31-
* Add attributes that are declared as Unknown, without any resolver.
32-
*
33-
* @deprecated Use {@link AsyncProgram#evaluateToCompletion(CelResolvableAttributePattern...)}
34-
* instead to propagate the unknown attributes along with the resolvers into the program.
35-
*/
36-
@CanIgnoreReturnValue
37-
@Deprecated
38-
CelAsyncRuntimeBuilder addUnknownAttributePatterns(CelAttributePattern... attributes);
39-
40-
/**
41-
* Marks an attribute pattern as unknown and associates a resolver with it.
42-
*
43-
* @deprecated Use {@link AsyncProgram#evaluateToCompletion(CelResolvableAttributePattern...)}
44-
* instead to propagate the unknown attributes along with the resolvers into the program.
45-
*/
46-
@CanIgnoreReturnValue
47-
@Deprecated
48-
CelAsyncRuntimeBuilder addResolvableAttributePattern(
49-
CelAttributePattern attribute, CelUnknownAttributeValueResolver resolver);
50-
5128
/**
5229
* Set the maximum number of allowed evaluation passes.
5330
*

runtime/src/main/java/dev/cel/runtime/async/CelAsyncRuntimeImpl.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
package dev.cel.runtime.async;
1616

1717
import com.google.common.base.Preconditions;
18-
import com.google.common.collect.ImmutableMap;
19-
import com.google.common.collect.ImmutableSet;
18+
import com.google.common.collect.ImmutableList;
2019
import com.google.common.util.concurrent.ListeningExecutorService;
2120
import com.google.common.util.concurrent.MoreExecutors;
2221
import javax.annotation.concurrent.ThreadSafe;
2322
import dev.cel.common.CelAbstractSyntaxTree;
24-
import dev.cel.runtime.CelAttributePattern;
2523
import dev.cel.runtime.CelEvaluationException;
2624
import dev.cel.runtime.CelRuntime;
2725
import dev.cel.runtime.CelRuntimeFactory;
@@ -32,39 +30,31 @@
3230
/** Default {@link CelAsyncRuntime} runtime implementation. See {@link AsyncProgramImpl}. */
3331
@ThreadSafe
3432
final class CelAsyncRuntimeImpl implements CelAsyncRuntime {
35-
private final ImmutableMap<CelAttributePattern, CelUnknownAttributeValueResolver>
36-
unknownAttributeResolvers;
37-
private final ImmutableSet<CelAttributePattern> unknownAttributePatterns;
3833
private final CelRuntime runtime;
3934
private final ListeningExecutorService executorService;
4035
private final ThreadSafeCelVariableResolver variableResolver;
4136
private final int maxEvaluateIterations;
4237

4338
private CelAsyncRuntimeImpl(
44-
ImmutableMap<CelAttributePattern, CelUnknownAttributeValueResolver> unknownAttributeResolvers,
45-
ImmutableSet<CelAttributePattern> unknownAttributePatterns,
4639
ThreadSafeCelVariableResolver variableResolver,
4740
CelRuntime runtime,
4841
ListeningExecutorService executorService,
4942
int maxEvaluateIterations) {
50-
this.unknownAttributeResolvers = unknownAttributeResolvers;
51-
this.unknownAttributePatterns = unknownAttributePatterns;
5243
this.variableResolver = variableResolver;
5344
this.runtime = runtime;
5445
this.executorService = executorService;
5546
this.maxEvaluateIterations = maxEvaluateIterations;
5647
}
5748

5849
private UnknownContext newAsyncContext() {
59-
return UnknownContext.create(variableResolver, unknownAttributePatterns);
50+
return UnknownContext.create(variableResolver, ImmutableList.of());
6051
}
6152

6253
@Override
6354
public AsyncProgram createProgram(CelAbstractSyntaxTree ast) throws CelEvaluationException {
6455
return new AsyncProgramImpl(
6556
runtime.createProgram(ast),
6657
executorService,
67-
unknownAttributeResolvers,
6858
maxEvaluateIterations,
6959
newAsyncContext());
7060
}
@@ -76,17 +66,12 @@ static Builder newBuilder() {
7666
/** {@link CelAsyncRuntimeBuilder} implementation for {@link CelAsyncRuntimeImpl}. */
7767
private static final class Builder implements CelAsyncRuntimeBuilder {
7868
private CelRuntime runtime;
79-
private final ImmutableSet.Builder<CelAttributePattern> unknownAttributePatterns;
80-
private final ImmutableMap.Builder<CelAttributePattern, CelUnknownAttributeValueResolver>
81-
unknownAttributeResolvers;
8269
private ListeningExecutorService executorService;
8370
private Optional<ThreadSafeCelVariableResolver> variableResolver;
8471
private int maxEvaluateIterations;
8572

8673
private Builder() {
8774
runtime = CelRuntimeFactory.standardCelRuntimeBuilder().build();
88-
unknownAttributeResolvers = ImmutableMap.builder();
89-
unknownAttributePatterns = ImmutableSet.builder();
9075
variableResolver = Optional.empty();
9176
maxEvaluateIterations = DEFAULT_MAX_EVALUATE_ITERATIONS;
9277
}
@@ -97,20 +82,6 @@ public Builder setRuntime(CelRuntime runtime) {
9782
return this;
9883
}
9984

100-
@Override
101-
public Builder addUnknownAttributePatterns(CelAttributePattern... attributes) {
102-
unknownAttributePatterns.add(attributes);
103-
return this;
104-
}
105-
106-
@Override
107-
public Builder addResolvableAttributePattern(
108-
CelAttributePattern attribute, CelUnknownAttributeValueResolver resolver) {
109-
unknownAttributeResolvers.put(attribute, resolver);
110-
unknownAttributePatterns.add(attribute);
111-
return this;
112-
}
113-
11485
@Override
11586
public Builder setMaxEvaluateIterations(int n) {
11687
Preconditions.checkArgument(n > 0, "maxEvaluateIterations must be positive");
@@ -134,8 +105,6 @@ public Builder setExecutorService(ExecutorService executorService) {
134105
public CelAsyncRuntime build() {
135106
Preconditions.checkNotNull(executorService, "executorService must be specified.");
136107
return new CelAsyncRuntimeImpl(
137-
unknownAttributeResolvers.buildOrThrow(),
138-
unknownAttributePatterns.build(),
139108
variableResolver.orElse((unused) -> Optional.empty()),
140109
runtime,
141110
executorService,

0 commit comments

Comments
 (0)