Steffen Müller > Algorithm-SpatialIndex > Algorithm::SpatialIndex::Storage::DBI

Download:
Algorithm-SpatialIndex-0.06.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Algorithm::SpatialIndex::Storage::DBI - DBI storage backend

SYNOPSIS ^

  use Algorithm::SpatialIndex;
  my $dbh = ...;
  my $idx = Algorithm::SpatialIndex->new(
    storage      => 'DBI',
    dbh_rw       => $dbh,
    dbh_ro       => $dbh, # defaults to dbh_rw
    table_prefix => 'si_',
  );

DESCRIPTION ^

WARNING: WHILE IT SEEMS TO WORK FOR ME, THIS STORAGE BACKEND IS HIGHLY EXPERIMENTAL AND IN A PROOF-OF-CONCEPT STATE. Unsurprisingly, it is also 20x slower when using SQLite as the storage engine then when using the memory storage backend. Has only been tested with SQLite but has mysql-specific and SQLite specific code paths as well as a general SQL code path which is less careful about race conditions.

Inherits from Algorithm::SpatialIndex::Storage.

This storage backend is persistent.

No implementation of schema migration yet, so expect to have to reinitialize the index after a module upgrade!

ACCESSORS ^

table_prefix

Returns the prefix of the table names.

coord_types

Returns an array reference containing the coordinate type strings.

item_coord_types

Returns an array reference containing the item coordinate type strings.

node_coord_create_sql

Returns the precomputed SQL fragment of the node coordinate columns (CREATE TABLE syntax).

no_of_subnodes

Returns the no. of subnodes per node.

subnodes_create_sql

Returns the precomputed SQL fragment of the subnode id columns (CREATE TABLE syntax).

config

Returns the hash reference of configuration options read from the config table.

dbh_rw

Returns the read/write database handle.

dbh_ro

Returns the read-only database handle. Falls back to the read/write handle if not defined.

OTHER METHODS ^

init

Reads the options from the database for previously existing indexes. Creates tables and writes default configuration for those that didn't exist before.

Doesn't do any schema migration at this point.

_read_config_table

Reads the configuration table. Returns whether this succeeded or not. In case of failure, this initializes some of the configuration options from other sources.

_init_tables

Creates the index's tables.

_write_config

Writes the index's configuration to the configuration table.

_coord_types_to_sql

Given an array ref containing coordinate type strings (cf. Algorithm::SpatialIndex::Strategy), stores the SQL fragments for SELECT and CREATE TABLE for the node coordinates.

The coordinates will be called c$i where $i starts at 0.

_subnodes_sql

Given the number of subnodes per node, creates a string of column specifications for interpolation into a CREATE TABLE and one for interpolation into a SELECT. Saves those strings into the object.

The columns are named sn$i with $i starting at 0.

AUTHOR ^

Steffen Mueller, <smueller@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2010, 2011 by Steffen Mueller

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: