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

tutorial update, and a few changes due to warnings

parent f4d04b00
No related branches found
No related tags found
No related merge requests found
......@@ -252,7 +252,7 @@ a function in Tarantool's library of Lua functions.
.. code-block:: lua_tarantool
function main_function()
local string_value
local string_value, t
string_value = string_function()
t = box.tuple.new({1, string_value})
return t
......@@ -268,7 +268,7 @@ For more about Tarantool tuples see Tarantool manual section :mod:`Package box.t
The screen now looks like this:
| :codenormal:`tarantool>` :codebold:`function main_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value, t`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`string_value = string_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`t = box.tuple.new({1, string_value})`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`return t`
......@@ -293,7 +293,7 @@ it's like a database table.
.. code-block:: lua_tarantool
function main_function()
local string_value
local string_value, t
string_value = string_function()
t = box.tuple.new({1,string_value})
box.space.tester:replace(t)
......@@ -324,7 +324,7 @@ For more about Tarantool insert and replace calls, see Tarantool manual section
The screen now looks like this:
| :codenormal:`tarantool>` :codebold:`function main_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value, t`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`string_value = string_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`t = box.tuple.new({1,string_value})`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`box.space.tester:replace(t)`
......@@ -353,16 +353,16 @@ wrinkle that we add here is a timing function.
.. code-block:: lua_tarantool
function main_function()
local string_value
start_time = os.clock()
local string_value, t
for i = 1,1000000,1 do
string_value = string_function()
t = box.tuple.new({i,string_value})
box.space.tester:replace(t)
end
end_time = os.clock()
end!
start_time = os.clock()!
main_function()!
end_time = os.clock()!
'insert done in ' .. end_time - start_time .. ' seconds'!
The Lua ``os.clock()`` function will return the number of seconds since the
......@@ -400,16 +400,16 @@ and the request that invokes ``main_function()``.
end!
function main_function()
local string_value
start_time = os.clock()
local string_value, t
for i = 1,1000000,1 do
string_value = string_function()
t = box.tuple.new({i,string_value})
box.space.tester:replace(t)
end
end_time = os.clock()
end!
start_time = os.clock()!
main_function()!
end_time = os.clock()!
'insert done in ' .. end_time - start_time .. ' seconds'!
The screen now looks like this:
......@@ -428,23 +428,27 @@ The screen now looks like this:
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`function main_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`start_time = os.clock()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`local string_value, t`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`for i = 1,1000000,1 do`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| |nbsp| |nbsp| :codebold:`string_value = string_function()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| |nbsp| |nbsp| :codebold:`t = box.tuple.new({i,string_value})`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| |nbsp| |nbsp| :codebold:`box.space.tester:replace(t)`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`end`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`end_time = os.clock()`
| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| |nbsp| :codenormal:`->` |nbsp| |nbsp| :codebold:`end!`
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`start_time = os.clock()`
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`main_function()!`
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`end_time = os.clock()`
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`'insert done in ' .. end_time - start_time .. ' seconds'!`
| :codenormal:`---`
| :codenormal:`- insert done in 60.62 seconds`
| :codenormal:`- insert done in 37.62 seconds`
| :codenormal:`...`
| :codenormal:`tarantool>`
......@@ -453,8 +457,10 @@ do more with Tarantool's Lua stored procedures than one can do with stored
procedures in some SQL DBMSs), and that it's straightforward to combine
Lua-library functions and Tarantool-library functions.
What has also been shown is that inserting a million tuples took 60 seconds. The
host computer was a Toshiba laptop with a 2.2-GHz Intel Core Duo CPU.
What has also been shown is that inserting a million tuples took 37 seconds. The
host computer was a Linux laptop. By changing :confval:`wal_mode <wal_mode>` to 'none' before
running the test, one can reduce the elapsed time to 4 seconds.
=====================================================================
......@@ -470,8 +476,8 @@ experience in one way to read and process tuples.
.. code-block:: lua_tarantool
console = require('console'); console.delimiter('!')
json = require('json')
function sum_json_field(field_name)
json = require('json')
local v, t, sum, field_value, is_valid_json, lua_table --[[1]]
sum = 0 --[[2]]
for v, t in box.space.tester:pairs() do --[[3]]
......
......@@ -41,8 +41,8 @@ on top of the **cooperative multitasking** environment that Tarantool itself
uses. A key feature is that the functions can access and modify databases
atomically. Thus some developers look at it as a DBMS with a popular stored
procedure language, while others look at it as a replacement for multiple
components of multi-tier Web application architectures. Performance is a few
thousand transactions per second on a laptop, scalable upwards or outwards to
components of multi-tier Web application architectures. Performance can be a few
hundred thousand transactions per second on a laptop, scalable upwards or outwards to
server farms.
**Tarantool is lock-free** in typical situations. Instead of the operating system's
......
......@@ -98,9 +98,9 @@ the old master went down, they would have to be re-applied manually.
Step 1. Start the first server thus:
|:codenormal:`tarantool>`:codebold:`box.cfg{listen=` :codebolditalic:`uri#1` :codenormal:`}`
|:codenormal:`tarantool>`:codebold:`box.schema.user.grant('guest','read,write,execute','universe') -- replace with more restrictive request`
|:codenormal:`tarantool>`:codebold:`box.snapshot()`
| :codenormal:`tarantool>` :codebold:`box.cfg{listen=` :codebolditalic:`uri#1` :codenormal:`}`
| :codenormal:`tarantool>` :codebold:`box.schema.user.grant('guest','read,write,execute','universe') -- replace with more restrictive request`
| :codenormal:`tarantool>` :codebold:`box.snapshot()`
... Now a new cluster exists.
......@@ -112,7 +112,7 @@ server's databases can happen without conflicts.
Step 3. Start the second server thus:
|:codenormal:`tarantool>`:codebold:`box.cfg{listen=` :codebolditalic:`uri#2` :codebold:`, replication_source=` :codebolditalic:`uri#1` :codebold:`}`
| :codenormal:`tarantool>` :codebold:`box.cfg{listen=` :codebolditalic:`uri#2` :codebold:`, replication_source=` :codebolditalic:`uri#1` :codebold:`}`
... where ``uri#1`` = the :ref:`URI` that the first server is listening on.
......@@ -319,10 +319,10 @@ On the first shell, which we'll call Terminal #1, execute these commands:
| :codenormal:`$` :codebold:`rm -R ~/tarantool_test_node_1/*`
| :codenormal:`$` :codebold:`~/tarantool/src/tarantool`
|
| :codenormal:`tarantool>`:codebold:`box.cfg{listen=3301}`
| :codenormal:`tarantool>`:codebold:`box.schema.user.create('replicator', {password = 'password'})`
| :codenormal:`tarantool>`:codebold:`box.schema.user.grant('replicator','read,write','universe')`
| :codenormal:`tarantool>`:codebold:`box.space._cluster:select({0},{iterator='GE'})`
| :codenormal:`tarantool>` :codebold:`box.cfg{listen=3301}`
| :codenormal:`tarantool>` :codebold:`box.schema.user.create('replicator', {password = 'password'})`
| :codenormal:`tarantool>` :codebold:`box.schema.user.grant('replicator','read,write','universe')`
| :codenormal:`tarantool>` :codebold:`box.space._cluster:select({0},{iterator='GE'})`
The result is that a new cluster is set up, and the UUID is displayed.
Now the screen looks like this: (except that UUID values are always different):
......@@ -394,8 +394,8 @@ On the second shell, which we'll call Terminal #2, execute these commands:
| :codenormal:`$` :codebold:`rm -R ~/tarantool_test_node_2/*`
| :codenormal:`$` :codebold:`~/tarantool/src/tarantool`
|
| :codenormal:`tarantool>`:codebold:`box.cfg{listen=3302, replication_source='replicator:password@localhost:3301'}`
| :codenormal:`tarantool>`:codebold:`box.space._cluster:select({0},{iterator='GE'})`
| :codenormal:`tarantool>` :codebold:`box.cfg{listen=3302, replication_source='replicator:password@localhost:3301'}`
| :codenormal:`tarantool>` :codebold:`box.space._cluster:select({0},{iterator='GE'})`
The result is that a replica is set up. Messages appear on Terminal #1
confirming that the replica has connected and that the WAL contents have
......@@ -817,8 +817,8 @@ been asked to act as a replication source.
On Terminal #1, say:
| :codenormal:`tarantool>`:codebold:`box.cfg{replication_source='replicator:password@localhost:3302'}`
| :codenormal:`tarantool>`:codebold:`box.space.tester:select({0},{iterator='GE'})`
| :codenormal:`tarantool>` :codebold:`box.cfg{replication_source='replicator:password@localhost:3302'}`
| :codenormal:`tarantool>` :codebold:`box.space.tester:select({0},{iterator='GE'})`
The screen now looks like this:
......
......@@ -30,8 +30,8 @@ on top of the **cooperative multitasking** environment that Tarantool itself
uses. A key feature is that the functions can access and modify databases
atomically. Thus some developers look at it as a DBMS with a popular stored
procedure language, while others look at it as a replacement for multiple
components of multi-tier Web application architectures. Performance is a few
thousand transactions per second on a laptop, scalable upwards or outwards to
components of multi-tier Web application architectures. Performance can be a few
hundred thousand transactions per second on a laptop, scalable upwards or outwards to
server farms.
===============================================================================
......
......@@ -66,7 +66,7 @@ The shard-configuration is a table with these fields:
* password (the password for the login)
* redundancy (a number, minimum 1)
* binary (a port number that this host is listening on, on the current host)
(distinguishable from the 'listen' port specified by box.cfg)
(distinguishable from the 'listen' port specified by box.cfg)
Possible Errors: Redundancy should not be greater than the number of servers;
the servers must be alive; two replicas of the same shard should not be in the same zone.
......
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