File: suite.lua

package info (click to toggle)
tarantool 2.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 85,412 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,178; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (111 lines) | stat: -rw-r--r-- 3,828 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

function string_function()
    local random_number
    local random_string
    random_string = ""
    for x = 1,20,1 do
        random_number = math.random(65, 90)
        random_string = random_string .. string.char(random_number)
    end
    return random_string
end

function delete_replace_update(engine_name)
    local string_value
    if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
        box.space.tester:drop()
    end
    box.schema.space.create('tester', {engine=engine_name})
    box.space.tester:create_index('primary',{type = 'tree', parts = {1, 'STR'}})

    local random_number
    local string_value_2
    local string_value_3
    local counter = 1
    while counter < 100000 do
        local string_value = string_function()

        local string_table = box.space.tester.index.primary:select({string_value}, {iterator = 'GE', limit = 1})
        if string_table[1] == nil then
            box.space.tester:insert{string_value, counter}
            string_value_2 = string_value
        else
            string_value_2 = string_table[1][1]
        end

        if string_value_2 == nil then
            box.space.tester:insert{string_value, counter}
            string_value_2 = string_value
        end

        random_number = math.random(1,6)

        string_value_3 = string_function()
--      print('<'..counter..'> [' ..  random_number .. '] value_2: ' .. string_value_2 .. ' value_3: ' .. string_value_3)
        if random_number == 1 then
            box.space.tester:delete{string_value_2}
        end
        if random_number == 2 then
            box.space.tester:replace{string_value_2, counter, string_value_3}
        end
        if random_number == 3 then
            box.space.tester:delete{string_value_2}
            box.space.tester:insert{string_value_2, counter}
        end
        if random_number == 4 then
            if counter < 1000000 then
                box.space.tester:delete{string_value_3}
                box.space.tester:insert{string_value_3, counter, string_value_2}
            end
        end
        if random_number == 5 then
            box.space.tester:update({string_value_2}, {{'=', 2, string_value_3}})
        end
        if random_number == 6 then
            box.space.tester:update({string_value_2}, {{'=', 2, string_value_3}})
        end
        counter = counter + 1
    end

    box.space.tester:drop()
    return {counter, random_number, string_value_2, string_value_3}
end

function delete_insert(engine_name)
    local string_value
    if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
        box.space.tester:drop()
    end
    box.schema.space.create('tester', {engine=engine_name})
    box.space.tester:create_index('primary',{type = 'tree', parts = {1, 'STR'}})
    local string_value_2
    local counter = 1
    while counter < 100000 do
        local string_value = string_function()
        local string_table = box.space.tester.index.primary:select({string_value}, {iterator = 'GE', limit = 1})

        if string_table[1] == nil then
            -- print (1, ' insert', counter, string_value)
            box.space.tester:insert{string_value, counter}
            string_value_2 = string_value
        else
            string_value_2 = string_table[1][1]
        end

        if string_value_2 == nil then
            -- print (2, ' insert', counter, string_value)
            box.space.tester:insert{string_value, counter}
            string_value_2 = string_value
        end

        -- print (3, ' delete', counter, string_value_2)
        box.space.tester:delete{string_value_2}

        -- print (4, ' insert', counter, string_value_2)
        box.space.tester:insert{string_value_2, counter}

        counter = counter + 1
    end
    box.space.tester:drop()
    return {counter, string_value_2}
end