Algorithm::SpatialIndex::Storage::DBI - DBI storage backend
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_', );
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!
Returns the prefix of the table names.
Returns an array reference containing the coordinate type strings.
Returns an array reference containing the item coordinate type strings.
Returns the precomputed SQL fragment of the node coordinate columns (
CREATE TABLE syntax).
Returns the no. of subnodes per node.
Returns the precomputed SQL fragment of the subnode id columns (
CREATE TABLE syntax).
Returns the hash reference of configuration options read from the config table.
Returns the read/write database handle.
Returns the read-only database handle. Falls back to the read/write handle if not defined.
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.
Reads the configuration table. Returns whether this succeeded or not. In case of failure, this initializes some of the configuration options from other sources.
Creates the index's tables.
Writes the index's configuration to the configuration table.
Given an array ref containing coordinate type strings (cf. Algorithm::SpatialIndex::Strategy), stores the SQL fragments for
CREATE TABLE for the node coordinates.
The coordinates will be called
$i starts at 0.
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
$i starting at 0.
Steffen Mueller, <email@example.com>
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.