I have a case class
case class S3FileRecords(
rank: Integer,
name: String,
)
and while passing this case class name inside the function of my class, its taking the entire path of case class instead of just taking the case class name.
My class:
class LocalFileReader extends FileHandler {
def read[S3FileRecords](rootDir: String, fileName: String): (List[String], List[S3FileRecords]) = {
// generate full path using rootDir and fileName
val file = new File(rootDir, fileName)
//Read content from the file path
val fileContent = new FileInputStream(file);
// zip data
val zipFileContent = new GZIPInputStream(fileContent)
//convert to json
val jsonfileContent = Source.fromInputStream(zipFileContent).mkString
//Deserialize jsonFileContent
val (err, ok) = jsonfileContent
.split("\n")
.map(decodeWithError)
.partitionMap(identity)
(err.toList, ok.toList)
}
def decodeWithError(str: String): Either[String, S3FileRecords] =
{
decode[S3FileRecords](str) match {
case Right(value) => Right(value)
case Left(ParsingFailure(message, _)) => Left(s"Error parsing string; Message: $message; Original string: $str")
case Left(DecodingFailure(message, ops)) => {
val failedCursor = str.asJson.hcursor.replay(ops).focus.toString
Left(s"Error decoding to ${classOf[S3FileRecords].toString};" +
s" Error Message: $message, Failed cursor: $failedCursor; Original record: $str")
}
}
}
}
(err.toList, ok.toList) This is throwing below ERROR :
Type mismatch. Required: scala.collection.immutable.List[S3FileRecords], found: scala.collection.immutable.List[user.path.s3FileEvent.S3FileRecords]
where S3FileRecords is the case class and user/path/s3FileEvent is the location of case class - S3FileRecords