|
53 | 53 | import org.apache.beam.sdk.values.TypeDescriptor; |
54 | 54 | import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Predicates; |
55 | 55 | import org.checkerframework.checker.nullness.qual.Nullable; |
| 56 | +import org.checkerframework.dataflow.qual.Pure; |
56 | 57 |
|
57 | 58 | /** |
58 | 59 | * Describes the signature of a {@link DoFn}, in particular, which features it uses, which extra |
|
67 | 68 | }) |
68 | 69 | public abstract class DoFnSignature { |
69 | 70 | /** Class of the original {@link DoFn} from which this signature was produced. */ |
| 71 | + @Pure |
70 | 72 | public abstract Class<? extends DoFn<?, ?>> fnClass(); |
71 | 73 |
|
72 | 74 | /** Whether this {@link DoFn} does a bounded amount of work per element. */ |
| 75 | + @Pure |
73 | 76 | public abstract PCollection.IsBounded isBoundedPerElement(); |
74 | 77 |
|
75 | 78 | /** Details about this {@link DoFn}'s {@link DoFn.ProcessElement} method. */ |
| 79 | + @Pure |
76 | 80 | public abstract ProcessElementMethod processElement(); |
77 | 81 |
|
78 | 82 | /** Details about the state cells that this {@link DoFn} declares. Immutable. */ |
| 83 | + @Pure |
79 | 84 | public abstract Map<String, StateDeclaration> stateDeclarations(); |
80 | 85 |
|
81 | 86 | /** Details about this {@link DoFn}'s {@link DoFn.StartBundle} method. */ |
| 87 | + @Pure |
82 | 88 | public abstract @Nullable BundleMethod startBundle(); |
83 | 89 |
|
84 | 90 | /** Details about this {@link DoFn}'s {@link DoFn.FinishBundle} method. */ |
| 91 | + @Pure |
85 | 92 | public abstract @Nullable BundleMethod finishBundle(); |
86 | 93 |
|
87 | 94 | /** Details about this {@link DoFn}'s {@link DoFn.Setup} method. */ |
| 95 | + @Pure |
88 | 96 | public abstract @Nullable LifecycleMethod setup(); |
89 | 97 |
|
90 | 98 | /** Details about this {@link DoFn}'s {@link DoFn.Teardown} method. */ |
| 99 | + @Pure |
91 | 100 | public abstract @Nullable LifecycleMethod teardown(); |
92 | 101 |
|
93 | 102 | /** Details about this {@link DoFn}'s {@link DoFn.OnWindowExpiration} method. */ |
| 103 | + @Pure |
94 | 104 | public abstract @Nullable OnWindowExpirationMethod onWindowExpiration(); |
95 | 105 |
|
96 | 106 | /** Timer declarations present on the {@link DoFn} class. Immutable. */ |
| 107 | + @Pure |
97 | 108 | public abstract Map<String, TimerDeclaration> timerDeclarations(); |
98 | 109 |
|
99 | 110 | /** TimerMap declarations present on the {@link DoFn} class. Immutable. */ |
| 111 | + @Pure |
100 | 112 | public abstract Map<String, TimerFamilyDeclaration> timerFamilyDeclarations(); |
101 | 113 |
|
102 | 114 | /** Field access declaration. */ |
| 115 | + @Pure |
103 | 116 | public abstract @Nullable Map<String, FieldAccessDeclaration> fieldAccessDeclarations(); |
104 | 117 |
|
105 | 118 | /** Details about this {@link DoFn}'s {@link DoFn.GetInitialRestriction} method. */ |
| 119 | + @Pure |
106 | 120 | public abstract @Nullable GetInitialRestrictionMethod getInitialRestriction(); |
107 | 121 |
|
108 | 122 | /** Details about this {@link DoFn}'s {@link DoFn.SplitRestriction} method. */ |
| 123 | + @Pure |
109 | 124 | public abstract @Nullable SplitRestrictionMethod splitRestriction(); |
110 | 125 |
|
111 | 126 | /** Details about this {@link DoFn}'s {@link TruncateRestriction} method. */ |
| 127 | + @Pure |
112 | 128 | public abstract @Nullable TruncateRestrictionMethod truncateRestriction(); |
113 | 129 |
|
114 | 130 | /** Details about this {@link DoFn}'s {@link DoFn.GetRestrictionCoder} method. */ |
| 131 | + @Pure |
115 | 132 | public abstract @Nullable GetRestrictionCoderMethod getRestrictionCoder(); |
116 | 133 |
|
117 | 134 | /** Details about this {@link DoFn}'s {@link DoFn.GetWatermarkEstimatorStateCoder} method. */ |
| 135 | + @Pure |
118 | 136 | public abstract @Nullable GetWatermarkEstimatorStateCoderMethod getWatermarkEstimatorStateCoder(); |
119 | 137 |
|
120 | 138 | /** Details about this {@link DoFn}'s {@link DoFn.GetInitialWatermarkEstimatorState} method. */ |
| 139 | + @Pure |
121 | 140 | public abstract @Nullable GetInitialWatermarkEstimatorStateMethod |
122 | 141 | getInitialWatermarkEstimatorState(); |
123 | 142 |
|
124 | 143 | /** Details about this {@link DoFn}'s {@link DoFn.NewWatermarkEstimator} method. */ |
| 144 | + @Pure |
125 | 145 | public abstract @Nullable NewWatermarkEstimatorMethod newWatermarkEstimator(); |
126 | 146 |
|
127 | 147 | /** Details about this {@link DoFn}'s {@link DoFn.NewTracker} method. */ |
| 148 | + @Pure |
128 | 149 | public abstract @Nullable NewTrackerMethod newTracker(); |
129 | 150 |
|
130 | 151 | /** Details about this {@link DoFn}'s {@link DoFn.GetSize} method. */ |
| 152 | + @Pure |
131 | 153 | public abstract @Nullable GetSizeMethod getSize(); |
132 | 154 |
|
133 | 155 | /** Details about this {@link DoFn}'s {@link DoFn.OnTimer} methods. */ |
| 156 | + @Pure |
134 | 157 | public abstract @Nullable Map<String, OnTimerMethod> onTimerMethods(); |
135 | 158 |
|
136 | 159 | /** Details about this {@link DoFn}'s {@link DoFn.OnTimerFamily} methods. */ |
| 160 | + @Pure |
137 | 161 | public abstract @Nullable Map<String, OnTimerFamilyMethod> onTimerFamilyMethods(); |
138 | 162 |
|
139 | 163 | /** @deprecated use {@link #usesState()}, it's cleaner */ |
140 | 164 | @Deprecated |
| 165 | + @Pure |
141 | 166 | public boolean isStateful() { |
142 | 167 | return stateDeclarations().size() > 0; |
143 | 168 | } |
144 | 169 |
|
145 | 170 | /** Whether the {@link DoFn} described by this signature uses state. */ |
| 171 | + @Pure |
146 | 172 | public boolean usesState() { |
147 | 173 | return stateDeclarations().size() > 0; |
148 | 174 | } |
149 | 175 |
|
150 | 176 | /** Whether the {@link DoFn} described by this signature uses timers. */ |
| 177 | + @Pure |
151 | 178 | public boolean usesTimers() { |
152 | 179 | return timerDeclarations().size() > 0 || timerFamilyDeclarations().size() > 0; |
153 | 180 | } |
154 | 181 |
|
| 182 | + @Pure |
155 | 183 | static Builder builder() { |
156 | 184 | return new AutoValue_DoFnSignature.Builder(); |
157 | 185 | } |
@@ -208,12 +236,14 @@ abstract Builder setFieldAccessDeclarations( |
208 | 236 |
|
209 | 237 | abstract Builder setOnTimerFamilyMethods(Map<String, OnTimerFamilyMethod> onTimerFamilyMethods); |
210 | 238 |
|
| 239 | + @Pure |
211 | 240 | abstract DoFnSignature build(); |
212 | 241 | } |
213 | 242 |
|
214 | 243 | /** A method delegated to an annotated method of an underlying {@link DoFn}. */ |
215 | 244 | public interface DoFnMethod { |
216 | 245 | /** The annotated method itself. */ |
| 246 | + @Pure |
217 | 247 | Method targetMethod(); |
218 | 248 | } |
219 | 249 |
|
|
0 commit comments