Skip to content
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

Merged
merged 18 commits into from
Feb 21, 2018

Conversation

igorbernstein2
Copy link

@igorbernstein2 igorbernstein2 commented Feb 16, 2018

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

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.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
@googleapis googleapis deleted a comment Feb 16, 2018
Copy link

@kevinsi4508 kevinsi4508 left a 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.

This comment was marked as spam.

This comment was marked as spam.

if (sizeA == sizeB) {
return 0;
}
return sizeA < sizeB ? -1 : 1;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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.

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.


@Override
public boolean hasFullFrame() {
return nextRow != null || readNextRow();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* <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.

This comment was marked as spam.

This comment was marked as spam.


@Override
public boolean hasPartialFrame() {
return hasFullFrame() || stateMachine.isRowInProgress();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


@Override
public RowT pop() {
RowT row = nextRow;

This comment was marked as spam.

This comment was marked as spam.

@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@googleapis googleapis deleted a comment Feb 17, 2018
@igorbernstein2
Copy link
Author

Ok, I think I addressed all of Kevin's feedback. @pongad @garrettjonesgoogle, this should be ready for you

@kevinsi4508
Copy link

LGTM, please ask Gary to take a look as well.

@igorbernstein2
Copy link
Author

@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.

/**
* 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.


/**
* 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.

* <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.


/**
* Returns the last completed row and transitions to awaiting a new row.
*

This comment was marked as spam.

This comment was marked as spam.


@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.

rowKey = chunk.getRowKey();
adapter.startRow(rowKey);

// auto transition

This comment was marked as spam.

This comment was marked as spam.

}
adapter.finishCell();

if (!chunk.getCommitRow()) {

This comment was marked as spam.

This comment was marked as spam.

}
};

private static final State AWAITING_ROW_CONSUME =

This comment was marked as spam.

This comment was marked as spam.

@igorbernstein2
Copy link
Author

@garye Thanks for reviewing, I think addressed all feedback. PTAL

Copy link
Contributor

@pongad pongad left a 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.


/**
* 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.

@igorbernstein2
Copy link
Author

Please merge when ready.

@pongad pongad merged commit 7131ecc into googleapis:master Feb 21, 2018
@igorbernstein2 igorbernstein2 deleted the 09b-impl-read-rows-merging branch February 22, 2018 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants