OpenRefine / OpenRefine/OpenRefine

Replace use of java.util.Properties in Bindings

Open
#6,401 3 comments 0 reactions 1 assignee View on GitHub

@tfmorris is already working on this.

Since Feb 26, 2024.

grel refactoring Type: Feature Request
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 Properties like Evaluable, HasFields, HasFieldsList, Function, and Control to use the new Bindings class with default implementations for backward compatibility.
  • Extend Binder interface to implement implement the new variable lookup protocol
  • Change code which does direct creation of bindings using new Properties() to use ExpressionUtils.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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.