sqlite/ext/rtree
drh 5db59b33c4 Completely unroll the dimension loop inside of cellArea() in RTREE.
FossilOrigin-Name: 3c4c0126c287f844220b65e00fec17c059fbb7c8
2017-02-01 16:41:30 +00:00
..
README Fix another typo in the rtree README file. (CVS 5187) 2008-06-04 15:09:16 +00:00
rtree1.test Improve the error messages generated by the rtree module when a constraint fails. 2016-05-23 16:16:13 +00:00
rtree2.test Fix a couple of memory leaks in r-tree that can occur following an OOM condition. 2010-08-26 14:15:37 +00:00
rtree3.test Improve the error messages generated by the rtree module when a constraint fails. 2016-05-23 16:16:13 +00:00
rtree4.test The SQLITE_RTREE_INT_ONLY compile-time option causes the RTree extension 2012-04-02 21:35:42 +00:00
rtree5.test Correct test numbering on several rtree tests. 2013-04-10 02:56:24 +00:00
rtree6.test Do not use virtual (and hence redundant) WHERE-clause terms to restrict the 2014-10-25 12:28:25 +00:00
rtree7.test The SQLITE_RTREE_INT_ONLY compile-time option causes the RTree extension 2012-04-02 21:35:42 +00:00
rtree8.test Fix test cases for the new EXPLAIN QUERY PLAN format. Add the 2013-06-10 23:30:09 +00:00
rtree9.test Remove a couple stray test breakpoint calls. 2015-05-08 00:58:39 +00:00
rtree_perf.tcl Remove the obsolete "$Id:$" RCS identifier strings from the source code. 2009-11-10 01:30:52 +00:00
rtree_util.tcl Remove the obsolete "$Id:$" RCS identifier strings from the source code. 2009-11-10 01:30:52 +00:00
rtree.c Completely unroll the dimension loop inside of cellArea() in RTREE. 2017-02-01 16:41:30 +00:00
rtree.h
rtreeA.test Add tests to e_delete.test. 2010-09-23 18:47:36 +00:00
rtreeB.test Add the sqlite3_rtree_query_callback() API to the RTree virtual table. 2014-04-28 17:56:19 +00:00
rtreeC.test Remove an extra "finish_test" from the end of rtreeC.test. 2016-05-23 18:06:51 +00:00
rtreeD.test Fix a problem in rtreeD.test causing it to fail in OMIT_BUILTIN_TEST builds. 2016-11-17 20:05:00 +00:00
rtreeE.test Update with fixes and enhancements from trunk. 2015-05-22 18:40:48 +00:00
rtreeF.test Fix a faulty assert() statement. Add comments to clarify the behavior of 2014-08-21 14:10:23 +00:00
rtreeG.test Fix the rtreeG.test test case. 2016-05-23 18:27:07 +00:00
sqlite3rtree.h Add the sqlite3_value_dup() and sqlite3_value_free() interfaces. Use 2015-05-20 21:28:32 +00:00
tkt3363.test Fix a couple of memory leaks in r-tree that can occur following an OOM condition. 2010-08-26 14:15:37 +00:00
viewrtree.tcl Remove the obsolete "$Id:$" RCS identifier strings from the source code. 2009-11-10 01:30:52 +00:00

This directory contains an SQLite extension that implements a virtual 
table type that allows users to create, query and manipulate r-tree[1] 
data structures inside of SQLite databases. Users create, populate 
and query r-tree structures using ordinary SQL statements.

    1.  SQL Interface

        1.1  Table Creation
        1.2  Data Manipulation
        1.3  Data Querying
        1.4  Introspection and Analysis

    2.  Compilation and Deployment

    3.  References


1. SQL INTERFACE

  1.1 Table Creation.

    All r-tree virtual tables have an odd number of columns between
    3 and 11. Unlike regular SQLite tables, r-tree tables are strongly 
    typed. 

    The leftmost column is always the pimary key and contains 64-bit 
    integer values. Each subsequent column contains a 32-bit real
    value. For each pair of real values, the first (leftmost) must be 
    less than or equal to the second. R-tree tables may be 
    constructed using the following syntax:

      CREATE VIRTUAL TABLE <name> USING rtree(<column-names>)

    For example:

      CREATE VIRTUAL TABLE boxes USING rtree(boxno, xmin, xmax, ymin, ymax);
      INSERT INTO boxes VALUES(1, 1.0, 3.0, 2.0, 4.0);

    Constructing a virtual r-tree table <name> creates the following three
    real tables in the database to store the data structure:

      <name>_node
      <name>_rowid
      <name>_parent

    Dropping or modifying the contents of these tables directly will
    corrupt the r-tree structure. To delete an r-tree from a database,
    use a regular DROP TABLE statement:

      DROP TABLE <name>;

    Dropping the main r-tree table automatically drops the automatically
    created tables. 

  1.2 Data Manipulation (INSERT, UPDATE, DELETE).

    The usual INSERT, UPDATE or DELETE syntax is used to manipulate data
    stored in an r-tree table. Please note the following:

      * Inserting a NULL value into the primary key column has the
        same effect as inserting a NULL into an INTEGER PRIMARY KEY
        column of a regular table. The system automatically assigns
        an unused integer key value to the new record. Usually, this
        is one greater than the largest primary key value currently
        present in the table.

      * Attempting to insert a duplicate primary key value fails with
        an SQLITE_CONSTRAINT error.

      * Attempting to insert or modify a record such that the value
        stored in the (N*2)th column is greater than that stored in
        the (N*2+1)th column fails with an SQLITE_CONSTRAINT error.

      * When a record is inserted, values are always converted to 
        the required type (64-bit integer or 32-bit real) as if they
        were part of an SQL CAST expression. Non-numeric strings are
        converted to zero.

  1.3 Queries.

    R-tree tables may be queried using all of the same SQL syntax supported
    by regular tables. However, some query patterns are more efficient
    than others.

    R-trees support fast lookup by primary key value (O(logN), like 
    regular tables).

    Any combination of equality and range (<, <=, >, >=) constraints
    on spatial data columns may be used to optimize other queries. This
    is the key advantage to using r-tree tables instead of creating 
    indices on regular tables.

  1.4 Introspection and Analysis.

    TODO: Describe rtreenode() and rtreedepth() functions.


2. COMPILATION AND USAGE

  The easiest way to compile and use the RTREE extension is to build
  and use it as a dynamically loadable SQLite extension. To do this
  using gcc on *nix:

    gcc -shared rtree.c -o libSqliteRtree.so

  You may need to add "-I" flags so that gcc can find sqlite3ext.h
  and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be
  loaded into sqlite in the same way as any other dynamicly loadable
  extension.


3. REFERENCES

  [1]  Atonin Guttman, "R-trees - A Dynamic Index Structure For Spatial 
       Searching", University of California Berkeley, 1984.

  [2]  Norbert Beckmann, Hans-Peter Kriegel, Ralf Schneider, Bernhard Seeger,
       "The R*-tree: An Efficient and Robust Access Method for Points and
       Rectangles", Universitaet Bremen, 1990.