-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
researchThis requires a deeper dive to gather a better understandingThis requires a deeper dive to gather a better understanding
Description
Motivation:
- Nice to have an ability to hide reading the schema and object construction from the user in DI style where all the data sources and its life-cycle is managed by DI framework
- Unified approach for Spring developers
We want to have something like
@DataSource(csvFile = "data.csv")
val df: DataFrame<MyRowType>
it should be, for example RUNTIME-annotation
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.RUNTIME)
annotation class DataSource(val csvFile: String)
we need a DataFrame postprocessor in the style
@Component
class DataFramePostProcessor : BeanPostProcessor {
override fun postProcessBeforeInitialization(bean: Any, beanName: String): Any? {
bean::class.memberProperties.forEach { prop ->
val annotation = prop.findAnnotation<DataSource>()
if (annotation != null) {
val csvPath = annotation.csvFile
val dataFrame = DataFrame.readCSV(File(csvPath))
val field = bean.javaClass.getDeclaredField(prop.name)
field.isAccessible = true
field.set(bean, dataFrame)
}
}
return bean
}
}
The usage of the bean could be like below
@Component
class MyDataService {
@DataSource(csvFile = "data.csv")
lateinit var df: DataFrame<MyRow>
fun process() {
println(df.rowsCount())
}
}
Copilot
Metadata
Metadata
Labels
researchThis requires a deeper dive to gather a better understandingThis requires a deeper dive to gather a better understanding