diff --git a/doc/sphinx/book/box/box_index.rst b/doc/sphinx/book/box/box_index.rst index c269c7009b286b17e5fae6bd5c973ce5c26f1a4a..7fad8932fd69db0fe2daa496e67cbb512175c0d8 100644 --- a/doc/sphinx/book/box/box_index.rst +++ b/doc/sphinx/book/box/box_index.rst @@ -196,47 +196,47 @@ API is a direct binding to corresponding methods of index objects of type **RTREE iterator types** - +--------------------+-----------+---------------------------------------------+ - | Type | Arguments | Description | - +====================+===========+=============================================+ - | box.index.ALL | none | All keys match. Tuples are returned in | - | or 'ALL' | | ascending order of the primary key. | - +--------------------+-----------+---------------------------------------------+ - | box.index.EQ | field | Keys match if the rectangle defined by the | - | or 'EQ' | values | field values is the same as the rectangle | - | | | defined by the key -- where "key" means | - | | | "the key in the RTREE index" and | - | | | "rectangle" means "rectangle as explained | - | | | in section RTREE_. | - +--------------------+-----------+---------------------------------------------+ - | box.index.GT | field | Keys match if all points of the rectangle | - | or 'GT' | values | defined by the field values are within the | - | | | rectangle defined by the key. | - +--------------------+-----------+---------------------------------------------+ - | box.index.GE | field | Keys match if all points of the rectangle | - | or 'GE' | values | defined by the field values are within, or | - | | | at the side of, the rectangle defined by | - | | | the key. | - +--------------------+-----------+---------------------------------------------+ - | box.index.LT | field | Keys match if all points of the rectangle | - | or 'LT' | values | defined by the key are within the rectangle | - | | | defined by the field values. | - +--------------------+-----------+---------------------------------------------+ - | box.index.LE | field | Keys match if all points of the rectangle | - | or 'LE' | values | defined by the key are within, or at the | - | | | side of, the rectangle defined by the field | - | | | values. | - +--------------------+-----------+---------------------------------------------+ - | box.index.OVERLAPS | field | Keys match if all points of the rectangle | - | or 'OVERLAPS' | values | defined by the key are within, or at the | - | | | side of, the rectangle defined by the field | - | | | values. | - +--------------------+-----------+---------------------------------------------+ - | box.index.NEIGHBOR | field | Keys match if all points of the rectangle | - | or 'NEIGHBOR' | values | defined by the key are within, or at the | - | | | side of, the rectangle defined by the field | - | | | values. | - +--------------------+-----------+---------------------------------------------+ + +--------------------+-----------+-----------------------------------------------------+ + | Type | Arguments | Description | + +====================+===========+=====================================================+ + | box.index.ALL | none | All keys match. Tuples are returned in | + | or 'ALL' | | ascending order of the primary key. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.EQ | field | Keys match if the rectangle-or-box defined by the | + | or 'EQ' | values | field values is the same as the rectangle-or-box | + | | | defined by the key -- where "key" means | + | | | "the key in the RTREE index" and | + | | | "rectangle-or-box" means "rectangle-or-box as | + | | | explained in section RTREE_". | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.GT | field | Keys match if all points of the rectangle-or-box | + | or 'GT' | values | defined by the field values are within the | + | | | rectangle-or-box defined by the key. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.GE | field | Keys match if all points of the rectangle-or-box | + | or 'GE' | values | defined by the field values are within, or | + | | | at the side of, the rectangle-or-box defined by | + | | | the key. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.LT | field | Keys match if all points of the rectangle-or-box | + | or 'LT' | values | defined by the key are within the rectangle-or-box | + | | | defined by the field values. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.LE | field | Keys match if all points of the rectangle-or-box | + | or 'LE' | values | defined by the key are within, or at the | + | | | side of, the rectangle-or-box defined by the field | + | | | values. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.OVERLAPS | field | Keys match if all points of the rectangle-or-box | + | or 'OVERLAPS' | values | defined by the key are within, or at the | + | | | side of, the rectangle-or-box defined by the field | + | | | values. | + +--------------------+-----------+-----------------------------------------------------+ + | box.index.NEIGHBOR | field | Keys match if all points of the rectangle-or-box | + | or 'NEIGHBOR' | values | defined by the key are within, or at the | + | | | side of, the rectangle-or-box defined by the field | + | | | values. | + +--------------------+-----------+-----------------------------------------------------+ |br| @@ -627,7 +627,14 @@ Lua functions `os.date()`_ and `string.sub()`_. ============================================================================= The :mod:`box.index` package may be used for spatial searches if the index type -is RTREE. There are operations for searching *rectangles*. Rectangles are +is RTREE. There are operations for searching *rectangles* (geometric objects +with 4 corners and 4 sides) and *boxes* (geometric objects with more than 4 +corners and more than 4 sides, sometimes called hyperrectangles). +This manual uses term *rectangle-or-box* for the whole class +of objects that includes both rectangles and boxes. +Only rectangles will be illustrated. + +Rectangles are described according to their X-axis (horizontal axis) and Y-axis (vertical axis) coordinates in a grid of arbitrary size. Here is a picture of four rectangles on a grid with 11 horizontal points and 11 vertical points: @@ -693,6 +700,20 @@ NEIGHBOR iterator always returns all tuples, and the first returned tuple will be {3,5,9,10} ("Rectangle#2" in the picture) because it is the closest neighbor of {1,2,3,4} ("Rectangle#1" in the picture). +Now let us create a space and index for cuboids, which are rectangle-or-boxes that have +6 corners and 6 sides. + + | :codebold:`box.schema.space.create('R')` + | :codebold:`box.space.R:create_index('primary',{parts={1,'NUM'}})` + | :codebold:`box.space.R:create_index('S',{type='RTREE',unique=false,dimension=3,parts={2,'ARRAY'}})` + +The additional field here is 'dimension=3'. The default dimension is 2, which is +why it didn't need to be specified for the examples of rectangle. The maximum dimension +is 20. Now for insertions and selections there will usually be 6 coordinates. For example: + + | :codebold:`box.space.R:insert{1,{0,3,0,3,0,3}}` + | :codebold:`box.space.R.index.S:select({1,2,1,2,1,2},{iterator=box.index.GT})` + More examples of spatial searching are online in the file `R tree index quick start and usage`_. diff --git a/doc/sphinx/book/box/limitations.rst b/doc/sphinx/book/box/limitations.rst index 7851d49ad1c081f9b3c8626ac2187e5254614cd1..755deb9e01543a8272fcdd277e23d637f8139b5c 100644 --- a/doc/sphinx/book/box/limitations.rst +++ b/doc/sphinx/book/box/limitations.rst @@ -4,8 +4,8 @@ Number of fields in an index For BITSET indexes, the maximum is 1. For TREE or HASH indexes, the maximum - is 255 (``box.schema.INDEX_PART_MAX``). For RTREE indexes, the number of - fields must be either 2 or 4. + is 255 (``box.schema.INDEX_PART_MAX``). For RTREE indexes, the + maximum is 1 but the field is an ARRAY. Number of indexes in a space 10 (``box.schema.INDEX_MAX``).