-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bigtable 9b. Implement ReadRows row merging logic. #2914
Bigtable 9b. Implement ReadRows row merging logic. #2914
Conversation
This PR sets the stage for ReadRows by implementing the row merging in a RowMergingCallable. In a future commit, this callable will be part of a chain that will implement the ReadRowsCallable chain. For now its disconnected. The implementation relies on ReframingResponseObserver to handle flow control and integrates with it by implementing the Reframer interface in RowMerger. The RowMerger, simply glues the Reframer api to the StateMachine. The StateMachine contains all of the logic of merging rows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, more to come.
if (byteA == byteB) { | ||
continue; | ||
} | ||
return byteA < byteB ? -1 : 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if (sizeA == sizeB) { | ||
return 0; | ||
} | ||
return sizeA < sizeB ? -1 : 1; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
buffer = response; | ||
nextChunk = 0; | ||
|
||
// If the server sends a scan heartbeat, wrap it in a synthetic row that will be be filtered out |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
nextChunk = 0; | ||
|
||
// If the server sends a scan heartbeat, wrap it in a synthetic row that will be be filtered out | ||
// after the resume logic. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
@Override | ||
public boolean hasFullFrame() { | ||
return nextRow != null || readNextRow(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* <p>Package-private for internal use. | ||
*/ | ||
@InternalApi | ||
class RowMerger<RowT> implements Reframer<RowT, ReadRowsResponse> { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
@Override | ||
public boolean hasPartialFrame() { | ||
return hasFullFrame() || stateMachine.isRowInProgress(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
@Override | ||
public RowT pop() { | ||
RowT row = nextRow; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Ok, I think I addressed all of Kevin's feedback. @pongad @garrettjonesgoogle, this should be ready for you |
LGTM, please ask Gary to take a look as well. |
@garye can you take a look as well? |
* | ||
* <ul> | ||
* <li>Logical rows that were constructed using the {@link RowBuilder} | ||
* <li>Special marker rows that represent resumption points that were sent by Last scanned row |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
/** | ||
* Feeds the last scanned serverside key into the state machine. The adapter will wrap this key in | ||
* a special marker row that can be used downstream for efficient resume. It is the callers | ||
* responsibility to eventually filter out this row. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Feeds the last scanned serverside key into the state machine. The adapter will wrap this key in | ||
* a special marker row that can be used downstream for efficient resume. It is the callers |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* <dt>Valid states: | ||
* <dd>{@link StateMachine#AWAITING_NEW_ROW} | ||
* <dt>Resulting states: | ||
* <dd>{@link StateMachine#AWAITING_ROW_CONSUME} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Returns the last completed row and transitions to awaiting a new row. | ||
* |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
@Override | ||
State handleChunk(CellChunk chunk) { | ||
validate(!chunk.getResetRow(), "AWAITING_NEW_ROW: can't reset"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
rowKey = chunk.getRowKey(); | ||
adapter.startRow(rowKey); | ||
|
||
// auto transition |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
adapter.finishCell(); | ||
|
||
if (!chunk.getCommitRow()) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
}; | ||
|
||
private static final State AWAITING_ROW_CONSUME = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@garye Thanks for reviewing, I think addressed all feedback. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits but looks good as far as I can tell otherwise. I'm not qualified to fully review the state machine though :(
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.stub.read_rows; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Feeds a new chunk into the sate machine. If the chunk is invalid, the state machine will throw | ||
* an exception and should be used for further input. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Please merge when ready. |
This PR sets the stage for ReadRows by implementing the row merging in a RowMergingCallable. In a future commit, this callable will be part of a chain that will implement the ReadRowsCallable chain. For now its disconnected.
The implementation relies on ReframingResponseObserver to handle flow control and integrates with it by implementing the Reframer interface in RowMerger.
The RowMerger, simply glues the Reframer api to the StateMachine.
The StateMachine contains all of the logic of merging rows.
This has not been reviewed yet by anyone on the Bigtable team.
@kevinsi4508 can you take a look at this when you have a (very long) moment?
For reference the reframing logic was merged in this PR:
#2907