Skip to content

Commit

Permalink
Fix text formatting and code examples according to Lua style guide (#…
Browse files Browse the repository at this point in the history
…2249)

* Fix text formatting and code examples according to Lua style guide

Translated by ainoneko, translation reviewed by Patience Daur and Alexander Turenko

Co-authored-by: ainoneko <ainoneko@gmail.com>
Co-authored-by: Patience Daur <patiencedaur@gmail.com>
Alexander Turenko <alexander.turenko@tarantool.org>
  • Loading branch information
NickVolynkin committed Oct 6, 2021
1 parent 8c7fb5f commit 7073e32
Show file tree
Hide file tree
Showing 13 changed files with 572 additions and 471 deletions.
68 changes: 35 additions & 33 deletions doc/reference/reference_lua/key_def.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ to extract or compare the index key values.
Create a new key_def instance.

:param table parts: field numbers and types.
There must be at least one part and it
must have at least fieldno and type.
There must be at least one part.
Every part must have the attributes ``type`` and ``fieldno``/``field``.
Other attributes are optional.

:returns: key_def-object :ref:`a key_def object <key_def-object>`

The parts table has components which are the same as
the ``parts`` option in
:ref:`Options for space_object:create_index() <box_space-create_index-options>`.

fieldno (integer) for example fieldno = 1. It is legal to say field instead of fieldno.
``fieldno`` (integer) for example ``fieldno = 1``.
It is legal to use ``field`` instead of ``fieldno``.

type (string) for example type = 'string'.
``type`` (string) for example ``type = 'string'``.

Other components are optional.

Expand All @@ -54,15 +56,15 @@ to extract or compare the index key values.

.. method:: extract_key(tuple)

Return a tuple containing only the fields of the key_def object.
Return a tuple containing only the fields of the ``key_def`` object.

:param table tuple: tuple or Lua table with field contents

:return: the fields that were defined for the key_def object
:return: the fields that were defined for the ``key_def`` object

**Example #1:**

.. code-block:: none
.. code-block:: tarantoolsession
-- Suppose that an item has five fields
-- 1, 99.5, 'X', nil, 99.5
Expand All @@ -76,7 +78,7 @@ to extract or compare the index key values.
...
tarantool> k = key_def.new({{type = 'string', fieldno = 3},
> {type = 'unsigned', fieldno =1 }})
> {type = 'unsigned', fieldno = 1}})
---
...
Expand All @@ -87,7 +89,7 @@ to extract or compare the index key values.
**Example #2**

.. code-block:: none
.. code-block:: lua
-- Now suppose that the item is a tuple in a space which
-- has an index on field #3 plus field #1.
Expand All @@ -96,14 +98,14 @@ to extract or compare the index key values.
-- The result will be the same.
key_def = require('key_def')
box.schema.space.create('T')
i = box.space.T:create_index('I',{parts={3,'string',1,'unsigned'}})
i = box.space.T:create_index('I', {parts={3, 'string', 1, 'unsigned'}})
box.space.T:insert{1, 99.5, 'X', nil, 99.5}
k = key_def.new(i.parts)
k:extract_key(box.space.T:get({'X', 1}))
**Example #3**

.. code-block:: none
.. code-block:: lua
-- Iterate through the tuples in a secondary non-unique index.
-- extracting the tuples' primary-key values so they can be deleted
Expand All @@ -125,11 +127,11 @@ to extract or compare the index key values.

.. method:: compare(tuple_1, tuple_2)

Compare the key fields of tuple_1 to the key fields of tuple_2.
Compare the key fields of ``tuple_1`` to the key fields of ``tuple_2``.
This is a tuple-by-tuple comparison so users do not have to
write code which compares a field at a time.
Each field's type and collation will be taken into account.
In effect it is a comparison of extract_key(tuple_1) with extract_key(tuple_2).
In effect it is a comparison of ``extract_key(tuple_1)`` with ``extract_key(tuple_2)``.

:param table tuple1: tuple or Lua table with field contents
:param table tuple2: tuple or Lua table with field contents
Expand All @@ -140,22 +142,22 @@ to extract or compare the index key values.

**Example:**

.. code-block:: none
.. code-block:: lua
-- This will return 0
key_def = require('key_def')
k = key_def.new({{type='string',fieldno=3,collation='unicode_ci'},
{type='unsigned',fieldno=1}})
k = key_def.new({{type = 'string', fieldno = 3, collation = 'unicode_ci'},
{type = 'unsigned', fieldno = 1}})
k:compare({1, 99.5, 'X', nil, 99.5}, {1, 99.5, 'x', nil, 99.5})
.. _key_def-compare_with_key:

.. method:: compare_with_key(tuple_1, tuple_2)

Compare the key fields of tuple_1 to all the fields of tuple_2.
Compare the key fields of ``tuple_1`` to all the fields of ``tuple_2``.
This is the same as :ref:`key_def_object:compare() <key_def-compare>`
except that tuple_2 contains only the key fields.
In effect it is a comparison of extract_key(tuple_1) with tuple_2.
except that ``tuple_2`` contains only the key fields.
In effect it is a comparison of ``extract_key(tuple_1)`` with ``tuple_2``.

:param table tuple1: tuple or Lua table with field contents
:param table tuple2: tuple or Lua table with field contents
Expand All @@ -166,32 +168,32 @@ to extract or compare the index key values.

**Example:**

.. code-block:: none
.. code-block:: lua
-- This will return 0
key_def = require('key_def')
k = key_def.new({{type='string',fieldno=3,collation='unicode_ci'},
{type='unsigned',fieldno=1}})
k = key_def.new({{type = 'string', fieldno = 3, collation = 'unicode_ci'},
{type = 'unsigned', fieldno = 1}})
k:compare_with_key({1, 99.5, 'X', nil, 99.5}, {'x', 1})
.. _key_def-merge:

.. method:: merge (other_key_def_object)

Combine the main key_def_object with other_key_def_object.
The return value is a new key_def_object containing all the fields of
the main key_def_object, then all the fields of other_key_def_object which
are not in the main key_def_object.
Combine the main ``key_def_object`` with ``other_key_def_object``.
The return value is a new ``key_def_object`` containing all the fields of
the main ``key_def_object``, then all the fields of ``other_key_def_object`` which
are not in the main ``key_def_object``.

:param key_def_object other_key_def_object: definition of fields to add

:return: key_def_object

**Example:**

.. code-block:: none
.. code-block:: lua
-- This will return a key definition with fieldno=3 and fieldno=1.
-- This will return a key definition with fieldno = 3 and fieldno = 1.
key_def = require('key_def')
k = key_def.new({{type = 'string', fieldno = 3}})
k2= key_def.new({{type = 'unsigned', fieldno = 1},
Expand All @@ -202,21 +204,21 @@ to extract or compare the index key values.

.. method:: totable()

Return a table containing what is in the key_def_object.
Return a table containing what is in the ``key_def_object``.
This is the reverse of ``key_def.new()``:

* ``key_def.new()`` takes a table and returns a key_def object,
* ``key_def_object:totable()`` takes a key_def object and returns a table.
* ``key_def.new()`` takes a table and returns a ``key_def`` object,
* ``key_def_object:totable()`` takes a ``key_def`` object and returns a table.

This is useful for input to ``_serialize`` methods.

:return: table

**Example:**

.. code-block:: none
.. code-block:: lua
-- This will return a table with type='string', fieldno=3
-- This will return a table with type = 'string', fieldno = 3
key_def = require('key_def')
k = key_def.new({{type = 'string', fieldno = 3}})
k:totable()
16 changes: 9 additions & 7 deletions locale/ru/LC_MESSAGES/book/connectors/index.po
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ msgstr ""
"поддерживает как отдельные узлы и кластеры Tarantool, так и приложения, "
"созданные с использованием :doc:`фреймворка Cartridge </book/cartridge>` и "
"его модулей. Команда Tarantool активно добавляет в этот модуль новейшие "
"функциональные возможности Tarantool."
"функциональные возможности платформы."

msgid ""
"`tarantool-java <http://github.com/tarantool/tarantool-java/>`__ works with "
Expand All @@ -268,11 +268,13 @@ msgstr ""
"`tarantool-java <http://github.com/tarantool/tarantool-java/>`__ "
"предназначен для ранних версий Tarantool (1.6 и выше) и предоставляет "
"интерфейс JDBC для одиночных узлов Tarantool. Этот модуль *в настоящее время"
" не поддерживается* и не работает с новейшими функциональными возможностями "
"Tarantool 2.x и с кластерами Tarantool."
" не поддерживается* и не работает ни с новейшими функциональными "
"возможностями Tarantool 2.x, ни с кластерами Tarantool."

msgid "The following modules support Java libraries and frameworks:"
msgstr "Следующие модули поддерживают библиотеки и фреймворки Java:"
msgstr ""
"Для работы с библиотеками и фреймворками Java в Tarantool существуют "
"следующие модули:"

msgid ""
"`TestContainers Tarantool module <http://github.com/tarantool/cartridge-"
Expand All @@ -299,9 +301,9 @@ msgid ""
"<http://github.com/tarantool/spring-petclinic-tarantool/>`__ to get familiar"
" with using this module in real applications."
msgstr ""
"`Проект Spring Pet Clinic <http://github.com/tarantool/spring-petclinic-"
"tarantool/>`__, показывает, как использовать этот модуль в реальных "
"приложениях."
"Чтобы узнать, как использовать этот модуль в реальных приложениях, "
"ознакомьтесь с `проектом Spring Pet Clinic "
"<http://github.com/tarantool/spring-petclinic-tarantool/>`__."

msgid "Go"
msgstr "Go"
Expand Down

0 comments on commit 7073e32

Please sign in to comment.