Taxi::Mysql::Hit - extendable full-text index using mysql: query results


NAME

Taxi::Mysql::Hit - extendable full-text index using mysql: query results

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Taxi::Mysql::Hit;
 ##========================================================================
 ## Constructors etc.
 $hit = $CLASS_OR_OBJ->new(%args);
 ##========================================================================
 ## Conventions
 $q  = $hit->{query};     ##-- source query, a Taxi::Mysql::Query::Base object
 $ix = $q->{index};       ##-- queried index, a Taxi::Mysql object
 ##========================================================================
 ## Retrieval: SQL
 undef     = $hit->sql_prepare();
 $colName = $hit->hitColumnName();
 $tabName = $hit->hitTableName();
 $colName = $hit->matchColumnName();
 $tabName = $hit->matchTableName();
 $matchcol_sql_frag = $hit->sql_matched_column();
 $columns_sql_frag  = $hit->sql_select_columns();
 $tables_sql_frag   = $hit->sql_from_tables();
 $hitconds          = $hit->sql_hit_conditions();
 $where             = $hit->sql_where();
 $order             = $hit->sql_order_by;
 $sql = $hit->sql();
 ##========================================================================
 ## Retrieval: open/close
 $hit = $hit->open();
 $hit = $hit->close();
 ##========================================================================
 ## Retrieval: population
 \@row = $hit->fetch1();
 undef = $hit->populate();

(Back to Top)


DESCRIPTION

Taxi::Mysql::Hit is a base class represening an elementary result unit returned by a Taxi user query.

Globals etc.

Variable: @ISA

Taxi::Mysql::Hit inherits from Taxi::Mysql::Bas.

Constructors etc.

new
 $hit = $CLASS_OR_OBJ->new(%args);

Most users will not need to call this constructor directly. Use of the Taxi::Mysql::Query::Base API is preferred; see in particular the Taxi::Mysql::Query::Base methods open(), fetchHit(), fetchHitList(), and close().

Object structure / keyword %args:

   {
    ##-- source query [REQUIRED]
    query => $q,           ##-- source Taxi::Mysql::Query object [handle source, should be open]
    qdata => \@qdata,      ##-- source row as returned by $q->{sth}->fetchrow_arrayref();
    ##-- retrieval
    matched => $label,     ##-- column label for boolean 'matched' column (default='matched')
    sth     => $sth,       ##-- statement handle for hit retrieval query
    ##-- cached data
    sth_NAME => $column_names,   ##-- as returned by DBI
    data     => [ \@row1, ... ], ##-- retrieved data as array-of-arrays
   }

Retrieval: SQL

sql_prepare
 undef = $hit->sql_prepare();

Prepares cached values for executing hit retrieval backend query. Caches values:

 $hit->{hitColumnName}   ##-- name of the source/dest hit id-column
 $hit->{matchColumnName} ##-- name of the source/dest match id-column [different from 'matched']
hitColumnName
 $colName = $hit->hitColumnName();

Returns user-specified name of the unique hit identifier (primary key). Default is the name of the first column in the (open) statement handle $hit->{query}{sth}.

hitTableName
 $tabName = $hit->hitTableName();

Returns the SQL name of the table containing unique hit identifiers. Default returns the SQL name of $hit->{query}{default_table}.

matchColumnName
 $colName = $hit->matchColumnName();

Returns column name of the token (match) column. Default is the name of the second column in the (open) statement handle $hit->{query}{sth}.

matchTableName
 $tabName = $hit->matchTableName();

Returns the SQL name of the token (match) table. Default returns the SQL name of $hit->{query}{default_table}.

sql_matched_column
 $matchcol_sql_frag = $hit->sql_matched_column();

Assumes $hit->sql_prepare() has been called. Returns SELECT subclause for hit backend SQL boolean 'matched' column.

sql_select_columns
 $columns_sql_frag = $hit->sql_select_columns();

Assumes $hit->sql_prepare() has been called. Returns SELECT column list for hit backend SQL. Default version calls $ix->hitColumns() and $hit->sql_matched_column().

sql_from_tables
 $tables_sql_frag = $hit->sql_from_tables();

Assumes $hit->sql_prepare() has been called. Returns FROM tables list or hit backend SQL. Default version calls $ix->hitFrom().

sql_hit_conditions
 $hitconds = $hit->sql_hit_conditions();

Assumes $hit->sql_prepare() has been called. Returns WHERE conditions for hit backend SQL as a string. Default version restricts hitTableName().hitColumnName() to the value of the first column fetched by the Taxi query.

sql_where
 $where = $hit->sql_where();

Assumes $hit->sql_prepare() has been called. Returns WHERE clause for hit backend SQL. Calls $ix->hitJoins() and $hit->sql_hit_conditions().

sql_order_by
 $order = $hit->sql_order_by;

Assumes $hit->sql_prepare() has been called. Returns ORDER BY clause for hit backend SQL.

sql
 $sql = $hit->sql();

Compute and return the hit backend SQL query string. Implicitly calls $hit->sql_prepare() if relevant values are uncached. Calls $hit->sql_*() methods.

Retrieval: open/close

open
 $hit = $hit->open();

Computes hit backend SQL and opens a backend statement handle for hit retrieval.

close
 $hit = $hit->close();

Closes backend statement handle (if any), and clears hit-local caches.

Retrieval: population

fetch1
 \@row = $hit->fetch1();

Fetch a single row of data (a single token) from the hit's backend statement handle (which must be present and open) into $hit->{data}. Really just a wrapper for $hit->{sth}->fetchrow_arrayref().

populate
 undef = $hit->populate();

Fetch all remaining data rows from the hit's backend statement handle (which must be present and open) into $hit->{data}. Mostly just a wrapper for $hit->{sth}->etchall_arrayref(). Calls finish() on statement handle on completion.

(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::Mysql(3perl), Taxi::Mysql::Query::Base(3perl), Taxi::Mysql::HitList(3perl).

(Back to Top)

 Taxi::Mysql::Hit - extendable full-text index using mysql: query results