lutaml-model 0.8.207 → 0.8.209
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 +4 -4
- data/bench/baselines/main_mml.json +20 -20
- data/bench/baselines/main_niso.json +15 -15
- data/bench/baselines/main_sts.json +20 -20
- data/bench/baselines/main_unitsml.json +5 -5
- data/bench/baselines/main_xmi.json +20 -20
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/leptris/native_emission.rb +21 -0
- data/lib/lutaml/xml/leptris/plan_hydrator.rb +64 -16
- data/lib/lutaml/xml/leptris/plan_serializer.rb +228 -41
- data/lib/lutaml/xml/model_transform.rb +89 -28
- data/spec/lutaml/model/unmatched_rule_replay_spec.rb +127 -0
- data/spec/lutaml/model/writer_assigned_attribute_spec.rb +61 -0
- data/spec/lutaml/xml/leptris/nested_namespace_declaration_spec.rb +234 -0
- data/spec/lutaml/xml/leptris/plan_hydrator_bridge_scope_spec.rb +151 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c396586c2729a6d9858da3c633b98c574358efdb100964340d531f20545a618b
|
|
4
|
+
data.tar.gz: 8833a24a372af34a4cdcaf82ff7921ada9fe9053140609e1a89d6180de2b6c6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5748f05813b63d2b93c7957a07aba9ff3faa5bcd770c0609aaded9e38ecbc6eb5e246eaaf188654cb75679e9dae582fce48580947f91204558a34ffa22c6bf3
|
|
7
|
+
data.tar.gz: bcd7c3a604633dc61fdfbe8007c39dc09545d3f27bbf83b7a26218576279bf69af5582f3e76a2022413510a7fbc219bc25134525f353785eb7ec052b7626803c
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"complex1-46KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips": 27.
|
|
3
|
+
"avg_time": 0.0364748943333287,
|
|
4
|
+
"min_time": 0.035120398999993085,
|
|
5
|
+
"max_time": 0.037068958999995516,
|
|
6
|
+
"allocations": 48203,
|
|
7
|
+
"ips": 27.41611780589194
|
|
8
8
|
},
|
|
9
9
|
"complex4-50KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips":
|
|
10
|
+
"avg_time": 0.05115535466666188,
|
|
11
|
+
"min_time": 0.04903352099999836,
|
|
12
|
+
"max_time": 0.05247602199999335,
|
|
13
|
+
"allocations": 67781,
|
|
14
|
+
"ips": 19.548295706601824
|
|
15
15
|
},
|
|
16
16
|
"size1000-245KB": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips": 3.
|
|
17
|
+
"avg_time": 0.2900418076666635,
|
|
18
|
+
"min_time": 0.2876202389999918,
|
|
19
|
+
"max_time": 0.29324903599999175,
|
|
20
|
+
"allocations": 382265,
|
|
21
|
+
"ips": 3.447778815215738
|
|
22
22
|
},
|
|
23
23
|
"complex3-567KB": {
|
|
24
|
-
"avg_time": 0.
|
|
25
|
-
"min_time": 0.
|
|
26
|
-
"max_time": 0.
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips": 2.
|
|
24
|
+
"avg_time": 0.42179371233333995,
|
|
25
|
+
"min_time": 0.4200932080000115,
|
|
26
|
+
"max_time": 0.42285213400001,
|
|
27
|
+
"allocations": 560055,
|
|
28
|
+
"ips": 2.370827185801453
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metrology-4KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips":
|
|
3
|
+
"avg_time": 0.013732422666663524,
|
|
4
|
+
"min_time": 0.013354440000000523,
|
|
5
|
+
"max_time": 0.01399934799999869,
|
|
6
|
+
"allocations": 6644,
|
|
7
|
+
"ips": 72.8203627483426
|
|
8
8
|
},
|
|
9
9
|
"bmj-49KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips":
|
|
10
|
+
"avg_time": 0.11612695866666438,
|
|
11
|
+
"min_time": 0.11488018500000408,
|
|
12
|
+
"max_time": 0.11780903400000398,
|
|
13
|
+
"allocations": 61486,
|
|
14
|
+
"ips": 8.611264873218985
|
|
15
15
|
},
|
|
16
16
|
"pnas-152KB": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips": 2.
|
|
17
|
+
"avg_time": 0.4207894683333298,
|
|
18
|
+
"min_time": 0.4172780809999779,
|
|
19
|
+
"max_time": 0.4247577579999984,
|
|
20
|
+
"allocations": 233115,
|
|
21
|
+
"ips": 2.3764853335346467
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"feature-doc-23KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips":
|
|
3
|
+
"avg_time": 0.04404333933335162,
|
|
4
|
+
"min_time": 0.04362466399999221,
|
|
5
|
+
"max_time": 0.0444422120000354,
|
|
6
|
+
"allocations": 29387,
|
|
7
|
+
"ips": 22.70490873617193
|
|
8
8
|
},
|
|
9
9
|
"tbx-nisosts-101KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips": 6.
|
|
10
|
+
"avg_time": 0.15528667266666693,
|
|
11
|
+
"min_time": 0.15354131700001972,
|
|
12
|
+
"max_time": 0.15623446500001137,
|
|
13
|
+
"allocations": 114125,
|
|
14
|
+
"ips": 6.43970266622021
|
|
15
15
|
},
|
|
16
16
|
"iso-13849-1MB": {
|
|
17
|
-
"avg_time":
|
|
18
|
-
"min_time":
|
|
19
|
-
"max_time":
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips": 0.
|
|
17
|
+
"avg_time": 2.9371749226666943,
|
|
18
|
+
"min_time": 2.9121822650000126,
|
|
19
|
+
"max_time": 2.9545246739999698,
|
|
20
|
+
"allocations": 1419414,
|
|
21
|
+
"ips": 0.34046320914795525
|
|
22
22
|
},
|
|
23
23
|
"din-iso-1.1MB": {
|
|
24
|
-
"avg_time": 0.
|
|
25
|
-
"min_time": 0.
|
|
26
|
-
"max_time": 0.
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips": 1.
|
|
24
|
+
"avg_time": 0.6223951049999906,
|
|
25
|
+
"min_time": 0.6178283360000023,
|
|
26
|
+
"max_time": 0.6269072419999588,
|
|
27
|
+
"allocations": 846514,
|
|
28
|
+
"ips": 1.606696440840445
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"800-expressions": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips":
|
|
3
|
+
"avg_time": 0.13142044666666663,
|
|
4
|
+
"min_time": 0.12954049200000384,
|
|
5
|
+
"max_time": 0.13376315700000418,
|
|
6
|
+
"allocations": 139002,
|
|
7
|
+
"ips": 7.60916604199641
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"ea251": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips":
|
|
3
|
+
"avg_time": 0.15194719033331694,
|
|
4
|
+
"min_time": 0.15037986999999475,
|
|
5
|
+
"max_time": 0.15446484799997506,
|
|
6
|
+
"allocations": 175969,
|
|
7
|
+
"ips": 6.581233899793496
|
|
8
8
|
},
|
|
9
9
|
"medium": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips": 2.
|
|
10
|
+
"avg_time": 0.397459121333308,
|
|
11
|
+
"min_time": 0.39441433599995435,
|
|
12
|
+
"max_time": 0.401802325999995,
|
|
13
|
+
"allocations": 460164,
|
|
14
|
+
"ips": 2.515982012553696
|
|
15
15
|
},
|
|
16
16
|
"citygml": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips":
|
|
17
|
+
"avg_time": 0.4615553376666715,
|
|
18
|
+
"min_time": 0.45299937200002205,
|
|
19
|
+
"max_time": 0.4655662110000094,
|
|
20
|
+
"allocations": 571585,
|
|
21
|
+
"ips": 2.1665874455170644
|
|
22
22
|
},
|
|
23
23
|
"large": {
|
|
24
|
-
"avg_time":
|
|
25
|
-
"min_time":
|
|
26
|
-
"max_time":
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips": 0.
|
|
24
|
+
"avg_time": 3.8421088003333352,
|
|
25
|
+
"min_time": 3.769278003000011,
|
|
26
|
+
"max_time": 3.8997934000000214,
|
|
27
|
+
"allocations": 4399032,
|
|
28
|
+
"ips": 0.26027373298570866
|
|
29
29
|
}
|
|
30
30
|
}
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -350,6 +350,7 @@ module Lutaml
|
|
|
350
350
|
# refuse here: the doc takes the DOM lane.
|
|
351
351
|
child_plan = PlanCompiler.compile(item.class, register)
|
|
352
352
|
return false unless child_plan
|
|
353
|
+
return false if blank_opt_out_unspellable?(child_plan, item)
|
|
353
354
|
return false unless subtree_gate_ok?(child_plan, item,
|
|
354
355
|
register)
|
|
355
356
|
end
|
|
@@ -379,6 +380,26 @@ module Lutaml
|
|
|
379
380
|
!PlanCompiler.compile(child_type, register).nil?
|
|
380
381
|
end
|
|
381
382
|
|
|
383
|
+
# A nested island in default-namespace form (an EXACT tree ns
|
|
384
|
+
# without a prefix) over an item that recorded no prefix carries
|
|
385
|
+
# :blank rows — its local elements, in no namespace — that must
|
|
386
|
+
# opt out with xmlns="" (the island's own declaration would
|
|
387
|
+
# put them in its namespace). The ops spelling has no opt-out:
|
|
388
|
+
# ns_emittable? refuses the shape on the root, the DOM lane
|
|
389
|
+
# mints it for the island (a MathML island under a
|
|
390
|
+
# namespace-less root, #1342's family).
|
|
391
|
+
def blank_opt_out_unspellable?(child_plan, item)
|
|
392
|
+
return false if item.is_a?(::Lutaml::Model::Serialize) &&
|
|
393
|
+
prefixed_source?(item)
|
|
394
|
+
|
|
395
|
+
ns = child_plan.dig(:tree, :ns)
|
|
396
|
+
return false unless ns.is_a?(::Hash) && ns[:prefix].to_s.empty?
|
|
397
|
+
|
|
398
|
+
(child_plan.dig(:tree, :children) || []).any? do |r|
|
|
399
|
+
r[:ns] == :blank
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
382
403
|
# Namespace-emittability for ORDERED trees: content and
|
|
383
404
|
# wildcard rows carry no spelling of their own (content
|
|
384
405
|
# emits text; wildcards bail in subtree_gate_ok?), so the
|
|
@@ -19,8 +19,40 @@ module Lutaml
|
|
|
19
19
|
# child_row_plans).
|
|
20
20
|
CHILD_ROW_KINDS = %i[nested ordered_deferred].freeze
|
|
21
21
|
XSI_URI = "http://www.w3.org/2001/XMLSchema-instance"
|
|
22
|
+
# Fiber-local bridge context and its nesting depth (see call).
|
|
23
|
+
BRIDGE_CONTEXT_KEY = :lutaml_plan_hydrator_bridge_context
|
|
24
|
+
BRIDGE_DEPTH_KEY = :lutaml_plan_hydrator_bridge_depth
|
|
22
25
|
|
|
23
26
|
class << self
|
|
27
|
+
# Wrappers for deferred islands bridge leptris nodes into one
|
|
28
|
+
# moxml context per top-level deserialization, never for the
|
|
29
|
+
# process: on Ruby >= 4.0 (and < 3.4) moxml's wrapper registry
|
|
30
|
+
# is a strong Hash (moxml#303), and a context kept any longer
|
|
31
|
+
# pins every bridged document's whole tree for the life of the
|
|
32
|
+
# process — one registered wrapper references its native, the
|
|
33
|
+
# native its document, the document every node
|
|
34
|
+
# (lutaml-model#1335). Wrappers a model keeps stay alive
|
|
35
|
+
# through the model's own references; the registry's go when
|
|
36
|
+
# the deserialization returns.
|
|
37
|
+
def call(model_class, plan, value, **kwargs)
|
|
38
|
+
depth = (Thread.current[BRIDGE_DEPTH_KEY] || 0) + 1
|
|
39
|
+
Thread.current[BRIDGE_DEPTH_KEY] = depth
|
|
40
|
+
begin
|
|
41
|
+
hydrate(model_class, plan, value, **kwargs)
|
|
42
|
+
ensure
|
|
43
|
+
release_bridge_context(depth)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def release_bridge_context(depth)
|
|
48
|
+
if depth > 1
|
|
49
|
+
Thread.current[BRIDGE_DEPTH_KEY] = depth - 1
|
|
50
|
+
else
|
|
51
|
+
Thread.current[BRIDGE_DEPTH_KEY] = nil
|
|
52
|
+
Thread.current[BRIDGE_CONTEXT_KEY] = nil
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
24
56
|
# plan: the compiled plan entry for model_class
|
|
25
57
|
# value: the walk root PlanValue (element)
|
|
26
58
|
# node: the parsed source element (leptris); ordered/mixed
|
|
@@ -31,8 +63,25 @@ module Lutaml
|
|
|
31
63
|
# :lazy is honored as :eager — the lazy variant pins the
|
|
32
64
|
# raw engine DOM, the retention the eager default exists
|
|
33
65
|
# to avoid)
|
|
34
|
-
|
|
35
|
-
|
|
66
|
+
# parent_prefix: the enclosing instance's recorded source prefix
|
|
67
|
+
# (nil for the root) — a nested instance records its own only
|
|
68
|
+
# under a parent that recorded none, the interpretive reader's
|
|
69
|
+
# rule
|
|
70
|
+
def hydrate(model_class, plan, value, parent: nil, node: nil,
|
|
71
|
+
register: nil, declaration_plan_mode: :eager, intern: nil,
|
|
72
|
+
parent_prefix: nil)
|
|
73
|
+
# Prefix fidelity (the interpretive transform records it from
|
|
74
|
+
# the source element): prefixed sources keep their prefixes
|
|
75
|
+
# through the serialize lane's format preservation — on the
|
|
76
|
+
# root, and on a nested instance whose parent recorded none
|
|
77
|
+
# (the interpretive reader's rule; a nested island spelled
|
|
78
|
+
# `<p:leaf>` under a default-namespace root re-emits with its
|
|
79
|
+
# prefix, #1342).
|
|
80
|
+
source_prefix = if node.respond_to?(:prefix) then node.prefix end
|
|
81
|
+
own_prefix = if parent_prefix.to_s.empty? && source_prefix &&
|
|
82
|
+
!source_prefix.empty?
|
|
83
|
+
source_prefix
|
|
84
|
+
end
|
|
36
85
|
# The child model's declared lutaml_default_register takes
|
|
37
86
|
# precedence over the ambient register — the same
|
|
38
87
|
# resolve_for_child contract the interpretive path applies.
|
|
@@ -55,7 +104,7 @@ module Lutaml
|
|
|
55
104
|
child_kwargs, children, delegates, run_children,
|
|
56
105
|
element_children =
|
|
57
106
|
children_kwargs(model_class, plan, value, buckets, register,
|
|
58
|
-
intern, node: node)
|
|
107
|
+
intern, node: node, parent_prefix: own_prefix)
|
|
59
108
|
# A collection absent from the document keeps the
|
|
60
109
|
# deserialization seed's lazy sentinel and its default mark
|
|
61
110
|
# — the interpretive parse's state. The reader materializes
|
|
@@ -68,14 +117,7 @@ module Lutaml
|
|
|
68
117
|
instance = model_class.instantiate(attr_kwargs, register)
|
|
69
118
|
instance.lutaml_parent = parent if parent
|
|
70
119
|
instance.lutaml_root ||= parent&.lutaml_root || parent
|
|
71
|
-
|
|
72
|
-
# it from the source element): prefixed sources keep their
|
|
73
|
-
# prefixes through the serialize lane's format
|
|
74
|
-
# preservation.
|
|
75
|
-
if parent.nil? && node.respond_to?(:prefix) && node.prefix &&
|
|
76
|
-
!node.prefix.empty?
|
|
77
|
-
instance.xml_namespace_prefix = node.prefix
|
|
78
|
-
end
|
|
120
|
+
instance.xml_namespace_prefix = own_prefix if own_prefix
|
|
79
121
|
# #909: order summaries are per-instance pinned records —
|
|
80
122
|
# read-only consumers skip them via the config. Ordered and
|
|
81
123
|
# sequence models record them: the ordered walk replays
|
|
@@ -108,6 +150,8 @@ module Lutaml
|
|
|
108
150
|
instance
|
|
109
151
|
end
|
|
110
152
|
|
|
153
|
+
private :hydrate, :release_bridge_context
|
|
154
|
+
|
|
111
155
|
# leptris#1874: snapshot rows -> the ns_data hash
|
|
112
156
|
# ({path => {prefix_key => {uri:, prefix:, format:}}}), the
|
|
113
157
|
# exact shape the recursion builds. Public: it is the
|
|
@@ -405,7 +449,8 @@ module Lutaml
|
|
|
405
449
|
# parent/root links once the parent exists; delegate values
|
|
406
450
|
# wait for the instance (their target object must exist).
|
|
407
451
|
def children_kwargs(_model_class, plan, value, buckets = nil,
|
|
408
|
-
register = nil, intern = {}, node: nil
|
|
452
|
+
register = nil, intern = {}, node: nil,
|
|
453
|
+
parent_prefix: nil)
|
|
409
454
|
register ||= Lutaml::Model::Config.default_register
|
|
410
455
|
grouped, tagged, run_children = group_children(value,
|
|
411
456
|
plan[:row_tags])
|
|
@@ -506,7 +551,8 @@ module Lutaml
|
|
|
506
551
|
items = (selected || []).map do |n|
|
|
507
552
|
call(child_type, child_plan,
|
|
508
553
|
child_plan[:descriptor].walk(n), node: n,
|
|
509
|
-
register: child_register, intern: intern
|
|
554
|
+
register: child_register, intern: intern,
|
|
555
|
+
parent_prefix: parent_prefix)
|
|
510
556
|
end
|
|
511
557
|
unless items.empty?
|
|
512
558
|
children.concat(items)
|
|
@@ -576,7 +622,8 @@ module Lutaml
|
|
|
576
622
|
items = selected.map do |n|
|
|
577
623
|
call(child_type, child_plan,
|
|
578
624
|
child_plan[:descriptor].walk(n), node: n,
|
|
579
|
-
register: child_register, intern: intern
|
|
625
|
+
register: child_register, intern: intern,
|
|
626
|
+
parent_prefix: parent_prefix)
|
|
580
627
|
end
|
|
581
628
|
else
|
|
582
629
|
values = grouped.fetch(name, [])
|
|
@@ -591,7 +638,8 @@ module Lutaml
|
|
|
591
638
|
while pos < count
|
|
592
639
|
items[pos] = call(child_type, child_plan, values[pos],
|
|
593
640
|
node: cursor && cursor[pos],
|
|
594
|
-
register: child_register, intern: intern
|
|
641
|
+
register: child_register, intern: intern,
|
|
642
|
+
parent_prefix: parent_prefix)
|
|
595
643
|
pos += 1
|
|
596
644
|
end
|
|
597
645
|
end
|
|
@@ -804,7 +852,7 @@ module Lutaml
|
|
|
804
852
|
end
|
|
805
853
|
|
|
806
854
|
def bridge_context
|
|
807
|
-
|
|
855
|
+
Thread.current[BRIDGE_CONTEXT_KEY] ||= Moxml::Context.new(:leptris)
|
|
808
856
|
end
|
|
809
857
|
|
|
810
858
|
# Rows carry the delegate NAME (the interpretive
|