Using Univocity framework to do custom parsing requirements. we have an iterator outputing each line as an event by calling parseNext(), we do not want to use "parse(File file)" .
We have this Scala case class as the final output but at the moment we are handling output from parser and using a factory class to create scala case classes.
Is there an iterator way to generate case class objects from univocity (I did find BeanListProcessor but which does not work for iterator way)?
Answer can be in Java or Scala..
Thanks, R
def parseRecord(field: Array[String], univocityContext: Option[ParsingContext]): Option[lineEvent] = {
val parsingContext = univocityContext.get
val parsedEvent = new ParsedEventConstructor()
for ((index, counter) <- parsingContext.extractedFieldIndexes().zipWithIndex){
val columnHeader = parsingContext.headers()(index)
columnHeader match {
case "header1" => {
parsedEvent.parsedheader1 += field(counter)
}
case "header2" => {
parsedEvent.parsedheader2 += field(counter)
}
case _ => parsedEvent.parsedOtherValues += field(counter)
}
}
Some(parsedEvent.getParsedEvent())
}