⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groupby.pm

📁 普通的ETL工具
💻 PM
字号:
# vim:ts=4 sw=4
# ----------------------------------------------------------------------------------------------------
#  Name		: ETL::Pequel3::Type::Section::GroupBy.pm
#  Created	: 22 June 2006
#  Author	: Mario Gaffiero (gaffie)
#
# Copyright 1999-2007 Mario Gaffiero.
# 
# This file is part of Pequel(TM).
# 
# Pequel is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# Pequel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Pequel; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ----------------------------------------------------------------------------------------------------
# Modification History
# When          Version     Who     What
# ----------------------------------------------------------------------------------------------------
package ETL::Pequel3::Type::Section::GroupBy;
require 5.005_62;
use strict;
use warnings;
use ETL::Pequel3::Type::Section;
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::GroupBy;
	use base qw(ETL::Pequel3::Type::Section::Abstract);
	use Class::STL::ClassMembers
		qw( 
			input_fields 
		),
		Class::STL::ClassMembers::DataMember->new(name => 'target_mem_name', default => 'section_name'),
		Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'group_by'),
		Class::STL::ClassMembers::DataMember->new(name => 'item_type', default => __PACKAGE__ . '::Item'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
		Class::STL::ClassMembers::DataMember->new(name => 'description', default => 'Use this section to activate break processing. Break processing is required to be able to use I<aggregation> in the output section. One or more input fields can be specified - the input data must be sorted on the I<group by fields>, unless the F<hash> option is used. A break will occur when any of the group field values changes. The F<pequel_type> attribute can be used to specify F<numeric> grouping for a field -- this will cause leading zeros to be stripped from the input field value. Group by on I<derived> input fields is usefull when the F<hash> option is in use since the input data does not need to be pre-sorted.');
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->input_fields($self->pequel_ref()->catalogue()->fieldsets()->group_by_fields()->new(
			pequel_ref => $self->pequel_ref()))
		if (defined($self->pequel_ref()));
		return $self;
	}
	sub prepare
	{
		my $self = shift;
#?		if ($self->pequel_ref()->configuration()->hash() && $self->user()->size() == 0) {
#?			$self->err()->user_warn(10200, "@{[ 
#?				$main->pequel_name() ]}:The 'hash' option is only relevant when grouping is used -- ignored.");
#?			$main->configuration()->hash(0);
#?		}
#?		return unless ($self->user()->size());
		$self->input_fields()->clear();
		$self->input_fields()->map_input(
			$self->items(), 
			$self->pequel_ref()->input()->input_fields()
		);

#?		if ($main->input_dataset()->name() eq 'dbi') {
#?			# TODO: $main->input_dataset()->select_order_by($s->key_field());
#?		}
	}

	package ETL::Pequel3::Type::Section::GroupBy::Item;
	use base qw(ETL::Pequel3::Type::Section::Item::Abstract);
	use Class::STL::ClassMembers;
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->attributes()->push_back(
			ETL::Pequel3::Type::Properties::FieldName->new(required => 1),
			ETL::Pequel3::Type::Properties::PequelType->new(),
		);
	}
}
# ----------------------------------------------------------------------------------------------------
1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -