Class: Hyperion::Riak::RangeStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion/riak/optimized_filter_order.rb

Instance Method Summary collapse

Constructor Details

#initialize(filters, bucket_name) ⇒ RangeStrategy

Returns a new instance of RangeStrategy.



64
65
66
67
# File 'lib/hyperion/riak/optimized_filter_order.rb', line 64

def initialize(filters, bucket_name)
  @filters = filters
  @optimizer = OptimizedRangeFilters.new(filters)
end

Instance Method Details

#can_optimize?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/hyperion/riak/optimized_filter_order.rb', line 69

def can_optimize?
  @optimizer.less_than_filter && @optimizer.greater_than_filter
end

#filtersObject



81
82
83
# File 'lib/hyperion/riak/optimized_filter_order.rb', line 81

def filters
  @optimizer.remaining_filters
end

#optimal_index_fieldObject



73
74
75
# File 'lib/hyperion/riak/optimized_filter_order.rb', line 73

def optimal_index_field
  @optimizer.less_than_filter.field
end

#optimal_index_valueObject



77
78
79
# File 'lib/hyperion/riak/optimized_filter_order.rb', line 77

def optimal_index_value
  @value ||= @optimizer.less_than_filter.value.to_s .. @optimizer.greater_than_filter.value.to_s
end