Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
2a4a2839
Unverified
Commit
2a4a2839
authored
8 months ago
by
Oleksandr Yakushev
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
perf: Work around Apache POI ColumnHelper performance bug (#45667)
parent
8aeebaa2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/query_processor/streaming/xlsx.clj
+30
-0
30 additions, 0 deletions
src/metabase/query_processor/streaming/xlsx.clj
with
30 additions
and
0 deletions
src/metabase/query_processor/streaming/xlsx.clj
+
30
−
0
View file @
2a4a2839
...
...
@@ -395,6 +395,35 @@
(
catch
Exception
_
value
value
))))
;; ColumnHelper hack.
;;
;; Starting with Apache POI 5.2.3, when a cell is added, its default style is computed from the styles of the whole
;; column. When exporting big datasets, this creates a lot of unnecessary work. Unfortunately, there is no easy way to
;; undo this other than hacking into private fields to replace the ColumnHelper object with our custom proxy.
;;
;; See https://github.com/apache/poi/blob/0dac5680/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java#L306.
(
defn-
private-field
^
java.lang.reflect.Field
[
object
field-name
]
(
doto
(
.getDeclaredField
(
class
object
)
field-name
)
(
.setAccessible
true
)))
(
defn-
sxssfsheet->xssfsheet
[
sxssfsheet
]
(
.get
(
private-field
sxssfsheet
"_sh"
)
sxssfsheet
))
(
defn-
xssfsheet->worksheet
[
xssfsheet
]
(
.get
(
private-field
xssfsheet
"worksheet"
)
xssfsheet
))
(
defn-
no-style-column-helper
"Returns a proxy ColumnHelper that always returns `-1` (meaning empty style) as a default column style."
[
worksheet
]
(
proxy
[
org.apache.poi.xssf.usermodel.helpers.ColumnHelper
]
[
worksheet
]
(
getColDefaultStyle
[
idx
]
-1
)))
(
defn-
set-no-style-custom-helper
[
sxssfsheet
]
(
let
[
xssfsheet
(
sxssfsheet->xssfsheet
sxssfsheet
)
new-helper
(
no-style-column-helper
(
xssfsheet->worksheet
xssfsheet
))]
(
.set
(
private-field
xssfsheet
"columnHelper"
)
xssfsheet
new-helper
)))
(
defmulti
^
:private
add-row!
"Adds a row of values to the spreadsheet. Values with the `scaled` viz setting are scaled prior to being added.
...
...
@@ -569,6 +598,7 @@
[
_
^
OutputStream
os
]
(
let
[
workbook
(
SXSSFWorkbook.
)
sheet
(
spreadsheet/add-sheet!
workbook
(
tru
"Query result"
))
_
(
set-no-style-custom-helper
sheet
)
data-format
(
.
workbook
createDataFormat
)
cell-styles
(
volatile!
nil
)
typed-cell-styles
(
volatile!
nil
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment