GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix#47 Respect decode: false option when cell value is split between … · googleapis/google-cloud-node@d650514

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handwritten/bigtable
    • src
      • chunktransformer.js
    • test
      • chunktransformer.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handwritten/bigtable/src/chunktransformer.js‎

Copy file name to clipboardExpand all lines: handwritten/bigtable/src/chunktransformer.js
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,21 @@ ChunkTransformer.prototype.processCellInProgress = function(chunk) {
346346
if (chunk.resetRow) {
347347
return this.reset();
348348
}
349-
this.qualifier.value += Mutation.convertFromBytes(chunk.value, {
349+
const chunkQualifierValue = Mutation.convertFromBytes(chunk.value, {
350350
userOptions: this.options,
351351
});
352+
353+
if (
354+
chunkQualifierValue instanceof Buffer &&
355+
this.qualifier.value instanceof Buffer
356+
) {
357+
this.qualifier.value = Buffer.concat([
358+
this.qualifier.value,
359+
chunkQualifierValue,
360+
]);
361+
} else {
362+
this.qualifier.value += chunkQualifierValue;
363+
}
352364
this.moveToNextState(chunk);
353365
};
354366

Collapse file

‎handwritten/bigtable/test/chunktransformer.js‎

Copy file name to clipboardExpand all lines: handwritten/bigtable/test/chunktransformer.js
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,65 @@ describe('Bigtable/ChunkTransformer', function() {
737737
'state mismatch'
738738
);
739739
});
740+
it('should concat buffer when decode option is false', function() {
741+
chunkTransformer = new ChunkTransformer({decode: false});
742+
processCellInProgressSpy = sinon.spy(
743+
chunkTransformer,
744+
'processCellInProgress'
745+
);
746+
resetSpy = sinon.spy(chunkTransformer, 'reset');
747+
commitSpy = sinon.spy(chunkTransformer, 'commit');
748+
destroySpy = sinon.spy(chunkTransformer, 'destroy');
749+
chunkTransformer.qualifier = {
750+
value: Buffer.from('value'.toString('base64'), 'base64'),
751+
size: 0,
752+
timestamp: 0,
753+
labels: [],
754+
};
755+
chunkTransformer.qualifiers = [chunkTransformer.qualifier];
756+
chunkTransformer.family = {
757+
qualifier: chunkTransformer.qualifiers,
758+
};
759+
chunkTransformer.row = {
760+
key: 'key',
761+
data: {
762+
family: chunkTransformer.family,
763+
},
764+
};
765+
const chunk = {
766+
commitRow: false,
767+
value: Buffer.from('value'.toString('base64'), 'base64'),
768+
valueSize: 0,
769+
};
770+
chunkTransformer.processCellInProgress(chunk);
771+
assert(!resetSpy.called, 'invalid call to reset');
772+
assert(!commitSpy.called, 'invalid call to commit');
773+
assert.equal(rows.length, 0, 'wrong call to push');
774+
const expectedState = {
775+
key: 'key',
776+
data: {
777+
family: {
778+
qualifier: [
779+
{
780+
value: Buffer.concat([
781+
Buffer.from('value'.toString('base64'), 'base64'),
782+
Buffer.from('value'.toString('base64'), 'base64'),
783+
]),
784+
size: 0,
785+
timestamp: 0,
786+
labels: [],
787+
},
788+
],
789+
},
790+
},
791+
};
792+
assert.deepEqual(chunkTransformer.row, expectedState, 'row mismatch');
793+
assert.equal(
794+
chunkTransformer.state,
795+
RowStateEnum.ROW_IN_PROGRESS,
796+
'state mismatch'
797+
);
798+
});
740799
});
741800
describe('_flush', function() {
742801
var _flushSpy;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.