Taxi::Mysql - Extendable full-text index using mysql backend |
Taxi::Mysql - Extendable full-text index using mysql backend
##======================================================================== ## PRELIMINARIES
use Taxi::Mysql;
##======================================================================== ## Constructors etc.
$ix = $CLASS_OR_OBJ->new(%args); ##-- new object
##======================================================================== ## Compilation
$ix = $ix->compile(); ##-- compile table references, etc. $ix = $ix->addTables(@table_specs); ##-- add new tables
##======================================================================== ## Index Administration
$bool = $ix->drop(); $bool = $ix->create(); $bool = $ix->truncate(); $ldr = $ix->loader(%loaderNewArgs); $bool = $ix->loadData(%args); $bool = $ix->exportData(%args); $bool = $ix->exportScript($file_or_fh,%args); $bool = $ix->analyzeDataFiles(%loadData_and_maybe_other_args);
##======================================================================== ## Querying
$q = $index->newQuery($queryClass, %queryArgs);
##======================================================================== ## Hit Retrieval
\@tableBasenames = $ix->hitTables(); $sql_frag = $ix->hitFrom(); \@sqlColumnNames = $ix->hitColumns(); \@sqlFragments = $ix->hitJoins();
##======================================================================== ## Hit Formatting
$fmt = $ix->newFormat($fmtClass,%fmtArgs);
##======================================================================== ## I/O: Hooks
$tmpData = $obj->preSaveHook(); undef = $obj->postSaveHook($tmpData); undef = $obj->postLoadHook();
Taxi::Mysql is the top-level class for Taxi::Mysql indices. All required methods have default implementations, so it can be used directly for simple indices. More complex index structures may require you to derive a new index subclass from Taxi::Mysql.
Taxi::Mysql inherits from Taxi::Mysql::Connection.
$ix = $CLASS_OR_OBJ->new(%args);
Object structure / keyword %args:
{ ##-- SQL connection information handleArgs => \%handleArgs, ##-- passed to Taxi::Mysql::Handle->new() [via ::Connection] loadDataAgs => \%loadDataArgs, ##-- passed to Taxi::Mysql::Table->loadDataInfileSql()
##-- verbosity behavior verbose => $vlevel, ##-- see Taxi::Mysql::Base
##-- Index Configuration data prefix=> $prefix, ##-- table prefix [default: '_textindex_'] tables=> \%tabname2table, ##-- Taxi::MySql::Table objects indexed by basename dbEncoding=>$encoding, ##-- database encoding, default='UTF-8' dbCharset=>$dbCharset, ##-- for server I/O (mysql charset alias); default='binary'
##-- Query generation queryArgs=>\%qArgs, ##-- arguments for Taxi::Mysql::Query->new()
##-- Hit construction hitClass => $hitClass, ##-- hit class (used by $query->fetch()) hitArgs => \%hitArgs, ##-- shared arguments to $hitClass->new()
##-- Cached Data hitTables => \@tabNames, ##-- hit tables hitFrom => \@sqlTabNames, ##-- hit table SQL names (for 'FROM' clause) hitColumns => \@sqlColNames, ##-- hit column SQL names (for 'SELECT' clause) extraHitColumns => [[$tabName,$colName],...], ##-- ... additional hit columns hitJoins => \@sqlWhereFragments, ##-- hit join conditions (for 'WHERE' clause)
##-- Hit formatting fmtClass => $fmtClass, ##-- default formatter class fmtArgs => \%fmtArgs, ##-- default arguments to $fmtClass->new() fmtClassArgs => \%class2args, ##-- ... dispatch by format class: {$class => \%fmtArgsForClass, ...}
##-- Low-level data handle=>$sql_handle, ##-- actual db handle [via ::Connection] }
$ix = $ix->compile();
Compiles table index information (references etc.).
$ix = $ix->addTables(@table_specs);
Adds one or more tables to the index. Adding a table probably requires re-compilation.
$bool = $ix->drop();
Drops the index from the backend server.
$bool = $ix->create();
Drops & re-creates the index on the backend server.
Note: tables should be compiled before calling this method.
$bool = $ix->truncate();
Truncates all index tables in the backend server.
$ldr = $ix->loader(%loaderNewArgs);
Returns a Taxi::Mysql::Loader (or subclass) object for this index.
$bool = $ix->loadData(%args);
Loads data for all tables
%args are common arguments for $tab->loadDataInfileSql(), as well as:
( dir => $base_directory, ##-- prefixed to all filenames ext => $extension, ##-- default extension (".txt") files => { $tabname=>$filename, ... } ##-- default: $tab->sqlName().$extension tables => \@table_names, ##-- default: all )
$bool = $ix->exportData(%args);
Exports data for all tables to text files.
%args are common arguments for $tab->loadDataInfileSql(), as well as:
( dir => $base_directory, ##-- prefixed to all filenames ext => $extension, ##-- default extension (".txt") files => { $tabname=>$filename, ... } ##-- default: $tabname=>$tab->sqlName().$extension tables => \@table_names, ##-- default: all encoding => $encoding, ##-- default: $ix->{dbEncoding} )
$bool = $ix->exportScript($file_or_fh,%args);
Exports create+load SQL script for all tables.
%args are common arguments for $tab->loadDataInfileSql(), as well as:
( dir => $base_directory, ##-- prefixed to all filenames ext => $extension, ##-- default extension (".txt") files => { $tabname=>$filename, ... } ##-- default: $tabname=>$tab->sqlName().$extension tables => \@table_names, ##-- default: all encoding => $encoding, ##-- default: $ix->{dbEncoding} )
Calls $ix->{handle}->dbTableAnalyze(%args)
on each extant table.
%args: see Taxi::Mysql::Handle::dbTableAnalyze().
$bool = $ix->analyzeDataFiles(%loadData_and_maybe_other_args);
Hook for derived classes. This function is called to perform preprocessing on text-format table files as extracted from the XML documents to be loaded before these files are actually uploaded as tables to the backend server.
Calls $ix->{handle}->dbTableOptimize(%args)
on each extant table.
%args: see Taxi::Mysql::Handle::dbTableOptimize().
$q = $index->newQuery($queryClass, %queryArgs);
Returns a new Taxi::Mysql::Query::Base (or subclass) object for querying this index. Default implementation sets the 'index' and 'dbCharset' properties of the new query to conform to those set for the index object.
\@tableBasenames = $ix->hitTables();
Should return a list of table basenames to be joined into a hit-retrieval query for this index. The default implementation uses the cached ARRAY-ref $ix->{hitTables} if available, and sets $ix->{hitTables} to the list of all known tables otherwise.
$sql_frag = $ix->hitFrom();
Should return an SQL fragment string for the 'FROM' clause of a hit retrieval query for this index. The default implementation uses the cached string $ix->{hitFrom} if available, and sets $ix->{hitFrom} to the SQL names of $ix->hitTables otherwise.
\@sqlColumnNames = $ix->hitColumns();
Should return an ARRAY-ref of fully qualified SQL column names for the 'SELECT' clause of a hit retrieval query for this index. The default implementation uses the cached string $ix->{hitColumns} if available, and sets $ix->{hitColumns} to the SQL names of all known 'attr'-type columns otherwise. If defined, the ARRAY-ref $ix->{extraHitColumns} is expected to contain a list of [$tableName, $colName] pairs whose SQL names will be appended to the list of generated hit columns.
\@sqlFragments = $ix->hitJoins();
Should return an ARRAY-ref of SQL fragments representing join
conditions for the 'WHERE'
clause of a hit retrieval query for this index.
The default implementation
uses the cached ARRAY-ref $ix->{hitJoins} if available, and
sets it by joining on all known 'ref' attributes of the tables
returned by $ix->hitTables()
otherwise.
$fmt = $ix->newFormat($fmtClass_or_undef,%fmtArgs);
Returns a new hit formatting object (Taxi::Mysql::Format conformant object) for this index. The default implementation uses $ix->{fmtClass} as the default formatting object class if $fmtClass_or_undef is undefined.
%fmtArgs are passed to Format->new($fmtClass,%fmtArgs).
$tmpData = $obj->preSaveHook();
Sanitize object for save, returns temprorary data.
undef = $obj->postSaveHook($tmpData);
(undocumented)
undef = $obj->postLoadHook();
(undocumented)
Perl by Larry Wall.
Bryan Jurish <moocow@ling.uni-potsdam.de>
Copyright (C) 2006 by Bryan Jurish
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
perl(1), taxi-admin.perl(1), taxi-query.perl(1), taxi-server.perl(1), Taxi::Mysql::Connection(3perl), Taxi::Mysql::Handle(3perl), Taxi::Mysql::Table(3perl), Taxi::Mysql::Query(3perl), Taxi::Mysql::Hit(3perl), Taxi::Mysql::Format(3perl), Taxi::Mysql::Server(3perl).
Taxi::Mysql - Extendable full-text index using mysql backend |