Sha256: bf75df1248f1079d00c207cab130b2ede94b6905ff16e5ef39bf79e4f8342f15

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 Bytes

Contents

require 'java'
java_package 'jp.gr.java_conf.ogibayashi.norikra.udf'

class Lookup  # FQDN: org.example.yourcompany.norikra.udf.MyUDF1
  @@lookup_table = nil
  
  def self.read_tsv(path)
    data = File.open(path).readlines.map do |line|
      line.chomp.split("\t")
    end
    Hash[data]
  end

  def self.lookup_tsv(path,key,default_value)
    unless @@lookup_table
      @@lookup_table = self.read_tsv(path)
    end
    @@lookup_table[key] || default_value
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
norikra-udf-lookup-0.0.1-java lib/esper_plugin/lookup.rb