java.lang.Object
io.github.mnesimiyilmaz.sql4json.engine.FieldKey.Interner
Enclosing class:
FieldKey

public static final class FieldKey.Interner extends Object
Query-scoped interner — created once per query execution, GC'd when query finishes. Sharing identical path strings and FieldKey instances across rows reduces GC pressure.
  • Constructor Details

    • Interner

      public Interner()
      Creates a new empty interner.
  • Method Details

    • intern

      public String intern(String s)
      Interns a string, returning the canonical instance.

      Hand-rolled get/put pair instead of computeIfAbsent(s, k -> k) — the lambda form allocates a fresh closure on every call (cache hit or miss), which dominated allocations during JsonParser-heavy workloads (profiler: 537 MB of FieldKey$Interner$$Lambda on a 512 MB GROUP BY query).

      Parameters:
      s - the string to intern
      Returns:
      the canonical instance of the string
    • internFieldKey

      public FieldKey internFieldKey(String key)
      Interns a FieldKey, returning the canonical instance for the given key path.

      Lambda-free hot path — see intern(String) for the rationale.

      Parameters:
      key - the field key path to intern
      Returns:
      the canonical FieldKey instance for the given path