File Coverage

blib/lib/Data/Range/Compare/Stream/Iterator/Compare/Base.pm
Criterion Covered Total %
statement 49 51 96.0
branch 5 8 62.5
condition 2 6 33.3
subroutine 16 17 94.1
pod 7 11 63.6
total 79 93 84.9


line stmt bran cond sub pod time code
1             package Data::Range::Compare::Stream::Iterator::Compare::Base;
2              
3 6     6   40108 use strict;
  6         12  
  6         214  
4 6     6   31 use warnings;
  6         13  
  6         163  
5 6     6   32 use Carp qw(croak);
  6         11  
  6         369  
6              
7 6     6   3758 use Data::Range::Compare::Stream::Iterator::Compare::Result;
  6         17  
  6         216  
8 6     6   46 use constant RESULT_CLASS=>'Data::Range::Compare::Stream::Iterator::Compare::Result';
  6         8  
  6         388  
9              
10 6     6   32 use base qw(Data::Range::Compare::Stream::Iterator::Base);
  6         10  
  6         3985  
11              
12             sub new {
13 46     46 0 10240 my ($class,%args)=@_;
14 46         448 $class->SUPER::new(column_map=>[],root_ids=>[],dead_columns=>[],last_row=>0,iterators_empty=>0,prepared=>0,consolidateors=>[],raw_row=>[],%args);
15             }
16              
17 46     46 0 214 sub on_dead_iterator { 1 }
18              
19 691     691 0 3293 sub prepared { $_[0]->{prepared} }
20              
21             sub add_consolidator {
22 96     96 1 637 my ($self,$consolidator)=@_;
23              
24 96 50       259 croak "Fatal error, cannot add new objects once the consolidator has been called!!" if $self->prepared;
25 96         134 push @{$self->{consolidateors}},$consolidator;
  96         220  
26 96         128 my $id=$#{$self->{consolidateors}};
  96         188  
27              
28 96         351 $consolidator->set_column_id($id);
29 96         448 return $id
30             }
31              
32             sub insert_consolidator {
33 28     28 1 1019 my ($self,$consolidator)=@_;
34              
35 28         40 push @{$self->{consolidateors}},$consolidator;
  28         69  
36 28         42 my $id=$#{$self->{consolidateors}};
  28         57  
37              
38 28         151 $consolidator->set_column_id($id);
39              
40 28 100       70 if($self->prepared) {
41 8 50       37 croak "cannot insert empty consolidators!" unless $consolidator->has_next;
42 8         36 $self->{raw_row}->[$id]=$consolidator->get_next;
43             }
44              
45 28         77 return $id;
46             }
47              
48             sub get_iterator_by_id {
49 82     82 1 1902 my ($self,$id)=@_;
50 82 50 33     266 croak "id out of bounds" if !defined($id) or $id>$#{$_[0]->{consolidateors}} or $id<0;
  82   33     543  
51 82         401 return $self->{consolidateors}->[$id];
52             }
53 1527     1527 1 7335 sub get_column_count_human_readable { 1 + $_[0]->get_column_count}
54              
55 1587     1587 1 10188 sub get_column_count { $#{$_[0]->{consolidateors}} }
  1587         13856  
56              
57 0     0 0 0 sub get_consolidateors { @{$_[0]->{consolidateors}} }
  0         0  
58              
59 308     308 1 1067 sub get_current_row { $_[0]->{current_row} }
60              
61 6     6 1 33 sub iterators_empty { $_[0]->{iterators_empty} }
62              
63              
64             1;