Repository: incubator-predictionio Updated Branches: refs/heads/develop 7111b74dc -> 0fa51c291
[PIO-64] Fixed a bug that JDBCPEvents unit tests fail intermittently. Closes #382 Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/commit/0fa51c29 Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/tree/0fa51c29 Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/diff/0fa51c29 Branch: refs/heads/develop Commit: 0fa51c29104f9f776ec26ee2d9a211cb304a1dd3 Parents: 7111b74 Author: shimamoto <[email protected]> Authored: Thu May 18 16:55:35 2017 +0900 Committer: shimamoto <[email protected]> Committed: Thu May 18 17:12:37 2017 +0900 ---------------------------------------------------------------------- .../apache/predictionio/core/SelfCleaningDataSource.scala | 2 +- .../apache/predictionio/data/storage/jdbc/JDBCPEvents.scala | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/0fa51c29/core/src/main/scala/org/apache/predictionio/core/SelfCleaningDataSource.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/predictionio/core/SelfCleaningDataSource.scala b/core/src/main/scala/org/apache/predictionio/core/SelfCleaningDataSource.scala index acbd4a9..3520d80 100644 --- a/core/src/main/scala/org/apache/predictionio/core/SelfCleaningDataSource.scala +++ b/core/src/main/scala/org/apache/predictionio/core/SelfCleaningDataSource.scala @@ -180,7 +180,7 @@ trait SelfCleaningDataSource { sc: SparkContext ): Unit = { val (appId, channelId) = Common.appNameToId(appName, None) - pEventsDb.write(newEvents, appId)(sc) + pEventsDb.write(newEvents.map(x => recreateEvent(x, None, x.eventTime)), appId)(sc) removePEvents(eventsToRemove, appId, sc) } http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/0fa51c29/storage/jdbc/src/main/scala/org/apache/predictionio/data/storage/jdbc/JDBCPEvents.scala ---------------------------------------------------------------------- diff --git a/storage/jdbc/src/main/scala/org/apache/predictionio/data/storage/jdbc/JDBCPEvents.scala b/storage/jdbc/src/main/scala/org/apache/predictionio/data/storage/jdbc/JDBCPEvents.scala index ff16d5d..487ae2f 100644 --- a/storage/jdbc/src/main/scala/org/apache/predictionio/data/storage/jdbc/JDBCPEvents.scala +++ b/storage/jdbc/src/main/scala/org/apache/predictionio/data/storage/jdbc/JDBCPEvents.scala @@ -146,14 +146,7 @@ class JDBCPEvents(client: String, config: StorageClientConfig, namespace: String case "postgresql" => eventsColumnNamesInDF.map(_.toLowerCase) case _ => eventsColumnNamesInDF } - val eventDF = events.map(x => - Event(eventId = None, event = x.event, entityType = x.entityType, - entityId = x.entityId, targetEntityType = x.targetEntityType, - targetEntityId = x.targetEntityId, properties = x.properties, - eventTime = x.eventTime, tags = x.tags, prId = x.prId, - creationTime = x.eventTime) - ) - .map { event => + val eventDF = events.map { event => (event.eventId.getOrElse(JDBCUtils.generateId) , event.event , event.entityType
