Module: HBase::Table::ThreadLocalCache

Defined in:
lib/hbase-jruby/table.rb

Instance Method Summary collapse

Instance Method Details

#lookup_and_parse(col, expect_cq) ⇒ Object

Schema lookup with column-key caching



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/hbase-jruby/table.rb', line 320

def lookup_and_parse col, expect_cq
  cache = thread_local(@hbase, @name_sym, :columns)

  # Column-key cache invalidation
  schema = @hbase.schema
  if schema.to_h.object_id != @schema_h.object_id
    @schema_h = schema.to_h
    cache.clear
  end

  unless parsed = cache[col]
    parsed = schema.lookup_and_parse(@name_sym, col, expect_cq)
    cache[col] = parsed if cache.length < @cache_size
  end
  parsed
end