1
1
# -*- coding: utf-8 -*-
2
2
import ydb
3
3
import time
4
- import random
5
4
import threading
6
- from enum import Enum
7
5
8
6
from ydb .tests .stress .common .common import WorkloadBase
9
7
@@ -23,7 +21,7 @@ def __init__(self, client, prefix, stop, is_olap):
23
21
def get_stat (self ):
24
22
with self .lock :
25
23
return f"Tables: { self .tables_count } , TotalRows: { self .total_rows } , LastTableRows: { self .prev_rows [0 ]} "
26
-
24
+
27
25
def get_create_query (self ):
28
26
table_path = self .get_table_path (self .table_name + str (self .tables_count ))
29
27
@@ -32,7 +30,7 @@ def get_create_query(self):
32
30
params = "STORE = COLUMN"
33
31
else :
34
32
params = "STORE = ROW"
35
-
33
+
36
34
if self .tables_count == 0 :
37
35
return f"""
38
36
CREATE TABLE `{ table_path } ` (
@@ -51,9 +49,9 @@ def get_create_query(self):
51
49
WITH (
52
50
{ params }
53
51
) AS SELECT
54
- Unwrap(CAST(1 AS Uint64)) AS Key, "{ ('0' * self .value_bytes ) } " AS Value;
52
+ Unwrap(CAST(1 AS Uint64)) AS Key, "{ ('0' * self .value_bytes )} " AS Value;
55
53
"""
56
-
54
+
57
55
def get_ctas_query (self ):
58
56
table_path = self .get_table_path (self .table_name + str (self .tables_count ))
59
57
prev_table_path1 = self .get_table_path (self .table_name + str (self .tables_count - 1 ))
@@ -66,10 +64,10 @@ def get_ctas_query(self):
66
64
FROM `{ prev_table_path1 } `
67
65
UNION ALL
68
66
SELECT
69
- Key + Unwrap(CAST({ self .prev_rows [0 ]} AS Uint64)) AS Key, Value
67
+ Key + Unwrap(CAST({ self .prev_rows [0 ]} AS Uint64)) AS Key, Value
70
68
FROM `{ prev_table_path2 } `
71
69
"""
72
-
70
+
73
71
def prepare (self ):
74
72
create_query = self .get_create_query ()
75
73
self .client .query (
@@ -84,7 +82,6 @@ def prepare(self):
84
82
)
85
83
self .tables_count += 1
86
84
87
-
88
85
def _loop (self ):
89
86
self .prepare ()
90
87
@@ -105,7 +102,7 @@ def _loop(self):
105
102
expected = self .prev_rows [0 ] + self .prev_rows [1 ]
106
103
if actual != expected :
107
104
raise Exception (f"Incorrect result: expected:{ expected } , actual:{ actual } " )
108
-
105
+
109
106
self .prev_rows = (actual , self .prev_rows [0 ])
110
107
self .total_rows += actual
111
108
self .tables_count += 1
0 commit comments