Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,25 @@ trait StreamTest extends QueryTest with SharedSQLContext with TimeLimits with Be
val defaultCheckpointLocation =
Utils.createTempDir(namePrefix = "streaming.metadata").getCanonicalPath
try {
startedTest.foreach { action =>
val actionIterator = startedTest.iterator.buffered
while (actionIterator.hasNext) {
// Synchronize sequential addDataMemory actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

// Synchronize --> // Collectively synchronize .... actions so that the data gets added together in a single batch.

val addDataMemoryActions = ArrayBuffer[AddDataMemory[_]]()
while (actionIterator.hasNext && actionIterator.head.isInstanceOf[AddDataMemory[_]]) {
addDataMemoryActions.append(actionIterator.next().asInstanceOf[AddDataMemory[_]])
}
if (addDataMemoryActions.nonEmpty) {
val synchronizeAll = addDataMemoryActions
Copy link
Contributor

Choose a reason for hiding this comment

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

This is some magic-ish code. Can you add a bit more comments on how this compose thing works?

.map(t => t.source.synchronized[Unit] _)
.reduce(_.compose(_))
synchronizeAll {
addDataMemoryActions.foreach(handleAction)
}
} else {
handleAction(actionIterator.next())
}
}
def handleAction: StreamAction => Unit = { action =>
logInfo(s"Processing test stream action: $action")
action match {
case StartStream(trigger, triggerClock, additionalConfs, checkpointLocation) =>
Expand Down