Data type conversion method and device, equipment and medium

CN119357264APending Publication Date: 2025-01-24HANGZHOU YUNSHEN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411402714.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-01-24

AI Technical Summary

Benefits of technology

[0046]本发明所述的数据类型转换方法,首先根据数据查询请求,生成目标ANTLR4表达式,将目标ANTLR4表达式中的若干中间表达式分别转换成若干个中间sql片段,且每一中间sql片段对应一个中间sql标签,根据若干逻辑运算操作符的运算顺序,采用后缀表达式的方式对若干个中间sql标签和若干逻辑运算操作符进行重新组合,通过标签的设置,使得在中间处理过程中只需对标签组合即可,节省内存资源与计算资源的占用,且转换成后缀表达式的排序方式,使得计算机在读取和计算过程中,不需要考虑运算优先级的问题,只需按照顺序依次获取元素,然后进行计算即可,有利于数据查询效率的提升;然后对每一逻辑运算操作符进行目标运算函数转换,结合若干中间sql标签的组合顺序,得到数据转换结果,根据若干个中间sql片段和数据转换结果,生成目标sql语句,通过这一数据类型转换方式,完成了表达式到sql语句的转换,能够实现复杂表达式到数据计算规则的转换,进而实现快速高效地数据查询和处理,且同时能够满足多种业务查询需求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357264A_ABST
    Figure CN119357264A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a data type conversion method, device and equipment and a medium, the method comprises the following steps: generating a target ANTLR4 expression according to a data query request, respectively converting a plurality of intermediate expressions in the target ANTLR4 expression into a plurality of intermediate sql fragments, and each intermediate sql fragment corresponds to an intermediate sql tag, recombining the plurality of intermediate sql labels and the plurality of logical operation operators by adopting a suffix expression mode according to an operation sequence of the plurality of logical operation operators, then performing target operation function conversion on each logical operation operator, and obtaining a data conversion result by combining a combination sequence of the plurality of intermediate sql labels; generating a target sql statement according to a plurality of intermediate sql fragments and the data conversion result; according to the method, the conversion from the expression to the data calculation rule can be realized, so that quick and efficient data query and processing are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data type conversion method, device, equipment and medium. Background Art

[0002] In the field of data processing, ANTLR4 (ANother Tool for Language Recognition) is a language recognition tool and a powerful parser generator for reading, processing, executing or translating structured text or binary files. It is widely used in building languages, tools and frameworks. It can generate a parser that can build and traverse the parse tree according to the grammar, so as to express and parse various complex compound conditions.

[0003] Column storage database (CK, ClickHouse) is a high-performance and low-cost database management system, which is often used for big data analysis and task processing. When querying data, ANTLR4 expressions can express various compound query conditions, so they are often used to construct query conditions in various data query scenarios. However, the query language that CK can recognize is SQL. Considering the complexity of the expression and the characteristics of SQL in CK, how to combine ANTLR4 expressions with SQL in CK environment to realize fast data query is a problem that needs to be solved urgently. Summary of the invention

[0004] The purpose of the present invention is to provide a data type conversion method, device, equipment and medium, which can convert the expression corresponding to the business query condition into a SQL statement during data query, realize the conversion of the expression into data calculation rules, and thus realize fast and efficient data query and processing.

[0005] According to a first aspect of the present invention, there is provided a data type conversion method, comprising the following steps:

[0006] According to a data query request, a target ANTLR4 expression is generated; the data query request is a request including a number of query condition tags, the target ANTLR4 expression includes a number of intermediate expressions and a number of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one.

[0007] The intermediate expressions in the target ANTLR4 expression are respectively converted into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0008] According to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression, a plurality of intermediate SQL tags and a plurality of logical operation operators are recombined in a suffix expression manner to obtain a tag combination result.

[0009] A target operation function conversion is performed on each logical operation operator in the label combination result, and a data conversion result is obtained according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment.

[0010] According to the several intermediate SQL fragments and the data conversion results, a target SQL statement is generated to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0011] Furthermore, the query condition tags include APP category tags, location tags, and device category tags;

[0012] Among them, the APP category labels include high-risk labels, low-risk labels, and financial management labels; the device category labels include simulator categories, device brands, and device models.

[0013] Furthermore, the step of converting the plurality of intermediate expressions in the target ANTLR4 expression into a plurality of intermediate SQL fragments, each of which corresponds to an intermediate SQL tag, comprises the following steps:

[0014] The target ANTLR4 expression is parsed to obtain a plurality of intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag.

[0015] Constructing a plurality of temporary virtual tables; the temporary virtual tables correspond one-to-one to the intermediate expressions.

[0016] Several intermediate expressions are stored in several temporary virtual tables respectively, several intermediate SQL fragments are generated, and the name of the temporary virtual table corresponding to each intermediate SQL fragment is determined as the intermediate SQL label corresponding to the intermediate SQL fragment itself.

[0017] Furthermore, the method obtains the label combination result by the following steps:

[0018] The target ANTLR4 expression is parsed to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators.

[0019] According to the distribution order of the several intermediate expressions, the several intermediate SQL tags and the several logical operation operators are reordered to obtain a preprocessed SQL statement; the preprocessed SQL statement is a statement composed of prefix expressions.

[0020] According to the operation order of the plurality of logical operation operators, the preprocessing SQL statement is converted into an intermediate SQL statement combined by using a suffix expression, and the intermediate SQL statement is used as a label combination result.

[0021] Furthermore, the method generates a target SQL statement through the following steps:

[0022] Get the intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result.

[0023] The intermediate SQL fragments corresponding to each intermediate SQL tag are added to the corresponding positions of the intermediate SQL tag itself in the data conversion result, and the intermediate SQL tag itself is deleted to generate a target SQL statement.

[0024] According to a second aspect of the present invention, there is provided a data type conversion device, the device comprising:

[0025] The first generation module is used to generate a target ANTLR4 expression according to a data query request; the data query request refers to a request including a number of query condition tags, the target ANTLR4 expression includes a number of intermediate expressions and a number of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one.

[0026] The conversion module is used to convert several intermediate expressions in the target ANTLR4 expression into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0027] The combination module is used to recombine several intermediate SQL tags and several logical operation operators in a suffix expression manner according to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression to obtain a tag combination result.

[0028] The processing module is used to convert each logical operation operator in the label combination result into a target operation function, and obtain a data conversion result according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment.

[0029] The second generating module is used to generate a target SQL statement according to the plurality of intermediate SQL fragments and the data conversion result, so as to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0030] Furthermore, the query condition tags include APP category tags, location tags, and device category tags;

[0031] Among them, the APP category labels include high-risk labels, low-risk labels, and financial management labels; the device category labels include simulator categories, device brands, and device models.

[0032] Furthermore, the conversion module includes:

[0033] The first acquisition module is used to parse the target ANTLR4 expression to obtain a plurality of intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag.

[0034] A construction module is used to construct a plurality of temporary virtual tables; the temporary virtual tables correspond one to one with the intermediate expressions.

[0035] The determination module is used to store several intermediate expressions in several temporary virtual tables respectively, generate several intermediate SQL fragments, and determine the name of the temporary virtual table corresponding to each intermediate SQL fragment as the intermediate SQL label corresponding to the intermediate SQL fragment itself.

[0036] Furthermore, the combined module includes:

[0037] The second acquisition module is used to parse the target ANTLR4 expression to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators.

[0038] The third acquisition module is used to reorder the several intermediate SQL tags and several logical operation operators according to the distribution order of the several intermediate expressions to obtain a preprocessed SQL statement; the preprocessed SQL statement is a statement composed of prefix expressions.

[0039] The fourth acquisition module is used to convert the preprocessing SQL statement into an intermediate SQL statement combined with a suffix expression according to the operation order of the plurality of logical operation operators, and use the intermediate SQL statement as a label combination result.

[0040] Furthermore, the second generating module includes:

[0041] The fifth acquisition module is used to acquire the intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result.

[0042] The third generating module is used to add the intermediate SQL fragment corresponding to each intermediate SQL tag to the corresponding position of the intermediate SQL tag itself in the data conversion result, and delete the intermediate SQL tag itself to generate a target SQL statement.

[0043] According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data type conversion method when executing the computer program.

[0044] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned data type conversion method when executed by a processor.

[0045] Compared with the prior art, the present invention has at least the following beneficial effects:

[0046] The data type conversion method of the present invention comprises the following steps: firstly, a target ANTLR4 expression is generated according to a data query request, and several intermediate expressions in the target ANTLR4 expression are respectively converted into several intermediate SQL fragments, each of which corresponds to an intermediate SQL label, and according to the operation order of several logical operation operators, several intermediate SQL labels and several logical operation operators are recombined in a suffix expression manner, and through the setting of labels, only the label combination is required in the intermediate processing process, which saves the occupation of memory resources and computing resources, and the sorting mode of the conversion into the suffix expression is required, so that the computer does not need to consider the problem of operation priority in the reading and computing process, and only the elements need to be obtained in sequence and then the computing is performed, which is conducive to improving the data query efficiency; then, a target operation function conversion is performed on each logical operation operator, and a data conversion result is obtained in combination with the combination order of several intermediate SQL labels, and a target SQL statement is generated according to several intermediate SQL fragments and the data conversion result, and the conversion of the expression into the SQL statement is completed through this data type conversion mode, and the conversion of the complex expression into the data computing rule can be realized, thereby realizing fast and efficient data query and processing, and meeting multiple business query requirements at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 A flowchart of a data type conversion method provided in Embodiment 1 of the present invention;

[0049] Figure 2 A flowchart of step S200 provided in the first embodiment of the present invention;

[0050] Figure 3 A flowchart of step S300 provided in the first embodiment of the present invention;

[0051] Figure 4 A flowchart of step S500 provided in the first embodiment of the present invention;

[0052] Figure 5 A schematic diagram of the structure of a data type conversion device provided in Embodiment 2 of the present invention;

[0053] Figure 6 A schematic diagram of the structure of a conversion module 200 provided in Embodiment 2 of the present invention;

[0054] Figure 7 A schematic diagram of the structure of the combination module 300 provided in the second embodiment of the present invention;

[0055] Figure 8 This is a schematic diagram of the structure of the second generation module 500 provided in the second embodiment of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0057] Embodiment 1

[0058] like Figure 1 As shown, this embodiment provides a data type conversion method, comprising the following steps:

[0059] S100, generating a target ANTLR4 expression according to a data query request; the data query request is a request including a plurality of query condition tags, the target ANTLR4 expression includes a plurality of intermediate expressions and a plurality of logical operation operators, and the intermediate expressions correspond one to one with the query condition tags.

[0060] Specifically, the query condition tags include APP category tags, location tags and device category tags; wherein the APP category tags include but are not limited to high-risk tags, low-risk tags, and financial management tags; the device category tags include but are not limited to simulator categories, device brands, and device models.

[0061] Specifically, the location tag may be one of a permanent residence, a home location, a workplace, and a latest location.

[0062] Specifically, the logic operation operator is any one of intersection “^”, union “#”, and difference “%”.

[0063] S200, converting a plurality of intermediate expressions in the target ANTLR4 expression into a plurality of intermediate SQL fragments respectively, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0064] Specifically, Figure 2 As shown, step S200 includes the following steps:

[0065] S201, parse the target ANTLR4 expression to obtain several intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag; it can be understood that: when the query condition tag is composed of several query condition sub-tags, the intermediate expression corresponding to the query condition tag is composed of sub-expressions corresponding to several query condition sub-tags.

[0066] For better explanation, an example is given below: when searching for a certain location and a certain device brand that includes a low-risk label APP and a financial label APP, "a certain location" and "a certain device brand" are each a query condition label, "low-risk label APP and financial label APP" is a query condition label, and "low-risk label APP" and "financial label APP" are both query condition sub-labels. Each query condition label corresponds to an intermediate expression, and each query condition sub-label corresponds to a sub-expression.

[0067] S202, constructing several temporary virtual tables; the temporary virtual tables correspond to the intermediate expressions one by one.

[0068] Specifically, a temporary virtual table is defined and constructed through the with clause in the SQL language.

[0069] For example: for the target ANTLR4 expression ((c0)^(c1#c2#c3#c4#c5)^(c6fa0#c6fa1))%((f0#f1)^(f2#f3)), the correspondence between the names of the generated temporary virtual tables and the intermediate expressions is: with_tmp_table_1 corresponds to c0, with_tmp_table_2 corresponds to c1#c2#c3#c4#c5, with_tmp_table_3 corresponds to c6fa0#c6fa1, with_tmp_table_4 corresponds to f0#f1, and with_tmp_table_5 corresponds to f2#f3.

[0070] S203, store several intermediate expressions into several temporary virtual tables respectively, generate several intermediate SQL fragments, and determine the name of the temporary virtual table corresponding to each intermediate SQL fragment as the intermediate SQL label corresponding to the intermediate SQL fragment itself; it can be understood as: determining the table name corresponding to the with clause as the intermediate SQL label.

[0071] As described above, when processing complex expressions, several intermediate expressions after parsing are temporarily saved by building a temporary virtual table, and parsed in memory as a temporary memory table, which can improve the execution efficiency and readability of SQL statements, and is conducive to subsequent complex data calculations. Moreover, the temporary virtual table is only valid in the current query and can be destroyed after use, which is conducive to the rational use of memory resources.

[0072] S300, according to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression, a plurality of intermediate SQL tags and a plurality of logical operation operators are recombined in a suffix expression manner to obtain a tag combination result.

[0073] Specifically, Figure 3 As shown, step S300 includes the following steps:

[0074] S301, parsing the target ANTLR4 expression to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators.

[0075] S302, according to the distribution order of the several intermediate expressions, the several intermediate SQL tags and the several logical operation operators are reordered to obtain a preprocessed SQL statement; the preprocessed SQL statement is a statement composed of prefix expressions; it can be understood as: sorting the several intermediate SQL tags according to the distribution order of the several intermediate expressions, and using the sorting result as the preprocessed SQL statement.

[0076] S303: According to the operation order of the plurality of logical operation operators, the preprocessing SQL statement is converted into an intermediate SQL statement combined by a suffix expression, and the intermediate SQL statement is used as a label combination result.

[0077] For ease of understanding, an example is given below:

[0078] As in the above target ANTLR4 expression, the intermediate expressions are: (c0), (c1#c2#c3#c4#c5), (c6fa0#c6fa1), (f0#f1), (f2#f3); the operation sequence is: first perform the union operation in each intermediate expression, then calculate the intersection of the first three expressions and the intersection of the last two expressions in turn, and finally perform the difference operation on the two sets; the expression obtained after converting the target ANTLR4 expression into a suffix expression is (c0)(c1#c2#c3#c4#c5)^(c6fa0#c6fa1)^(f0#f1)(f2#f3)^%, that is, the intermediate SQL statement obtained is with_tmp_table_1with_tmp_table_2^with_tmp_table_3^with_tmp_table_4with_tmp_table_5^%.

[0079] As mentioned above, by converting the preprocessed SQL statement in the form of a prefix expression into an intermediate SQL statement in the form of a suffix expression, the computer does not need to consider the issue of operation priority during reading and calculation. It only needs to obtain the elements in sequence and then perform calculations. This is very convenient for computer data processing and is conducive to improving the efficiency of data query.

[0080] S400, perform target operation function conversion on each logical operation operator in the label combination result, and obtain a data conversion result according to the combination order of the intermediate SQL labels in the label combination result; it can be understood as: combining the result after the target operation function conversion with several sorted intermediate SQL labels to obtain a data conversion result.

[0081] Specifically, the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment; it can be understood that: each logical operation operator corresponds to a bitmap operation function of CK; for example, the operation function corresponding to the intersection is bitmapAnd, the operation function corresponding to the union is groupBitmapOrState or bitmapOr, and the operation function corresponding to the difference is bitmapAndNot.

[0082] S500, generating a target SQL statement according to the plurality of intermediate SQL fragments and the data conversion result, so as to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0083] Specifically, Figure 4 As shown, step S500 includes the following steps:

[0084] S501, obtaining the intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result; it can be understood that: the intermediate SQL fragment corresponding to the intermediate SQL tag refers to the SQL statement in the temporary virtual table corresponding to the intermediate SQL tag.

[0085] S502, adding the intermediate SQL fragments corresponding to each intermediate SQL tag to the corresponding positions of the intermediate SQL tag itself in the data conversion result, and deleting the intermediate SQL tag itself to generate a target SQL statement.

[0086] As mentioned above, by replacing the corresponding intermediate sql tags with several intermediate sql fragments and adding them to the data conversion results, it is shown that the target ANTLR4 expression has completed the complete conversion to the sql statement. Through this data type conversion method, any combination of any number of business query conditions can be converted from a complex expression to a bitmap calculation sql statement that can be executed by CK, thereby realizing fast and efficient query and processing of data, so as to meet multiple business query requirements at the same time.

[0087] The data type conversion method described in this embodiment first generates a target ANTLR4 expression according to a data query request, converts several intermediate expressions in the target ANTLR4 expression into several intermediate sql fragments, and each intermediate sql fragment corresponds to an intermediate sql label. According to the operation order of several logical operation operators, the several intermediate sql labels and the several logical operation operators are recombined in the form of suffix expressions. Through the setting of labels, only the labels need to be combined in the intermediate processing process, which saves the occupation of memory resources and computing resources. The sorting method converted into suffix expressions does not need to consider the problem of operation priority during the reading and calculation process of the computer, and only elements need to be obtained in sequence and then calculated, which is conducive to improving the efficiency of data query. Then, each logical operation operator is converted into a target operation function, and the data conversion result is obtained by combining the combination order of several intermediate sql labels. According to the several intermediate sql fragments and the data conversion results, a target sql statement is generated. Through this data type conversion method, the conversion from expression to sql statement is completed, and the conversion from complex expression to data calculation rule can be realized, thereby realizing fast and efficient data query and processing, and at the same time, it can meet various business query requirements.

[0088] In another specific implementation scenario, the data of the bitmap data structure needs to be stored in a column-based database management system. Therefore, the present application also provides a method for storing data of the bitmap data structure, comprising the following steps:

[0089] P100, when the number of elements of the received bitmap data structure is greater than 32, the bitmap data structure is marked as a first preset data type, and the number of target high-order elements is obtained from the bitmap data structure; it can be understood that: the first preset data type refers to a target byte array whose number of target high-order elements is not 0, that is, when the number of elements of the bitmap data structure is not greater than 32, the number of target high-order elements is 0.

[0090] Specifically, the target high-order element refers to an element in a high-order bucket obtained according to the high-order and low-order allocation rules of the bitmap data structure.

[0091] For better understanding, further explanation is given as follows. In the bitmap data structure, the 64-bit integer range is divided into high and low parts. The high part is usually used to represent a large range of integer values. The high part refers to 33-64 bits, and the low part refers to 1-32 bits. The number of target high-order elements refers to the number of elements in the high-order part. Since this number of elements can provide further information about the 64-bit bitmap data structure, such as the coverage of the data range and the distribution of the data, it plays a very important role in subsequent data restoration operations.

[0092] P200, perform binary processing on the data of the bitmap data structure to obtain an initial byte array and an initial byte length corresponding to the bitmap data structure.

[0093] Specifically, the P200 step includes the following steps:

[0094] P201, converting the data of the bitmap data structure into binary byte data, and determining the binary byte data as an initial byte array corresponding to the bitmap data structure.

[0095] P202, obtain the byte length of the initial byte array, and determine the byte length of the initial byte array as the initial byte length corresponding to the bitmap data structure.

[0096] As mentioned above, by performing binary processing on the data of the bitmap data structure, it is converted into a byte array, thereby realizing the transformation of the data arrangement structure. Since the column-based database management system has the effect of efficiently storing data in the form of byte arrays, after the above-mentioned data object conversion, the structure of the data is kept consistent with the data structure stored in the column-based database management system, completing the preliminary processing of the data, which is conducive to realizing the rapid storage of large-scale data sets in the column-based database management system.

[0097] P300, converting the initial sequence type corresponding to the initial byte array into a target sequence type, and obtaining a target byte array; specifically comprising the following steps:

[0098] P301, obtain an initial sequence type corresponding to the initial byte array; the initial sequence type corresponding to the initial byte array is a big-endian byte sequence type.

[0099] P302, convert the initial byte array from a big-endian byte sequence type to a little-endian byte sequence type, and obtain a target byte array.

[0100] Specifically, a byte buffer object is used to convert the initial byte array from a big-endian byte sequence type to a little-endian byte sequence type, wherein the target byte buffer object refers to a buffer capable of storing big-endian data and little-endian data. In a specific implementation, a byte buffer is generally used for data format conversion, for example, converting big-endian data into little-endian data, or converting little-endian data into big-endian data; in this embodiment, the target byte buffer uses a ByteBuffer buffer.

[0101] As mentioned above, since the bitmap data structures in Java are all data arranged in big-endian order, and CK supports data arranged in little-endian order, the big-endian byte sequence type is converted into the little-endian byte sequence type through the byte buffer, so that the original bitmap data structure is converted into a data sequence that CK can read normally, which is conducive to fast data transmission and efficient storage.

[0102] P400, based on the initial byte length, perform byte compression processing on the initial byte array to obtain a target byte length corresponding to the compressed initial byte array.

[0103] Specifically, the P400 step also includes the following steps:

[0104] P401, encode the initial byte array corresponding to the bitmap data structure by using variable-length byte encoding to obtain a compressed encoding sequence.

[0105] Preferably, the variable-length byte encoding adopts varint encoding; varint encoding is a method of performing variable-length byte encoding on positive integers. For example, when an int-type integer occupies 4 bytes, if the value of the integer is less than 256, it can be stored in one byte of space, wasting 3 bytes of space. Therefore, using varint encoding can effectively save byte space of data, especially for integers with larger values, the compression effect is more obvious.

[0106] P402, obtain the first byte length corresponding to the compressed coding sequence; it can be understood that: the first byte length refers to the byte length of the coding sequence after compression.

[0107] P403, based on the variable-length byte encoding adopted, calculate the second byte length corresponding to the initial byte length; it can be understood that: the second byte length refers to the byte length that should be obtained when the variable-length byte encoding encodes the initial byte array. For example, when an int integer occupies 4 bytes, if the value of the integer is less than 256, the corresponding second byte length is 1 byte.

[0108] P404, when the first byte length is consistent with the second byte length, the first byte length is determined as the target byte length, otherwise, a prompt verification message is sent to the target user.

[0109] As described above, by compressing the initial byte array corresponding to the bitmap data structure, the storage space occupied by the byte data can be effectively reduced, thereby reducing the impact on data transmission and computing resources, which is conducive to quickly storing data in a column-based database management system while saving storage resources for column-based database management.

[0110] P500, splicing the first preset data type, target byte length, target number of high-order elements and target byte array into a new byte array according to a preset splicing order, so as to store the new byte array in a given column-based database management system.

[0111] Specifically, the preset splicing order refers to the order of sequentially splicing the first preset data type, the target byte length, the number of target high-order elements, and the target byte array.

[0112] As described above, by splicing multiple information into a new byte array, it is beneficial to achieve accurate restoration of data when querying data. In addition, the first preset data type is placed in the first byte of the target byte array, so that the data type of the target byte data is obtained first when reading data, so that different data restoration methods are used according to different data types to maximize data parsing efficiency.

[0113] Preferably, in another embodiment, the method further comprises the following steps:

[0114] P001, when the number of elements of the bitmap data structure is not greater than 32, obtain the occupied byte length of the bitmap data structure, and mark the bitmap data structure as a second preset data type; it can be understood that: the second preset data type refers to a target byte array whose number of target high-order elements is 0, that is, when the number of elements of the bitmap data structure is greater than 32, the number of target high-order elements is greater than 0.

[0115] P002, perform byte compression processing on the occupied byte length to obtain the key byte length.

[0116] Specifically, the manner of performing byte compression processing on the occupied byte length is consistent with the manner of performing byte compression processing on the initial byte array, which will not be described in detail here.

[0117] P003, converting the data of the bitmap data structure into data of a little-endian byte sequence type.

[0118] P004, concatenate the data of the second preset data type, key byte length and little endian byte sequence type into a new byte array, so as to store the new byte array in a given column-based database management system.

[0119] As mentioned above, when the bitmap data structure of a small data set is stored in a column-based database management system, there is no need to perform binary processing and serialized byte array conversion because the parsing will not fail due to the large amount of data when the data is restored. Instead, the data in the bitmap data structure can be directly read and written into a preset empty byte array in little-endian order, which reduces the data processing flow and facilitates the rapid storage of data.

[0120] In another specific implementation scenario, after storing the data in a column-based database management system, when the required data is queried from the column-based database management system, the data needs to be parsed. Therefore, the present application also provides a byte array data parsing method, comprising the following steps:

[0121] Z100, receives a target byte array from a given column-based database management system; the target byte array includes a target data type, a target byte length, the number of target high-order elements and an intermediate byte array; the target data type includes a first preset data type and a second preset data type; it can be understood that: the target byte array is the byte array queried according to the converted target SQL statement.

[0122] Specifically, the given column-based database management system refers to a system in which stored data exists in the form of byte arrays; in this embodiment, the given column-based database management system is the ClickHouse database.

[0123] Specifically, the first preset data type refers to a target byte array whose number of target high-order elements is not 0, and the second preset data type refers to a target byte array whose number of target high-order elements is 0.

[0124] Specifically, the first byte of the target byte array received from a given column-based database management system is used to represent the target data type. By representing the target data type with the first byte of the byte array, when the target byte array is received and read, the data type corresponding to the target byte array can be read first, and then the corresponding parsing method can be quickly selected to parse the target byte array.

[0125] When the first byte of the received target byte array is the first preset byte, it represents that the target data type is the first preset data type; when the first byte of the received target byte array is the second preset byte, it represents that the target data type is the second preset data type; technicians in this field set the first preset byte and the second preset byte according to actual needs, for example, setting the first preset byte to 1 and setting the second preset byte to 0.

[0126] Specifically, the target byte length refers to the byte length corresponding to the middle byte array in the target byte array.

[0127] Specifically, the target high-order element refers to an element in a high-order bucket obtained according to a high-order and low-order allocation rule of a bitmap data structure.

[0128] For better understanding, further explanation is given as follows. In the bitmap data structure, the 64-bit integer range is divided into high and low parts. The high part is usually used to represent a large range of integer values. The high part refers to 33-64 bits, and the low part refers to 1-32 bits. The number of target high-order elements refers to the number of elements in the high-order part. Since this number of elements can provide further information about the 64-bit bitmap data structure, such as the coverage of the data range and the distribution of the data, it plays a very important role in subsequent operations.

[0129] Specifically, the intermediate byte array refers to any set of serialized data stored in a given column-based database management system; it can be understood that: the target byte array is an array received including any intermediate byte array and some information of the intermediate byte array itself.

[0130] Z200, writes the target byte array into a pre-constructed target byte buffer object; the intermediate byte array in the target byte array is arranged in little endian order in the target byte buffer object; it can be understood that: the target byte array arranged in little endian order still exists in little endian form after being written into the target byte buffer, and the target byte buffer includes the target data type, target byte length, number of target high-order elements and intermediate byte array in the received target byte array.

[0131] Specifically, the target byte buffer object refers to a buffer that can store big-endian data and little-endian data. In a specific implementation, a byte buffer is usually used to perform data format conversion, for example, converting big-endian data to little-endian data, or converting little-endian data to big-endian data. In this embodiment, the target byte buffer adopts a ByteBuffer buffer. This target byte buffer is only used for temporary storage of arrays in this embodiment and is not used for data sorting type conversion.

[0132] As mentioned above, since the target byte array contains multiple array information, when querying data, only the intermediate byte array in the target byte array needs to be obtained, that is, the original byte array is converted into a new byte array. The target byte buffer object can more conveniently perform operations such as reading and identifying data on the byte array. That is, the target byte buffer object provides a more friendly way to operate the byte array, thereby ensuring the accuracy of the array conversion.

[0133] Z300: Parse the target byte array in the target byte buffer object into a bitmap data structure according to the content of the target byte buffer object.

[0134] Specifically, the Z300 step includes the following steps:

[0135] Z310, sequentially read the data of the target byte buffer object to obtain the first byte corresponding to the target byte buffer object.

[0136] Z320, determine the target data type corresponding to the target byte array according to the first byte corresponding to the target byte buffer object.

[0137] As described above, by reading the first byte corresponding to the target byte buffer object, the target data type corresponding to the target byte array can be obtained first, so that different data parsing methods can be adopted for the target byte array according to different data types to maximize the parsing effect, thereby improving the efficiency of data query.

[0138] In a special case, when the first byte corresponding to the target byte buffer object is not the first preset byte and the second preset byte, the target byte array is parsed into an empty bitmap data structure.

[0139] In one embodiment, the Z300 step specifically includes the following steps:

[0140] Z301, when the target data type is a first preset data type, obtain the target byte length and the number of target high-order elements from the target byte buffer object.

[0141] Z303, construct an empty byte array corresponding to the target byte length obtained from the target byte buffer object.

[0142] Specifically, step Z303 also includes the following steps:

[0143] Z3031, when the target byte length obtained from the target byte buffer object is the original byte length corresponding to the intermediate byte array obtained from the target byte buffer object, construct an empty byte array with a byte length equal to the target byte length.

[0144] Z3032, when the target byte length obtained from the target byte buffer object is the byte length of the intermediate byte array obtained from the target byte buffer object after compression processing, calculate the original byte length corresponding to the target byte length obtained from the target byte buffer object, and construct an empty byte array with a byte length equal to the original byte length.

[0145] Z305, read the intermediate byte array arranged in little endian order from the target byte buffer object, and store the read intermediate byte array into the empty byte array.

[0146] Z307, stores the number of target high-order elements obtained from the target byte buffer object and the data in the empty byte array into a preset new byte buffer object, so as to convert the intermediate byte array stored in the empty byte array into a byte array arranged in big-endian order through the new byte buffer object.

[0147] Z309, parse the content of the new byte buffer object to obtain a bitmap data structure.

[0148] Specifically, the big-endian and little-endian conversion method in the Java language is used to convert the little-endian data in the new byte buffer object into big-endian data to obtain a corresponding 64-bit bitmap data structure.

[0149] As described above, when processing the byte array of the first preset data type, the target byte array is directly parsed at the byte array level, and the serialized byte array can be parsed into data of a bitmap data structure in Java through a little-endian to big-endian conversion. There is no need to perform multiple encoding and decoding operations, which reduces the object conversion and calculation process, thereby simplifying the data parsing process in the query process and improving data query efficiency.

[0150] In another embodiment, the Z300 step further comprises the following steps:

[0151] Z302: When the target data type is a second preset data type, obtain a number of valid bytes from the target byte buffer object.

[0152] Specifically, the valid bytes refer to the byte arrays in the intermediate byte array in the target byte buffer object that are arranged in order and comply with the data reading rules; for example, in this embodiment, the data stored in CK is long integer data, each data occupies 8 bytes, then the number of valid bytes is n times 8, n is the number of data elements, and n times 8 valid bytes are extracted as the obtained number of valid bytes.

[0153] Z304, read the several valid bytes in sequence to obtain several long integer data; it can be understood that: read every eight bytes, each time read, a long integer data is read out, and finally after parsing, n data are obtained.

[0154] Z306, storing the plurality of long integer data in sequence into a pre-constructed bitmap data structure to implement parsing of the target byte array into a bitmap data structure; the initial state of the pre-constructed bitmap data structure is empty.

[0155] As described above, for the byte array of the second preset data type, when reading data, no conversion of the byte buffer object is involved, and the read data is directly stored in a pre-built bitmap data structure, which makes the data parsing method simpler and is conducive to improving the efficiency of data query.

[0156] Embodiment 2

[0157] like Figure 5 As shown, this embodiment 2 provides a data type conversion device, including:

[0158] The first generation module 100 is used to generate a target ANTLR4 expression according to a data query request; the data query request refers to a request including a number of query condition tags, and the target ANTLR4 expression includes a number of intermediate expressions and a number of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one.

[0159] Specifically, the query condition tags include APP category tags, location tags and device category tags; wherein the APP category tags include but are not limited to high-risk tags, low-risk tags, and financial management tags; the device category tags include but are not limited to simulator categories, device brands, and device models.

[0160] Specifically, the location tag may be one of a permanent residence, a home location, a workplace, and a latest location.

[0161] Specifically, the logic operation operator is any one of intersection “^”, union “#”, and difference “%”.

[0162] The conversion module 200 is used to convert the intermediate expressions in the target ANTLR4 expression into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0163] Specifically, Figure 6 As shown, the conversion module 200 includes:

[0164] The first acquisition module 201 is used to parse the target ANTLR4 expression to obtain several intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag; it can be understood that: when the query condition tag is composed of several query condition sub-tags, the intermediate expression corresponding to the query condition tag is composed of sub-expressions corresponding to several query condition sub-tags.

[0165] For better explanation, an example is given below: when searching for a certain location and a certain device brand that includes a low-risk label APP and a financial label APP, "a certain location" and "a certain device brand" are each a query condition label, "low-risk label APP and financial label APP" is a query condition label, and "low-risk label APP" and "financial label APP" are both query condition sub-labels. Each query condition label corresponds to an intermediate expression, and each query condition sub-label corresponds to a sub-expression.

[0166] The construction module 202 is used to construct a plurality of temporary virtual tables; the temporary virtual tables correspond to the intermediate expressions one by one.

[0167] Specifically, a temporary virtual table is defined and constructed through the with clause in the SQL language.

[0168] For example: for the target ANTLR4 expression ((c0)^(c1#c2#c3#c4#c5)^(c6fa0#c6fa1))%((f0#f1)^(f2#f3)), the correspondence between the names of the generated temporary virtual tables and the intermediate expressions is: with_tmp_table_1 corresponds to c0, with_tmp_table_2 corresponds to c1#c2#c3#c4#c5, with_tmp_table_3 corresponds to c6fa0#c6fa1, with_tmp_table_4 corresponds to f0#f1, and with_tmp_table_5 corresponds to f2#f3.

[0169] Determination module 203 is used to store several intermediate expressions into several temporary virtual tables respectively, generate several intermediate SQL fragments, and determine the name of the temporary virtual table corresponding to each intermediate SQL fragment as the intermediate SQL label corresponding to the intermediate SQL fragment itself; it can be understood as: determining the table name corresponding to the with clause as the intermediate SQL label.

[0170] As described above, when processing complex expressions, several intermediate expressions after parsing are temporarily saved by building a temporary virtual table, and parsed in memory as a temporary memory table, which can improve the execution efficiency and readability of SQL statements, and is conducive to subsequent complex data calculations. Moreover, the temporary virtual table is only valid in the current query and can be destroyed after use, which is conducive to the rational use of memory resources.

[0171] The combination module 300 is used to recombine several intermediate SQL tags and several logical operation operators in a suffix expression manner according to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression to obtain a tag combination result.

[0172] Specifically, Figure 7 As shown, the combined module 300 includes:

[0173] The second acquisition module 301 is used to parse the target ANTLR4 expression to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators.

[0174] The third acquisition module 302 is used to reorder the several intermediate SQL tags and several logical operation operators according to the distribution order of the several intermediate expressions to obtain a preprocessed SQL statement; the preprocessed SQL statement is a statement composed of prefix expressions; it can be understood as: sorting the several intermediate SQL tags according to the distribution order of the several intermediate expressions, and using the sorting result as the preprocessed SQL statement.

[0175] The fourth acquisition module 303 is used to convert the preprocessing SQL statement into an intermediate SQL statement combined with a suffix expression according to the operation order of the plurality of logical operation operators, and use the intermediate SQL statement as a label combination result.

[0176] For ease of understanding, an example is given below:

[0177] As in the above target ANTLR4 expression, the intermediate expressions are: (c0), (c1#c2#c3#c4#c5), (c6fa0#c6fa1), (f0#f1), (f2#f3); the operation sequence is: first perform the union operation in each intermediate expression, then calculate the intersection of the first three expressions and the intersection of the last two expressions in turn, and finally perform the difference operation on the two sets; the expression obtained after converting the target ANTLR4 expression into a suffix expression is (c0)(c1#c2#c3#c4#c5)^(c6fa0#c6fa1)^(f0#f1)(f2#f3)^%, that is, the intermediate SQL statement obtained is with_tmp_table_1with_tmp_table_2^with_tmp_table_3^with_tmp_table_4with_tmp_table_5^%.

[0178] As mentioned above, by converting the preprocessed SQL statement in the form of a prefix expression into an intermediate SQL statement in the form of a suffix expression, the computer does not need to consider the issue of operation priority during reading and calculation. It only needs to obtain the elements in sequence and then perform calculations. This is very convenient for computer data processing and is conducive to improving the efficiency of data query.

[0179] The processing module 400 is used to perform a target operation function conversion on each logical operation operator in the label combination result, and obtain a data conversion result according to the combination order of the intermediate SQL labels in the label combination result; it can be understood as: combining the result after the target operation function conversion with several sorted intermediate SQL labels to obtain a data conversion result.

[0180] Specifically, the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment; it can be understood that: each logical operation operator corresponds to a bitmap operation function of CK; for example, the operation function corresponding to the intersection is bitmapAnd, the operation function corresponding to the union is groupBitmapOrState or bitmapOr, and the operation function corresponding to the difference is bitmapAndNot.

[0181] The second generating module 500 is used to generate a target SQL statement according to the plurality of intermediate SQL fragments and the data conversion result, so as to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0182] Specifically, Figure 8 As shown, the second generating module 500 includes:

[0183] The fifth acquisition module 501 is used to obtain the intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result; it can be understood that: the intermediate SQL fragment corresponding to the intermediate SQL tag refers to the SQL statement in the temporary virtual table corresponding to the intermediate SQL tag.

[0184] The third generating module 502 is used to add the intermediate SQL fragment corresponding to each intermediate SQL tag to the corresponding position of the intermediate SQL tag itself in the data conversion result, and delete the intermediate SQL tag itself to generate a target SQL statement.

[0185] As mentioned above, by replacing the corresponding intermediate sql tags with several intermediate sql fragments and adding them to the data conversion results, it is shown that the target ANTLR4 expression has completed the complete conversion to the sql statement. Through this data type conversion method, any combination of any number of business query conditions can be converted from a complex expression to a bitmap calculation sql statement that can be executed by CK, thereby realizing fast and efficient query and processing of data, so as to meet multiple business query requirements at the same time.

[0186] When the data type conversion device described in this embodiment is used, first, according to the data query request, a target ANTLR4 expression is generated, and several intermediate expressions in the target ANTLR4 expression are respectively converted into several intermediate sql fragments, and each intermediate sql fragment corresponds to an intermediate sql label. According to the operation order of several logical operation operators, several intermediate sql labels and several logical operation operators are recombined in the form of suffix expressions. Through the setting of labels, only the labels need to be combined in the intermediate processing process, which saves the occupation of memory resources and computing resources. The sorting method of converting to suffix expressions makes it unnecessary for the computer to consider the problem of operation priority during reading and calculation, and only the elements need to be obtained in sequence and then calculated, which is conducive to improving the efficiency of data query. Then, the target operation function conversion is performed on each logical operation operator, and the data conversion result is obtained by combining the combination order of several intermediate sql labels. According to several intermediate sql fragments and data conversion results, a target sql statement is generated. Through this data type conversion method, the conversion from expression to sql statement is completed, and the conversion from complex expression to data calculation rule can be realized, thereby realizing fast and efficient data query and processing, and meeting multiple business query requirements at the same time.

[0187] Embodiment 3

[0188] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0189] According to a data query request, a target ANTLR4 expression is generated; the data query request is a request including a number of query condition tags, the target ANTLR4 expression includes a number of intermediate expressions and a number of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one.

[0190] The intermediate expressions in the target ANTLR4 expression are respectively converted into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0191] According to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression, a plurality of intermediate SQL tags and a plurality of logical operation operators are recombined in a suffix expression manner to obtain a tag combination result.

[0192] A target operation function conversion is performed on each logical operation operator in the label combination result, and a data conversion result is obtained according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment.

[0193] According to the several intermediate SQL fragments and the data conversion results, a target SQL statement is generated to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0194] Embodiment 4

[0195] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0196] According to a data query request, a target ANTLR4 expression is generated; the data query request is a request including a number of query condition tags, the target ANTLR4 expression includes a number of intermediate expressions and a number of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one.

[0197] The intermediate expressions in the target ANTLR4 expression are respectively converted into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag.

[0198] According to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression, a plurality of intermediate SQL tags and a plurality of logical operation operators are recombined in a suffix expression manner to obtain a tag combination result.

[0199] A target operation function conversion is performed on each logical operation operator in the label combination result, and a data conversion result is obtained according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment.

[0200] According to the several intermediate SQL fragments and the data conversion results, a target SQL statement is generated to complete the data type conversion from the ANTLR4 expression to the SQL statement.

[0201] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0202] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0203] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A data type conversion method, characterized in that: The following steps are involved: Generate a target ANTLR4 expression according to a data query request; the data query request is a request including a plurality of query condition tags, the target ANTLR4 expression includes a plurality of intermediate expressions and a plurality of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one; Convert several intermediate expressions in the target ANTLR4 expression into several intermediate SQL fragments respectively, and each intermediate SQL fragment corresponds to an intermediate SQL tag; According to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression, a plurality of intermediate SQL tags and a plurality of logical operation operators are recombined in a suffix expression manner to obtain a tag combination result; Performing target operation function conversion on each logical operation operator in the label combination result, and obtaining a data conversion result according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment; According to the several intermediate SQL fragments and the data conversion result, a target SQL statement is generated to complete the data type conversion from the ANTLR4 expression to the SQL statement.

2. The data type conversion method according to claim 1, characterized in that: The query condition tags include APP category tags, location tags and device category tags; Among them, the APP category labels include high-risk labels, low-risk labels, and financial management labels; the device category labels include simulator categories, device brands, and device models.

3. The data type conversion method according to claim 1, characterized in that: The step of converting the plurality of intermediate expressions in the target ANTLR4 expression into a plurality of intermediate SQL fragments, wherein each intermediate SQL fragment corresponds to an intermediate SQL tag, comprises the following steps: Parsing the target ANTLR4 expression to obtain a plurality of intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag; Constructing a plurality of temporary virtual tables; wherein the temporary virtual tables correspond one to one with the intermediate expressions; Several intermediate expressions are stored in several temporary virtual tables respectively, several intermediate SQL fragments are generated, and the name of the temporary virtual table corresponding to each intermediate SQL fragment is determined as the intermediate SQL label corresponding to the intermediate SQL fragment itself.

4. The data type conversion method according to claim 1, characterized in that: The method obtains the label combination result by the following steps: Parsing the target ANTLR4 expression to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators; According to the distribution order of the intermediate expressions, the intermediate SQL labels and the logical operation operators are reordered to obtain a preprocessing SQL statement; the preprocessing SQL statement is a statement composed of prefix expressions; According to the operation order of the plurality of logical operation operators, the preprocessing SQL statement is converted into an intermediate SQL statement combined by using a suffix expression, and the intermediate SQL statement is used as a label combination result.

5. The data type conversion method according to claim 1, characterized in that: The method generates a target SQL statement through the following steps: Obtain the intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result; The intermediate SQL fragments corresponding to each intermediate SQL tag are added to the corresponding positions of the intermediate SQL tag itself in the data conversion result, and the intermediate SQL tag itself is deleted to generate a target SQL statement.

6. A data type conversion device, characterized in that: The device comprises: A first generating module is used to generate a target ANTLR4 expression according to a data query request; the data query request is a request including a plurality of query condition tags, the target ANTLR4 expression includes a plurality of intermediate expressions and a plurality of logical operation operators, and the intermediate expressions correspond to the query condition tags one by one; A conversion module, used for converting several intermediate expressions in the target ANTLR4 expression into several intermediate SQL fragments, and each intermediate SQL fragment corresponds to an intermediate SQL tag; A combination module is used to recombine several intermediate SQL labels and several logical operation operators in a suffix expression manner according to the operation order of the logical operation operator corresponding to each intermediate expression in the target ANTLR4 expression to obtain a label combination result; A processing module, used for converting each logical operation operator in the label combination result into a target operation function, and obtaining a data conversion result according to the combination order of the intermediate SQL labels in the label combination result; the target operation function refers to the operation function corresponding to the logical operation operator in the SQL language environment; The second generating module is used to generate a target SQL statement according to the plurality of intermediate SQL fragments and the data conversion result, so as to complete the data type conversion from the ANTLR4 expression to the SQL statement.

7. The data type conversion device according to claim 6, characterized in that: The query condition tags include APP category tags, location tags and device category tags; Among them, the APP category labels include high-risk labels, low-risk labels, and financial management labels; the device category labels include simulator categories, device brands, and device models.

8. The data type conversion device according to claim 6, characterized in that: The conversion module comprises: A first acquisition module is used to parse the target ANTLR4 expression to obtain a plurality of intermediate expressions; each of the intermediate expressions corresponds to at least one query condition sub-tag; each of the query condition tags includes at least one query condition sub-tag; A construction module, used to construct a plurality of temporary virtual tables; the temporary virtual tables correspond one to one with the intermediate expressions; The determination module is used to store several intermediate expressions in several temporary virtual tables respectively, generate several intermediate SQL fragments, and determine the name of the temporary virtual table corresponding to each intermediate SQL fragment as the intermediate SQL label corresponding to the intermediate SQL fragment itself.

9. The data type conversion device according to claim 6, characterized in that: The combined module comprises: A second acquisition module is used to parse the target ANTLR4 expression to obtain the distribution order of several intermediate expressions and the operation order of several logical operation operators; A third acquisition module is used to reorder the plurality of intermediate SQL tags and the plurality of logical operation operators according to the distribution order of the plurality of intermediate expressions to obtain a preprocessing SQL statement; the preprocessing SQL statement is a statement composed of prefix expressions; The fourth acquisition module is used to convert the preprocessing SQL statement into an intermediate SQL statement combined with a suffix expression according to the operation order of the plurality of logical operation operators, and use the intermediate SQL statement as a label combination result.

10. The data type conversion device according to claim 6, characterized in that: The second generation module comprises: A fifth acquisition module, used to acquire an intermediate SQL fragment corresponding to each intermediate SQL tag in the data conversion result; The third generating module is used to add the intermediate SQL fragment corresponding to each intermediate SQL tag to the corresponding position of the intermediate SQL tag itself in the data conversion result, and delete the intermediate SQL tag itself to generate a target SQL statement.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the data type conversion method according to any one of claims 1 to 5 is implemented.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data type conversion method according to any one of claims 1 to 5 is implemented.

Citation Information

Cited By

  • Data query method, device and equipment based on database bitmap operation and medium

    CN120296035A