java_bin 0.3.1 → 0.3.2
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.
- data/CHANGELOG +4 -0
- data/README.rdoc +1 -3
- data/VERSION +1 -1
- data/ext/java_bin/ext/extconf.rb +2 -2
- data/ext/java_bin/ext/parser.h +6 -4
- data/java_bin.gemspec +2 -2
- data/lib/java_bin/pure/parser.rb +3 -2
- data/test/test_java_bin_parser.rb +8 -7
- metadata +2 -2
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -46,7 +46,7 @@ This is an Apache Solr JavaBin format (binary format) implementation for Ruby.
|
|
46
46
|
|
47
47
|
* Ruby1.8.7 or later (include 1.9.x)
|
48
48
|
* (recommended) C compiler (gcc or vc++): you can also use java_bin without c extension, but 'pure' is 30 times slower than 'ext'.
|
49
|
-
* JavaBin has been tested with MRI 1.8.7, REE 1.8.7, YARV 1.9.2 pre1 on Ubuntu Linux 9.10 (32bit) and MRI 1.8.6 on Windows Vista (32bit), and Apache Solr 1.4
|
49
|
+
* JavaBin has been tested with MRI 1.8.7, REE 1.8.7, YARV 1.9.2 pre1 on Ubuntu Linux 9.10 (32bit) and MRI 1.8.6, YARV 1.9.1 on Windows Vista (32bit), and Apache Solr 1.4
|
50
50
|
|
51
51
|
== Install
|
52
52
|
|
@@ -91,9 +91,7 @@ This is an Apache Solr JavaBin format (binary format) implementation for Ruby.
|
|
91
91
|
|
92
92
|
* more parse speed
|
93
93
|
* license
|
94
|
-
* pure parse encoding bug (1.9.x)
|
95
94
|
* shared string over parsing
|
96
|
-
* windows build(1.9.x)
|
97
95
|
* 64bit build
|
98
96
|
* builder(writer)作成
|
99
97
|
* JRuby support
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/ext/java_bin/ext/extconf.rb
CHANGED
@@ -9,6 +9,8 @@ unless RUBY_PLATFORM =~ /mswin32/ # Linux
|
|
9
9
|
if CONFIG['CC'] =~ /gcc/
|
10
10
|
$CFLAGS << ' -Wall'
|
11
11
|
end
|
12
|
+
have_header("byteswap.h")
|
13
|
+
have_header("sys/types.h")
|
12
14
|
else # Windows
|
13
15
|
$CFLAGS.gsub!(/-O2b2xg-/, '/O2b2x')
|
14
16
|
$CFLAGS.gsub!(/-MD/, ' /MT')
|
@@ -18,8 +20,6 @@ end
|
|
18
20
|
|
19
21
|
$CFLAGS << ' -DRUBY_19' if RUBY_VERSION >= '1.9'
|
20
22
|
|
21
|
-
have_header("byteswap.h")
|
22
|
-
have_header("sys/types.h")
|
23
23
|
have_header("ruby.h")
|
24
24
|
have_header("ruby/encoding.h")
|
25
25
|
|
data/ext/java_bin/ext/parser.h
CHANGED
@@ -102,10 +102,12 @@ typedef struct java_bin_parser {
|
|
102
102
|
#endif
|
103
103
|
|
104
104
|
#ifdef _WIN32
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
#ifndef RUBY_19
|
106
|
+
typedef signed char int8_t;
|
107
|
+
typedef signed short int16_t;
|
108
|
+
typedef signed int int32_t;
|
109
|
+
typedef signed __int64 int64_t;
|
110
|
+
#endif
|
109
111
|
typedef unsigned char u_int8_t;
|
110
112
|
typedef unsigned short u_int16_t;
|
111
113
|
typedef unsigned int u_int32_t;
|
data/java_bin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{java_bin}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kennyj"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.description = %q{Apache Solr JavaBin format (binary format) implementation for Ruby.}
|
14
14
|
s.email = %q{kennyj@gmail.com}
|
15
15
|
s.extensions = ["ext/java_bin/ext/extconf.rb"]
|
data/lib/java_bin/pure/parser.rb
CHANGED
@@ -47,7 +47,7 @@ module JavaBin
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def parse(input)
|
50
|
-
array = input.
|
50
|
+
array = input.unpack("C*")
|
51
51
|
check_version(array[0])
|
52
52
|
@input = array
|
53
53
|
@current = 1 # HINT VERSIONをとばす
|
@@ -191,7 +191,7 @@ module JavaBin
|
|
191
191
|
|
192
192
|
def read_chars
|
193
193
|
size = read_size
|
194
|
-
str =
|
194
|
+
str = []
|
195
195
|
size.times {
|
196
196
|
# HINT. read utf-8 char
|
197
197
|
b = getbyte
|
@@ -208,6 +208,7 @@ module JavaBin
|
|
208
208
|
str << getbyte
|
209
209
|
end
|
210
210
|
}
|
211
|
+
str = str.pack("C*")
|
211
212
|
str.force_encoding('utf-8') if str.respond_to? :force_encoding
|
212
213
|
str
|
213
214
|
end
|
@@ -13,7 +13,8 @@ end
|
|
13
13
|
|
14
14
|
class TestJavaBinParser < Test::Unit::TestCase
|
15
15
|
|
16
|
-
|
16
|
+
READ_UTF8 = (RUBY_VERSION >= '1.9' ? 'rb:utf-8' : 'rb')
|
17
|
+
READ_ASCII = (RUBY_VERSION >= '1.9' ? 'rb:ascii' : 'rb')
|
17
18
|
|
18
19
|
private
|
19
20
|
def write_v_int(i, output)
|
@@ -63,22 +64,22 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def test_javabin_dat
|
66
|
-
result = @parser.parse(open("fixtures/javabin.dat",
|
67
|
+
result = @parser.parse(open("fixtures/javabin.dat", READ_ASCII).read)
|
67
68
|
assert result['response']['docs'][0]['features'].include?('eaiou with umlauts: ëäïöü')
|
68
69
|
assert_equal result['response']['docs'][1]['incubationdate_dt'], Time.local(2006, 1, 17, 9, 0, 0)
|
69
70
|
assert_equal result['response']['docs'][1]['score'], 0.5030758380889893
|
70
71
|
end
|
71
72
|
|
72
73
|
def test_javabin2_dat
|
73
|
-
result = @parser.parse(open("fixtures/javabin2.dat",
|
74
|
+
result = @parser.parse(open("fixtures/javabin2.dat", READ_ASCII).read)
|
74
75
|
assert_equal 19, result['response']['docs'].size
|
75
76
|
end
|
76
77
|
|
77
78
|
|
78
79
|
TIMES = 5000
|
79
80
|
def test_javabin_parse_and_ruby_eval
|
80
|
-
r = open("fixtures/ruby.dat",
|
81
|
-
jb = open("fixtures/javabin.dat",
|
81
|
+
r = open("fixtures/ruby.dat", READ_UTF8).read
|
82
|
+
jb = open("fixtures/javabin.dat", READ_ASCII).read
|
82
83
|
puts ""
|
83
84
|
r_et = elapsed_time("ruby eval parse. ", TIMES) { eval(r) }
|
84
85
|
jb_et = elapsed_time("javabin parse. ", TIMES) { @parser.parse(jb) }
|
@@ -87,8 +88,8 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def test_javabin2_parse_and_ruby2_eval
|
90
|
-
r = open("fixtures/ruby2.dat",
|
91
|
-
jb = open("fixtures/javabin2.dat",
|
91
|
+
r = open("fixtures/ruby2.dat", READ_UTF8).read
|
92
|
+
jb = open("fixtures/javabin2.dat", READ_ASCII).read
|
92
93
|
puts ""
|
93
94
|
r_et = elapsed_time("ruby2 eval parse. ", TIMES) { eval(r) }
|
94
95
|
jb_et = elapsed_time("javabin2 parse. ", TIMES) { @parser.parse(jb) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: java_bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kennyj
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-26 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|