Storage method and query method of character string, computer equipment and storage medium

By establishing a mapping table of preset keywords and splitting the string into binary sequences to store it in the form of inefficient string storage and query in the prior art, efficient storage and query are achieved.

CN119415748APending Publication Date: 2025-02-11ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411551155.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

With the rapid growth of data volume, the storage and query efficiency of the prior art strings can no longer be matched with the increasing amount of data, resulting in inaccurate storage and query efficiency.

Method used

By establishing a mapping table of preset keywords, the string to be stored is split into several preset keywords, and matching is done based on the preset order in the mapping table, and the preset keywords are binary converted according to the matching result, and obtain A binary sequence, stored in the database as a binary sequence.

Benefits of technology

It realizes efficient querying using the residual strategy and overlay strategy in the database, maximizes compressed storage, avoids duplicate storage, and improves storage and query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415748A_ABST
    Figure CN119415748A_ABST
Patent Text Reader

Abstract

The invention relates to a character string storage method, a query method, computer equipment and a storage medium. The method comprises the following steps: establishing a mapping table of preset keywords; splitting the to-be-stored character string into a plurality of preset keywords; based on a preset sequence in the mapping table, matching preset keywords in the to-be-stored character string with the mapping table in sequence; according to a matching result, performing binary conversion on a preset keyword in the stored character string to obtain a binary sequence; and storing the to-be-stored character string in a database in the form of a binary sequence. According to the method and the device, the to-be-stored character string is converted into the form of the binary sequence based on the mapping table and is stored in the database, so that whether the to-be-queried preset keyword exists in the character string stored in the database or not can be queried by adopting the remainder taking strategy and the superposition strategy in the database, and compression storage can be performed to the maximum extent; and the stored character strings can be quickly queried, so that the storage efficiency and the query efficiency are higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to a storage method, a query method, a computer device and a storage medium for a character string. Background Art

[0002] With the rapid development of computer technology and network technology, the data and information generated in the process of accessing and operating over the network need to be stored in the database system for subsequent query and use. The database system can realize the sharing of data in the database and the centralized management of operations such as writing, reading and modifying.

[0003] With the rapid growth of modern data, the data size of strings in databases is also getting larger and larger. The storage and query efficiency of strings in existing technologies can no longer keep up with the increasing amount of data. Therefore, a method with higher storage and query efficiency is urgently needed. Summary of the invention

[0004] Based on this, it is necessary to provide a storage method, query method, computer device and storage medium for efficiently storing and querying character strings in response to the above technical problems.

[0005] In a first aspect, a method for storing a string is provided in this embodiment, comprising:

[0006] Establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0007] Splitting the character string to be stored into a plurality of the preset keywords;

[0008] Based on the preset order in the mapping table, sequentially matching the preset keywords in the character string to be stored with the mapping table; performing binary conversion on the preset keywords in the stored character string according to the matching result to obtain a binary sequence;

[0009] The character string to be stored is stored in the database in the form of the binary sequence.

[0010] In some of the embodiments, the step of performing binary conversion on the preset keywords in the stored character string to obtain a binary sequence according to the matching result includes:

[0011] The highest bit of the binary sequence is set to 1; the lowest bit to the second highest bit of the binary sequence correspond to the preset keywords in the preset sequence respectively;

[0012] According to the matching result, the corresponding positions of the binary sequence are filled in sequence starting from the lowest bit; wherein, for the preset keywords included in the character string to be stored, the corresponding positions of the binary sequence are filled with 1; for the preset keywords not included in the character string to be stored, the corresponding positions of the binary sequence are filled with 0.

[0013] In some of the embodiments, it also includes:

[0014] When the preset keyword is added to the mapping table, the number of bits of the binary sequence is updated accordingly; the newly added preset keyword corresponds to the second highest bit of the updated binary sequence.

[0015] In a second aspect, a method for querying a string is provided in this embodiment, including:

[0016] Establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0017] Obtaining query conditions of a database; the query conditions include preset keywords to be queried;

[0018] Determine a corresponding four arithmetic operations query strategy according to the number of preset keywords to be queried; the query strategy includes a remainder strategy and a superposition strategy based on the mapping table;

[0019] Based on the query strategy, it is queried whether the preset keyword to be queried exists in the character string stored in the database.

[0020] In some of the embodiments, when the query condition includes a preset keyword, the remainder strategy is used to perform the query;

[0021] Among them, based on the mapping table, the preset keyword is converted into binary to obtain a first target sequence; the first target sequence is modulo the stored character string, and if the unit digit of the modulo result is 1, it means that the preset keyword exists in the stored character string.

[0022] In some of the embodiments, when the query condition includes at least two preset keywords, the superposition strategy is used to perform the query;

[0023] Among them, based on the mapping table, the at least two preset keywords are binary converted to obtain a second target sequence; the second target sequence is superimposed with the stored character string, and if the number at the position corresponding to the preset keyword in the superposition result is 2, it indicates that the preset keyword exists in the stored character string.

[0024] In a third aspect, a storage device for a string is provided in this embodiment, including:

[0025] A mapping establishment module, used to establish a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0026] A string splitting module, used for splitting the string to be stored into a plurality of preset keywords;

[0027] The storage module is used to match the preset keywords in the character string to be stored with the mapping table in sequence based on the preset order in the mapping table; according to the matching result, the preset keywords in the stored character string are binary converted to obtain a binary sequence; and the character string to be stored is stored in the database in the form of the binary sequence.

[0028] In a fourth aspect, in this embodiment, a device for querying a character string is provided, including:

[0029] A mapping establishment module, used to establish a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0030] An acquisition module, used to acquire database query conditions; the query conditions include preset keywords to be queried;

[0031] A query module is used to determine a corresponding four arithmetic operation query strategy according to the number of preset keywords to be queried; the query strategy includes a remainder strategy and an overlay strategy based on the mapping table; based on the query strategy, query whether the preset keywords to be queried exist in the character string stored in the database.

[0032] In a fifth aspect, a computer device is provided in this embodiment, 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 method for storing a character string described in the first aspect and / or the method for querying a character string described in the second aspect are implemented.

[0033] In a sixth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the method for storing a string described in the first aspect and / or the method for querying a string described in the second aspect are implemented.

[0034] Compared with the related art, the storage method, query method, computer device and storage medium of the string provided in this embodiment establish a mapping table of preset keywords; the mapping table includes the preset order of the preset keywords; the string to be stored is split into a number of the preset keywords; based on the preset order in the mapping table, the preset keywords in the string to be stored are matched with the mapping table in sequence; according to the matching result, the preset keywords in the stored string are binary converted to obtain a binary sequence; the string to be stored is stored in the database in the form of the binary sequence. Through this embodiment, the string to be stored is converted into a binary sequence based on the mapping table and stored in the database, thereby, the remainder strategy and the superposition strategy can be adopted in the database to query whether the string stored in the database has the preset keyword to be queried, which can maximize the compression storage and quickly query the stored string, and the storage efficiency and query efficiency are higher.

[0035] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0037] Figure 1 is a hardware structure block diagram of a terminal of a method for storing a string of characters in an embodiment;

[0038] Figure 2 is a flowchart of a method for storing a string in an embodiment;

[0039] Figure 3 is a schematic diagram of the correspondence between a character string to be stored and a binary sequence in one embodiment;

[0040] Figure 4 is another schematic diagram of the correspondence between a character string to be stored and a binary sequence in one embodiment;

[0041] Figure 5 is a flowchart of a method for querying a string in an embodiment;

[0042] Figure 6 is a flowchart of a method for storing and querying a string in an embodiment;

[0043] Figure 7 is a structural block diagram of a storage device for a string in an embodiment;

[0044] Figure 8 The present invention is a flowchart of a device for querying a character string in an embodiment.

[0045] In the figure: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 10, mapping establishment module; 20, string splitting module; 30, storage module; 40, acquisition module; 50, query module. DETAILED DESCRIPTION

[0046] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0047] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0048] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 4 is a hardware structure diagram of a terminal of the method for storing a string of characters in this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0049] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the storage method of the string in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0050] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0051] With the rapid development of computer technology and network technology, the data and information generated in the process of accessing and operating over the network need to be stored in the database system for subsequent query and use. The database system can realize the sharing of data in the database and the centralized management of operations such as writing, reading and modifying.

[0052] With the rapid growth of modern data, the data size of strings in databases is also getting larger and larger. The storage and query efficiency of strings in existing technologies can no longer keep up with the increasing amount of data. Therefore, a method with higher storage and query efficiency is urgently needed.

[0053] In this embodiment, a method for storing a string is provided. Figure 2 is a flow chart of the method for storing a string in this embodiment, such as Figure 2 As shown, the method comprises the following steps:

[0054] Step S201, establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords.

[0055] Specifically, the preset keywords are words or phrases that may appear in multiple strings to be stored and are used to describe or represent the common characteristics or content of these strings. By analyzing a large number of strings to be stored, frequently appearing or representative common words are extracted as a set of preset keywords, and each preset keyword appears only once in the string to be stored. For example, if the content of the string to be stored is a business attribute, the corresponding preset keywords can be a set of attribute parameters; if the content of the string to be stored is a server status, the corresponding preset keywords can be a set of status parameters; if the content of the string to be stored is a product configuration, the corresponding preset keywords can be a set of configuration parameters.

[0056] For strings to be stored in different application scenarios, different preset keywords can be extracted, and a mapping table can be established after sorting a group of preset keywords. The mapping table includes the preset order of preset keywords, and can also include the number of each preset keyword according to the preset order. Taking a group of preset keywords A, B, C, D, E as an example, A, B, C, D, E can be different attribute parameters respectively, and their preset order includes but is not limited to ABCDE, ABEDC, BEACD, EADCB, etc. Taking the preset order of A, B, C, D, E as an example, the following Table 1 is a mapping table for preset keywords.

[0057] Table 1:

[0058] 1 A 2 B 3 C 4 D 5 E

[0059] It should be noted that the specific order of the preset keywords is not limited in this embodiment and can be sorted arbitrarily. However, the sorting order cannot be changed after it is determined, otherwise the strings to be stored in different preset orders will be incompatible, which will also affect subsequent string queries.

[0060] Step S202: split the character string to be stored into a number of preset keywords.

[0061] Specifically, the character string to be stored in this embodiment has the characteristics of being definite and having no order requirement, that is, there is no order requirement between the preset keywords in the character string to be stored, and two character strings to be stored containing exactly the same preset keywords are only stored as one character string when stored. The character string to be stored is split into several preset keywords, for example, the split character string [A, B, C, D, E] and the character string [B, E, A, C, D], although the order of the preset keywords is different, contain exactly the same preset keywords and are considered to be the same character string to be stored.

[0062] It should be noted that not every character string to be stored includes all preset keywords. For example, the character string to be stored may be split into [A, C, D, E], [B, E, D], [C], etc.

[0063] Step S203, based on the preset order in the mapping table, sequentially matching the preset keywords in the character string to be stored with the mapping table; and performing binary conversion on the preset keywords in the stored character string according to the matching result to obtain a binary sequence.

[0064] Specifically, since not every string to be stored includes all preset keywords, the preset keywords in the string to be stored are matched according to the preset order in the mapping table to obtain a matching result of whether the string to be stored contains the corresponding preset keywords in the mapping table. For example, a set of preset keywords is in a preset order of A, B, C, D, E, and the string to be stored is split into [A, C, D, E], and a matching result can be obtained that the string to be stored includes A, C, D, E, but does not include B.

[0065] The binary sequence is of fixed length, and its length is determined by the number of preset keywords, specifically, the number of preset keywords plus one. Regardless of the order in which the preset keywords in the string to be stored are arranged, the positions from the lowest bit to the second highest bit in the binary sequence correspond to the preset keywords of the preset order, respectively. It can be understood that, in the order of the numbers in the preset table from small to large, each preset keyword corresponds to the position starting from the lowest bit in a fixed-length binary sequence. According to this correspondence and matching results, the preset keywords of the stored string are converted into binary to obtain a binary sequence consisting of 0 and 1.

[0066] Step S204: store the character string to be stored in the database in the form of a binary sequence.

[0067] Specifically, the character strings to be stored in the form of binary sequences are all converted into binary in the same preset order, and can be compressed and stored to a large extent, and the consistency and compatibility of the character strings stored in the database are guaranteed to avoid affecting subsequent character string queries.

[0068] Through the above steps, a mapping table of preset keywords is established, and the character string to be stored is converted into a binary sequence based on the preset order of the mapping table and stored in the database, which can maximize the compression storage. In addition, considering that the character string to be stored is fixed and has no order requirement, the storage method in this embodiment can also avoid repeated storage, effectively improving storage efficiency.

[0069] In some of the embodiments, in the above steps, according to the matching result, the preset keywords in the stored character string are converted into binary to obtain a binary sequence, including the following steps:

[0070] The highest bit of the binary sequence is set to 1; the lowest bit to the second highest bit of the binary sequence correspond to the preset keywords in the preset order respectively; according to the matching result, the corresponding positions of the binary sequence are filled in sequence starting from the lowest bit; wherein, for the preset keywords included in the character string to be stored, the corresponding positions of the binary sequence are filled with 1; for the preset keywords not included in the character string to be stored, the corresponding positions of the binary sequence are filled with 0.

[0071] Specifically, taking the preset keywords A, B, C, D, E and the preset order in Table 1 as an example, for the string [B, E, D] to be stored, Figure 3 is a schematic diagram of the correspondence between the character string to be stored and the binary sequence in this embodiment, such as Figure 3 As shown, the length of the binary sequence is 6, and the highest bit is set to 1. Since the string to be matched contains B, E, and D, the corresponding positions in the binary sequence are filled with 1. For A and C that are not included in the string to be matched, the corresponding positions in the binary sequence are filled with 0, and the binary sequence is 111010.

[0072] Take a set of preset keywords representing business attributes, Wall Mount, Pendant Mount, Ceiling Mount, Vertical Pole Mount, Horizontal Pole Mount, In-Ceiling Mount, Plane Mount, Parapet Mount, Junction Mount, Pole Mount, Corner Mount, as an example, each preset keyword represents an attribute parameter. The mapping table is shown in Table 2 below.

[0073] Table 2:

[0074] 1 Wall Mount 2 Pendant Mount 3 Ceiling Mount 4 Vertical Pole Mount 5 Horizontal Pole Mount 6 In-Ceiling Mount 7 Plane Mount 8 Parapet Mount 9 Junction Mount 10 Pole Mount 11 Corner Mount

[0075] Taking the string to be stored [Wall Mount, Ceiling Mount, Pole Mount, Corner Mount, Parapet Mount] as an example, the matching result is obtained after matching with the above mapping table. Based on the preset order, the above string to be stored can be converted into binary bit by bit to obtain a binary sequence of length 12, 111010000101. Figure 4 is another schematic diagram of the correspondence between the character string to be stored and the binary sequence in this embodiment, such as Figure 4 As shown, the highest bit of the binary sequence is reserved and set to 1, and from the lowest bit to the second highest bit, they correspond to the preset keywords in the preset order. According to the matching results and the preset order, if the string to be stored contains Wall Mount, the lowest bit of the binary sequence is filled with 1, and if the string to be stored does not contain Pendant Mount, the first bit starting from the lowest bit is filled with 0 in order. If the string to be stored contains Ceiling Mount, the second bit starting from the lowest bit of the binary sequence is filled with 1, and so on, until the second highest bit is filled to complete the binary sequence.

[0076] In this embodiment, by performing binary conversion on the preset keywords in the character string to be matched in sequence according to the preset order to obtain a binary sequence, the character string to be stored can be compressed to a greater extent and stored in the database.

[0077] In some of the embodiments, when a preset keyword is added to the mapping table, the number of bits of the binary sequence is updated accordingly; the newly added preset keyword corresponds to the second highest bit of the updated binary sequence.

[0078] Specifically, in actual applications, new preset keywords can be added, but in order not to change the preset order of the original preset keywords and affect data compatibility, new preset keywords are added at the end of the preset order. Taking Table 1 as an example, if a new preset keyword F is added, its order is after the preset keyword E, and the new preset order is shown in Table 3.

[0079] Table 3:

[0080] 1 A 2 B 3 C 4 D 5 E 6 F

[0081] If you continue to add preset keywords, you will continue to sort based on the preset order, and the length of the binary sequence will be updated accordingly. Taking the preset keywords A, B, C, D, E, F and the preset order in Table 3 as an example, for the string [B, E, D] to be stored, the corresponding binary sequence is 1011010, with a length of 7.

[0082] Through this embodiment, it is possible to continue to add preset keywords during the storage process without affecting the already stored character strings and subsequent queries.

[0083] Some of the embodiments further include the following steps for querying the character strings stored in the database.

[0084] Obtain query conditions of the database; the query conditions include preset keywords to be queried; determine corresponding four arithmetic operations query strategies according to the number of preset keywords to be queried; the query strategies include remainder strategies and superposition strategies based on mapping tables; based on the query strategies, query whether there are preset keywords to be queried in the character strings stored in the database.

[0085] Specifically, the character string to be stored has been stored in the database in the form of a binary sequence through the above storage method. When it is necessary to query the character string stored in the database, a query condition including the preset keyword to be queried is set to query whether the preset keyword to be queried exists in the stored character string. Since the preset keyword is usually a common feature or content of the stored character string, specifically the preset keyword is a group of attribute parameters, by setting the query condition including the preset keyword to be queried, it can be queried whether a certain attribute parameter exists in the character string.

[0086] During the query, the corresponding four arithmetic query strategy is determined according to the number of preset keywords in a single query, which is divided into a single query of one preset keyword and a single query of at least two (or more than one) preset keywords. The query strategy is a remainder strategy and a superposition strategy based on the mapping table.

[0087] It should be noted that if character strings are stored and queried in the same database, it is necessary to ensure that the same mapping table is used for storage and query, that is, the preset keywords and the preset order are consistent, otherwise the query cannot be performed normally.

[0088] In this embodiment, string search is performed on the basis of the string storage in the above embodiment. For strings in the form of binary sequences, it is not necessary to match the characters of the entire string for search, which effectively improves the search efficiency. In addition, the number of strings stored repeatedly in the database is reduced, which further improves the search efficiency and avoids searching for multiple identical strings.

[0089] In some of the embodiments, when the query condition includes a preset keyword, a remainder strategy is used for query; wherein, based on a mapping table, the preset keyword is converted into binary to obtain a first target sequence; the first target sequence is modulo the stored character string, and if the unit digit of the remainder result is 1, it indicates that the preset keyword exists in the stored character string.

[0090] Specifically, in the remainder strategy, a preset keyword to be queried is first converted into binary based on the mapping table to obtain a first target sequence. Taking the mapping table in Table 1 and the stored string 111010 as an example, if the preset keyword to be queried is C, the first target sequence obtained by conversion is 100, and the first target sequence is modulo the stored string, and the unit digit of the modulo result is 0, indicating that the preset keyword C does not exist in the stored string. If the preset keyword to be queried is D, the first target sequence obtained by conversion is 1000, and the first target sequence is modulo the stored string, and the unit digit of the modulo result is 1, indicating that the preset keyword D exists in the stored string.

[0091] Taking the mapping table in Table 2 and the stored string 111010000101 as an example, if the preset keyword to be queried is Ceiling Mount, Ceiling Mount is first converted into the first target sequence 100, and the query condition can be set to WHERE KEY_ITEM = 'Installation' AND VALUE_ITEM / 100%2 = 1, indicating that the unit digit of the remainder result is 1, and the preset keyword Ceiling Mount exists in the stored sequence.

[0092] In some of the embodiments, when the query conditions include at least two preset keywords, a superposition strategy is adopted for query; wherein, based on a mapping table, at least two preset keywords are binary converted to obtain a second target sequence; the second target sequence is superimposed with the stored character string, and if the number at the position corresponding to the preset keyword in the superposition result is 2, it indicates that the preset keyword exists in the stored character string.

[0093] Specifically, in the superposition strategy, each preset keyword is first converted into a binary system to obtain a second target sequence. Taking the mapping table in Table 2 and the stored string 111010000101 as an example, when the preset keywords Ceiling Mount, Horizontal pole Mount, and Junction Mount are queried simultaneously at a single time, the second target sequence 100010100 converted from the three preset keywords is first obtained, and then the second target sequence and the stored string 111010000101 are superimposed to obtain a superposition result of 100010100+111010000101=111110010201. At this time, the third bit is equal to 2, and the other bits are 0 or 1, indicating that the preset keyword Ceiling Mount exists in the stored string, but the preset keywords Horizontal poleMount and Junction Mount do not exist.

[0094] When the preset keywords Parapet Mount and Plane Mount are queried simultaneously at a single time, the second target sequence 11000000 converted from the two preset keywords is first obtained, and then the second target sequence and the stored character string 111010000101 are superimposed to obtain the superposition result 11000000+111010000101=111021000101. At this time, the eighth bit is equal to 2, and the other bits are 0 or 1, indicating that the preset keyword Parapet Mount exists in the stored character string, but the preset keyword PlaneMount does not exist.

[0095] By adopting the remainder strategy and the superposition strategy based on the mapping table in this embodiment, different numbers of preset keywords to be queried are queried respectively, so as to obtain the query result of whether the character string stored in the database contains the preset keywords to be queried more quickly.

[0096] This embodiment also provides a method for querying a character string. Figure 5 is a flow chart of the method for querying a string in this embodiment, such as Figure 5 As shown, the method comprises the following steps:

[0097] Step S501, establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords.

[0098] Specifically, the preset keywords are words or phrases that may appear in multiple strings to be stored and are used to describe or represent the common characteristics or content of these strings. By analyzing a large number of strings to be stored, frequently appearing or representative common words are extracted as a set of preset keywords, and each preset keyword appears only once in the string to be stored. For example, if the content of the string to be stored is a business attribute, the corresponding preset keywords can be a set of attribute parameters; if the content of the string to be stored is a server status, the corresponding preset keywords can be a set of status parameters; if the content of the string to be stored is a product configuration, the corresponding preset keywords can be a set of configuration parameters.

[0099] For the character strings to be stored in different application scenarios, different preset keywords can be extracted, and a mapping table can be established after sorting a group of preset keywords. The mapping table is shown in Table 1, and can include the preset order of the preset keywords, and can also include the number of each preset keyword according to the preset order. It should be noted that the specific order of the preset keywords is not limited in this embodiment, and they can be sorted arbitrarily, but the sorting order cannot be changed after it is determined, otherwise the character strings to be stored stored in different preset orders are incompatible with each other, and it will also affect subsequent character string queries.

[0100] Step S502, obtaining database query conditions; the query conditions include preset keywords to be queried.

[0101] Specifically, when it is necessary to query the character string stored in the database, a query condition including the preset keyword to be queried is set to query whether the preset keyword to be queried exists in the stored character string.

[0102] Step S503, determining corresponding four arithmetic operations query strategies according to the number of preset keywords to be queried; the query strategies include a remainder strategy and a superposition strategy based on a mapping table.

[0103] Specifically, when querying, the corresponding four arithmetic query strategies are determined according to the number of preset keywords in a single query, which are divided into single query of one preset keyword and single query of at least two (or more than one) preset keywords, and the query strategies are remainder strategies and superposition strategies based on the mapping table.

[0104] Step S504: Based on the query strategy, query whether the character string stored in the database contains the preset keyword to be queried.

[0105] Specifically, by using the four arithmetic operations query strategy to query the character string in the binary sequence form in the database, it is possible to quickly query whether there is a query result of the preset keyword to be queried.

[0106] It should be noted that if character strings are stored and queried in the same database, it is necessary to ensure that the same mapping table is used for storage and query, that is, the preset keywords and the preset order are consistent, otherwise the query cannot be performed normally.

[0107] Through the above steps, for the binary sequence string in the database, there is no need to match the characters of the entire string for query, which effectively improves the query efficiency. In addition, the database reduces the number of repeatedly stored strings, further improving the query efficiency and avoiding querying multiple identical strings.

[0108] In some of the embodiments, the following steps are also included:

[0109] The character string to be stored is split into several preset keywords; based on the preset order in the mapping table, the preset keywords in the character string to be stored are matched with the mapping table in turn; according to the matching result, the preset keywords in the stored character string are binary converted to obtain a binary sequence; the character string to be stored is stored in the database in the form of a binary sequence.

[0110] Specifically, the character string to be stored has the characteristics of being definite and having no order requirement, that is, there is no order requirement between the preset keywords in the character string to be stored, and two character strings to be stored containing exactly the same preset keywords are stored as only one character string when stored. The character string to be stored is split into several preset keywords, for example, the split character string [A, B, C, D, E] and the character string [B, E, A, C, D], although the order of the preset keywords is different, contain exactly the same preset keywords and are considered to be the same character string to be stored.

[0111] It should be noted that not every character string to be stored includes all preset keywords. For example, the character string to be stored may be split into [A, C, D, E], [B, E, D], [C], etc.

[0112] Since not every string to be stored includes all preset keywords, the preset keywords in the string to be stored are matched according to the preset order in the mapping table to obtain a matching result of whether the string to be stored contains the corresponding preset keywords in the mapping table. For example, a set of preset keywords is in the preset order of A, B, C, D, E, and the string to be stored is split into [A, C, D, E], and a matching result can be obtained that the string to be stored includes A, C, D, E, but does not include B.

[0113] The binary sequence is of fixed length, and its length is determined by the number of preset keywords, specifically, the number of preset keywords plus one. Regardless of the order in which the preset keywords in the string to be stored are arranged, the positions from the lowest bit to the second highest bit in the binary sequence correspond to the preset keywords of the preset order, respectively. It can be understood that, in the order of the numbers in the preset table from small to large, each preset keyword corresponds to the position starting from the lowest bit in a fixed-length binary sequence. According to this correspondence and matching results, the preset keywords of the stored string are converted into binary to obtain a binary sequence consisting of 0 and 1.

[0114] By establishing a mapping table of preset keywords in this embodiment, the character string to be stored is converted into a binary sequence based on the preset order of the mapping table and stored in the database, which can maximize the compression storage. In addition, considering that the character string to be stored is fixed and has no order requirement, the storage method in this embodiment can also avoid repeated storage, effectively improve storage efficiency, and can perform character string queries in the database more quickly.

[0115] In some of the embodiments, in the above steps, according to the matching result, the preset keywords in the stored character string are converted into binary to obtain a binary sequence, including the following steps:

[0116] The highest bit of the binary sequence is set to 1; the lowest bit to the second highest bit of the binary sequence correspond to the preset keywords in the preset order respectively; according to the matching result, the corresponding positions of the binary sequence are filled in sequence starting from the lowest bit; wherein, for the preset keywords included in the character string to be stored, the corresponding positions of the binary sequence are filled with 1; for the preset keywords not included in the character string to be stored, the corresponding positions of the binary sequence are filled with 0.

[0117] Specifically, taking the preset keywords A, B, C, D, E and the preset order in Table 1 as an example, for the string [B, E, D] to be stored, Figure 3 As shown, the length of the binary sequence is 6, and the highest bit is set to 1. Since the string to be matched contains B, E, and D, the corresponding positions in the binary sequence are filled with 1. For A and C that are not included in the string to be matched, the corresponding positions in the binary sequence are filled with 0, and the binary sequence is 111010.

[0118] With mapping table 2 and Figure 4 For example, taking the string to be stored [Wall Mount, Ceiling Mount, PoleMount, Corner Mount, Parapet Mount] as an example, the matching result is obtained after matching with the above mapping table. Based on the preset order, the above string to be stored can be converted into binary bit by bit to obtain a binary sequence of length 12 111010000101.

[0119] In this embodiment, by performing binary conversion on the preset keywords in the character string to be matched in sequence according to the preset order to obtain a binary sequence, the character string to be stored can be compressed to a greater extent and stored in the database.

[0120] In some of the embodiments, when a preset keyword is added to the mapping table, the number of bits of the binary sequence is updated accordingly; the newly added preset keyword corresponds to the second highest bit of the updated binary sequence.

[0121] Specifically, in actual applications, new preset keywords can be added, but in order not to change the preset order of the original preset keywords and affect data compatibility, new preset keywords are added at the end of the preset order. Taking Table 1 as an example, if a new preset keyword F is added, its order is after the preset keyword E, and the new preset order is as shown in Table 3 in the above embodiment.

[0122] If you continue to add preset keywords, you will continue to sort based on the preset order, and the length of the binary sequence will be updated accordingly. Taking the preset keywords A, B, C, D, E, F and the preset order in Table 3 as an example, for the string [B, E, D] to be stored, the corresponding binary sequence is 1011010, with a length of 7.

[0123] Through this embodiment, it is possible to continue to add preset keywords during the storage process without affecting the already stored character strings and subsequent queries.

[0124] In some of the embodiments, when the query condition includes a preset keyword, a remainder strategy is used for query; wherein, based on a mapping table, the preset keyword is converted into binary to obtain a first target sequence; the first target sequence is modulo the stored character string, and if the unit digit of the remainder result is 1, it indicates that the preset keyword exists in the stored character string.

[0125] Specifically, in the remainder strategy, a preset keyword to be queried is first converted into binary based on the mapping table to obtain a first target sequence. Taking the mapping table in Table 1 and the stored string 111010 as an example, if the preset keyword to be queried is C, the first target sequence obtained by conversion is 100, and the first target sequence is modulo the stored string, and the unit digit of the modulo result is 0, indicating that the preset keyword C does not exist in the stored string. If the preset keyword to be queried is D, the first target sequence obtained by conversion is 1000, and the first target sequence is modulo the stored string, and the unit digit of the modulo result is 1, indicating that the preset keyword D exists in the stored string.

[0126] Taking the mapping table in Table 2 and the stored string 111010000101 as an example, if the preset keyword to be queried is Ceiling Mount, Ceiling Mount is first converted into the first target sequence 100, and the query condition can be set to WHERE KEY_ITEM = 'Installation' AND VALUE_ITEM / 100%2 = 1, indicating that the unit digit of the remainder result is 1, and the preset keyword Ceiling Mount exists in the stored sequence.

[0127] In some of the embodiments, when the query conditions include at least two preset keywords, a superposition strategy is adopted for query; wherein, based on a mapping table, at least two preset keywords are binary converted to obtain a second target sequence; the second target sequence is superimposed with the stored character string, and if the number at the position corresponding to the preset keyword in the superposition result is 2, it indicates that the preset keyword exists in the stored character string.

[0128] Specifically, in the superposition strategy, each preset keyword is first converted into a binary system to obtain a second target sequence. Taking the mapping table in Table 2 and the stored string 111010000101 as an example, when the preset keywords Ceiling Mount, Horizontal pole Mount, and Junction Mount are queried simultaneously at a single time, the second target sequence 100010100 converted from the three preset keywords is first obtained, and then the second target sequence and the stored string 111010000101 are superimposed to obtain a superposition result of 100010100+111010000101=111110010201. At this time, the third bit is equal to 2, and the other bits are 0 or 1, indicating that the preset keyword Ceiling Mount exists in the stored string, but the preset keywords Horizontal poleMount and Junction Mount do not exist.

[0129] When the preset keywords Parapet Mount and Plane Mount are queried simultaneously at a single time, the second target sequence 11000000 converted from the two preset keywords is first obtained, and then the second target sequence and the stored character string 111010000101 are superimposed to obtain the superposition result 11000000+111010000101=111021000101. At this time, the eighth bit is equal to 2, and the other bits are 0 or 1, indicating that the preset keyword Parapet Mount exists in the stored character string, but the preset keyword PlaneMount does not exist.

[0130] By adopting the remainder strategy and the superposition strategy based on the mapping table in this embodiment, different numbers of preset keywords to be queried are queried respectively, so as to obtain the query result of whether the character string stored in the database contains the preset keywords to be queried more quickly.

[0131] The present embodiment is described and illustrated below through preferred embodiments.

[0132] Figure 6 is a flow chart of the method for storing and querying a string in this embodiment, such as Figure 6 As shown, the method comprises the following steps:

[0133] Step S601, establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords.

[0134] Step S602: split the character string to be stored into a number of preset keywords.

[0135] Step S603, setting the highest bit of the binary sequence to 1; the lowest bit to the second highest bit of the binary sequence correspond to preset keywords in a preset order respectively.

[0136] Step S604, filling the corresponding positions of the binary sequence in sequence starting from the lowest bit; wherein, for the preset keywords included in the string to be stored, the corresponding positions of the binary sequence are filled with 1; for the preset keywords not included in the string to be stored, the corresponding positions of the binary sequence are filled with 0.

[0137] Step S605, obtaining query conditions of the database; the query conditions include preset keywords to be queried.

[0138] Step S606, determining corresponding four arithmetic operations query strategies according to the number of preset keywords to be queried; the query strategies include a remainder strategy and a superposition strategy based on a mapping table.

[0139] Step S607, when the query condition includes a preset keyword, based on the mapping table, the preset keyword is converted into binary to obtain a first target sequence; the first target sequence is modulo the stored character string, and if the unit digit of the modulo result is 1, it indicates that the preset keyword exists in the stored character string.

[0140] Step S608, when the query condition includes at least two preset keywords, based on the mapping table, at least two preset keywords are binary converted to obtain a second target sequence; the second target sequence is superimposed with the stored character string, and if the number at the position corresponding to the preset keyword in the superposition result is 2, it indicates that the preset keyword exists in the stored character string.

[0141] Through the method provided in this embodiment, the character string to be stored can be converted into a binary sequence based on the preset order of the mapping table and stored in the database, which can maximize the compression storage. In addition, considering that the character string to be stored is fixed and has no order requirement, the storage method in this embodiment can also avoid repeated storage, effectively improving storage efficiency. Further, for the character string in the form of a binary sequence, it is not necessary to match the characters of the entire character string for query, which effectively improves the query efficiency, and the repeated storage of the character string in the database is reduced, which further improves the query efficiency.

[0142] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0143] In this embodiment, a device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit" and the like used below can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0144] Figure 7 is a structural block diagram of a storage device for a string in this embodiment, such as Figure 7 As shown, the device comprises:

[0145] A mapping establishment module 10 is used to establish a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0146] The character string splitting module 20 is used to split the character string to be stored into a plurality of preset keywords;

[0147] The storage module 30 is used to match the preset keywords in the character string to be stored with the mapping table in sequence based on the preset order in the mapping table; according to the matching result, the preset keywords in the stored character string are binary converted to obtain a binary sequence; and the character string to be stored is stored in the database in the form of a binary sequence.

[0148] By using the device provided in this embodiment, a mapping table of preset keywords is established, and the character string to be stored is converted into a binary sequence based on the preset order of the mapping table and stored in the database, which can maximize the compression storage. In addition, considering that the character string to be stored is fixed and has no order requirement, the storage method in this embodiment can also avoid repeated storage, effectively improving storage efficiency.

[0149] In some embodiments, the apparatus further comprises:

[0150] The query module is used to obtain database query conditions; the query conditions include preset keywords to be queried; according to the number of preset keywords to be queried, the corresponding four arithmetic operations query strategy is determined; the query strategy includes a remainder strategy and an overlay strategy based on a mapping table; based on the query strategy, whether the preset keywords to be queried exist in the character string stored in the database.

[0151] Figure 8 is a structural block diagram of the storage query device of the string in this embodiment, such as Figure 8 As shown, the device comprises:

[0152] A mapping establishment module 10 is used to establish a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords;

[0153] The acquisition module 40 is used to acquire database query conditions; the query conditions include preset keywords to be queried;

[0154] The query module 50 is used to determine the corresponding four arithmetic operations query strategy according to the number of preset keywords to be queried; the query strategy includes a remainder strategy and an overlay strategy based on a mapping table; based on the query strategy, query whether the preset keywords to be queried exist in the character string stored in the database.

[0155] Through the device provided in this embodiment, for a string in binary sequence form in the database, there is no need to match the characters of the entire string to perform a query, which effectively improves the query efficiency. In addition, the number of strings stored repeatedly in the database is reduced, which further improves the query efficiency and avoids querying multiple identical strings.

[0156] In some embodiments, the apparatus further comprises:

[0157] The storage module is used to split the string to be stored into several preset keywords; based on the preset order in the mapping table, the preset keywords in the string to be stored are matched with the mapping table in turn; according to the matching result, the preset keywords in the stored string are binary converted to obtain a binary sequence; the string to be stored is stored in the database in the form of a binary sequence.

[0158] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0159] In this embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0160] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0161] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0162] In addition, in combination with the string storage method and / or string query method provided in the above embodiments, a storage medium may be provided in the present embodiment to implement the above embodiments. The storage medium stores a computer program; when the computer program is executed by the processor, any string storage method and / or string query method in the above embodiments is implemented.

[0163] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0164] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0165] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0166] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0167] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A method for storing a string, characterized in that: include: Create a mapping table of preset keywords; The mapping table includes a preset order of the preset keywords; Splitting the character string to be stored into a plurality of the preset keywords; Based on a preset order in the mapping table, sequentially matching the preset keywords in the character string to be stored with the mapping table; According to the matching result, the preset keyword in the stored character string is converted into a binary sequence; The character string to be stored is stored in the database in the form of the binary sequence.

2. The method for storing a character string according to claim 1, characterized in that: According to the matching result, the preset keyword in the stored character string is converted into a binary sequence, including: The highest bit of the binary sequence is set to 1; the lowest bit to the second highest bit of the binary sequence correspond to the preset keywords in the preset sequence respectively; According to the matching result, the corresponding positions of the binary sequence are filled in sequence starting from the lowest bit; wherein, for the preset keywords included in the character string to be stored, the corresponding positions of the binary sequence are filled with 1; for the preset keywords not included in the character string to be stored, the corresponding positions of the binary sequence are filled with 0.

3. The method for storing a character string according to claim 1, wherein: Also includes: When the preset keyword is added to the mapping table, the number of bits of the binary sequence is updated accordingly; The newly added preset keyword corresponds to the second highest bit of the updated binary sequence.

4. A method for querying a character string, characterized in that: include: Establishing a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords; Get the query conditions of the database; The query conditions include preset keywords to be queried; Determine a corresponding four arithmetic operations query strategy according to the number of preset keywords to be queried; the query strategy includes a remainder strategy and a superposition strategy based on the mapping table; Based on the query strategy, it is queried whether the preset keyword to be queried exists in the character string stored in the database.

5. The method for searching a character string according to claim 4, characterized in that: When the query condition includes a preset keyword, the remainder strategy is used to perform the query; Among them, based on the mapping table, the preset keyword is converted into binary to obtain a first target sequence; the first target sequence is modulo the stored character string, and if the unit digit of the modulo result is 1, it means that the preset keyword exists in the stored character string.

6. The method for searching a character string according to claim 4, characterized in that: When the query condition includes at least two preset keywords, the superposition strategy is used to perform the query; Among them, based on the mapping table, the at least two preset keywords are binary converted to obtain a second target sequence; the second target sequence is superimposed with the stored character string, and if the number at the position corresponding to the preset keyword in the superposition result is 2, it indicates that the preset keyword exists in the stored character string.

7. A storage device for a character string, characterized in that: include: A mapping establishment module, used to establish a mapping table of preset keywords; The mapping table includes a preset order of the preset keywords; A string splitting module, used for splitting the string to be stored into a plurality of preset keywords; A storage module, used for sequentially matching the preset keywords in the character string to be stored with the mapping table based on the preset order in the mapping table; According to the matching result, the preset keyword in the stored character string is converted into a binary sequence; The character string to be stored is stored in the database in the form of the binary sequence.

8. A character string query device, characterized in that: include: A mapping establishment module, used to establish a mapping table of preset keywords; the mapping table includes a preset order of the preset keywords; The acquisition module is used to obtain database query conditions; The query conditions include preset keywords to be queried; A query module is used to determine a corresponding four arithmetic operation query strategy according to the number of preset keywords to be queried; the query strategy includes a remainder strategy and an overlay strategy based on the mapping table; based on the query strategy, query whether the preset keywords to be queried exist in the character string stored in the database.

9. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor is configured to run the computer program to execute the method for storing a character string according to any one of claims 1 to 3, and / or the method for searching a character string according to any one of claims 4 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method for storing a character string according to any one of claims 1 to 3 and / or the method for searching a character string according to any one of claims 4 to 6.