NAME
Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn - Consolidates by moving overlaps to new columns
SYNOPSIS
my
$compare
=new Data::Range::Compare::Stream::Iterator::Compare::Asc();
foreach
my
$file
(
qw(source_a.src source_b.src source_d.src source_c.src source_d.src)
) {
my
$src
=Data::Range::Compare::Stream::Iterator::File->new(
filename
=>
$file
);
my
$con
=new Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn(
$src
,
$compare
);
$compare
->add_consolidator(
$con
);
}
my
$format
=
' | %-12s | %-26s | %-26s| %-26s| %-26s|'
.
"\n"
;
my
$break
=
" +--------------+----------------------------+----------------------------+----------------------------+----------------------------+\n"
;
printf
"$break$format$break"
,
"Intersection"
,
"Set A"
,
'Set B'
,
'Set C'
,
'Set D'
;
while
(
$compare
->has_next) {
my
$result
=
$compare
->get_next;
next
if
$result
->is_empty;
my
$columns
=
$result
->get_root_results(
$result
);
my
@row
=(
$result
->get_common);
foreach
my
$id
(@{
$result
->get_root_ids}) {
if
($
#{$columns->[$id]}!=-1) {
push
@row
,
join
', '
,
map
{
$_
->get_common } @{
$columns
->[
$id
]};
}
else
{
push
@row
,
"No Data"
;
}
}
printf
$format
,
@row
;
$break
;
}
DESCRIPTION
This module extends the consolidation engine for Data::Range::Compare::Stream. Unlike the default consolidation object this class does not merge ranges when they overlap: It creates additional instances of itself and inserts them into the "Compare" object. Each new object refers to the object that created it.
Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn can consolidate ranges sorted in the following order:
Consolidation Asc range_start asc,range_end desc.
OO Methods
my $processor=new Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn($iterator,$cmp);
Object constructor has 2 required arguments: $processor and $cmp: An $iterator object must implement Data::Range::Compare::Stream::Iterator::Base. A $cmp object must implement Data::Range::Compare::Stream::Iterator::Compare::Asc.
Optional Arguments:
factory_instance
=>
$obj
# defines the object that implements the $obj->factory($start,$end,$data).
# new ranges are constructed from the factory interfcae. If a factory interface
# is not created an instance of Data::Range::Compare::Stream is assumed.
while($processor->has_next) { do something }
Returns true when the there are more ranges to consolidate
my $range=$processor->get_next;
if $processor->has_next returns true Returns a instance of Data::Range::Compare::Stream::Iterator::Consolidate::Result.
$self->on_consolidate($new_range,$overlapping_range,$next_range)
Called during the consolidation process to copy ranges that overlap with the current range being compared into the next valid column.
$processor->set_column_id($id);
Sets the column_id value. This is used by the Compare Layer
my $id=$processor->get_column_id($id);
Gets the column_id, returns undef if not set.
my $cmp=$processor->get_compare
Returns the Data::Range::Compare::Stream::Iterator::Compare::Asc object passed to the constructor.
my $result=$processor->get_current_result;
Returns the last Data::Range::Compare::Stream::Iterator::Consolidate::Result object from the $processor->has_next call.
my $count=$processor->buffer_count;
Returns the current buffer count.
if($processor->iterator_has_next) { ... }
Returns the internal iterator has_next state
$self->push_to_buffer;
Internal function. Pushes results onto the buffer.
my $class=$processor->NEW_ARRAY_ITERATOR_FROM;
Defines the class that will be used to create iterator objects: $class must implement Data::Range::Compare::Stream::Iterator::Base.
my $class=$processor->NEW_CHILD_CONSOLIDATOR_FROM;
Defines the class that will be used to create consolidator objects that will be pushed into the compare object at runtime. $class must implement Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn .
my $id=$processor->get_root_column_id;
Gets the parent object's column_id, returns undef if not set.
if($processor->is_child) { ... }
Returns true if this object is a child of another Consolidator object.
SEE ALSO
Data::Range::Compare::Stream::Iterator::Consolidate::OverlapAsColumn::Result
Data::Range::Compare::Stream::Iterator::Base
Data::Range::Compare::Stream::Cookbook
AUTHOR
Michael Shipper
Source-Forge Project
As of version 0.001 the Project has been moved to Source-Forge.net
Data Range Compare https://sourceforge.net/projects/data-range-comp/
COPYRIGHT
Copyright 2011 Michael Shipper. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.