lutaml-model 0.8.71 → 0.8.72

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: a883654d3aade8e954a1c8c13b5e90e93fbc31a50c91de6cf01112a6cab8309f
4
- data.tar.gz: f63078d1f4aacf1b33f9cc8a1170ddab301515195dfc415056924d533f087a94
3
+ metadata.gz: 95182bda9669da0320508b55f43356fede1a292ce745cf3909f8f1caa9b07b42
4
+ data.tar.gz: 9d28efcea7784103991d992e3e85a4fd4f00b8caf90ec3edf137bea4b2fdc768
5
5
  SHA512:
6
- metadata.gz: 1588bee4f62fdf4e5849d44286567400acb69f47df50569af652ebff39d02a437a6b9ff036f9a18affed3c176bd3ec192df2cd8b2b8fcce55721a34af432245e
7
- data.tar.gz: 20dae52f3cb83a71079724c6d882e16b5a0cd7a0f279d62d7e34f5b85c51b4e2d5a1755eb08d5cad09cc33ebc04fd88a3213f2e8888cf58d1ed768e31b69d00c
6
+ metadata.gz: '03994dc9b1069fc2fdb00f41b2ee949a0a9b9f0845673847af0b5c2ffff9d63e6a6d72078f03938f65e657dbb27b8fe29e426c9f6764b7ee692f49ce5b9cd3af'
7
+ data.tar.gz: 24f6867bb3851091561f98fbff70566f7734d58da18fa8ce2d9b220fb99d4a0ee87db1f497ce69278aa12462a7addb1e0bbccd726dfeb8e139aeb5c98c761c6d
@@ -12,6 +12,17 @@
12
12
  # bundle exec ruby bench/bench_uniword.rb
13
13
 
14
14
  require "bundler/setup"
15
+
16
+ # TODO.perf/15: run any benchmark with PLAN_COMPILE_STATS=1 to append
17
+ # the plan-compiler opt-out histogram (which clauses keep a corpus on
18
+ # the interpretive path) after the benchmark output.
19
+ if ENV["PLAN_COMPILE_STATS"]
20
+ at_exit do
21
+ require "pp"
22
+ puts "\nPlanCompiler opt-out histogram:"
23
+ pp(Lutaml::Xml::PlanCompiler.stats)
24
+ end
25
+ end
15
26
  require "benchmark"
16
27
  require "fileutils"
17
28
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.71"
5
+ VERSION = "0.8.72"
6
6
  end
7
7
  end
@@ -24,6 +24,19 @@ module Lutaml
24
24
  # full semantics audit (parent links, consolidation, ordering
25
25
  # metadata) completes.
26
26
  module PlanCompiler
27
+ # TODO.perf/15: env-gated histogram of why models opt out of the
28
+ # plan path. Set PLAN_COMPILE_STATS=1 and read PlanCompiler.stats
29
+ # after a parse. Zero cost when disabled.
30
+ def self.stats
31
+ @stats ||= Hash.new(0)
32
+ end
33
+
34
+ def self.opt_out!(clause)
35
+ @plan_stats ||= Hash.new(0)
36
+ @plan_stats[clause] += 1 if ENV["PLAN_COMPILE_STATS"]
37
+ nil
38
+ end
39
+
27
40
  # Isolated holder: suites freeze model classes; a cache on a
28
41
  # frozen constant would be immutable (TypeProbeCache precedent).
29
42
  PLAN_CACHE = ::Class.new do
@@ -103,8 +116,8 @@ module Lutaml
103
116
  else
104
117
  model_class.attributes(register)[rule.to]
105
118
  end
106
- return nil if attr.nil?
107
- return nil if attr.derived?
119
+ return opt_out!(:attr_nil) if attr.nil?
120
+ return opt_out!(:derived) if attr.derived?
108
121
 
109
122
  # Partition rows (TODO 34 step 2) ride native predicates
110
123
  # only in the plain-capture shape; any other when_attribute
@@ -118,7 +131,7 @@ module Lutaml
118
131
  !attr.polymorphic? && !attr.union? &&
119
132
  !(t.is_a?(Class) &&
120
133
  t.include?(::Lutaml::Model::Serialize))
121
- return nil unless plain_partition
134
+ return opt_out!(:non_plain_partition) unless plain_partition
122
135
  end
123
136
 
124
137
  # Interpretive hydration materializes every mapped
@@ -132,20 +145,20 @@ module Lutaml
132
145
  # ns-qualified models keep those rules interpretive.
133
146
  fragment_needed = rule.has_custom_method_for_deserialization? ||
134
147
  rule.polymorphic_mapping? || attr.polymorphic? || attr.union?
135
- return nil if fragment_needed && model_ns
148
+ return opt_out!(:fragment_with_ns) if fragment_needed && model_ns
136
149
 
137
150
  if rule.attribute?
138
- return nil unless scalar_type?(attr, register)
151
+ return opt_out!(:non_scalar) unless scalar_type?(attr, register)
139
152
  # Attribute plan rows are local-name keyed; a type-level
140
153
  # namespace makes the attribute (URI, local)-identified
141
154
  # (lutaml-model#744) — the interpretive matcher owns it
142
155
  # until plan rows carry namespace identity.
143
- return nil if attr.type_namespace_class(register)
156
+ return opt_out!(:attr_type_ns) if attr.type_namespace_class(register)
144
157
 
145
158
  attr_rows << [rule, attr]
146
159
  plan_attrs << { name: rule.name.to_s }
147
160
  elsif rule.content_mapping?
148
- return nil if content_rows(rows) >= 1
161
+ return opt_out!(:multi_content) if content_rows(rows) >= 1
149
162
 
150
163
  mixed_content = true
151
164
  compiled << [rule, attr,
@@ -161,7 +174,7 @@ module Lutaml
161
174
  rows << { name: rule.name.to_s, kind: :raw }
162
175
  elsif rule.polymorphic_mapping? || attr.polymorphic? || attr.union?
163
176
  type = attr.type(register)
164
- return nil unless serializable_type?(type) || attr.union?
177
+ return opt_out!(:non_serializable_poly) unless serializable_type?(type) || attr.union?
165
178
 
166
179
  needs_nodes = true
167
180
  compiled << [rule, attr, :polymorphic, nil, delegate_target]
@@ -170,7 +183,7 @@ module Lutaml
170
183
  type = attr.type(register)
171
184
  if serializable_type?(type)
172
185
  child = compile(type, register)
173
- return nil unless child
186
+ return opt_out!(:child_uncompilable) unless child
174
187
 
175
188
  if child[:ordered]
176
189
  # Ordered/mixed children need element_order on their
@@ -178,7 +191,7 @@ module Lutaml
178
191
  # source nodes, so the subtree defers interpretively
179
192
  # (the fragment parse runs the full machinery,
180
193
  # order included).
181
- return nil if model_ns
194
+ return opt_out!(:ordered_child_with_ns) if model_ns
182
195
 
183
196
  needs_nodes = true
184
197
  compiled << [rule, attr, :ordered_deferred, nil,
@@ -200,7 +213,7 @@ module Lutaml
200
213
  type_tag: (tag += 1) }
201
214
  end
202
215
  else
203
- return nil unless scalar_type?(attr, register)
216
+ return opt_out!(:non_scalar) unless scalar_type?(attr, register)
204
217
 
205
218
  row = { name: rule.name.to_s }
206
219
  row[:ns] = child_ns(rule, model_ns) if rule.namespace_set?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.71
4
+ version: 0.8.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.