|
|
@@ -1,10 +1,10 @@
|
|
|
package com.example.model.helper
|
|
|
|
|
|
import java.io.{ByteArrayOutputStream, ObjectOutputStream}
|
|
|
-
|
|
|
import com.example.SparkConnect
|
|
|
import com.example.dao.{HdfsDao, ModelDao}
|
|
|
-import org.apache.spark.ml.PipelineModel
|
|
|
+import org.apache.spark.ml.classification.LogisticRegressionModel
|
|
|
+import org.apache.spark.ml.{Model, PipelineModel}
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
|
import org.springframework.stereotype.Component
|
|
|
|
|
|
@@ -52,4 +52,23 @@ class Utils extends SparkConnect{
|
|
|
// if (modelObject != null) return true
|
|
|
// return false
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @throws(classOf[Exception])
|
|
|
+ def storeLogisticModel(pipelineModel: LogisticRegressionModel, modelId: Int): Boolean = {
|
|
|
+ val modelPath = hdfsServer + "_" + modelId + ".model"
|
|
|
+
|
|
|
+
|
|
|
+ hdfsDao.deleteFileInHdfs(modelPath, true)
|
|
|
+
|
|
|
+ val flag = pipelineModel.save(modelPath)
|
|
|
+ val modelOfGet = modelDao.findById(modelId)
|
|
|
+
|
|
|
+ modelOfGet.setModelPath(modelPath)
|
|
|
+
|
|
|
+ val modelObject = modelDao.save(modelOfGet)
|
|
|
+ if (modelObject != null) return true
|
|
|
+
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|