Skip to content

Commit d05c8ea

Browse files
muraliQlogicGautamSharda
authored andcommitted
Fix for Issue#354 (#355)
1 parent cf2361d commit d05c8ea

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

handwritten/bigtable/src/chunktransformer.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class ChunkTransformer extends Transform {
131131
* @private
132132
*/
133133
reset() {
134-
this.prevRowKey = null;
135134
this.family = {};
136135
this.qualifiers = [];
137136
this.qualifier = {};
@@ -140,13 +139,13 @@ class ChunkTransformer extends Transform {
140139
}
141140

142141
/**
143-
* sets prevRowkey and calls reset when row is committed.
142+
* sets lastRowkey and calls reset when row is committed.
144143
* @private
145144
*/
146145
commit() {
147146
const row = this.row;
148147
this.reset();
149-
this.prevRowKey = row.key;
148+
this.lastRowKey = row.key;
150149
}
151150

152151
/**
@@ -195,7 +194,7 @@ class ChunkTransformer extends Transform {
195194
*/
196195
validateNewRow(chunk, newRowKey) {
197196
const row = this.row;
198-
const prevRowKey = this.prevRowKey;
197+
const lastRowKey = this.lastRowKey;
199198
let errorMessage;
200199

201200
if (typeof row.key !== 'undefined') {
@@ -208,7 +207,7 @@ class ChunkTransformer extends Transform {
208207
errorMessage = 'A row key must be set';
209208
} else if (chunk.resetRow) {
210209
errorMessage = 'A new row cannot be reset';
211-
} else if (prevRowKey === newRowKey) {
210+
} else if (lastRowKey === newRowKey) {
212211
errorMessage = 'A commit happened but the same key followed';
213212
} else if (!chunk.familyName) {
214213
errorMessage = 'A family must be set';

handwritten/bigtable/test/chunktransformer.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ describe('Bigtable/ChunkTransformer', function() {
6060
describe('instantiation', function() {
6161
it('should have initial state', function() {
6262
assert(chunkTransformer instanceof ChunkTransformer);
63-
this.prevRowKey = '';
63+
this.lastRowKey = '';
6464
this.family = {};
6565
this.qualifiers = [];
6666
this.qualifier = {};
6767
this.row = {};
6868
this.state = RowStateEnum.NEW_ROW;
6969
assert.deepStrictEqual(chunkTransformer.row, {}, 'invalid initial state');
7070
assert.deepStrictEqual(
71-
chunkTransformer.prevRowKey,
72-
null,
71+
chunkTransformer.lastRowKey,
72+
undefined,
7373
'invalid initial state'
7474
);
7575
assert.deepStrictEqual(
@@ -142,7 +142,7 @@ describe('Bigtable/ChunkTransformer', function() {
142142
assert(destroySpy.called);
143143
done();
144144
});
145-
chunkTransformer.prevRowKey = 'key';
145+
chunkTransformer.lastRowKey = 'key';
146146

147147
processNewRowSpy.call(chunkTransformer, {
148148
rowKey: 'key',
@@ -194,9 +194,9 @@ describe('Bigtable/ChunkTransformer', function() {
194194
assert(resetSpy.called, 'reset state failed');
195195
assert(commitSpy.called, 'commit row failed');
196196
assert.strictEqual(
197-
chunkTransformer.prevRowKey,
197+
chunkTransformer.lastRowKey,
198198
chunk.rowKey,
199-
'wrong state prevrowkey'
199+
'wrong state lastRowKey'
200200
);
201201
const expectedRow = {
202202
key: chunk.rowKey,
@@ -351,7 +351,7 @@ describe('Bigtable/ChunkTransformer', function() {
351351
timestampMicros: 10,
352352
});
353353
});
354-
it('should destroy when rowKey not equal to prevRowKey', function(done) {
354+
it('should destroy when rowKey not equal to lastRowKey', function(done) {
355355
chunkTransformer.on('error', function() {
356356
assert(destroySpy.called);
357357
done();
@@ -963,7 +963,7 @@ describe('Bigtable/ChunkTransformer', function() {
963963
});
964964
describe('reset', function() {
965965
it('should reset initial state', function() {
966-
chunkTransformer.prevRowKey = 'prevkey';
966+
chunkTransformer.lastRowKey = 'prevkey';
967967
chunkTransformer.qualifier = {
968968
value: 'value',
969969
size: 0,
@@ -984,8 +984,8 @@ describe('Bigtable/ChunkTransformer', function() {
984984
chunkTransformer.reset();
985985
assert.deepStrictEqual(chunkTransformer.row, {}, 'invalid initial state');
986986
assert.deepStrictEqual(
987-
chunkTransformer.prevRowKey,
988-
null,
987+
chunkTransformer.lastRowKey,
988+
'prevkey',
989989
'invalid initial state'
990990
);
991991
assert.deepStrictEqual(
@@ -1015,8 +1015,8 @@ describe('Bigtable/ChunkTransformer', function() {
10151015
beforeEach(function() {
10161016
resetSpy = sinon.spy(chunkTransformer, 'reset');
10171017
});
1018-
it('should reset to initial state and set prevRowKey', function() {
1019-
chunkTransformer.prevRowKey = '';
1018+
it('should reset to initial state and set lastRowKey', function() {
1019+
chunkTransformer.lastRowKey = '';
10201020
chunkTransformer.qualifier = {
10211021
value: 'value',
10221022
size: 0,
@@ -1038,7 +1038,7 @@ describe('Bigtable/ChunkTransformer', function() {
10381038
assert(resetSpy.called, 'did not call reset');
10391039
assert.deepStrictEqual(chunkTransformer.row, {}, 'invalid initial state');
10401040
assert.deepStrictEqual(
1041-
chunkTransformer.prevRowKey,
1041+
chunkTransformer.lastRowKey,
10421042
'key',
10431043
'invalid initial state'
10441044
);

0 commit comments

Comments
 (0)