DBD-Sys

 view release on metacpan or  search on metacpan

lib/DBD/Sys/CompositeTable.pm  view on Meta::CPAN

package DBD::Sys::CompositeTable;

use strict;
use warnings;
use vars qw(@ISA $VERSION);

require SQL::Eval;
require DBI::DBD::SqlEngine;
use Scalar::Util qw(blessed weaken);
use Clone qw(clone);
use Carp qw(croak);

@ISA     = qw(DBD::Sys::Table);
$VERSION = "0.102";

=pod

=head1 NAME

DBD::Sys::CompositeTable - Table implementation to compose different sources into one table

=head1 ISA

  DBD::Sys::CompositeTable
  ISA DBD::Sys::Table
    ISA DBI::DBD::SqlEngine::Table

=head1 DESCRIPTION

DBD::Sys::CompositeTable provides a table which composes the data from
several sources in one data table.

While constructing this table, the columns of the embedded tables are
collected and a heading and a merge plan for the composed result table
is generated.

Simplified example of table procs:

  $alltables = $dbh->selectall_hashref("select * from procs", "pid");

  # calls
  # DBD::Sys::CompositeTable( [ 'DBD::Sys::Plugin::Any::Procs',
  #                             'DBD::Sys::Plugin::Win32::Procs' ],
  #                           $attr );

This will fetch the column names from both embedded tables and get (simplfied):

  # %colNames = (
  #     'DBD::Sys::Plugin::Any::Procs' => [
  #       'pid', 'ppid', 'uid', 'gid', 'cmndline', 'sess', 'priority', 'ttynum', 'start', 'run', 'status',
  #     ],
  #     'DBD::Sys::Plugin::Win32::Procs' => [
  #       'pid', 'ppid', 'uid', 'gid', 'cmndline', 'sess', 'priority', 'thread', 'start', 'run', 'status',
  #     ]
  # );
  # @colNames = (
  #       'pid', 'ppid', 'uid', 'gid', 'cmndline', 'sess', 'priority', 'ttynum', 'start', 'run', 'status', 'threads',
  # );
  # %mergeCols = (
  #     'DBD::Sys::Plugin::Any::Procs' => [
  #         0 .. 10,
  #     ],
  #     'DBD::Sys::Plugin::Win32::Procs' => [
  #         7,
  #     ]
  # );
  # $primaryKey = 'pid';

The merge phase in C<collect_data()> finally does (let's assume running



( run in 0.578 second using v1.01-cache-2.11-cpan-39bf76dae61 )