ree 1.3.4 → 1.3.5

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: fc1a6ceaa82a725d38d02a6c62ed8f9db63b5af83e899442981c52edd3736ddc
4
- data.tar.gz: 85cdd65fc59888a77116379b51ae093cd53462d10567fec028bef06ff5673085
3
+ metadata.gz: 452953a21318a446a47364d8bc043f9fdbc2d8bfd85731714f6b10eeb1f553da
4
+ data.tar.gz: 3326d95a0384bed8a496de402d0ef7e2f126546976e7cc321dc2bb8b7bd0ffb4
5
5
  SHA512:
6
- metadata.gz: cd5e95f265f16c743c3b57115b15fb5e2054e09715cf8532ec82607e23c67bdc6495db827cc3f9192d47d3f524719b311bad17f3d7a28b8923d131a1e119a86d
7
- data.tar.gz: 16896abb9ded31351b057c6a992d380ba2611ac7cd9db90779d806106b8a381f1cf4a1e6762df19c7ba40073771a8f06f1d2699af8b0dc26c16e71d2b56de4d6
6
+ metadata.gz: 6350771b8847969833e106028195c609130b3476ccd9ab84701a84fb27401737ae57e1aee130d0c05ef04f3caf1cc34371f70b05220d5878c009b8760b907c07
7
+ data.tar.gz: 6e8c7039300062b1f470fc5d6f7d026f2bc6a66302109364ec6185915659371e661b02e05d45418191bd2d51402f57f5df9d219d48093b6d8eb20f9185ff8fdc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.3.4)
4
+ ree (1.3.5)
5
5
  base64
6
6
  commander
7
7
  logger
data/README.md CHANGED
@@ -449,6 +449,28 @@ end
449
449
  ### Disabling contracts
450
450
  If you want to disable contracts, set the `NO_CONTRACTS` environment variable. This will disable contracts and you won't have a performance hit.
451
451
 
452
+ ### DB load performance mode
453
+ Read models that load many rows pay for casting every column through the
454
+ mapper even though the DB driver already returns correctly typed values.
455
+ Enable the mode in `ree.setup.rb` (before any DAO or mapper is loaded):
456
+
457
+ ```ruby
458
+ if ENV['RUBY_ENV'] == 'production'
459
+ Ree.enable_db_load_performance_mode
460
+ end
461
+ ```
462
+
463
+ Mappers built while the mode is on compile a specialized `db_load` method:
464
+ primitive fields (`integer`, `string`, `bool`, `float`, `date`, `time`,
465
+ `date_time`, `rational`, `any`) skip casting behind a single type-guard
466
+ check, and dto construction avoids intermediate allocations. Values that
467
+ fail the guard (e.g. a date stored as a string inside `pg_jsonb`, or a
468
+ `BigDecimal` from a `numeric` column mapped to `float`) are cast exactly as
469
+ before, so results and errors are identical to the normal mode. Custom
470
+ types, enums, `pg_array`/`pg_jsonb` and nested mappers are always cast.
471
+ Calls with `role:`/`only:`/`except:` fall back to the generic
472
+ implementation. Running production under YJIT compounds the gain.
473
+
452
474
  ## Ree Schemas
453
475
  Coming soon...
454
476
 
@@ -8,4 +8,7 @@ end
8
8
  if ENV['RUBY_ENV'] == 'production'
9
9
  # Define preload context for registered objects
10
10
  Ree.preload_for(:production)
11
+
12
+ # Skip db casting for values already typecast by the DB driver
13
+ # Ree.enable_db_load_performance_mode
11
14
  end
data/lib/ree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ree
4
- VERSION = "1.3.4"
4
+ VERSION = "1.3.5"
5
5
  end
data/lib/ree.rb CHANGED
@@ -148,6 +148,23 @@ module Ree
148
148
  !!@hide_internal_swagger_endpoints
149
149
  end
150
150
 
151
+ # Mappers built while this mode is on compile a specialized :db_load
152
+ # method that trusts DB values already typecast by the driver: primitive
153
+ # fields skip casting behind a cheap type guard, and dto construction
154
+ # avoids intermediate allocations. Read at mapper build time, so enable
155
+ # it in ree.setup.rb before any DAO/mapper is loaded.
156
+ def enable_db_load_performance_mode
157
+ @db_load_performance_mode = true
158
+ end
159
+
160
+ def disable_db_load_performance_mode
161
+ @db_load_performance_mode = false
162
+ end
163
+
164
+ def db_load_performance_mode?
165
+ !!@db_load_performance_mode
166
+ end
167
+
151
168
  def obfuscated?
152
169
  ENV.has_key?('REE_LICENSE_KEY')
153
170
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov