@@ -114,51 +114,13 @@ public void testWriteRead() throws Exception {
114114 assertThat (row .getCells ().get (1 ).getValue ()).isEqualTo (largeValue );
115115 }
116116
117- static class AccumulatingObserver implements ResponseObserver <Row > {
118-
119- final List <Row > responses = Lists .newArrayList ();
120- final SettableApiFuture <Void > completionFuture = SettableApiFuture .create ();
121-
122- void awaitCompletion () throws Throwable {
123- try {
124- completionFuture .get (10 , TimeUnit .MINUTES );
125- } catch (ExecutionException e ) {
126- throw e .getCause ();
127- }
128- }
129-
130- @ Override
131- public void onStart (StreamController controller ) {}
132-
133- @ Override
134- public void onResponse (Row row ) {
135- responses .add (row );
136- }
137-
138- @ Override
139- public void onError (Throwable t ) {
140- completionFuture .setException (t );
141- }
142-
143- @ Override
144- public void onComplete () {
145- completionFuture .set (null );
146- }
147- }
148-
149117 @ Test
150- public void read () throws Throwable {
118+ public void testSkipLargeRow () throws Throwable {
151119 assume ()
152120 .withMessage ("Large row read errors are not supported by emulator" )
153121 .that (testEnvRule .env ())
154122 .isNotInstanceOf (EmulatorEnv .class );
155123
156- // TODO: remove this once skip large row for read is released
157- assume ()
158- .withMessage ("Skip large row for read is not released yet" )
159- .that (System .getProperty ("bigtable.testSkipLargeRowIntegrationTests" ))
160- .isEqualTo ("true" );
161-
162124 BigtableDataClient client = testEnvRule .env ().getDataClient ();
163125 String tableId = table .getId ();
164126 String familyId = this .familyId ;
@@ -202,12 +164,34 @@ public void read() throws Throwable {
202164 ImmutableList .<String >of (),
203165 ByteString .copyFromUtf8 ("my-value" ))));
204166
167+ Row expectedRow5 =
168+ Row .create (
169+ ByteString .copyFromUtf8 ("r5" ),
170+ ImmutableList .of (
171+ RowCell .create (
172+ familyId ,
173+ ByteString .copyFromUtf8 ("qualifier" ),
174+ timestampMicros ,
175+ ImmutableList .of (),
176+ ByteString .copyFromUtf8 ("my-value" ))));
177+
178+ Row expectedRow6 =
179+ Row .create (
180+ ByteString .copyFromUtf8 ("r6" ),
181+ ImmutableList .of (
182+ RowCell .create (
183+ familyId ,
184+ ByteString .copyFromUtf8 ("qualifier" ),
185+ timestampMicros ,
186+ ImmutableList .of (),
187+ ByteString .copyFromUtf8 ("my-value" ))));
188+
205189 // large row creation
206190 byte [] largeValueBytes = new byte [3 * 1024 * 1024 ];
207191 ByteString largeValue = ByteString .copyFrom (largeValueBytes );
208192
209193 for (int i = 0 ; i < 100 ; i ++) {
210- ByteString qualifier = ByteString .copyFromUtf8 ("qualifier1_" + "_" + String . valueOf ( i ) );
194+ ByteString qualifier = ByteString .copyFromUtf8 ("qualifier1_" + "_" + i );
211195 client .mutateRow (
212196 RowMutation .create (TableId .of (tableId ), "r2" ).setCell (familyId , qualifier , largeValue ));
213197 client .mutateRow (
@@ -222,7 +206,8 @@ public void read() throws Throwable {
222206 .call (
223207 Query .create (tableId )
224208 .range (ByteStringRange .unbounded ().startClosed ("r1" ).endOpen ("r3" ))))
225- .containsExactly (expectedRow1 );
209+ .containsExactly (expectedRow1 )
210+ .inOrder ();
226211
227212 assertThat (
228213 client
@@ -231,7 +216,8 @@ public void read() throws Throwable {
231216 .call (
232217 Query .create (tableId )
233218 .range (ByteStringRange .unbounded ().startClosed ("r1" ).endClosed ("r4" ))))
234- .containsExactly (expectedRow1 , expectedRow4 );
219+ .containsExactly (expectedRow1 , expectedRow4 )
220+ .inOrder ();
235221
236222 List <Row > emptyRows =
237223 client
@@ -267,7 +253,78 @@ public void read() throws Throwable {
267253 .call (
268254 Query .create (tableId )
269255 .range (ByteStringRange .unbounded ().startClosed ("r1" ).endClosed ("r4" ))))
270- .containsExactly (expectedRow1 , expectedRow4 );
256+ .containsExactly (expectedRow1 , expectedRow4 )
257+ .inOrder ();
258+
259+ assertThat (client .skipLargeRowsCallable ().all ().call (Query .create (tableId )))
260+ .containsExactly (expectedRow1 , expectedRow4 , expectedRow5 , expectedRow6 )
261+ .inOrder ();
262+
263+ assertThat (
264+ client
265+ .skipLargeRowsCallable ()
266+ .all ()
267+ .call (Query .create (tableId ).range (ByteStringRange .unbounded ().endClosed ("r4" ))))
268+ .containsExactly (expectedRow1 , expectedRow4 )
269+ .inOrder ();
270+
271+ assertThat (
272+ client
273+ .skipLargeRowsCallable ()
274+ .all ()
275+ .call (Query .create (tableId ).range (ByteStringRange .unbounded ().startClosed ("r1" ))))
276+ .containsExactly (expectedRow1 , expectedRow4 , expectedRow5 , expectedRow6 )
277+ .inOrder ();
278+
279+ assertThat (
280+ client
281+ .skipLargeRowsCallable ()
282+ .all ()
283+ .call (Query .create (tableId ).range (ByteStringRange .unbounded ().endOpen ("r4" ))))
284+ .containsExactly (expectedRow1 );
285+
286+ assertThat (
287+ client
288+ .skipLargeRowsCallable ()
289+ .all ()
290+ .call (Query .create (tableId ).range (ByteStringRange .unbounded ().startOpen ("r1" ))))
291+ .containsExactly (expectedRow4 , expectedRow5 , expectedRow6 );
292+
293+ assertThat (client .skipLargeRowsCallable ().all ().call (Query .create (tableId ).reversed (true )))
294+ .containsExactly (expectedRow6 , expectedRow5 , expectedRow4 , expectedRow1 )
295+ .inOrder ();
296+
297+ assertThat (
298+ client
299+ .skipLargeRowsCallable ()
300+ .all ()
301+ .call (
302+ Query .create (tableId )
303+ .range (ByteStringRange .unbounded ().endClosed ("r4" ))
304+ .reversed (true )))
305+ .containsExactly (expectedRow4 , expectedRow1 )
306+ .inOrder ();
307+
308+ assertThat (
309+ client
310+ .skipLargeRowsCallable ()
311+ .all ()
312+ .call (
313+ Query .create (tableId )
314+ .range (ByteStringRange .unbounded ().startClosed ("r1" ))
315+ .reversed (true )))
316+ .containsExactly (expectedRow6 , expectedRow5 , expectedRow4 , expectedRow1 )
317+ .inOrder ();
318+
319+ assertThat (
320+ client
321+ .skipLargeRowsCallable ()
322+ .all ()
323+ .call (
324+ Query .create (tableId )
325+ .range (ByteStringRange .unbounded ().startClosed ("r2" ).endOpen ("r3\0 " ))))
326+ .isEmpty ();
327+
271328 // async
272329 AccumulatingObserver observer = new AccumulatingObserver ();
273330 Query query = Query .create (tableId ).range ("r1" , "r3" );
@@ -280,5 +337,44 @@ public void read() throws Throwable {
280337 client .skipLargeRowsCallable ().call (query2 , observer2 );
281338 observer2 .awaitCompletion ();
282339 assertThat (observer2 .responses ).containsExactly (expectedRow1 , expectedRow4 );
340+
341+ AccumulatingObserver observer3 = new AccumulatingObserver ();
342+ Query query3 = Query .create (tableId );
343+ client .skipLargeRowsCallable ().call (query3 , observer3 );
344+ observer3 .awaitCompletion ();
345+ assertThat (observer3 .responses )
346+ .containsExactly (expectedRow1 , expectedRow4 , expectedRow5 , expectedRow6 );
347+ }
348+
349+ static class AccumulatingObserver implements ResponseObserver <Row > {
350+
351+ final List <Row > responses = Lists .newArrayList ();
352+ final SettableApiFuture <Void > completionFuture = SettableApiFuture .create ();
353+
354+ void awaitCompletion () throws Throwable {
355+ try {
356+ completionFuture .get (10 , TimeUnit .MINUTES );
357+ } catch (ExecutionException e ) {
358+ throw e .getCause ();
359+ }
360+ }
361+
362+ @ Override
363+ public void onStart (StreamController controller ) {}
364+
365+ @ Override
366+ public void onResponse (Row row ) {
367+ responses .add (row );
368+ }
369+
370+ @ Override
371+ public void onError (Throwable t ) {
372+ completionFuture .setException (t );
373+ }
374+
375+ @ Override
376+ public void onComplete () {
377+ completionFuture .set (null );
378+ }
283379 }
284380}
0 commit comments