Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit 1f6b490

Browse files
Reacting to code review comments
1 parent 38c2659 commit 1f6b490

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main/scala/com/microsoft/azure/cosmosdb/spark/CosmosDBConnection.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
249249
}
250250

251251
def readChangeFeed(changeFeedOptions: ChangeFeedOptions, isStreaming: Boolean, shouldInferStreamSchema: Boolean): Tuple2[Iterator[Document], String] = {
252-
logDebug("--> readChangeFeed, PageSize: " + changeFeedOptions.getPageSize().toString() + ", ContinuationToken: " + changeFeedOptions.getRequestContinuation() + ", PartitionId: " + changeFeedOptions.getPartitionKeyRangeId() + ", ShouldInferSchema: " + shouldInferStreamSchema.toString())
252+
logDebug(s"--> readChangeFeed, PageSize: ${changeFeedOptions.getPageSize().toString()}, ContinuationToken: ${changeFeedOptions.getRequestContinuation()}, PartitionId: ${changeFeedOptions.getPartitionKeyRangeId()}, ShouldInferSchema: ${shouldInferStreamSchema.toString()}")
253253

254254
// The ChangeFeed API in the SDK allows accessing the continuation token
255255
// from the latest HTTP Response
@@ -293,12 +293,14 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
293293
// document with Id <lastProcessedIdBookmark>
294294
var previousBlockStartContinuation = originalContinuation
295295

296-
// The continuation token that would need to be used to retrive the next block
296+
// blockStartContinuation is used as a place holder to store the feedResponse.getResponseContinuation()
297+
// of the previous HTTP response to be able to apply it to previousBlockStartContinuation
298+
// accordingly
297299
var blockStartContinuation = originalContinuation
298300

299301
// This method can result in reading the next page of the changefeed and changing the continuation token header
300302
val feedResponse = documentClient.queryDocumentChangeFeed(collectionLink, changeFeedOptions)
301-
logDebug(" readChangeFeed.InitialResponseContinuation: " + feedResponse.getResponseContinuation())
303+
logDebug(s" readChangeFeed.InitialResponseContinuation: ${feedResponse.getResponseContinuation()}")
302304

303305
// If processing from the beginning (no continuation token passed into this method)
304306
// it is safe to increase previousBlockStartContinuation here because we always at least return
@@ -319,7 +321,7 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
319321
// hasNext can result in reading the next page of the changefeed and changing the continuation token header
320322
while (feedResponse.getQueryIterator.hasNext)
321323
{
322-
logDebug(" readChangeFeed.InWhile ContinuationToken: " + blockStartContinuation)
324+
logDebug(s" readChangeFeed.InWhile ContinuationToken: ${blockStartContinuation}")
323325
// fetchNextBlock can result in reading the next page of the changefeed and changing the continuation token header
324326
val feedItems = feedResponse.getQueryIterable.fetchNextBlock()
325327

@@ -354,7 +356,7 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
354356
}
355357
}
356358
}
357-
logDebug(s"Receving " + cfDocuments.length.toString() + " change feed items ${if (cfDocuments.nonEmpty) cfDocuments(0)}")
359+
logDebug(s"Receving ${cfDocuments.length.toString()} change feed items ${if (cfDocuments.nonEmpty) cfDocuments(0)}")
358360

359361
if (cfDocuments.length > 0)
360362
{
@@ -365,7 +367,7 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
365367
{
366368
nextContinuation = previousBlockStartContinuation + "|" + feedItems.last.get("id")
367369

368-
logDebug(" readChangeFeed.MaxPageCountExceeded NextContinuation: " + nextContinuation)
370+
logDebug(s" readChangeFeed.MaxPageCountExceeded NextContinuation: ${nextContinuation}")
369371
break;
370372
}
371373
else
@@ -380,12 +382,12 @@ private[spark] case class CosmosDBConnection(config: Config) extends CosmosDBLog
380382
previousBlockStartContinuation = blockStartContinuation
381383
blockStartContinuation = nextContinuation
382384

383-
logDebug(" readChangeFeed.EndInWhile NextContinuation: " + nextContinuation + ", blockStartContinuation: " + blockStartContinuation + ", previousBlockStartContinuation: " + previousBlockStartContinuation)
385+
logDebug(s" readChangeFeed.EndInWhile NextContinuation: ${nextContinuation}, blockStartContinuation: ${blockStartContinuation}, previousBlockStartContinuation: ${previousBlockStartContinuation}")
384386
}
385387
}
386388
}
387389

388-
logDebug("<-- readChangeFeed, Count: " + cfDocuments.length.toString() + ", NextContinuation: " + nextContinuation)
390+
logDebug(s"<-- readChangeFeed, Count: ${cfDocuments.length.toString()}, NextContinuation: ${nextContinuation}")
389391
Tuple2.apply(cfDocuments.iterator(), nextContinuation)
390392
} else
391393
{

0 commit comments

Comments
 (0)