Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sort::key::types(3pm) [debian man page]

Sort::Key::Types(3pm)					User Contributed Perl Documentation				     Sort::Key::Types(3pm)

NAME
Sort::Key::Types - handle Sort::Key data types SYNOPSIS
use Sort::Key::Types qw(register_type); register_type(Color => sub { $_->R, $_->G, $_->B }, qw(int, int, int)); # you better # use Sort::Key::Register ... DESCRIPTION
The Sort::Key family of modules can be extended to support new key types using this module (or the more friendly Sort::Key::Register). FUNCTIONS The following functions are provided: Sort::Key::register_type($name, &gensubkeys, @subkeystypes) registers a new datatype named $name defining how to convert it to a multikey. &gensubkeys should convert the object of type $name passed on $_ to a list of values composing the multikey. @subkeystypes is the list of types for the generated multikeys. For instance: Sort::Key::Types::register_type 'Person', sub { $_->surname, $_->name, $_->middlename }, qw(str str str); Sort::Key::Types::register_type 'Color', sub { $_->R, $_->G, $_->B }, qw(int int int); Once a datatype has been registered it can be used in the same way as types supported natively, even for defining new types, i.e.: Sort::Key::Types::register_type 'Family', sub { $_->father, $_->mother }, qw(Person Person); SEE ALSO
Sort::Key, Sort::Key::Merger, Sort::Key::Register. COPYRIGHT AND LICENSE
Copyright (C) 2005-2007 by Salvador Fandin~o, <sfandino@yahoo.com>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-06-30 Sort::Key::Types(3pm)

Check Out this Related Man Page

XML::Filter::Sort::BufferMgr(3pm)			User Contributed Perl Documentation			 XML::Filter::Sort::BufferMgr(3pm)

NAME
XML::Filter::Sort::BufferMgr - Implementation class used by XML::Filter::Sort DESCRIPTION
The documentation is targetted at developers wishing to extend or replace this class. For user documentation, see XML::Filter::Sort. Two classes are used to implement buffering records and spooling them back out in sorted order as SAX events. One instance of the XML::Filter::Sort::Buffer class is used to buffer each record and one or more instances of the XML::Filter::Sort::BufferMgr class are used to manage the buffers. API METHODS
The API of this module as used by XML::Filter::Sort::Buffer consists of the following sequence of method calls: 1. When the first 'record' in a sequence is encountered, XML::Filter::Sort creates a XML::Filter::Sort::BufferMgr object using the "new()" method. 2. XML::Filter::Sort calls the buffer manager's "new_buffer()" method to get a XML::Filter::Sort::Buffer object and all SAX events are directed to this object until the end of the record is encountered. The following events are supported by the current buffer implementation: start_element() characters() comment() processing_instruction() end_element() 3. When the end of the record is detected, XML::Filter::Sort calls the buffer manager's "close_buffer()" method, which in turn calls the buffer's "close()" method. The "close()" method returns a list of values for the sort keys and the buffer manager uses these to store the buffer for later recall. Subsequent records are handled as per step 2. 4. When the last record has been buffered, XML::Filter::Sort calls the buffer manager's "to_sax()" method. The buffer manager retrieves each of the buffers in sorted order and calls the buffer's "to_sax()" method. Each buffer attempts to match the sort key paths as SAX events are received. Once a value has been found for a given key, that same path match is not attempted against subsequent events. For efficiency, the code to match each key is compiled into a closure. For even more efficiency, this compilation is done once when the XML::Filter::Sort object is created. The "compile_matches()" method in the buffer manager class calls the "compile_matches()" method in the buffer class to achieve this. DATA STRUCTURES
In the current implementation, the XML::Filter::Sort::BufferMgr class simply uses a hash to store the buffer objects. If only one sort key was defined, only a single hash is required. The values in the hash are arrayrefs containing the list of buffers for records with identical keys. If two or more sort keys are defined, the hash values will be XML::Filter::Sort::BufferMgr objects which in turn will contain the buffers. The following illustration may clarify the relationship (BM=buffer manager, B=buffer): BM +----------------+---------------+ | | BM BM +-----+--------+ +-----+----------+ | | | | BM BM BM BM +-----+----+ +----+------+ +----+----+ +------+------+ | | | | | | | | | | | | [B,B,B] [B] [B,B] [B] [B,B] [B,B,B] [B] [B,B] [B] [B,B] [B,B,B] [B,B] This layered storage structure is transparent to the XML::Filter::Sort object which instantiates and interacts with only one buffer manager (the one at the top of the tree). COPYRIGHT
Copyright 2002 Grant McLean <grantm@cpan.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2002-06-14 XML::Filter::Sort::BufferMgr(3pm)
Man Page