Kotlin / Kotlin/dataframe

Explore the possiblity to define schema and constunct object in Spring (DI framework) style

Open
#1,321 2 comments 1 reaction 2 assignees Claimed by @zaleslaw View on GitHub
research
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

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
```

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()
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

fun process() {
println(df.rowsCount())
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.