Skip to content

Commit

Permalink
feature(index): index_sp option
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Jan 31, 2014
1 parent 641ad8e commit 8d55357
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/sphinx/integration/extensions/thinking_sphinx/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 8d55357

Please sign in to comment.