norikra-udf-lookup 0.0.1-java → 0.0.2-java
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 +4 -4
- data/jar/norikra-udf-lookup.jar +0 -0
- data/lib/esper_plugin/lookup.rb +17 -5
- data/lib/norikra/udf/lookup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29af22d854e0f0a23b4b24a06c00ae1d536ccf90
|
|
4
|
+
data.tar.gz: 301d3a84cbf3430fcf14620823f80aa20c9eae51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b709009220bc532c95207bd97faa6e519bed2645da1a368b1f168f6e677d3c66b276222e9242185345431a7e864de72a2e82703ddcb510381e785a2999fed5f
|
|
7
|
+
data.tar.gz: 72d6e73c9f20069a9174d31b0139ab29bb36db816ea1b400e6a51d602540108b0163a4b82f03082bca03496bc7710df5f4bd7e04a357945da118bbfecc6a8cd2
|
data/jar/norikra-udf-lookup.jar
CHANGED
|
Binary file
|
data/lib/esper_plugin/lookup.rb
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
require 'java'
|
|
2
2
|
java_package 'jp.gr.java_conf.ogibayashi.norikra.udf'
|
|
3
3
|
|
|
4
|
-
class Lookup
|
|
5
|
-
|
|
4
|
+
class Lookup
|
|
5
|
+
FILE_UPDATE_CHECK_INTERVAL = 60
|
|
6
|
+
@@lookup_table = Hash.new
|
|
7
|
+
@@next_update_check = nil
|
|
6
8
|
|
|
7
9
|
def self.read_tsv(path)
|
|
10
|
+
info "Lookup#read_tsv Loading file : #{path}" if @logger
|
|
11
|
+
@@next_update_check = Time.now + FILE_UPDATE_CHECK_INTERVAL
|
|
8
12
|
data = File.open(path).readlines.map do |line|
|
|
9
13
|
line.chomp.split("\t")
|
|
10
14
|
end
|
|
@@ -12,9 +16,17 @@ class Lookup # FQDN: org.example.yourcompany.norikra.udf.MyUDF1
|
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def self.lookup_tsv(path,key,default_value)
|
|
15
|
-
unless @@lookup_table
|
|
16
|
-
@@lookup_table = self.read_tsv(path)
|
|
19
|
+
unless @@lookup_table[path]
|
|
20
|
+
@@lookup_table[path] = self.read_tsv(path)
|
|
17
21
|
end
|
|
18
|
-
|
|
22
|
+
if Time.now > @@next_update_check
|
|
23
|
+
# Check if file was updated in last FILE_UPDATE_CHECK_INTERVAL sec.
|
|
24
|
+
if File::Stat.new(path).mtime > (@@next_update_check - FILE_UPDATE_CHECK_INTERVAL)
|
|
25
|
+
@@lookup_table[path] = self.read_tsv(path)
|
|
26
|
+
else
|
|
27
|
+
@@next_update_check = Time.now + FILE_UPDATE_CHECK_INTERVAL
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
@@lookup_table[path][key] || default_value
|
|
19
31
|
end
|
|
20
32
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: norikra-udf-lookup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Hironori Ogibayashi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-07-
|
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|