|
32 | 32 | import java.util.Iterator; |
33 | 33 | import java.util.List; |
34 | 34 | import java.util.Random; |
35 | | -import org.apache.beam.fn.harness.Cache; |
36 | 35 | import org.apache.beam.fn.harness.Caches; |
37 | 36 | import org.apache.beam.model.fnexecution.v1.BeamFnApi.StateKey; |
38 | 37 | import org.apache.beam.sdk.coders.StringUtf8Coder; |
@@ -111,75 +110,6 @@ public void testReiteration() throws Exception { |
111 | 110 | assertEquals(expected, Lists.newArrayList(iterable)); |
112 | 111 | } |
113 | 112 |
|
114 | | - @Test |
115 | | - public void testReiterationCached() throws Exception { |
116 | | - FakeBeamFnStateClient fakeBeamFnStateClient = |
117 | | - new FakeBeamFnStateClient( |
118 | | - StringUtf8Coder.of(), |
119 | | - ImmutableMap.of( |
120 | | - key("nonEmptySuffix"), asList("C", "D", "E", "F", "G", "H", "I", "J", "K"), |
121 | | - key("emptySuffix"), asList())); |
122 | | - |
123 | | - StateBackedIterable<String> iterable = |
124 | | - new StateBackedIterable<>( |
125 | | - Caches.eternal(), |
126 | | - fakeBeamFnStateClient, |
127 | | - "instruction", |
128 | | - key(suffixKey), |
129 | | - StringUtf8Coder.of(), |
130 | | - prefix); |
131 | | - |
132 | | - // Ensure that the load is lazy |
133 | | - assertEquals(0, fakeBeamFnStateClient.getCallCount()); |
134 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
135 | | - // We expect future reiterations to not perform any loads |
136 | | - int callCount = fakeBeamFnStateClient.getCallCount(); |
137 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
138 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
139 | | - assertEquals(callCount, fakeBeamFnStateClient.getCallCount()); |
140 | | - } |
141 | | - |
142 | | - @Test |
143 | | - public void testCacheKeyIsUnique() throws Exception { |
144 | | - // Share a cache for multiple iterables leads to distinct keys being used. |
145 | | - Cache cache = Caches.eternal(); |
146 | | - FakeBeamFnStateClient fakeBeamFnStateClient = |
147 | | - new FakeBeamFnStateClient( |
148 | | - StringUtf8Coder.of(), |
149 | | - ImmutableMap.of( |
150 | | - key("nonEmptySuffix"), asList("C", "D", "E", "F", "G", "H", "I", "J", "K"), |
151 | | - key("emptySuffix"), asList(), |
152 | | - key("otherIterable"), asList("Z"))); |
153 | | - |
154 | | - StateBackedIterable<String> otherIterable = |
155 | | - new StateBackedIterable<>( |
156 | | - cache, |
157 | | - fakeBeamFnStateClient, |
158 | | - "instruction", |
159 | | - key("otherIterable"), |
160 | | - StringUtf8Coder.of(), |
161 | | - Collections.emptyList()); |
162 | | - // Ensure that the load is lazy |
163 | | - assertEquals(0, fakeBeamFnStateClient.getCallCount()); |
164 | | - assertEquals(asList("Z"), Lists.newArrayList(otherIterable)); |
165 | | - |
166 | | - StateBackedIterable<String> iterable = |
167 | | - new StateBackedIterable<>( |
168 | | - cache, |
169 | | - fakeBeamFnStateClient, |
170 | | - "instruction", |
171 | | - key(suffixKey), |
172 | | - StringUtf8Coder.of(), |
173 | | - prefix); |
174 | | - |
175 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
176 | | - // We expect future reiterations to not perform any loads |
177 | | - int callCount = fakeBeamFnStateClient.getCallCount(); |
178 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
179 | | - assertEquals(expected, Lists.newArrayList(iterable)); |
180 | | - assertEquals(callCount, fakeBeamFnStateClient.getCallCount()); |
181 | | - } |
182 | | - |
183 | 113 | @Test |
184 | 114 | public void testUsingInterleavedReiteration() throws Exception { |
185 | 115 | FakeBeamFnStateClient fakeBeamFnStateClient = |
|
0 commit comments