riddle 1.0.12 → 1.1.0

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.
@@ -5,6 +5,7 @@ require 'riddle/client/response'
5
5
  module Riddle
6
6
  class VersionError < StandardError; end
7
7
  class ResponseError < StandardError; end
8
+ class OutOfBoundsError < StandardError; end
8
9
 
9
10
  # This class was heavily based on the existing Client API by Dmytro Shteflyuk
10
11
  # and Alexy Kovyrin. Their code worked fine, I just wanted something a bit
@@ -529,6 +530,8 @@ module Riddle
529
530
  self.connection.call(self)
530
531
  elsif self.class.connection
531
532
  self.class.connection.call(self)
533
+ elsif @server.index('/') == 0
534
+ UNIXSocket.new @server
532
535
  else
533
536
  TCPSocket.new @server, @port
534
537
  end
@@ -598,7 +601,9 @@ module Riddle
598
601
  puts response[4, length]
599
602
  response[4 + length, response.length - 4 - length]
600
603
  when Statuses[:error], Statuses[:retry]
601
- raise ResponseError, "searchd error (status: #{status}): #{response[4, response.length - 4]}"
604
+ message = response[4, response.length - 4]
605
+ klass = message[/out of bounds/] ? OutOfBoundsError : ResponseError
606
+ raise klass, "searchd error (status: #{status}): #{message}"
602
607
  else
603
608
  raise ResponseError, "Unknown searchd error (status: #{status})"
604
609
  end
@@ -3,6 +3,7 @@ require 'riddle/configuration/section'
3
3
  require 'riddle/configuration/distributed_index'
4
4
  require 'riddle/configuration/index'
5
5
  require 'riddle/configuration/indexer'
6
+ require 'riddle/configuration/realtime_index'
6
7
  require 'riddle/configuration/remote_index'
7
8
  require 'riddle/configuration/searchd'
8
9
  require 'riddle/configuration/source'
@@ -1,27 +1,28 @@
1
1
  module Riddle
2
2
  class Configuration
3
3
  class Index < Riddle::Configuration::Section
4
- self.settings = [:source, :path, :docinfo, :mlock, :morphology,
4
+ self.settings = [:type, :source, :path, :docinfo, :mlock, :morphology,
5
5
  :min_stemming_len, :stopwords, :wordforms, :exceptions, :min_word_len,
6
6
  :charset_dictpath, :charset_type, :charset_table, :ignore_chars,
7
7
  :min_prefix_len, :min_infix_len, :prefix_fields, :infix_fields,
8
- :enable_star, :ngram_len, :ngram_chars, :phrase_boundary,
9
- :phrase_boundary_step, :html_strip, :html_index_attrs,
10
- :html_remove_elements, :preopen, :ondisk_dict, :inplace_enable,
11
- :inplace_hit_gap, :inplace_docinfo_gap, :inplace_reloc_factor,
12
- :inplace_write_factor, :index_exact_words, :overshort_step,
13
- :stopwords_step]
8
+ :enable_star, :expand_keywords, :ngram_len, :ngram_chars,
9
+ :phrase_boundary, :phrase_boundary_step, :blend_chars, :html_strip,
10
+ :html_index_attrs, :html_remove_elements, :preopen, :ondisk_dict,
11
+ :inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
12
+ :inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
13
+ :overshort_step, :stopwords_step, :hitless_words]
14
14
 
15
- attr_accessor :name, :parent, :sources, :path, :docinfo, :mlock,
15
+ attr_accessor :name, :parent, :type, :sources, :path, :docinfo, :mlock,
16
16
  :morphologies, :min_stemming_len, :stopword_files, :wordform_files,
17
17
  :exception_files, :min_word_len, :charset_dictpath, :charset_type,
18
18
  :charset_table, :ignore_characters, :min_prefix_len, :min_infix_len,
19
- :prefix_field_names, :infix_field_names, :enable_star, :ngram_len,
20
- :ngram_characters, :phrase_boundaries, :phrase_boundary_step,
21
- :html_strip, :html_index_attrs, :html_remove_element_tags, :preopen,
22
- :ondisk_dict, :inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
23
- :inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
24
- :overshort_step, :stopwords_step
19
+ :prefix_field_names, :infix_field_names, :enable_star, :expand_keywords,
20
+ :ngram_len, :ngram_characters, :phrase_boundaries,
21
+ :phrase_boundary_step, :blend_chars, :html_strip, :html_index_attrs,
22
+ :html_remove_element_tags, :preopen, :ondisk_dict, :inplace_enable,
23
+ :inplace_hit_gap, :inplace_docinfo_gap, :inplace_reloc_factor,
24
+ :inplace_write_factor, :index_exact_words, :overshort_step,
25
+ :stopwords_step, :hitless_words
25
26
 
26
27
  def initialize(name, *sources)
27
28
  @name = name
@@ -2,7 +2,7 @@ module Riddle
2
2
  class Configuration
3
3
  class Indexer < Riddle::Configuration::Section
4
4
  self.settings = [:mem_limit, :max_iops, :max_iosize, :max_xmlpipe2_field,
5
- :write_buffer]
5
+ :write_buffer, :max_file_field_buffer]
6
6
 
7
7
  attr_accessor *self.settings
8
8
 
@@ -0,0 +1,39 @@
1
+ module Riddle
2
+ class Configuration
3
+ class RealtimeIndex < Riddle::Configuration::Section
4
+ self.settings = [:type, :path, :rt_mem_limit, :rt_field, :rt_attr_uint,
5
+ :rt_attr_bigint, :rt_attr_float, :rt_attr_timestamp, :rt_attr_string]
6
+
7
+ attr_accessor :name
8
+ attr_accessor *self.settings
9
+
10
+ def initialize(name)
11
+ @name = name
12
+ @rt_field = []
13
+ @rt_attr_uint = []
14
+ @rt_attr_bigint = []
15
+ @rt_attr_float = []
16
+ @rt_attr_timestamp = []
17
+ @rt_attr_string = []
18
+ end
19
+
20
+ def type
21
+ "rt"
22
+ end
23
+
24
+ def valid?
25
+ !(@name.nil? || @path.nil?)
26
+ end
27
+
28
+ def render
29
+ raise ConfigurationError unless valid?
30
+
31
+ (
32
+ ["index #{name}", "{"] +
33
+ settings_body +
34
+ ["}", ""]
35
+ ).join("\n")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -6,7 +6,9 @@ module Riddle
6
6
  :seamless_rotate, :preopen_indexes, :unlink_old, :attr_flush_period,
7
7
  :ondisk_dict_default, :max_packet_size, :mva_updates_pool,
8
8
  :crash_log_path, :max_filters, :max_filter_values, :listen_backlog,
9
- :read_buffer, :read_unhinted]
9
+ :read_buffer, :read_unhinted, :max_batch_queries, :subtree_docs_cache,
10
+ :subtree_hits_cache, :workers, :dist_threads, :binlog_path,
11
+ :binlog_flush, :binlog_max_log_size]
10
12
 
11
13
  attr_accessor *self.settings
12
14
 
@@ -4,12 +4,14 @@ module Riddle
4
4
  self.settings = [:type, :sql_host, :sql_user, :sql_pass, :sql_db,
5
5
  :sql_port, :sql_sock, :mysql_connect_flags, :mysql_ssl_cert,
6
6
  :mysql_ssl_key, :mysql_ssl_ca, :odbc_dsn, :sql_query_pre, :sql_query,
7
- :sql_query_range, :sql_range_step, :sql_query_killlist, :sql_attr_uint,
8
- :sql_attr_bool, :sql_attr_bigint, :sql_attr_timestamp,
9
- :sql_attr_str2ordinal, :sql_attr_float, :sql_attr_multi,
10
- :sql_query_post, :sql_query_post_index, :sql_ranged_throttle,
11
- :sql_query_info, :mssql_winauth, :mssql_unicode, :unpack_zlib,
12
- :unpack_mysqlcompress, :unpack_mysqlcompress_maxsize]
7
+ :sql_joined_field, :sql_file_field, :sql_query_range, :sql_range_step,
8
+ :sql_query_killlist, :sql_attr_uint, :sql_attr_bool, :sql_attr_bigint,
9
+ :sql_attr_timestamp, :sql_attr_str2ordinal, :sql_attr_float,
10
+ :sql_attr_multi, :sql_attr_string, :sql_attr_str2wordcount,
11
+ :sql_field_string, :sql_field_str2wordcount, :sql_query_post,
12
+ :sql_query_post_index, :sql_ranged_throttle, :sql_query_info,
13
+ :mssql_winauth, :mssql_unicode, :unpack_zlib, :unpack_mysqlcompress,
14
+ :unpack_mysqlcompress_maxsize]
13
15
 
14
16
  attr_accessor *self.settings
15
17
 
@@ -17,18 +19,24 @@ module Riddle
17
19
  @name = name
18
20
  @type = type
19
21
 
20
- @sql_query_pre = []
21
- @sql_attr_uint = []
22
- @sql_attr_bool = []
23
- @sql_attr_bigint = []
24
- @sql_attr_timestamp = []
25
- @sql_attr_str2ordinal = []
26
- @sql_attr_float = []
27
- @sql_attr_multi = []
28
- @sql_query_post = []
29
- @sql_query_post_index = []
30
- @unpack_zlib = []
31
- @unpack_mysqlcompress = []
22
+ @sql_query_pre = []
23
+ @sql_joined_field = []
24
+ @sql_file_field = []
25
+ @sql_attr_uint = []
26
+ @sql_attr_bool = []
27
+ @sql_attr_bigint = []
28
+ @sql_attr_timestamp = []
29
+ @sql_attr_str2ordinal = []
30
+ @sql_attr_float = []
31
+ @sql_attr_multi = []
32
+ @sql_attr_string = []
33
+ @sql_attr_str2wordcount = []
34
+ @sql_field_string = []
35
+ @sql_field_str2wordcount = []
36
+ @sql_query_post = []
37
+ @sql_query_post_index = []
38
+ @unpack_zlib = []
39
+ @unpack_mysqlcompress = []
32
40
  end
33
41
 
34
42
  def valid?
@@ -45,10 +45,12 @@ module Riddle
45
45
  end
46
46
 
47
47
  def stop
48
- return unless running?
48
+ return true unless running?
49
49
  Process.kill('SIGTERM', pid.to_i)
50
50
  rescue Errno::EINVAL
51
51
  Process.kill('SIGKILL', pid.to_i)
52
+ ensure
53
+ return !running?
52
54
  end
53
55
 
54
56
  def pid
@@ -0,0 +1,65 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Riddle::Configuration::RealtimeIndex do
4
+ let(:index) { Riddle::Configuration::RealtimeIndex.new('rt1') }
5
+
6
+ describe '#valid?' do
7
+ it "should not be valid without a name" do
8
+ index.name = nil
9
+ index.path = 'foo'
10
+ index.should_not be_valid
11
+ end
12
+
13
+ it "should not be valid without a path" do
14
+ index.path = nil
15
+ index.should_not be_valid
16
+ end
17
+
18
+ it "should be valid with a name and path" do
19
+ index.path = 'foo'
20
+ index.should be_valid
21
+ end
22
+ end
23
+
24
+ describe '#type' do
25
+ it "should be 'rt'" do
26
+ index.type.should == 'rt'
27
+ end
28
+ end
29
+
30
+ describe '#render' do
31
+ it "should raise a ConfigurationError if rendering when not valid" do
32
+ lambda {
33
+ index.render
34
+ }.should raise_error(Riddle::Configuration::ConfigurationError)
35
+ end
36
+
37
+ it "should render correctly if supplied settings are valid" do
38
+ index.path = '/var/data/rt'
39
+ index.rt_mem_limit = '512M'
40
+ index.rt_field << 'title' << 'content'
41
+
42
+ index.rt_attr_uint << 'gid'
43
+ index.rt_attr_bigint << 'guid'
44
+ index.rt_attr_float << 'gpa'
45
+ index.rt_attr_timestamp << 'ts_added'
46
+ index.rt_attr_string << 'author'
47
+
48
+ index.render.should == <<-RTINDEX
49
+ index rt1
50
+ {
51
+ type = rt
52
+ path = /var/data/rt
53
+ rt_mem_limit = 512M
54
+ rt_field = title
55
+ rt_field = content
56
+ rt_attr_uint = gid
57
+ rt_attr_bigint = guid
58
+ rt_attr_float = gpa
59
+ rt_attr_timestamp = ts_added
60
+ rt_attr_string = author
61
+ }
62
+ RTINDEX
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddle
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 12
10
- version: 1.0.12
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Allan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-27 00:00:00 +10:00
18
+ date: 2010-08-29 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - lib/riddle/configuration/distributed_index.rb
76
76
  - lib/riddle/configuration/index.rb
77
77
  - lib/riddle/configuration/indexer.rb
78
+ - lib/riddle/configuration/realtime_index.rb
78
79
  - lib/riddle/configuration/remote_index.rb
79
80
  - lib/riddle/configuration/searchd.rb
80
81
  - lib/riddle/configuration/section.rb
@@ -100,6 +101,7 @@ files:
100
101
  - spec/unit/configuration/distributed_index_spec.rb
101
102
  - spec/unit/configuration/index_spec.rb
102
103
  - spec/unit/configuration/indexer_spec.rb
104
+ - spec/unit/configuration/realtime_index_spec.rb
103
105
  - spec/unit/configuration/searchd_spec.rb
104
106
  - spec/unit/configuration/source_spec.rb
105
107
  - spec/unit/configuration/sql_source_spec.rb
@@ -162,6 +164,7 @@ test_files:
162
164
  - spec/unit/configuration/distributed_index_spec.rb
163
165
  - spec/unit/configuration/index_spec.rb
164
166
  - spec/unit/configuration/indexer_spec.rb
167
+ - spec/unit/configuration/realtime_index_spec.rb
165
168
  - spec/unit/configuration/searchd_spec.rb
166
169
  - spec/unit/configuration/source_spec.rb
167
170
  - spec/unit/configuration/sql_source_spec.rb