Class: Kumi::Core::Compiler::AccessCodegen
- Inherits:
-
Object
- Object
- Kumi::Core::Compiler::AccessCodegen
- Defined in:
- lib/kumi/core/compiler/access_codegen.rb
Constant Summary collapse
- CACHE =
{}
- CACHE_MUTEX =
Mutex.new
Class Method Summary collapse
Class Method Details
.compile(plan) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kumi/core/compiler/access_codegen.rb', line 19 def self.compile(plan) case plan.mode when :read then gen_read(plan) when :materialize then gen_materialize(plan) when :ravel then gen_ravel(plan) when :each_indexed then gen_each_indexed(plan) else raise "Unknown accessor mode: #{plan.mode.inspect}" end end |
.fetch_or_compile(plan) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/kumi/core/compiler/access_codegen.rb', line 12 def self.fetch_or_compile(plan) key = Digest::SHA1.hexdigest(Marshal.dump([plan.mode, plan.operations, plan.on_missing, plan.key_policy, plan.path])) CACHE_MUTEX.synchronize do CACHE[key] ||= compile(plan).tap(&:freeze) end end |