Taxi::Mysql::Table - extendable full-text index using mysql: table specifications |
Taxi::Mysql::Table - extendable full-text index using mysql: table specifications
##======================================================================== ## PRELIMINARIES
use Taxi::Mysql::Table;
##======================================================================== ## Constructors etc.
$tbl = $CLASS_OR_OBJ->new($table_name,%args);
##======================================================================== ## Initialization and Compilation
$tab = $tab->initialize(); $tab = $tab->compile($index);
##======================================================================== ## Properties
$sqlname = $tab->sqlName();
##======================================================================== ## db wrappers
$bool = $tbl->dbExists($ix); $bool = $tbl->dbClear($ix); $bool = $tbl->dbDrop($ix); $bool = $tbl->dbCreate($ix);
##======================================================================== ## SQL: Table Creation
$sql = $tab->createSql();
##======================================================================== ## SQL: Data loading
$sql = $tab->loadDataInfileSql(%args);
##======================================================================== ## SQL: Data export
$sql = $tab->exportDataSql(%args); $sql = $tab->selectAllSql(%args);
Taxi::Mysql::Table is a class for representing a relational table in a Taxi::Mysql index. Nearly all user-customizable features of a Taxi::Mysql index are implemented by keyword flags in the specific Taxi::Mysql::Table object instances which make up the index's table inventory.
$tbl = $CLASS_OR_OBJ->new($table_name,%args);
Constructor. Calls initialize().
NOTE: the table is not ready for use until the it has been compiled!
Object structre / keyword %args:
{ ##-- User data xpath => $table_xpath, ##-- for document loading (default: $table_name; false for none) mode => $xsl_mode, ##-- XSL mode (default=global) submodes => \%modes, ##-- ($xslMode=>$xpath): to for match children (default: ''=>'./*') name => $table_name, ##-- table basename (no prefix) prefix => $table_prefix, ##-- prefix for table name [imposed by associated index] gencols => \@genColSpecs, ##-- generic column specs for this table: ## + [ $colName=>\%genericColSpec, ... ] default_hit_within => $colName, ##-- default hit-container column for queries [obsolete?] ## + default value is last 'ref'- or 'id'-type column parsed delay_load => $bool, ##-- if true, loadData will be delayed by Loader.pm; default=0
##-- Low-level data (compiled) id => \%idCol, ##-- id-column colsa => \@columnSpecs, ##-- generic column specifications, ordered [array] colsh => \%name2Column, ##-- generic column specifications, by name [hash] tab2ref => \%tab2ref, ##-- maps referred-table name to local reference column constraints => \@constraints, ##-- additional user constraint & index clauses (SQL fragments) iconstraints => \@constraints, ##-- auto-generated constraints sqlcoda => $sql, ##-- SQL coda for CREATE TABLE loadDataArgs => \%args, ##-- for $tab->loadDataInfileSql() }
Where \%genericColSpec =
{ ##-- Obligatory Data name => $colName, ##-- column name (imposed from 'gencols' key) type => $colType, ##-- abstract column type (one of 'id', 'ref', 'attr'; default='attr')
##-- (type=>'id'): Primary Key Data key => $xsl_xpath, ##-- id-assignment string key, table-relative default='generate-id(.)'
##-- (type=>'ref'): Foreign Key (reference) data ref => $refTableName, ##-- name of referenced table refpath => $node_xpath, ##-- XSL XPath to node for referenced table (default: "./ancestor::${refTab}\[1\]") xpath => $key_xpath , ##-- XSL XPath for key of referenced table (default: derived) joinHits => $bool, ##-- whether to automatically join hits on this ref (default=true)
##-- (type=>'attr'): Attribute acquisition data xpath => $xsl_xpath, ##-- value XPath, table-node relative (default="string(./\@${colName})")
##-- Common data sqldef => $sql_fragment, ##-- sql 'create table' fragment ## + default (type=>'id') : 'INT UNSIGNED NOT NULL AUTO_INCREMENT' ## + default (type=>'ref') : -- copied from id-attr of referred table -- ## + default (type=>'attr'): 'VARCHAR(255) DEFAULT NULL'
index => $index_type, ##-- one of ($false_value,'unique','primary',$true_value) ## $false : do not index this column [default for (type=>'attr')] ## 'unique' : index column as unique ## 'primary' : index column as (partial) primary key ## $true : index column as non-unique [default for (type=>'ref')] ## + (type=>'id') implies (index=>'primary') }
$tab = $tab->initialize();
Compiles PARTIAL $tab->{colsa} and $tab->{colsh} from $tab->{gencols}
References are still incomplete when this method returns, since some table might be referenced which itself has not yet been initialized.
$tab = $tab->compile($index);
Compiles references, index-constraints and other index-related attributes.
All tables in $index should have been initialized before compile()
is called
on any table.
$sqlname = $tab->sqlName();
Returns SQL-safe name of $tab.
$bool = $tbl->dbExists($ix);
Returns true iff table exists in the backend for index $ix.
$bool = $tbl->dbClear($ix);
Clears table data.
$bool = $tbl->dbDrop($ix);
Drops table.
$bool = $tbl->dbCreate($ix);
Creates table in the backend DB for index $ix. Requires that the table has been compiled.
$sql = $tab->createSql();
Returns SQL code for creating the backend table. Requires that the table has been compiled.
$sql = $tab->loadDataInfileSql(%args);
Reurns SQL code for populating the table from a text data file. Recognized %args:
file => $filename, ##-- may be relative to cwd (default="${table_sqlname}.txt") replace => $bool, ##-- replace duplicate unique-key rows (default=no): overrides 'ignore' ignore => $bool, ##-- ignore duplicate unique-key rows (default=no) delay => $bool, ##-- 'LOW PRIORITY': delay until no other clients are reading the table concurrent => $bool, ##-- 'CONCURRENT': other threads might still be able to retrieve data: overrides 'delay' local => $bool, ##-- if true, all data is sent over the net (default=false) fields => $sql, ##-- SQL 'FIELDS' fragment lines => $sql, ##-- SQL 'LINES' fragment skip => $n, ##-- number of lines to skip (default=0) columns => \@names, ##-- list of column names to load (default=map {$_->{name}} $tab->{colsa}) set => $sql, ##-- SQL 'SET' fragment
Default %args can be set in $tab->{loadDataArgs}.
$sql = $tab->exportDataSql(%args);
Server-side data export to text file. Exported file will have owner and group of backend server. See Taxi::Mysql::Handle::sqlExportDataFile() for client-side export.
Known %args:
file => $filename, ##-- may be relative to cwd (default="${table_sqlname}.txt") fields => $sql, ##-- SQL 'FIELDS' fragment lines => $sql, ##-- SQL 'LINES' fragment columns => \@names, ##-- list of column names to load (default=map {$_->{name}} $tab->{colsa})
Default %args can be set in $tab->{exportDataArgs}.
$sql = $tab->selectAllSql(%args);
Returns SQL code for selecting all rows from $tab. Known %args:
columns=>\@names, ##-- list of column names to export (default=map {$_->{name}} $tab->{colsa})
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::Mysql(3perl), Taxi::Mysql::Handle(3perl), Taxi::Mysql::Query(3perl), Taxi::Mysql::Hit(3perl), Taxi::Mysql::Format(3perl).
Taxi::Mysql::Table - extendable full-text index using mysql: table specifications |