From 8d553572b8862d823acfb45a5fb9fb6f68c0d4b8 Mon Sep 17 00:00:00 2001 From: Merkushin Date: Fri, 31 Jan 2014 15:25:16 +0600 Subject: [PATCH] feature(index): index_sp option --- .../integration/extensions/thinking_sphinx/index.rb | 10 ++++++++++ .../extensions/thinking_sphinx/index_spec.rb | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/sphinx/integration/extensions/thinking_sphinx/index.rb b/lib/sphinx/integration/extensions/thinking_sphinx/index.rb index ddce1bd..f6de3b1 100644 --- a/lib/sphinx/integration/extensions/thinking_sphinx/index.rb +++ b/lib/sphinx/integration/extensions/thinking_sphinx/index.rb @@ -9,6 +9,7 @@ module Sphinx::Integration::Extensions::ThinkingSphinx::Index alias_method_chain :initialize, :mutex alias_method_chain :to_riddle, :replication alias_method_chain :to_riddle_for_distributed, :merged + alias_method_chain :to_riddle_for_core, :integration alias_method_chain :all_names, :rt end @@ -135,6 +136,7 @@ def to_riddle_for_rt(delta = false) index.path = File.join(config.searchd_file_path, index.name) index.rt_field = fields.map(&:unique_name) index.rt_mem_limit = local_options[:rt_mem_limit] if local_options[:rt_mem_limit] + index.index_sp = local_options[:index_sp] if local_options[:index_sp] collect_rt_index_attributes(index) @@ -175,6 +177,14 @@ def to_riddle_for_distributed_with_merged index end + def to_riddle_for_core_with_integration(offset) + index = to_riddle_for_core_without_integration(offset) + + index.index_sp = local_options[:index_sp] if local_options[:index_sp] + + index + end + # Truncate rt index # # index_name - String diff --git a/spec/sphinx/integration/extensions/thinking_sphinx/index_spec.rb b/spec/sphinx/integration/extensions/thinking_sphinx/index_spec.rb index c51ea90..9b90026 100644 --- a/spec/sphinx/integration/extensions/thinking_sphinx/index_spec.rb +++ b/spec/sphinx/integration/extensions/thinking_sphinx/index_spec.rb @@ -59,6 +59,14 @@ its(:rt_attr_uint){ should eql [:sphinx_internal_id, :sphinx_deleted, :class_crc, :region_id] } end + describe '#to_riddle_for_core' do + let(:core_index) { index.send(:to_riddle_for_core, 1) } + + before { index.local_options[:index_sp] = 1 } + + it { expect(core_index.index_sp).to eq 1 } + end + describe '#all_names' do it 'returns only distributed index name' do index.all_names.should == [index.name]