OpenRefine / OpenRefine/OpenRefine
Replace use of java.util.Properties in Bindings
@tfmorris is already working on this.
Since Feb 26, 2024.
- Dominant language
- Java
- Stars
- 12k
- Forks
- 2.2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 27
Description
Currently our variable storage, called "bindings", uses the java.util.Properties class for its implementation and its interface. It also pre-populates a variety of standard variables with newly instantiated objects WrappedCell, WrappedRow, and CellTuple which are rarely ever used, causing the object creation overhead to be wasted
Although it's strongly discouraged, the current code bypasses the setProperty and getProperty methods to use Hashtable's get() and put() directly, allowing it to support an effective contract of Map<String, Object> (but without support for null values since Hashtable doesn't support them).
Proposed solution
- Introduce a Bindings class which of
HashMap<String, Object>which does lazy creation of all wrapped objects only when they are needed. - Extend the interfaces which currently use
PropertieslikeEvaluable,HasFields,HasFieldsList,Function, andControlto use the new Bindings class with default implementations for backward compatibility. - Extend
Binderinterface to implement implement the new variable lookup protocol - Change code which does direct creation of bindings using
new Properties()to useExpressionUtils.getBindings(Project)like the main code does. Most occurrences of this pattern are scattered throughout the test code. - Log warnings on the console (or notify user at startup?) if any legacy Function, Control, or Binder is registered.
Alternatives considered
- Not attempt compatibility and force all extension writers to update their code immediately.
- Compatibility could be implemented on a per-call basis or the entire system could fall back to legacy mode if any legacy Function, Control, or Binder is registered - to be investigated if this simplifies things
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.