Module: Cassie::Statements::Execution::PartitionLinking::PolicyMethods

Extended by:
ActiveSupport::Concern
Included in:
SimplePolicy
Defined in:
lib/cassie/statements/execution/partition_linking/policy_methods.rb

Instance Method Summary collapse

Instance Method Details

#end_of_partition?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 40

def end_of_partition?
  !peeking_execution.result.peeked_row
rescue NoMethodError => ex
  message = "Results aren't available for linking. Did you forget to call `execute`?" if peeking_execution.result.nil?
  message ||= "Peeking not enabled. To link partitions, peeking must be included in the execution. Did you forget to call `link_partitions`?"
  raise ArgumentError, message
end

#initialize(executed, identifier, direction, range) ⇒ Object



11
12
13
14
15
16
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 11

def initialize(executed, identifier, direction, range)
  @peeking_execution = executed
  @identifier = identifier
  @direction = direction
  @range = range
end

returns linked result



19
20
21
22
23
24
25
26
27
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 19

def link
  if seek_partition? && partition_available?
    prepare_execution
    execution.execute
    combine_results
  else
    peeking_execution.result
  end
end

#partition_available?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 48

def partition_available?
  key = ascending? ? next_key(current_key) : previous_key(current_key)
  key >= first_key && key <= last_key
end

#prepare_executionObject



29
30
31
32
33
34
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 29

def prepare_execution
  @execution = peeking_execution.clone
  change_partition
  adjust_limit
  execution
end

#seek_partition?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/cassie/statements/execution/partition_linking/policy_methods.rb', line 36

def seek_partition?
  end_of_partition?
end