Taxi::Mysql - Extendable full-text index using mysql backend


(Back to Top)


NAME

Taxi::Mysql - Extendable full-text index using mysql backend

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## 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();

(Back to Top)


DESCRIPTION

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.

Global Variables

@ISA

Taxi::Mysql inherits from Taxi::Mysql::Connection.

Constructors etc.

new
 $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]
   }

Compilation

compile
 $ix = $ix->compile();

Compiles table index information (references etc.).

addTables
 $ix = $ix->addTables(@table_specs);

Adds one or more tables to the index. Adding a table probably requires re-compilation.

Index Administration

drop
 $bool = $ix->drop();

Drops the index from the backend server.

create
 $bool = $ix->create();

Drops & re-creates the index on the backend server.

Note: tables should be compiled before calling this method.

truncate
 $bool = $ix->truncate();

Truncates all index tables in the backend server.

loader
 $ldr = $ix->loader(%loaderNewArgs);

Returns a Taxi::Mysql::Loader (or subclass) object for this index.

loadData
 $bool = $ix->loadData(%args);
exportData
 $bool = $ix->exportData(%args);
exportScript
 $bool = $ix->exportScript($file_or_fh,%args);
dbAnalyze

Calls $ix->{handle}->dbTableAnalyze(%args) on each extant table.

%args: see Taxi::Mysql::Handle::dbTableAnalyze().

analyzeDataFiles
 $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.

dbOptimize

Calls $ix->{handle}->dbTableOptimize(%args) on each extant table.

%args: see Taxi::Mysql::Handle::dbTableOptimize().

Querying

newQuery
 $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.

Hit Retrieval

hitTables
 \@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.

hitFrom
 $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.

hitColumns
 \@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.

hitJoins
 \@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.

Hit Formatting

newFormat
 $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).

I/O: Hooks

preSaveHook
 $tmpData = $obj->preSaveHook();

Sanitize object for save, returns temprorary data.

postSaveHook
 undef = $obj->postSaveHook($tmpData);

(undocumented)

postLoadHook
 undef = $obj->postLoadHook();

(undocumented)

(Back to Top)


ACKNOWLEDGEMENTS

Perl by Larry Wall.

(Back to Top)


AUTHOR

Bryan Jurish <moocow@ling.uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

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.

(Back to Top)


SEE ALSO

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).

(Back to Top)

 Taxi::Mysql - Extendable full-text index using mysql backend