Skip to content

Conversation

stephenplusplus
Copy link
Contributor

@stephenplusplus stephenplusplus commented May 29, 2018

Fixes #180 and #198 by reworking the way we process streamed rows from PartialResultStream on Spanner. The high-level difference is this

  1. use RowBuilder for all streams. We had two code paths previously
  2. do not block on returning until we have a non-chunked row. We can hold the final value of a chunked segment and begin returning other data
  3. handle partial segments. Occasionally we will get a partial row and shouldn't try to send that to the user.

To Dos

  • Unit tests

@stephenplusplus stephenplusplus added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 29, 2018
@ghost ghost assigned stephenplusplus May 29, 2018
@ghost ghost added the cla: yes This human has signed the Contributor License Agreement. label May 29, 2018
@googlebot googlebot removed the cla: yes This human has signed the Contributor License Agreement. label May 29, 2018
@googlebot
Copy link

☹️ Sorry, but only Googlers may change the label cla: yes.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 29, 2018
@stephenplusplus
Copy link
Contributor Author

@crwilcox I made some changes, but my tests still pass. If this looks okay to you, I'll move onto unit tests.

@codecov
Copy link

codecov bot commented May 29, 2018

Codecov Report

Merging #208 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #208   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     12           
  Lines        1402   1385   -17     
=====================================
- Hits         1402   1385   -17
Impacted Files Coverage Δ
src/codec.js 100% <100%> (ø) ⬆️
src/partial-result-stream.js 100% <100%> (ø) ⬆️
src/row-builder.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10a99c0...a69c500. Read the comment docs.

@crwilcox
Copy link
Contributor

Thanks for stripping out that dead code. I had forgotten about that. I will stress it over lunch here just to make sure but it looks good after 5 loops. Feel free to move forward.

var field = fields[index];
return {
name: field.name,
value: codec.decode(value, field),

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor Author

Status update:

I took over the PR and did some refactors. Wrote unit tests, all was well. One quick check that the system tests work, then 💥 -- I don't remember the exact number, but let's say ~20 tests failed. I reverted my refactors to see if it was something I did, but unfortunately, same errors.

I realized something we didn't carry over when @crwilcox made his changes was a call to codec.decode. Since things were re-arranged from the old way, it wasn't exactly clear where it should go. But, I put it back, and all but one test fails. And I can't figure that one out.

Basically, I'm hoping @crwilcox can dive back in for a second to see if he has any ideas. I'll leave some comments on this PR next to the behavioral changes I've made since you last touched the code.

@@ -72,7 +71,7 @@ RowBuilder.formatValue = function(field, value) {
}

if (field.code !== 'STRUCT') {
return value;
return codec.decode(value, field);

This comment was marked as spam.

src/codec.js Outdated
@@ -118,7 +118,7 @@ codec.generateToJSONFromRow = generateToJSONFromRow;
* @private
*/
function decode(value, field) {
function decodeValue_(decoded, type) {
function decodeValue_(decoded, type, options) {

This comment was marked as spam.

@@ -46,7 +45,7 @@ RowBuilder.getValue = function(obj) {
var value = obj;

if (obj && obj.kind) {
value = obj[obj.kind];
value = commonGrpc.Service.decodeValue_(obj);

This comment was marked as spam.


if (!is.empty(this.rows[0]) && this.currentRow.length !== this.fields.length) {

This comment was marked as spam.

@stephenplusplus stephenplusplus removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 4, 2018
@stephenplusplus
Copy link
Contributor Author

@crwilcox I think we're finally good again. Units, systems, and your revision of the "issue-180.js" file I've checked are working. It would be great if you could confirm!

@crwilcox
Copy link
Contributor

crwilcox commented Jun 4, 2018

Some system tests are failing locally after the edits:

 insert & query
        3) should query in callback mode
        4) should query in promise mode
        5) should query in stream mode

Coverage numbers:
image

@stephenplusplus
Copy link
Contributor Author

100% line coverage is what we go for. Can you show more details about the system test errors?

@crwilcox
Copy link
Contributor

crwilcox commented Jun 4, 2018

Sure, but the system tests seem to also be an issue on builds before your commits.

3) Spanner
       Tables
         insert & query
           should query in callback mode:

      Uncaught AssertionError [ERR_ASSERTION]: { SingerId: 'gcloud-tests-id-1278e710',
  Name: 'gcloud-tests-name-1278e711',
  Float: null,
  Int: null,
  Info: null,
  Create deepEqual { SingerId: 'gcloud-tests-id-e12752a0',
  Name: 'gcloud-tests-name-e12752a1',
  Float: 8.2,
  Int: 2,
  Info: <Buffer 67 63 6c 6
      + expected - actual

       {
      -  "Accents": [null]
      -  "Created": [null]
      -  "DOB": [null]
      -  "Float": [null]
      -  "HasGear": [null]
      -  "Info": [null]
      -  "Int": [null]
      -  "Name": "gcloud-tests-name-1278e711"
      -  "PhoneNumbers": [null]
      -  "SingerId": "gcloud-tests-id-1278e710"
      +  "Accents": [
      +    "jamaican"
      +  ]
      +  "Created": [Date: 2018-06-04T16:46:51.082Z]
      +  "DOB": [Date: 1969-08-20T00:00:00.000Z]
      +  "Float": 8.2
      +  "HasGear": true
      +  "Info": [Buffer: [
      +    103
      +    99
      +    108
      +    111
      +    117
      +    100

@stephenplusplus
Copy link
Contributor Author

stephenplusplus commented Jun 4, 2018

@alexander-fenster ran the system tests and had a different failure. I don't believe these are related to our PR here. @callmehiphop can you run these?

I suppose we could always do a merge to let Circle have a go at them, then revert it if necessary.

@crwilcox
Copy link
Contributor

crwilcox commented Jun 4, 2018

Reran the tests and they pass on master and on this branch. I think this is safe to merge.

Copy link
Contributor

@alexander-fenster alexander-fenster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, hope I correctly understood the idea of the changes.

@crwilcox crwilcox merged commit b2f4fca into master Jun 4, 2018
@ghost ghost removed the cla: yes This human has signed the Contributor License Agreement. label Jun 4, 2018
@stephenplusplus stephenplusplus deleted the rewrite-partial-result-stream branch June 20, 2018 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants