com.google.cloud.bigtable.grpc.scanner
Class RowMerger
- java.lang.Object
-
- com.google.cloud.bigtable.grpc.scanner.RowMerger
-
- All Implemented Interfaces:
- io.grpc.stub.StreamObserver<com.google.bigtable.v2.ReadRowsResponse>
public class RowMerger extends Object implements io.grpc.stub.StreamObserver<com.google.bigtable.v2.ReadRowsResponse>
Builds a completeFlatRow
fromReadRowsResponse
objects. AReadRowsResponse
may contain a singleFlatRow
, multipleFlatRow
s, or even a part of aCell
if the cell isEach RowMerger object is valid only for building a single FlatRow. Expected usage is along the lines of:
StreamObserver
<FlatRow
> observer = ...; RowMerger rowMerger = new RowMerger(observer); ... rowMerger.onNext(...); .. rowMerger.onComplete();When a complete row is found,
StreamObserver.onNext(Object)
will be called.StreamObserver.onError(Throwable)
will be called forNOTE: RowMerger is not threadsafe.
- Version:
- $Id: $Id
- Author:
- sduskis
-
-
Constructor Summary
Constructors Constructor and Description RowMerger(io.grpc.stub.StreamObserver<FlatRow> observer)
Constructor for RowMerger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
clearRowInProgress()
ByteString
getLastCompletedRowKey()
Integer
getRowCountInLastMessage()
void
onCompleted()
void
onError(Throwable e)
void
onNext(com.google.bigtable.v2.ReadRowsResponse readRowsResponse)
static List<FlatRow>
toRows(Iterable<com.google.bigtable.v2.ReadRowsResponse> responses)
toRows.
-
-
-
Field Detail
-
LOG
protected static final Logger LOG
-
-
Constructor Detail
-
RowMerger
public RowMerger(io.grpc.stub.StreamObserver<FlatRow> observer)
Constructor for RowMerger.- Parameters:
observer
- aStreamObserver
object.
-
-
Method Detail
-
toRows
public static List<FlatRow> toRows(Iterable<com.google.bigtable.v2.ReadRowsResponse> responses)
toRows.
-
clearRowInProgress
public void clearRowInProgress()
-
onNext
public final void onNext(com.google.bigtable.v2.ReadRowsResponse readRowsResponse)
- Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<com.google.bigtable.v2.ReadRowsResponse>
-
getRowCountInLastMessage
public Integer getRowCountInLastMessage()
- Returns:
- the number of rows processed in the previous call to
onNext(ReadRowsResponse)
.
-
getLastCompletedRowKey
public ByteString getLastCompletedRowKey()
-
onCompleted
public void onCompleted()
All
ReadRowsResponse
have been processed, and HTTP OK was sent.- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<com.google.bigtable.v2.ReadRowsResponse>
-
onError
public void onError(Throwable e)
- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<com.google.bigtable.v2.ReadRowsResponse>
-
-