-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathTableBatchOrchestrator.ts
779 lines (736 loc) · 24.1 KB
/
TableBatchOrchestrator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
import BatchRequest from "./BatchRequest";
import BatchTableInsertEntityOptionalParams from "./BatchTableInsertEntityOptionalParams";
import TableStorageContext from "../context/TableStorageContext";
import Context from "../generated/Context";
import TableHandler from "../handlers/TableHandler";
import { TableBatchSerialization } from "./TableBatchSerialization";
import BatchTableDeleteEntityOptionalParams from "./BatchTableDeleteEntityOptionalParams";
import BatchTableUpdateEntityOptionalParams from "./BatchTableUpdateEntityOptionalParams";
import BatchTableMergeEntityOptionalParams from "./BatchTableMergeEntityOptionalParams";
import BatchTableQueryEntitiesWithPartitionAndRowKeyOptionalParams from "./BatchTableQueryEntitiesWithPartitionAndRowKeyOptionalParams";
import { TableQueryEntitiesWithPartitionAndRowKeyOptionalParams } from "../generated/artifacts/models";
import ITableMetadataStore from "../persistence/ITableMetadataStore";
import { v4 as uuidv4 } from "uuid";
import StorageErrorFactory from "../errors/StorageErrorFactory";
import TableBatchRepository from "./TableBatchRepository";
import BatchStringConstants from "./BatchStringConstants";
import BatchErrorConstants from "./BatchErrorConstants";
/**
* Currently there is a single distinct and concrete implementation of batch /
* entity group operations for the table api.
* The orchestrator manages the deserialization, submission and serialization of
* entity group transactions.
* ToDo: it might be possible to share code between this and the blob batch api, but there
* is relatively little commonality, due to the different ACL models and the fact that
* Azure Tables is owned by a different group to the Azure Blob Storage team.
*
* @export
* @class TableBatchOrchestrator
*/
export default class TableBatchOrchestrator {
private serialization = new TableBatchSerialization();
private context: TableStorageContext;
private parentHandler: TableHandler;
private wasError: boolean = false;
private errorResponse: string = "";
private readonly repository: TableBatchRepository;
// add a private member which will is a map of row keys to partition keys
// this will be used to check for duplicate row keys in a batch request
private partitionKeyMap: Map<string, string> = new Map<string, string>();
public constructor(
context: TableStorageContext,
handler: TableHandler,
metadataStore: ITableMetadataStore
) {
this.context = context;
this.parentHandler = handler;
this.repository = new TableBatchRepository(metadataStore);
}
/**
* This is the central route / sequence of the batch orchestration.
* Takes batchRequest body, deserializes requests, submits to handlers, then returns serialized response
*
* @param {string} batchRequestBody
* @return {*} {Promise<string>}
* @memberof TableBatchManager
*/
public async processBatchRequestAndSerializeResponse(
batchRequestBody: string
): Promise<string> {
const batchOperations =
this.serialization.deserializeBatchRequest(batchRequestBody);
if (batchOperations.length > 100) {
this.wasError = true;
this.errorResponse = this.serialization.serializeGeneralRequestError(
BatchErrorConstants.TOO_MANY_OPERATIONS,
this.context.xMsRequestID
);
} else {
batchOperations.forEach((operation) => {
const request: BatchRequest = new BatchRequest(operation);
this.repository.addBatchRequest(request);
});
await this.submitRequestsToHandlers();
}
return this.serializeResponses();
}
/**
* Submits requests to the appropriate handlers
* ToDo: Correct logic and handling of requests with Content ID
*
* @private
* @return {*} {Promise<void>}
* @memberof TableBatchManager
*/
private async submitRequestsToHandlers(): Promise<void> {
let contentID = 1;
if (this.repository.getBatchRequests().length > 0) {
const accountName = (this.context.account ??= "");
const tableName = this.repository.getBatchRequests()[0].getPath();
const batchId = uuidv4();
this.checkForPartitionKey();
// initialize transaction rollback capability
await this.initTransaction(batchId);
let batchSuccess = true;
for (const singleReq of this.repository.getBatchRequests()) {
try {
singleReq.response = await this.routeAndDispatchBatchRequest(
singleReq,
this.context,
contentID,
batchId
);
} catch (err: any) {
batchSuccess = false;
this.wasError = true;
this.errorResponse = this.serialization.serializeError(
err,
contentID,
singleReq
);
break;
}
contentID++;
}
await this.repository.endBatchTransaction(
accountName,
tableName,
batchId,
this.context,
batchSuccess
);
}
}
/**
* Ensures that we have a partition key for the batch request
*
* @private
* @memberof TableBatchOrchestrator
*/
private checkForPartitionKey() {
const requestPartitionKey = this.extractRequestPartitionKey(
this.repository.getBatchRequests()[0]
);
if (requestPartitionKey === undefined) {
this.wasError = true;
this.errorResponse = this.serialization.serializeGeneralRequestError(
BatchErrorConstants.NO_PARTITION_KEY,
this.context.xMsRequestID
);
}
}
/**
* Initializes the transaction for the batch request in the metadata store
*
* @param {string} batchId
* @memberof TableBatchOrchestrator
*/
async initTransaction(batchId: string) {
if (this.wasError == false) {
await this.repository.beginBatchTransaction(batchId);
}
}
/**
* Serializes responses from the table handler
* see Link below for details of response format
* tslint:disable-next-line: max-line-length
* https://docs.microsoft.com/en-us/rest/api/storageservices/performing-entity-group-transactions#json-versions-2013-08-15-and-later-2
*
* @private
* @return {*} {string}
* @memberof TableBatchManager
*/
private serializeResponses(): string {
let responseString: string = "";
// based on research, a stringbuilder is only worth doing with 1000s of string ops
// this can be optimized later if we get reports of slow batch operations
const batchBoundary = this.serialization.batchBoundary.replace(
BatchStringConstants.BATCH_REQ_BOUNDARY,
BatchStringConstants.BATCH_RES_BOUNDARY
);
let changesetBoundary = this.serialization.changesetBoundary.replace(
BatchStringConstants.CHANGESET_REQ_BOUNDARY,
BatchStringConstants.CHANGESET_RES_BOUNDARY
);
responseString += batchBoundary + BatchStringConstants.CRLF;
// (currently static header) ToDo: Validate if we need to correct headers via tests
responseString = this.serializeContentTypeAndBoundary(
responseString,
changesetBoundary
);
const changesetBoundaryClose: string =
BatchStringConstants.BOUNDARY_PREFIX +
changesetBoundary +
BatchStringConstants.BOUNDARY_CLOSE_SUFFIX;
changesetBoundary =
BatchStringConstants.BOUNDARY_PREFIX + changesetBoundary;
if (this.wasError === false) {
this.repository.getBatchRequests().forEach((request) => {
responseString += changesetBoundary;
responseString += request.response;
responseString += BatchStringConstants.DoubleCRLF;
});
} else {
// serialize the error
responseString += changesetBoundary + BatchStringConstants.CRLF;
// then headers
responseString += BatchStringConstants.CONTENT_TYPE_HTTP;
responseString += BatchStringConstants.TRANSFER_ENCODING_BINARY;
responseString += BatchStringConstants.CRLF;
// then HTTP/1.1 404 etc
responseString += this.errorResponse;
}
responseString += changesetBoundaryClose;
responseString +=
batchBoundary + BatchStringConstants.BOUNDARY_CLOSE_SUFFIX;
return responseString;
}
private serializeContentTypeAndBoundary(
responseString: string,
changesetBoundary: string
) {
responseString +=
BatchStringConstants.CONTENT_TYPE_MULTIPART_AND_BOUNDARY +
changesetBoundary +
BatchStringConstants.DoubleCRLF;
return responseString;
}
/**
* Routes and dispatches single operations against the table handler and stores
* the serialized result.
*
* @private
* @param {BatchRequest} request
* @param {Context} context
* @param {number} contentID
* @return {*} {Promise<any>}
* @memberof TableBatchManager
*/
private async routeAndDispatchBatchRequest(
request: BatchRequest,
context: Context,
contentID: number,
batchId: string
): Promise<any> {
const batchContextClone = this.createBatchContextClone(
context,
request,
batchId
);
let response: any;
let __return: any;
// we only use 5 HTTP Verbs to determine the table operation type
try {
switch (request.getMethod()) {
case BatchStringConstants.VERB_POST:
// INSERT: we are inserting an entity
// POST https://myaccount.table.core.windows.net/mytable
({ __return, response } = await this.handleBatchInsert(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_PUT:
// UPDATE: we are updating an entity
// PUT http://127.0.0.1:10002/devstoreaccount1/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
// INSERT OR REPLACE:
// PUT https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchUpdate(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_DELETE:
// DELETE: we are deleting an entity
// DELETE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchDelete(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_GET:
// QUERY : we are querying / retrieving an entity
// GET https://myaccount.table.core.windows.net/mytable(PartitionKey='<partition-key>',RowKey='<row-key>')?$select=<comma-separated-property-names>
({ __return, response } = await this.handleBatchQuery(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
case BatchStringConstants.VERB_CONNECT:
throw new Error("Connect Method unsupported in batch.");
break;
case BatchStringConstants.VERB_HEAD:
throw new Error("Head Method unsupported in batch.");
break;
case BatchStringConstants.VERB_OPTIONS:
throw new Error("Options Method unsupported in batch.");
break;
case BatchStringConstants.VERB_TRACE:
throw new Error("Trace Method unsupported in batch.");
break;
case BatchStringConstants.VERB_PATCH:
// this is using the PATCH verb to merge
({ __return, response } = await this.handleBatchMerge(
request,
response,
batchContextClone,
contentID,
batchId
));
break;
default:
// MERGE: this must be the merge, as the merge operation is not currently generated by autorest
// MERGE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
// INSERT OR MERGE
// MERGE https://myaccount.table.core.windows.net/mytable(PartitionKey='myPartitionKey', RowKey='myRowKey')
({ __return, response } = await this.handleBatchMerge(
request,
response,
batchContextClone,
contentID,
batchId
));
}
} catch (batchException) {
// this allows us to catch and debug any errors in the batch handling
throw batchException;
}
return __return;
}
/**
* Creates a clone of the context for the batch operation.
* Becuase the context that we have will not work with the calls and needs
* updating for batch operations.
* We use a deep clone, as each request needs to be treated seaprately.
*
* @private
* @param {Context} context
* @param {BatchRequest} request
* @return {*}
* @memberof TableBatchOrchestrator
*/
private createBatchContextClone(
context: Context,
request: BatchRequest,
batchId: string
) {
const batchContextClone = Object.create(context);
batchContextClone.tableName = request.getPath();
batchContextClone.path = request.getPath();
const updatedContext = new TableStorageContext(batchContextClone);
updatedContext.request = request;
updatedContext.batchId = batchId;
return updatedContext;
}
/**
* Handles an insert operation inside a batch
*
* @private
* @param {BatchRequest} request
* @param {*} response
* @param {*} batchContextClone
* @param {number} contentID
* @return {*} {Promise<{
* __return: string;
* response: any;
* }>}
* @memberof TableBatchManager
*/
private async handleBatchInsert(
request: BatchRequest,
response: any,
batchContextClone: any,
contentID: number,
batchId: string
): Promise<{
__return: string;
response: any;
}> {
request.ingestOptionalParams(new BatchTableInsertEntityOptionalParams());
const { partitionKey, rowKey } = this.extractKeys(request);
this.validateBatchRequest(partitionKey, rowKey, batchContextClone);
response = await this.parentHandler.insertEntity(
request.getPath(),
request.params as BatchTableInsertEntityOptionalParams,
batchContextClone
);
return {
__return: this.serialization.serializeTableInsertEntityBatchResponse(
request,
response
),
response
};
}
/**
* Handles a delete Operation inside a batch request
*
* @private
* @param {BatchRequest} request
* @param {*} response
* @param {*} batchContextClone
* @param {number} contentID
* @return {*} {Promise<{
* __return: string;
* response: any;
* }>}
* @memberof TableBatchManager
*/
private async handleBatchDelete(
request: BatchRequest,
response: any,
batchContextClone: any,
contentID: number,
batchId: string
): Promise<{
__return: string;
response: any;
}> {
request.ingestOptionalParams(new BatchTableDeleteEntityOptionalParams());
const ifmatch: string =
request.getHeader(BatchStringConstants.IF_MATCH_HEADER_STRING) ||
BatchStringConstants.ASTERISK;
const { partitionKey, rowKey } = this.extractKeys(request);
this.validateBatchRequest(partitionKey, rowKey, batchContextClone);
response = await this.parentHandler.deleteEntity(
request.getPath(),
partitionKey,
rowKey,
ifmatch,
request.params as BatchTableDeleteEntityOptionalParams,
batchContextClone
);
return {
__return: this.serialization.serializeTableDeleteEntityBatchResponse(
request,
response
),
response
};
}
private extractKeys(request: BatchRequest) {
const partitionKey = this.extractRequestPartitionKey(request);
const rowKey = this.extractRequestRowKey(request);
return { partitionKey, rowKey };
}
/**
* Handles an update Operation inside a batch request
*
* @private
* @param {BatchRequest} request
* @param {*} response
* @param {*} batchContextClone
* @param {number} contentID
* @return {*} {Promise<{
* __return: string;
* response: any;
* }>}
* @memberof TableBatchManager
*/
private async handleBatchUpdate(
request: BatchRequest,
response: any,
batchContextClone: any,
contentID: number,
batchId: string
): Promise<{
__return: string;
response: any;
}> {
request.ingestOptionalParams(new BatchTableUpdateEntityOptionalParams());
const { partitionKey, rowKey } = this.extractKeys(request);
this.validateBatchRequest(partitionKey, rowKey, batchContextClone);
const ifMatch = request.getHeader(
BatchStringConstants.IF_MATCH_HEADER_STRING
);
response = await this.parentHandler.updateEntity(
request.getPath(),
partitionKey,
rowKey,
{
ifMatch,
...request.params
} as BatchTableUpdateEntityOptionalParams,
batchContextClone
);
return {
__return: this.serialization.serializeTableUpdateEntityBatchResponse(
request,
response
),
response
};
}
/**
* Handles a query operation inside a batch request,
* should only ever be one operation if there is a query
*
* @private
* @param {BatchRequest} request
* @param {*} response
* @param {*} batchContextClone
* @param {number} contentID
* @return {*} {Promise<{
* __return: string;
* response: any;
* }>}
* @memberof TableBatchManager
*/
private async handleBatchQuery(
request: BatchRequest,
response: any,
batchContextClone: any,
contentID: number,
batchId: string
): Promise<{
__return: string;
response: any;
}> {
// need to validate that query is the only request in the batch!
const { partitionKey, rowKey } = this.extractKeys(request);
if (
null !== partitionKey &&
null !== rowKey &&
partitionKey !== "" &&
rowKey !== ""
) {
// ToDo: this is hideous... but we need the params on the request object,
// as they percolate through and are needed for the final serialization
// currently, because of the way we deconstruct / deserialize, we only
// have the right model at a very late stage in processing
// this might resolve when we simplify Query logic
// based on only accepting Query with partition and row key
request.ingestOptionalParams(
new BatchTableQueryEntitiesWithPartitionAndRowKeyOptionalParams()
);
response = await this.parentHandler.queryEntitiesWithPartitionAndRowKey(
request.getPath(),
partitionKey,
rowKey,
request.params as TableQueryEntitiesWithPartitionAndRowKeyOptionalParams,
batchContextClone
);
return {
__return:
await this.serialization.serializeTableQueryEntityWithPartitionAndRowKeyBatchResponse(
request,
response
),
response
};
} else {
throw StorageErrorFactory.getNotImplementedError(batchContextClone);
}
}
/**
* Handles a merge operation inside a batch request
*
* @private
* @param {BatchRequest} request
* @param {*} response
* @param {*} batchContextClone
* @param {number} contentID
* @return {*} {Promise<{
* __return: string;
* response: any;
* }>}
* @memberof TableBatchManager
*/
private async handleBatchMerge(
request: BatchRequest,
response: any,
batchContextClone: any,
contentID: number,
batchId: string
): Promise<{
__return: string;
response: any;
}> {
request.ingestOptionalParams(new BatchTableMergeEntityOptionalParams());
const { partitionKey, rowKey } = this.extractKeys(request);
this.validateBatchRequest(partitionKey, rowKey, batchContextClone);
response = await this.parentHandler.mergeEntity(
request.getPath(),
partitionKey,
rowKey,
{
ifMatch: request.getHeader(BatchStringConstants.IF_MATCH_HEADER_STRING),
...request.params
} as BatchTableMergeEntityOptionalParams,
batchContextClone
);
return {
__return: this.serialization.serializeTablMergeEntityBatchResponse(
request,
response
),
response
};
}
/**
* extracts the Partition key from a request
*
* @private
* @param {BatchRequest} request
* @return {*} {string}
* @memberof TableBatchOrchestrator
*/
private extractRequestPartitionKey(
request: BatchRequest
): string | undefined {
let partitionKey: string | undefined;
const originalUrl = request.getUrl();
const url = decodeURIComponent(originalUrl);
const partKeyMatch = url.match(/(?<=PartitionKey=')(.*)(?=',)/gi);
if (partKeyMatch === null) {
// row key not in URL, must be in body
const body = request.getBody();
if (body !== "") {
const jsonBody = JSON.parse(body ? body : "{}");
partitionKey = jsonBody.PartitionKey;
}
} else {
// keys can have more complex values which are URI encoded if they come from the URL
// we decode above.
partitionKey = partKeyMatch[0];
// Url should use double ticks and we need to remove them
partitionKey = this.replaceDoubleTicks(partitionKey);
}
return partitionKey;
}
/**
* Helper function to extract values needed for handler calls
*
* @private
* @param {BatchRequest} request
* @return { string }
* @memberof TableBatchManager
*/
private extractRequestRowKey(request: BatchRequest): string {
let rowKey: any;
// problem: sometimes the ticks are encoded, sometimes not!
// this is a difference between Azure Data-Tables and the deprecated
// Azure Storage SDK decode URI component will not remove double ticks
const url = decodeURIComponent(request.getUrl());
const rowKeyMatch = url.match(/(?<=RowKey=')(.+)(?='\))/gi);
rowKey = rowKeyMatch ? rowKeyMatch[0] : "";
// Url should use double ticks and we need to remove them
rowKey = this.replaceDoubleTicks(rowKey);
if (rowKeyMatch === null) {
// row key not in URL, must be in body
const body = request.getBody();
if (body !== "") {
const jsonBody = JSON.parse(body ? body : "{}");
rowKey = jsonBody.RowKey;
}
}
return rowKey;
}
/**
* Replace Double ticks for single ticks without replaceAll string prototype
* function, becuase node 14 does not support it.
* @param key
* @returns
*/
private replaceDoubleTicks(key: string): string {
const result = key.replace(/''/g, "'");
return result;
}
/**
* Helper function to validate batch requests.
* Additional validation functions should be added here.
*
* @private
* @param {string} partitionKey
* @param {string} rowKey
* @param {*} batchContextClone
* @memberof TableBatchOrchestrator
*/
private validateBatchRequest(
partitionKey: string | undefined,
rowKey: string,
batchContextClone: any
) {
if (partitionKey === undefined) {
throw StorageErrorFactory.getInvalidInput(batchContextClone);
}
this.checkForDifferingPartitionKeys(partitionKey, batchContextClone);
this.checkForDuplicateRowKey(partitionKey, rowKey, batchContextClone);
}
/**
* Checks that the partition key is the same for all requests in the batch
* @param {string} partitionKey
* @param {*} batchContextClone
* @memberof TableBatchOrchestrator
*/
private checkForDifferingPartitionKeys(
partitionKey: string,
batchContextClone: any
) {
if (this.partitionKeyMap.size > 0) {
console.log("checking for differing partition keys");
if (this.partitionKeyMap.values().next().value !== partitionKey) {
throw StorageErrorFactory.getBatchPartitionKeyMismatch(
batchContextClone
);
}
}
}
/**
*
*
*
* @private
* @param {string} partitionKey
* @param {string} rowKey
* @param {*} batchContextClone
* @memberof TableBatchOrchestrator
*/
private checkForDuplicateRowKey(
partitionKey: string,
rowKey: string,
batchContextClone: any
) {
const key = partitionKey + rowKey;
if (this.partitionKeyMap.has(key)) {
throw StorageErrorFactory.getBatchDuplicateRowKey(
batchContextClone,
rowKey
);
} else {
this.partitionKeyMap.set(key, partitionKey);
}
}
}