@Test public void adapt_oneRow() throws IOException { Result expectedResult = Result.create( ImmutableList.<Cell>of( new RowCell( Bytes.toBytes("row"), Bytes.toBytes("family"), Bytes.toBytes("q"), 10000L, Bytes.toBytes("value"), ImmutableList.<String>of()))); when(mockBigtableResultScanner.next()).thenReturn(expectedResult); ResultScanner scanner = adapter.adapt(mockBigtableResultScanner, mockSpan); assertArrayEquals(expectedResult.rawCells(), scanner.next().rawCells()); verify(mockBigtableResultScanner).next(); verify(mockSpan, times(0)).end(); }
public ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span) { return new AbstractClientScanner() { @Override public Result next() throws IOException { Result row = bigtableResultScanner.next(); if (row == null) { span.end(); return null; } Result filteredResult = externalizeResult(row); if (filteredResult == null) { close(); } return filteredResult; } @Override public void close() { try { bigtableResultScanner.close(); } catch (RuntimeException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getCause().getMessage())); throw ex; } finally { span.end(); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; }
BigtableWhileMatchResultScannerAdapter { public ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span) { return new AbstractClientScanner() { @Override public Result next() throws IOException { Result row = bigtableResultScanner.next(); if (row == null) { span.end(); return null; } Result filteredResult = externalizeResult(row); if (filteredResult == null) { close(); } return filteredResult; } @Override public void close() { try { bigtableResultScanner.close(); } catch (RuntimeException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getCause().getMessage())); throw ex; } finally { span.end(); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; } }
BigtableWhileMatchResultScannerAdapter { public ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span) { return new AbstractClientScanner() { @Override public Result next() throws IOException { Result row = bigtableResultScanner.next(); if (row == null) { span.end(); return null; } Result filteredResult = externalizeResult(row); if (filteredResult == null) { close(); } return filteredResult; } @Override public void close() { try { bigtableResultScanner.close(); } catch (RuntimeException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getCause().getMessage())); throw ex; } finally { span.end(); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; }  }
BigtableWhileMatchResultScannerAdapter { public ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span) { return new AbstractClientScanner() { @Override public Result next() throws IOException { Result row = bigtableResultScanner.next(); if (row == null) { span.end(); return null; } Result filteredResult = externalizeResult(row); if (filteredResult == null) { close(); } return filteredResult; } @Override public void close() { try { bigtableResultScanner.close(); } catch (RuntimeException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getCause().getMessage())); throw ex; } finally { span.end(); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; }  ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span); }
BigtableWhileMatchResultScannerAdapter { public ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span) { return new AbstractClientScanner() { @Override public Result next() throws IOException { Result row = bigtableResultScanner.next(); if (row == null) { span.end(); return null; } Result filteredResult = externalizeResult(row); if (filteredResult == null) { close(); } return filteredResult; } @Override public void close() { try { bigtableResultScanner.close(); } catch (RuntimeException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getCause().getMessage())); throw ex; } finally { span.end(); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; }  ResultScanner adapt(final ResultScanner bigtableResultScanner, final Span span);  }