1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef DISTRIBUTED_DB_SCHEMA_TEST_TOOLS_H
16 #define DISTRIBUTED_DB_SCHEMA_TEST_TOOLS_H
17 
18 #ifdef DB_DEBUG_ENV
19 #include <cfloat>
20 #endif
21 #include "kv_store_delegate.h"
22 #include "kv_store_delegate_manager.h"
23 #include "distributeddb_data_generator.h"
24 #include "distributeddb_nb_test_tools.h"
25 const static int RECORDNUM = 257;
26 const static int TWO_RECORD = 2;
27 const static int RECORDSIZE = 4;
28 const static int ARRAY_SIZE = 3;
29 const static int OVER_MAXSIZE = 4097;
30 const static int SCHEMA_INDEX = 5;
31 const static unsigned int INDEX_FIFY = 5;
32 const static unsigned int INDEX_SIX = 6;
33 const static unsigned int INDEX_NINE = 9;
34 const static unsigned int INDEX_TEN = 10;
35 // the valid std::string of schema field
36 const static std::string VALID_VERSION_1 = "1.0";
37 const std::vector<std::string> VALID_VERSION = {VALID_VERSION_1};
38 const static std::string VALID_MODE_1 = "STRICT";
39 const static std::string VALID_MODE_2 = "COMPATIBLE";
40 const std::vector<std::string> VALID_MODE = {VALID_MODE_1, VALID_MODE_2};
41 const static std::string VALID_DEFINE_1 = "{\"field1\":\"STRING,NOT NULL,DEFAULT 'fxy'\"," \
42     "\"_field1\":{\"field1\":\"STRING,NOT NULL,DEFAULT 'fxy'\",\"field2\":\"STRING  ,DEFAULT null\"," \
43     "\"field3\":{\"field4\":\"STRING,NOT NULL  \",\"field5\":{\"field6\":\"STRING\t\"," \
44     "\"field7\":[]}}},\"field1\":\"BOOL,NOT NULL,DEFAULT   true\"," \
45     "\"field9\":\"BOOL,DEFAULT false\",\"Field9\":\"\tBOOL\"," \
46     "\"field10\":{\"field10\":\"BOOL,DEFAULT null\",\"field11\":\"INTEGER, NOT NULL,DEFAULT -10\"," \
47     "\"field12\":\"INTEGER,DEFAULT null\",\"field13\":\"INTEGER  \",\"field14\":{}}," \
48     "\"field15\":\"LONG,NOT NULL,DEFAULT +10\",\"field16\":\"LONG,DEFAULT null\",\"field17\":\" LONG\"," \
49     "\"field18\":\"DOUBLE,NOT NULL,DEFAULT -0.0\",\"_19\":\"DOUBLE,DEFAULT null\",\"f\":\"DOUBLE\"}";
50 const static std::string SCHEMA_DEFINE_NNULL_DEFAULT = "{\"field1\":\"STRING, NOT NULL, DEFAULT \'json\'\","
51     "\"field2\":{\"field3\":\"INTEGER, NOT NULL, DEFAULT 0\",\"field4\":\"BOOL, NOT NULL, DEFAULT true\","
52     "\"field1\":{\"field5\":\"LONG, NOT NULL, DEFAULT 2021456\","
53     "\"field2\":{\"field6\":\"DOUBLE, NOT NULL, DEFAULT 2021.2\"}}}}";
54 const static std::string SCHEMA_DEFINE_NNULL = "{\"field1\":\"STRING, NOT NULL\",\"field2\":{\"field3\":"
55     "\"INTEGER, NOT NULL\",\"field4\":\"BOOL, NOT NULL\",\"field1\":{\"field5\":\"LONG, NOT NULL\","
56     "\"field2\":{\"field6\":\"DOUBLE, NOT NULL\"}}}}";
57 const static std::string SCHEMA_DEFINE_DEFAULT = "{\"field1\":\"STRING, DEFAULT \'json\'\","
58     "\"field2\":{\"field3\":\"INTEGER, DEFAULT 0\",\"field4\":\"BOOL, DEFAULT true\","
59     "\"field1\":{\"field5\":\"LONG, DEFAULT 2021456\",\"field2\":{\"field6\":\"DOUBLE,DEFAULT 2021.2\"}}}}";
60 const static std::string SCHEMA_DEFINE_NON_ATTRI = "{\"field1\":\"STRING\",\"field2\":{\"field3\":\"INTEGER\","
61     "\"field4\":\"BOOL\",\"field1\":{\"field5\":\"LONG\",\"field2\":{\"field6\":\"DOUBLE\"}}}}";
62 const static std::string COMPATIBLE_SCHEMA_DEFINE = "{\"field1\":\"STRING,NOT NULL,DEFAULT \'json\'\",\"field2\":"
63     "{\"field3\":\"INTEGER,NOT NULL,DEFAULT 0\",\"field4\":\"BOOL,NOT NULL,DEFAULT true\",\"field1\":{\"field5\":"
64     "\"LONG,NOT NULL,DEFAULT 2021456\",\"field2\":{\"field6\":\"DOUBLE,NOT NULL,DEFAULT 2021.2\",\"field_add1\":"
65     "\"STRING\"},\"field_add2\":\"INTEGER,DEFAULT 100\"},\"field_add3\":\"BOOL,NOT NULL,DEFAULT false\"},"
66     "\"field_add4\":[]}";
67 
68 const std::string VALID_DEFINE_STRING = "{\"field1\":\"STRING ,DEFAULT null\",\"field2\":"
69     "{\"field3\":\"STRING ,DEFAULT null\",\"field4\":[]}}";
70 const std::string VALID_DEFINE_BOOL = "{\"field1\": \"BOOL ,DEFAULT null\",\"field2\":"
71     "{\"field3\": \"BOOL ,DEFAULT null\",\"field4\":[]}}";
72 const std::string VALID_DEFINE_INT = "{\"field1\": \"INTEGER ,DEFAULT null\",\"field2\":"
73     "{\"field3\": \"INTEGER ,DEFAULT null\",\"field4\":[]}}";
74 const std::string VALID_DEFINE_LONG = "{\"field1\": \"LONG ,DEFAULT null\",\"field2\":"
75     "{\"field3\": \"LONG ,DEFAULT null\",\"field4\":[]}}";
76 const std::string VALID_DEFINE_DOUBLE = "{\"field1\": \"DOUBLE ,DEFAULT null\",\"field2\":"
77     "{\"field3\": \"DOUBLE ,DEFAULT null\",\"field4\": []}}";
78 
79 const std::vector<std::string> STRING_SCHEMA_VALUE = {
80     "{\"field1\":\"bxz\",\"field2\":{\"field3\":\"fxy\",\"field4\":[]}}",
81     "{\"field1\":\"abc\",\"field2\":{\"field3\":\"fxz\",\"field4\":[]}}",
82     "{\"field1\": null ,\"field2\":{\"field3\":\"fxw\",\"field4\":[]}}",
83     "{\"field1\":\"bxz\",\"field2\":{\"field3\": null ,\"field4\":[]}}",
84     "{\"field1\":\"TRUE\",\"field2\":{\"field3\": null ,\"field4\":[]}}"
85 };
86 const std::vector<std::string> BOOL_SCHEMA_VALUE = {
87     "{\"field1\":true,\"field2\":{\"field3\":null,\"field4\":[]}}",
88     "{\"field1\":false,\"field2\":{\"field3\":false,\"field4\":[]}}",
89     "{\"field1\":null ,\"field2\":{\"field3\":false,\"field4\":[]}}",
90     "{\"field1\":true,\"field2\":{\"field3\":null ,\"field4\":[]}}",
91     "{\"field1\":true,\"field2\":{\"field3\":null ,\"field4\":[]}}"
92 };
93 const std::vector<std::string> INTEGER_SCHEMA_VALUE = {
94     "{\"field1\":10,\"field2\":{\"field3\":null,\"field4\":[]}}",
95     "{\"field1\":null,\"field2\":{\"field3\":10,\"field4\":[]}}",
96     "{\"field1\":15,\"field2\":{\"field3\":null,\"field4\":[]}}",
97     "{\"field1\":10,\"field2\":{\"field3\":10,\"field4\":[]}}",
98     "{\"field1\":20,\"field2\":{\"field3\":null,\"field4\":[]}}"
99 };
100 const std::vector<std::string> LONG_SCHEMA_VALUE = {
101     "{\"field1\":10,\"field2\":{\"field3\":null,\"field4\":[]}}",
102     "{\"field1\":null,\"field2\":{\"field3\":10,\"field4\":[]}}",
103     "{\"field1\":18 ,\"field2\":{\"field3\":null,\"field4\":[]}}",
104     "{\"field1\":10,\"field2\":{\"field3\":-25 ,\"field4\":[]}}",
105     "{\"field1\":20,\"field2\":{\"field3\":null ,\"field4\":[]}}"
106 };
107 const std::vector<std::string> DOUBLE_SCHEMA_VALUE = {
108     "{\"field1\":null,\"field2\":{\"field3\":10.0,\"field4\":[]}}",
109     "{\"field1\":10.0,\"field2\":{\"field3\":null,\"field4\":[]}}",
110     "{\"field1\":-10.0 ,\"field2\":{\"field3\":30,\"field4\":[]}}",
111     "{\"field1\":10.5,\"field2\":{\"field3\":null ,\"field4\":[]}}",
112     "{\"field1\":-0.0,\"field2\":{\"field3\":12.5 ,\"field4\":[]}}"
113 };
114 const std::vector<std::string> COMBINE_SCHEMA_VALUE = {
115     "{\"field1\":\"abc\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":9,"
116         "\"field6\":{\"field7\":1000,\"field8\":12}}}}",
117     "{\"field1\":\"ab123\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":88,"
118         "\"field6\":{\"field7\":-100,\"field8\":-99}}}}",
119     "{\"field1\":\"abfxy\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":10,"
120         "\"field6\":{\"field7\":0,\"field8\":38}}}}",
121     "{\"field1\":\"ab789\",\"field2\":{\"field3\":false,\"field4\":{\"field5\":999,"
122         "\"field6\":{\"field7\":50,\"field8\":15.8}}}}",
123     "{\"field1\":\"ab000\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":33,"
124         "\"field6\":{\"field7\":30,\"field8\":149}}}}",
125     "{\"field1\":\"abxxx\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":12,"
126         "\"field6\":{\"field7\":120,\"field8\":-79}}}}",
127     "{\"field1\":\"ab\",\"field2\":{\"field3\":true,\"field4\":{\"field5\":20,"
128         "\"field6\":{\"field7\":82,\"field8\":150.999}}}}"
129 };
130 
131 const std::vector<std::string> VALID_DEFINE = {VALID_DEFINE_1};
132 const static std::string VALID_INDEX_1 = "[]";
133 const static std::string VALID_INDEX_2 = "[\" $.field1\",\"$.field10.field10 \",\"$.field10.field11\r\",\"$.f\"]";
134 const static std::string VALID_INDEX_3 = "[\"\t$.field1\",\" $._field1.field1\",\"$._field1.field3.field5.field6 \"," \
135     "\"$.field9\",\"$.Field9\"]";
136 const static std::string VALID_INDEX_4 = "[\"$.field9\",\"$.field10.field10\",\"$._field1.field3.field4\"," \
137     "\"$._field1.field3.field5.field6\"]";
138 const static std::string VALID_INDEX_5 = "[[\"field1\",\"field2.field3\",\"field2.field4.field5\"," \
139     "\"field2.field4.field6.field7\",\"field2.field4.field6.field8\"]]";
140 const std::vector<std::string> VALID_INDEX = {VALID_INDEX_1, VALID_INDEX_2, VALID_INDEX_3};
141 
142 const static std::string SCHMEA_INDEX_WITH_ONE_JOIN_INDEX = "[\"field1\", [\"field2.field3\", \"field1\"]]";
143 const static std::string SCHEMA_INDEX_WITH_MULTI_JOIN_INDEXS = "[\"field2.field3\",[\"field1\",\"field2.field3\"],"
144         "[\"field2.field_add3\",\"field2.field1.field2.field_add1\"]]";
145 
146 const static std::string INVALID_INDEX_1 = "[19]";
147 const static std::string INVALID_INDEX_2 = "[\"$.field1\",\"$._field1.field5.field6\",\"$.field10.field13\"," \
148     "\"$field20\"]";
149 const static std::string INVALID_INDEX_3 = "[\"$.field1\",\"$._field1.field5.field6\",\"$.field11.field10\"]";
150 const static std::string INVALID_INDEX_4 = "[\".field1\",\"$.field10.field11\"]";
151 const static std::string INVALID_INDEX_5 = "[\"$$.field1\",\"$.field10.field11\"]";
152 const static std::string INVALID_INDEX_6 = "[\"$.field1\",\"$.field10 .field11\"]";
153 const static std::string INVALID_INDEX_7 = "[\"$.field1\",\"$ .field10.field11\"]";
154 const static std::string INVALID_INDEX_8 = "[\"$.field1\",\"$.field1\"]";
155 const static std::string INVALID_INDEX_9 = "[\"$.field10.field14\"]";
156 const std::vector<std::string> INALID_INDEX = {INVALID_INDEX_1, INVALID_INDEX_2, INVALID_INDEX_3, INVALID_INDEX_4,
157     INVALID_INDEX_5, INVALID_INDEX_6, INVALID_INDEX_7, INVALID_INDEX_8, INVALID_INDEX_9};
158 const static std::string INVALID_VERSION_1 = "";
159 const static std::string INVALID_VERSION_2 = "1";
160 const static std::string INVALID_VERSION_3 = "1.1";
161 const std::vector<std::string> INVALID_VERSION = {INVALID_VERSION_1, INVALID_VERSION_2, INVALID_VERSION_3};
162 const static std::string INVALID_MODE_1 = "strict";
163 const static std::string INVALID_MODE_2 = "compatible";
164 const static std::string INVALID_MODE_3 = "LOOSE";
165 const static std::string INVALID_MODE_4 = "";
166 const std::vector<std::string> INVALID_MODE = {INVALID_MODE_1, INVALID_MODE_2, INVALID_MODE_3, INVALID_MODE_4};
167 const static std::string INVALID_DEFINE_1 = "{}";
168 const static std::string INVALID_DEFINE_2 = "{\"field1\":{\"field2\":{\"field3\":{\"field4\":{\"field5\":{}}}}}}";
169 static std::vector<std::string> VALID_DEFINE_FIELD = {"\"field\""};
170 static std::vector<std::string> INVALID_DEFINE_FIELD = {"\"field!\"", "\"_ \"", "\"1_field\"", "field", "\"\""};
171 static std::vector<std::string> VALID_TYPE = {"STRING", "BOOL", "INTEGER", "LONG", "DOUBLE"};
172 static std::vector<std::string> INVALID_TYPE = {"", "string", "FLOAT"};
173 static std::vector<std::string> VALID_NOTNULL = {"NOT NULL"};
174 static std::vector<std::string> INVALID_NOTNULL = {"", "NULL", "null", "\"null\"", "EMPTY", "NOTNULL",
175     "NOT  NULL", "NOT_NULL"};
176 static std::vector<std::string> VALID_DEFAULT = {"DEFAULT 'fxy'", "DEFAULT null", ""};
177 static std::vector<std::string> INVALID_DEFAULT = {"DEFAULT", "default", "DEFAULTtrue", "DEFAULT null",
178     "DEFAULT \"fxy\"", "DEFAULT 'true'", "DEFAULT 'false'", "DEFAULT TRUE", "DEFAULT FALSE", "DEFAULT '10'",
179     "DEFAULT '10.5'", "DEFAULT 10e4", "DEFAULT 1.05E-5", "DEFAULT 0X1A", ""};
180 // the order of three attributes is invalid
181 const std::string ATTRIBUTES_PRE1 = "\"INTEGER,NOT NULL,DEFAULT ";
182 const std::string ATTRIBUTES_PRE2 = "\"LONG,NOT NULL,DEFAULT ";
183 const std::string ATTRIBUTES_PRE3 = "\"DOUBLE,NOT NULL,DEFAULT ";
184 static std::vector<std::string> INVALID_ATTRIBUTES = {
185     "\"STRING,DEFAULT 'fxy',NOT NULL\"",
186     "\"DEFAULT 'fxy',NOT NULL,STRING\"",
187     "\"DEFAULT 'fxy',STRING,NOT NULL\"",
188     "\"NOT NULL,DEFAULT 'fxy',STRING\"",
189     "\"NOT NULL,STRING,DEFAULT 'fxy'\"",
190     "\"STRING,\"",
191     "\"STRING,DEFAULT\"",
192     "\"NOT NULL,DEFAULT 'fxy'\"",
193     "\"DEFAULT 'fxy'\"",
194     "\"NOT NULL\"",
195     "\"STRING,DEFAULT NULL\"",
196     "\"INTEGER,DEFAULT 'null'\"",
197     "\"STRING,NOT NULL,DEFAULT 'fxy',\"",
198     ATTRIBUTES_PRE1 + std::to_string(INT32_MAX) + "1\"",
199     ATTRIBUTES_PRE1 + std::to_string(INT32_MIN) + "1\"",
200     ATTRIBUTES_PRE2 + std::to_string(INT64_MAX) + "1\"",
201     ATTRIBUTES_PRE2 + std::to_string(INT64_MIN) + "1\"",
202     ATTRIBUTES_PRE3 + "1" + std::to_string(std::numeric_limits<double>::max()) + "\"",
203     ATTRIBUTES_PRE3 + "-1" + std::to_string(std::numeric_limits<double>::max()) + "\""
204 };
205 struct SchemaDefine {
206     std::vector<std::string> field;
207     std::vector<std::string> type;
208     std::vector<std::string> notnull;
209     std::vector<std::string> defaultValue;
210 };
211 
212 static std::string VALUE_MATCH_1 = "\"_field1\":{\"field1\":\"abc\",\"field2\":null,\"field3\":{\"field4\":\"def\"," \
213     "\"field5\":{\"field6\":\"fxy\",\"field7\":[]}}}";
214 static std::string VALUE_MATCH_2 = "\"field1\":false,\"field9\":null,\"Field9\":true,\"field10\":{\"field10\":true," \
215     "\"field11\":-1000000,\"field12\":null,\"field13\":150000,\"field14\":{}},\"field15\":666,\"field16\":null," \
216     "\"field17\":-100,\"field18\":-1.05e-4,\"_19\":0.0,\"f\":null";
217 
218 const std::string VALID_COMBINATION_DEFINE = "{\"field1\":\"STRING ,DEFAULT null\",\"field2\":" \
219     "{\"field3\":\"BOOL ,DEFAULT null\",\"field4\":{\"field5\":\"INTEGER ,DEFAULT null\",\"field6\":" \
220     "{\"field7\":\"LONG ,DEFAULT null\",\"field8\":\"DOUBLE ,DEFAULT null\"}}}}";
221 
222 const static std::string PERF_SCHEMA_DEFINE = "{\"field1\":\"LONG\"," \
223     "\"field2\":\"STRING\", \"field3\":\"STRING\", \"field4\":\"STRING\", \"field5\":\"STRING\"," \
224     "\"field6\":\"DOUBLE\", \"field7\":\"STRING\", \"field8\":\"STRING\", \"field9\":\"STRING\"," \
225     "\"field10\":\"STRING\", \"field11\":\"STRING\", \"field12\":\"STRING\", \"field13\":\"STRING\"," \
226     "\"field14\":\"STRING\", \"field15\":\"STRING\", \"field16\":\"STRING\", \"field17\":\"STRING\"," \
227     "\"field18\":\"STRING\", \"field19\":\"STRING\", \"field20\":\"STRING\", \"field21\":\"STRING\"," \
228     "\"field22\":\"STRING\", \"field23\":\"STRING\", \"field24\":\"STRING\", \"field25\":\"STRING\"," \
229     "\"field26\":\"STRING\", \"field27\":\"STRING\", \"field28\":\"STRING\", \"field29\":\"STRING\"," \
230     "\"field30\":\"STRING\"}";
231 const static std::string PERF_SCHEMA_SIX_INDEXES = "[\"$.field1\",\"$.field2\",\"$.field3\",\"$.field4\", " \
232     "\"$.field5\", \"$.field6\"]";
233 const static std::string SKIP_SIZE = "1";
234 const static unsigned int FIRST_FIELD = 1;
235 const static unsigned int SECOND_FIELD = 2;
236 const static unsigned int THIRD_FIELD = 3;
237 const static unsigned int FOURTH_FIELD = 4;
238 const static unsigned int FIFTH_FIELD = 5;
239 const static unsigned int SIXTH_FIELD = 6;
240 const static unsigned int THIRTIETH_FIELD = 30;
241 const static unsigned int TEST_START_CNT = 1;
242 
243 const static std::string VALUE_SKIP_STRING = "a";
244 struct RecordInfo {
245     uint8_t keyFilledChr;
246     unsigned int keyLength;
247     uint8_t valueFilledChr;
248     unsigned int valueLength;
RecordInfoRecordInfo249     RecordInfo(uint8_t keyFilledChr, unsigned int keyLength, uint8_t valueFilledChr, unsigned int valueLength)
250         : keyFilledChr(keyFilledChr), keyLength(keyLength), valueFilledChr(valueFilledChr), valueLength(valueLength)
251     {
252     }
253 };
254 class DistributedDBSchemaTestTools final {
255 public:
256 
DistributedDBSchemaTestTools()257     DistributedDBSchemaTestTools() {}
~DistributedDBSchemaTestTools()258     ~DistributedDBSchemaTestTools() {}
259 
260     // Delete the copy and assign constructors
261     DistributedDBSchemaTestTools(const DistributedDBSchemaTestTools &testTool) = delete;
262     DistributedDBSchemaTestTools& operator=(const DistributedDBSchemaTestTools &testTool) = delete;
263     DistributedDBSchemaTestTools(DistributedDBSchemaTestTools &&testTool) = delete;
264     DistributedDBSchemaTestTools& operator=(DistributedDBSchemaTestTools &&testTool) = delete;
265     static DistributedDB::Entry GenerateFixedLenJsonSchemaRecord(const unsigned long serialNo,
266         const EntrySize &entrySize, const uint8_t keyFilledChr, const uint8_t valueFilledChr);
267     static std::vector<DistributedDB::Entry> GenerateFixedJsonSchemaRecords(
268         const int recordNum, const EntrySize &entrySize, const uint8_t keyFilledChr, const uint8_t valueFilledChr,
269         std::vector<DistributedDB::Key> &allKeys);
270     static DistributedDB::Entry GenerateFixedLenSchemaPerfRecord(const uint64_t presetRecordsCnt,
271         const uint64_t serialNo, const RecordInfo &recordInfo,
272         const std::string &valueSkipString = VALUE_SKIP_STRING);
273     static bool SchemaIndexQuery(const DBParameters &parameters,
274         const std::string &dbPath, const std::string &schemaIndex, const Option &option = g_option);
275     static std::vector<std::string> GenerateCombinationSchemaValue(const std::vector<std::vector<std::string>>
276         &fieldValue);
277     static bool CombinationCheckQueryResult(DistributedDB::KvStoreNbDelegate &delegate,
278         const DistributedDB::Query &query, std::vector<DistributedDB::Entry> &expectEntry,
279         const DistributedDB::DBStatus status, bool canGetCount);
280     static DistributedDB::Value GenSchemaValue(DistributedDB::Value notSchemaValue);
281     template<typename T>
ConstructInvalidQuery(std::string & field,T value,std::vector<T> scope,std::vector<DistributedDB::Query> & queries)282     static void ConstructInvalidQuery(std::string &field, T value, std::vector<T> scope,
283         std::vector<DistributedDB::Query> &queries)
284     {
285         queries = {
286             DistributedDB::Query::Select().EqualTo(field, value),
287             DistributedDB::Query::Select().NotEqualTo(field, value),
288             DistributedDB::Query::Select().GreaterThan(field, value),
289             DistributedDB::Query::Select().GreaterThanOrEqualTo(field, value),
290             DistributedDB::Query::Select().LessThan(field, value),
291             DistributedDB::Query::Select().LessThanOrEqualTo(field, value),
292             DistributedDB::Query::Select().In(field, scope),
293             DistributedDB::Query::Select().NotIn(field, scope),
294             DistributedDB::Query::Select().OrderBy(field, false),
295             DistributedDB::Query::Select().IsNull(field),
296             DistributedDB::Query::Select().IsNotNull(field),
297         };
298     }
299 
300     static bool PreInsertRecords(DistributedDB::KvStoreNbDelegate *&delegate, std::vector<DistributedDB::Key> &keys,
301         const std::vector<std::string> &values, int beginNumber = 0);
302     static void GenerateRandQuery(DistributedDB::Query &query, int beginNum, int endNum);
303     static void GenerateCombineSchemaEntries(std::vector<DistributedDB::Entry> &entries,
304         const std::vector<std::vector<std::string>> &fieldValues, const std::vector<uint8_t> &keyPrefix = {'k'},
305         int startPoint = 0);
306     static bool TransformToSchemaEntry(std::vector<DistributedDB::Entry> &entries,
307         const std::vector<DistributedDB::Key> &keys, const std::vector<std::string> &schemasValue);
308     static void GenerateSpecificSchemaEntries(const int startPoint, const int recordNumber,
309         std::vector<DistributedDB::Entry> &entries, const std::vector<std::vector<std::string>> &values = {});
310 };
311 #endif // DISTRIBUTED_DB_SCHEMA_TEST_TOOLS_H
312