flipkart-incubator / flipkart-incubator/databuilderframework
Proper way to access dataSet from DataBuilderContext
- Dominant language
- Java
- Stars
- 40
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
As of now there are two methods by which we can get dataset from `DataBuilderContext`
- `getDataSet()` (marked as `@Deprecated`)
- `getDataSet(DataBuilder builder)`
While implementing `DataBuilder#process(DataBuilderContext context)` we would need to get dataset and isn't using `context.getDataSet()` is the correct way to access? (If yes then why is it marked as deprecated?)
I don't see a clean way to use `getDataSet(DataBuilder builder)` inside `process`, if I do `getDataSet(this)` there will a NPE as there won't be any `dataBuilderMeta` set with current instance
`getDataSet(DataBuilder builder)` enforces to use only data classes mentioned in `consumes`, `optional` and `access` anyways this enforcement is already happening from executors when calling `process`.
Ref:
- [OptimizedMultiThreadedDataFlowExecutor.java#L251 ](https://github.com/flipkart-incubator/databuilderframework/blob/master/src/main/java/com/flipkart/databuilderframework/engine/OptimizedMultiThreadedDataFlowExecutor.java#L251)
- [SimpleDataFlowExecutor.java#L76](https://github.com/flipkart-incubator/databuilderframework/blob/master/src/main/java/com/flipkart/databuilderframework/engine/SimpleDataFlowExecutor.java#L76)
- [MultiThreadedDataFlowExecutor.java#L232](https://github.com/flipkart-incubator/databuilderframework/blob/master/src/main/java/com/flipkart/databuilderframework/engine/MultiThreadedDataFlowExecutor.java#L232)
Either we have to set `dataBuilderMeta` when processed in `withDataBuilder` [here](https://github.com/flipkart-incubator/databuilderframework/blob/master/src/main/java/com/flipkart/databuilderframework/engine/DataFlowBuilder.java#L178) something like `dataBuilder.setDataBuilderMeta(dataBuilderMeta)` which set's it to dataBuilder instance and can be accessed when processing or make other non-deprecated or I should be missing something 😅
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with DataBuilderContext and DataFlowBuilder around withDataBuilder, then compare how SimpleDataFlowExecutor, MultiThreadedDataFlowExecutor, and OptimizedMultiThreadedDataFlowExecutor invoke process. Trace when dataBuilderMeta is available and how each dataset-access method is intended to work. Done means the process API has one clear, non-deprecated dataset access path without the reported null-pointer risk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100