Skip to content
Snippets Groups Projects
Commit b846a8d0 authored by ocelot-inc's avatar ocelot-inc
Browse files

box_index.rst, shard.rst, tarantool.rst

parent b0eea2c7
No related branches found
No related tags found
No related merge requests found
......@@ -636,9 +636,9 @@ is Rectangle#2", and "Rectangle#3 is entirely inside Rectangle#2".
Now let us create a space and add an RTREE index.
:codebold:`s = box.schema.create_space`
:codebold:`i = s:create_index('primary',{type='HASH',parts={1,'NUM'}})`
:codebold:`r = s:create_index('spatial',{type='RTREE',unique=false,parts={2,'ARRAY'}})`
| :codebold:`s = box.schema.create_space('rectangles')`
| :codebold:`i = s:create_index('primary',{type='HASH',parts={1,'NUM'}})`
| :codebold:`r = s:create_index('spatial',{type='RTREE',unique=false,parts={2,'ARRAY'}})`
Field#1 doesn't matter, we just make it because we need a primary-key index.
(RTREE indexes cannot be unique and therefore cannot be primary-key indexes.)
......@@ -646,17 +646,17 @@ The second field must be an "array", which means its values must represent
{x,y} points or {x1,y1,x2,y2} rectangles. Now let us populate the table by
inserting two tuples, containing the coordinates of Rectangle#2 and Rectangle#4.
:codebold:`s:insert{1, {3,5,9,10}}`
:codebold:`s:insert{2, {10,11}}`
| :codebold:`s:insert{1, {3,5,9,10}}`
| :codebold:`s:insert{2, {10,11}}`
And now, following the description of `RTREE iterator types`_, we can search the
rectangles with these requests:
.. _RTREE iterator types: rtree-iterator_
:codebold:`r:select({10,11,10,11},{iterator='EQ'}) -- Request#1 (returns 1 tuple)`
:codebold:`r:select({4,7,5,9},{iterator='GT'}) -- Request#2 (returns 1 tuple)`
:codebold:`r:select({1,2,3,4},{iterator='NEIGHBOR'}) -- Request#3 (returns 2 tuples)`
| :codebold:`r:select({10,11,10,11},{iterator='EQ'}) -- Request#1 (returns 1 tuple)`
| :codebold:`r:select({4,7,5,9},{iterator='GT'}) -- Request#2 (returns 1 tuple)`
| :codebold:`r:select({1,2,3,4},{iterator='NEIGHBOR'}) -- Request#3 (returns 2 tuples)`
Request#1 returns 1 tuple because the point {10,11} is the same as the rectangle
{10,11,10,11} ("Rectangle#4" in the picture). Request#2 returns 1 tuple because
......
......@@ -19,7 +19,7 @@ The shard package distributes according to a hash algorithm,
that is, it applies a hash function to a tuple's primary-key value
in order to decide which shard the tuple belongs to.
The hash function is `consistent`_
so that changing the number of tuples will not affect results for many keys.
so that changing the number of servers will not affect results for many keys.
The specific hash function that the shard package uses is
guava.digest in the :codeitalic:`digest` package. |br|
**Queue** ...
......
......@@ -8,9 +8,10 @@ By saying :code:`require('tarantool')`, one can answer
some questions about how the tarantool server was built,
such as "what flags were used", or "what was the version
of the compiler". Additionally one can see the uptime
and the server version and the process id, but those
information items are more commonly accessed with
:func:`box.info`.
and the server version and the process id. Those
information items can also be accessed with
:func:`box.info` but use of the tarantool package is
recommended.
| EXAMPLE
| :codenormal:`tarantool>` :codebold:`tarantool = require('tarantool')`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment