ea 0.6.168 → 0.6.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '090f1fb06dd45d8a7e52fdb723d878cb05511eee38d52427841bd988cda57a2d'
4
- data.tar.gz: a0386f3f4e6272498094aa66bfaab99e56e103ef64528022bbd6b44f8e248f20
3
+ metadata.gz: 64f6853e4e379b487e27521e58c582e9c47dd73b73339d8a075baf3087d8d852
4
+ data.tar.gz: b63f0584ce8a41eb307de27aafd29b0d96c1aa0990f0abc402a2d2257dd947fb
5
5
  SHA512:
6
- metadata.gz: 129810cd09fe475f5f65495c69a3cc7dd21428e458777d0bd0fe3a91ea360247c2eab96a5f5f4ecf821eb715e641ebc63caafc687786998076ee24f04b34e485
7
- data.tar.gz: d542b2a4aa938c7e4aa052b6d414097000c2418b997eda660c47988fb9ca2a3db3de4ef5009db21334b09af71dc4d1c66b624a1c76e477fb2c25c0506e6c0a70
6
+ metadata.gz: 1df85538e3b6281a9f44297985c572ebbc1c635765665e5d1a26be8cd2ee23b6ae8eea35ed7c899e43e91fc5bc576b8797249d0029c4989e4092ae0a81e8bc8b
7
+ data.tar.gz: 0c1ccd9a42e9aa736c23406feb34cf2d976f3fa51af5bd0e825a9b13df98d548b4f362beeb03cb28169ce3eaa43f69b7526a3ae138e62b11335b55085fe06367
@@ -23,9 +23,11 @@ module Ea
23
23
  # @param database [Database] loaded QEA database
24
24
  # @param guidance [Object, nil] guidance document for the drops
25
25
  # @return [Context] the lazy per-class drop context
26
- def for(database, guidance: nil)
26
+ def for(database, guidance: nil, klass_cache_cap: nil)
27
27
  require_uml!
28
- Context.new(database, guidance)
28
+ Context.new(database, guidance,
29
+ klass_cache_cap: klass_cache_cap ||
30
+ Context::DEFAULT_KLASS_CACHE_CAP)
29
31
  end
30
32
 
31
33
  # Load a .qea file and return the parsed-source shape the
@@ -35,10 +37,12 @@ module Ea
35
37
  # @param qea_path [String] path to the .qea file
36
38
  # @param guidance [Object, nil] guidance document
37
39
  # @return [ParsedResult]
38
- def parsed(qea_path, guidance: nil)
40
+ def parsed(qea_path, guidance: nil, klass_cache_cap: nil)
39
41
  require_uml!
40
42
  database = Services::DatabaseLoader.new(qea_path).load
41
- context = Context.new(database, guidance)
43
+ context = Context.new(database, guidance,
44
+ klass_cache_cap: klass_cache_cap ||
45
+ Context::DEFAULT_KLASS_CACHE_CAP)
42
46
  ParsedResult.new(
43
47
  parser: context.parser,
44
48
  xmi_id_index: context.xmi_id_index,
@@ -53,10 +57,12 @@ module Ea
53
57
  # @param qea_path [String] path to the .qea file
54
58
  # @param guidance [Object, nil] guidance document
55
59
  # @return [LazyGraph]
56
- def parsed_graph(qea_path, guidance: nil)
60
+ def parsed_graph(qea_path, guidance: nil, klass_cache_cap: nil)
57
61
  require_uml!
58
62
  database = Services::DatabaseLoader.new(qea_path).load
59
- context = Context.new(database, guidance)
63
+ context = Context.new(database, guidance,
64
+ klass_cache_cap: klass_cache_cap ||
65
+ Context::DEFAULT_KLASS_CACHE_CAP)
60
66
  LazyGraph.new(
61
67
  parser: context.parser,
62
68
  uml_document: LazyDocument.new(context),
@@ -81,11 +87,19 @@ module Ea
81
87
  # first request and cached by their XMI id; packages are
82
88
  # wrappers over the database indexes, not materialized trees.
83
89
  class Context
90
+ # Long compiles render each klass table once, so an
91
+ # insertion-ordered LRU bound on the class graph trades
92
+ # re-transformation of evicted entries for bounded memory.
93
+ # 0 disables the cap (hold every class — measurement mode).
94
+ DEFAULT_KLASS_CACHE_CAP = 1024
95
+
84
96
  attr_reader :database, :guidance, :lookup
85
97
 
86
- def initialize(database, guidance = nil)
98
+ def initialize(database, guidance = nil,
99
+ klass_cache_cap: DEFAULT_KLASS_CACHE_CAP)
87
100
  @database = database
88
101
  @guidance = guidance
102
+ @klass_cache_cap = klass_cache_cap
89
103
  @klass_cache = {}
90
104
  @lookup = QeaLookup.new(database)
91
105
  @class_transformer = Factory::ClassTransformer.new(database)
@@ -112,11 +126,16 @@ module Ea
112
126
  return nil unless object
113
127
 
114
128
  xmi_id = object_xmi_id(object)
115
- cache_hit = @klass_cache[xmi_id]
116
- return cache_hit if cache_hit
129
+ if (cache_hit = @klass_cache[xmi_id])
130
+ @klass_cache[xmi_id] = @klass_cache.delete(xmi_id)
131
+ return cache_hit
132
+ end
117
133
 
118
134
  klass = @class_transformer.transform(object)
119
- @klass_cache[xmi_id] = klass if klass
135
+ if klass
136
+ @klass_cache[xmi_id] = klass
137
+ evict_lru
138
+ end
120
139
  klass
121
140
  end
122
141
 
@@ -178,6 +197,15 @@ module Ea
178
197
  object = database.find_object(ea_object_id)
179
198
  object && Factory::DataTypeTransformer.new(database).transform(object)
180
199
  end
200
+
201
+ private
202
+
203
+ # The insertion-ordered Hash makes oldest-first eviction O(1).
204
+ def evict_lru
205
+ return unless @klass_cache_cap&.positive?
206
+
207
+ @klass_cache.shift while @klass_cache.size > @klass_cache_cap
208
+ end
181
209
  end
182
210
 
183
211
  # The Loaded graph shape the table renders consume. Classes are
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.168"
7
+ VERSION = "0.6.175".freeze
8
8
  end
data/lib/ea/xmi/slicer.rb CHANGED
@@ -134,6 +134,12 @@ module Ea
134
134
  # --- pass one: index id-bearing containers and their references --
135
135
 
136
136
  class IndexHandler < ::Moxml::SAX::Handler
137
+ # Shared frozen empty for nodes created outside links blocks:
138
+ # links_refs only ever receives appends for the node itself
139
+ # while it opens inside a links block, so a shared empty is
140
+ # safe for every other node (hundreds of thousands of them).
141
+ EMPTY_REFS = [].freeze
142
+
137
143
  attr_reader :nodes
138
144
 
139
145
  def initialize
@@ -143,6 +149,12 @@ module Ea
143
149
  @refs_off = 0
144
150
  @events = 0
145
151
  @links_depth = 0
152
+ # Interned strings: element tags, xmi:type values, ids,
153
+ # parent ids and refs are all highly repetitive across a
154
+ # large export; pooling replaces per-occurrence fresh
155
+ # strings (hundreds of MB on a 98MB model) with shared
156
+ # frozen copies.
157
+ @strpool = {}
146
158
  end
147
159
 
148
160
  # Only gated containers become nodes (packagedElement in the
@@ -155,6 +167,7 @@ module Ea
155
167
  # the enclosing container's reference set instead.
156
168
  def on_start_element(name, attributes = {}, _namespaces = {})
157
169
  Slicer.gc_when_bloated if (@events += 1) % 50_000 == 0
170
+ name = pooled(name)
158
171
  @section << section_for(name, @section.last)
159
172
  @refs_off += 1 if name == "links"
160
173
  @links_depth += 1 if name == "links"
@@ -167,9 +180,9 @@ module Ea
167
180
  # ancestry and both occurrences' references; the entry
168
181
  # usually carries the name.
169
182
  existing.name ||= attributes["name"]
170
- existing.xmi_type ||= attributes["xmi:type"]
183
+ existing.xmi_type ||= pooled(attributes["xmi:type"]) if attributes["xmi:type"]
171
184
  collect_refs(attributes, existing.refs)
172
- @stack << [id, existing.refs]
185
+ @stack << [pooled(id), existing.refs]
173
186
  return
174
187
  end
175
188
  # the parent is the nearest id-bearing element already on the
@@ -180,17 +193,18 @@ module Ea
180
193
  else
181
194
  (@stack.last ? @stack.last[1] : [])
182
195
  end
183
- @stack << [is_node ? id : nil, refs]
196
+ @stack << [is_node ? pooled(id) : nil, refs]
184
197
  unless is_node
185
198
  collect_refs(attributes, refs)
186
199
  return
187
200
  end
188
201
 
189
202
  node = Node.new(
190
- id: id, tag: name,
191
- xmi_type: attributes["xmi:type"], name: attributes["name"],
203
+ id: id = pooled(id), tag: name,
204
+ xmi_type: attributes["xmi:type"] && pooled(attributes["xmi:type"]),
205
+ name: attributes["name"],
192
206
  parent_id: parent, section: @section.last, refs: refs,
193
- links_refs: []
207
+ links_refs: @links_depth.positive? ? [] : EMPTY_REFS
194
208
  )
195
209
  @nodes[id] = node
196
210
  collect_refs(attributes, node.refs)
@@ -236,9 +250,15 @@ module Ea
236
250
  return if @refs_off.positive?
237
251
 
238
252
  attributes.each_value do |v|
239
- refs << v if v.is_a?(String) && v.match?(EA_ID_RE)
253
+ refs << pooled(v) if v.is_a?(String) && v.match?(EA_ID_RE)
240
254
  end
241
255
  end
256
+
257
+ # One shared frozen copy per distinct string content. The pool
258
+ # is write-only per pass; fetch-else-store keeps repeats O(1).
259
+ def pooled(s)
260
+ @strpool.fetch(s) { @strpool[s] = -s }
261
+ end
242
262
  end
243
263
 
244
264
  def index_pass
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.168
4
+ version: 0.6.175
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-29 00:00:00.000000000 Z
11
+ date: 2026-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.159
19
+ version: 0.8.194
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.159
26
+ version: 0.8.194
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lutaml-path
29
29
  requirement: !ruby/object:Gem::Requirement