Skip to content

[#noissue] Inject StringAllocatorFactory into the span row mapper#14061

Merged
emeroad merged 1 commit into
pinpoint-apm:masterfrom
emeroad:spanmapper-allocator-inject
Jul 23, 2026
Merged

[#noissue] Inject StringAllocatorFactory into the span row mapper#14061
emeroad merged 1 commit into
pinpoint-apm:masterfrom
emeroad:spanmapper-allocator-inject

Conversation

@emeroad

@emeroad emeroad commented Jul 23, 2026

Copy link
Copy Markdown
Member

SpanMapperV2 created CachedStringAllocator from a raw cacheSize int per
row. Introduce StringAllocatorFactory owning the per-scope allocation
strategy: the property binding moves to TraceConfiguration, and the
mapper just calls create() per row. The factory contract documents why
a caching allocator must not outlive a single row decode (its keys wrap
the row's backing array).

SpanMapperV2 created CachedStringAllocator from a raw cacheSize int per
row. Introduce StringAllocatorFactory owning the per-scope allocation
strategy: the property binding moves to TraceConfiguration, and the
mapper just calls create() per row. The factory contract documents why
a caching allocator must not outlive a single row decode (its keys wrap
the row's backing array).
@emeroad emeroad added this to the 4.0.0 milestone Jul 23, 2026
@emeroad
emeroad requested a review from Copilot July 23, 2026 09:42
@sonarqubecloud

Copy link
Copy Markdown

@emeroad
emeroad merged commit c78d80f into pinpoint-apm:master Jul 23, 2026
5 checks passed
@emeroad
emeroad deleted the spanmapper-allocator-inject branch July 23, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors trace span row decoding to use an injected StringAllocatorFactory, centralizing the string-allocation/caching strategy in Spring configuration and ensuring allocators are created per row decode scope (avoiding cache key lifetime issues tied to row backing arrays).

Changes:

  • Introduces StringAllocatorFactory in commons-buffer to create per-scope StringAllocator instances (default vs LRU-cached).
  • Moves web.hbase.mapper.cache.string.size property binding into TraceConfiguration and exposes a StringAllocatorFactory bean.
  • Updates SpanMapperV2 and SpanMapperFactory to use the factory rather than constructing CachedStringAllocator directly from an int.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
web/src/main/java/com/navercorp/pinpoint/web/trace/TraceConfiguration.java Adds a StringAllocatorFactory bean wired from web.hbase.mapper.cache.string.size.
web/src/main/java/com/navercorp/pinpoint/web/trace/dao/mapper/SpanMapperV2.java Replaces per-row cacheSize logic with stringAllocatorFactory.create() per row.
web/src/main/java/com/navercorp/pinpoint/web/trace/dao/mapper/SpanMapperFactory.java Injects StringAllocatorFactory and passes it into SpanMapperV2 constructors.
commons-buffer/src/main/java/com/navercorp/pinpoint/common/buffer/StringAllocatorFactory.java Adds the new factory interface and implementations for default vs cached allocators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +39
static StringAllocatorFactory cached(int cacheSize) {
return new CachedStringAllocatorFactory(cacheSize);
}
Comment on lines +19 to +23
/**
* Creates a {@link StringAllocator} per decode scope. Callers must call
* {@link #create()} once per scope (e.g. per row) and not share the returned
* allocator across scopes: a caching allocator keys on buffers over the
* decoded data's backing array, so it must not outlive that array.
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.70%. Comparing base (71ba12e) to head (b59e3d0).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...pinpoint/common/buffer/StringAllocatorFactory.java 0.00% 10 Missing ⚠️
...rp/pinpoint/web/trace/dao/mapper/SpanMapperV2.java 0.00% 6 Missing ⚠️
...npoint/web/trace/dao/mapper/SpanMapperFactory.java 0.00% 4 Missing ⚠️
...vercorp/pinpoint/web/trace/TraceConfiguration.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14061      +/-   ##
============================================
- Coverage     34.71%   34.70%   -0.02%     
+ Complexity    12357    12353       -4     
============================================
  Files          4205     4206       +1     
  Lines         99972    99984      +12     
  Branches      10720    10720              
============================================
- Hits          34707    34699       -8     
- Misses        62321    62338      +17     
- Partials       2944     2947       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants