CN109299110B - Data query method and device, storage medium and electronic equipment - Google Patents

Data query method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN109299110B
CN109299110B CN201811334227.4A CN201811334227A CN109299110B CN 109299110 B CN109299110 B CN 109299110B CN 201811334227 A CN201811334227 A CN 201811334227A CN 109299110 B CN109299110 B CN 109299110B
Authority
CN
China
Prior art keywords
query
data
row
matched
row key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811334227.4A
Other languages
Chinese (zh)
Other versions
CN109299110A (en
Inventor
吴擒龙
张德阳
黄治纲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Neusoft Corp
Original Assignee
Neusoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Neusoft Corp filed Critical Neusoft Corp
Priority to CN201811334227.4A priority Critical patent/CN109299110B/en
Publication of CN109299110A publication Critical patent/CN109299110A/en
Application granted granted Critical
Publication of CN109299110B publication Critical patent/CN109299110B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The disclosure relates to a data query method, a data query device, a storage medium and electronic equipment, relates to the technical field of information, and is applied to a server, wherein the method comprises the following steps: analyzing the query request sent by the terminal to obtain at least one query mode corresponding to at least one query message in the query request, searching whether a first row key matched with the at least one query mode exists in the index table, searching a data row matched with the at least one query message in a data row identified by the at least one first row key in the database when the at least one first row key exists in the index table, and sending the data row matched with the at least one query message to the terminal as a query result. The method and the device realize the query of the distributed database, improve the query efficiency of the distributed database and save storage resources.

Description

Data query method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of information technology, and in particular, to a data query method, apparatus, storage medium, and electronic device.
Background
With the rapid development of information technologies such as internet, cloud computing and internet of things, the data volume brought correspondingly also shows explosive growth, and the traditional database cannot meet the storage requirement of mass data, so a Distributed Database (DDB) is usually used for storing mass data. For example, the Hbase database is a distributed, column-oriented open source database suitable for unstructured data storage, and a row of records is read in the Hbase database by a row key (english: Rowkey) that can uniquely identify a row of records.
In the prior art, to query the Hbase database, it is necessary to manually index a table or a column specified in the database (a part of columns are mapped from the database), and when querying, query is performed only in the columns mapped by the index, so as to return a row key. Because the amount of data in the database is large and the structure is complex, the query efficiency is low, and meanwhile, the storage space is consumed for establishing the index.
Disclosure of Invention
The invention aims to provide a data query method, a data query device, a storage medium and electronic equipment, which are used for solving the problems of low data query efficiency and storage space consumption in the prior art.
In order to achieve the above object, according to a first aspect of the embodiments of the present disclosure, there is provided a data query method applied to a server, the method including:
analyzing a query request sent by a terminal to obtain at least one query mode corresponding to at least one query message in the query request;
looking up whether a first row key matched with the at least one query pattern exists in an index table;
when at least one first row key exists in the index table, searching a data row matched with the at least one query message in a data row identified by the at least one first row key in a database;
and sending the data line matched with the at least one piece of query information to the terminal as a query result.
Optionally, the searching for the data row matching the at least one query information in the data row identified by the at least one first row key in the database includes:
when at least one first row key exists in the index table, taking a data row identified by the at least one first row key in the database as a target row;
and searching the data row matched with the at least one query message in the target row.
Optionally, when at least one first row key exists in the index table, taking a data row identified by the at least one first row key in the database as a target row includes:
when at least one first row key exists in the index table, determining a first table name corresponding to each first row key;
searching a database for the data table identified by each first table name;
determining at least one data row identified by the at least one first row key in all the data tables;
and taking the at least one data line as the target line.
Optionally, the analyzing the query request sent by the terminal to obtain at least one query pattern corresponding to at least one query message in the query request includes:
acquiring a regular expression matched with each query message according to the at least one query message;
and taking each regular expression matched with the query information as one query pattern.
Optionally, the method further includes:
when the first row key does not exist in the index table, searching a target data column matched with the query pattern in the database, wherein a regular expression matched with data in the target data column is the same as the query pattern;
when at least one target data column exists in the database, determining at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key;
searching the database for the data table identified by each second table name;
determining at least one data row identified by the at least one second row key in all the data tables;
sending a data row matched with the at least one query information in the at least one data row identified by the at least one second row key as a query result to the terminal;
and updating the index table according to the at least one second row key, the second table name corresponding to each second row key and the query mode.
Optionally, the sending, as a query result, a data line, which is matched with the at least one query information, in the at least one data line identified by the at least one second row key to the terminal includes:
taking at least one data row identified by the at least one second row key as a target row;
and sending the data row matched with the at least one piece of query information in the target row as a query result to the terminal.
Optionally, the method further includes:
and when the target data column does not exist in the database, sending prompt information to the terminal, wherein the prompt information is used for indicating that the query fails.
Optionally, the updating the index table according to the at least one second row key, the second table name corresponding to each second row key, and the query mode includes:
and storing the corresponding relation between each second row key and the query mode and the corresponding relation between the query mode and the target data column into the index table.
According to a second aspect of the embodiments of the present disclosure, there is provided a data query apparatus applied to a server, the apparatus including: the analysis module is used for analyzing the query request sent by the terminal so as to obtain at least one query mode corresponding to at least one query message in the query request;
the first searching module is used for searching whether a first row key matched with the at least one query pattern exists in an index table;
the second searching and sending module is used for searching a data row matched with the at least one query message in a data row identified by at least one first row key in a database when the at least one first row key exists in the index table;
and the sending module is used for sending the data line matched with the at least one piece of query information to the terminal as a query result.
Optionally, the second lookup sending module includes:
the first lookup submodule is used for taking a data row identified by at least one first row key in the database as a target row when the index table has at least one first row key;
and the second searching sub-module is used for searching the data line matched with the at least one piece of query information in the target line.
Optionally, the first lookup sub-module is configured to:
when at least one first row key exists in the index table, determining a first table name corresponding to each first row key;
searching a database for the data table identified by each first table name;
determining at least one data row identified by the at least one first row key in all the data tables;
and taking the at least one data line as the target line.
Optionally, the parsing module includes:
the analysis submodule is used for acquiring a regular expression matched with each query message according to the at least one query message;
and the pattern determination sub-module is used for taking each regular expression matched with the query information as one query pattern.
Optionally, the apparatus further comprises:
a data column searching module, configured to search, when the first row key does not exist in the index table, a target data column matched with the query pattern in the database, where a regular expression matched with data in the target data column is the same as the query pattern;
the data column searching module is further configured to determine, when at least one target data column exists in the database, at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key;
the data column searching module is further configured to search the database for the data table identified by each second table name;
the data column searching module is further configured to determine, in all the data tables, at least one data row identified by the at least one second row key;
the sending module is further configured to send, to the terminal, a data line, which is matched with the at least one query information, in the at least one data line identified by the at least one second line key, as a query result;
and the updating module is used for updating the index table according to the at least one second row key, the second table name corresponding to each second row key and the query mode.
Optionally, the sending module includes:
the query submodule is used for taking at least one data line identified by the at least one second line key as a target line;
and the sending submodule is used for sending the data line matched with the at least one piece of query information in the target line to the terminal as a query result.
Optionally, the sending module is further configured to:
and when the target data column does not exist in the database, sending prompt information to the terminal, wherein the prompt information is used for indicating that the query fails.
Optionally, the update module is configured to:
and storing the corresponding relation between each second row key and the query mode and the corresponding relation between the query mode and the target data column into the index table.
According to a third aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the data query method provided by the first aspect.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the data query method provided by the first aspect.
According to the technical scheme, the method comprises the steps of firstly receiving a query request sent by a terminal, analyzing the query request to obtain at least one query mode corresponding to at least one query message contained in the query request, then searching whether a first row key matched with the at least one query mode exists in an index table, searching a data row matched with the at least one query message in data rows identified by all the first row keys when one or more first row keys exist in the index table, and finally sending the data row matched with the at least one query message to the terminal as a query result. The distributed database can be queried, the query efficiency of the distributed database is improved, and storage resources are saved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating a method of data querying in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating another method of data querying in accordance with an exemplary embodiment;
FIG. 3 is a flow diagram illustrating another method of data querying in accordance with an exemplary embodiment;
FIG. 4 is a flow diagram illustrating another method of data querying in accordance with an exemplary embodiment;
FIG. 5 is a flow diagram illustrating another method of data querying in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating a data query device in accordance with an exemplary embodiment;
FIG. 7 is a block diagram illustrating another data querying device, according to an example embodiment;
FIG. 8 is a block diagram illustrating another data querying device, according to an example embodiment;
FIG. 9 is a block diagram illustrating another data querying device, according to an example embodiment;
FIG. 10 is a block diagram illustrating another data querying device, according to an example embodiment;
FIG. 11 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Before introducing the data query method, apparatus, storage medium, and electronic device provided by the present disclosure, an application scenario related to each embodiment of the present disclosure is first introduced, where the application scenario includes a server and a terminal, the terminal can communicate with the server through a network, the server includes a database (for example, an Hbase database), and the server can receive a query request sent by the terminal and return a query result to the terminal. The server may be a local server or a cloud server, and the terminal may be a mobile terminal such as a smart phone, a tablet computer, a smart television, a smart watch, a PDA (Personal Digital Assistant, chinese), a portable computer, or a fixed terminal such as a desktop computer.
Fig. 1 is a flowchart illustrating a data query method according to an exemplary embodiment, where the method is applied to a server, as shown in fig. 1, and includes:
step 101, analyzing the query request sent by the terminal to obtain at least one query pattern corresponding to at least one query message in the query request.
For example, when a user needs to search for data in a database, a query request may be sent to the server through the terminal, where the query request may include data to be queried by the user, that is, query information, and the query information may be one or more. After receiving the query request, the server analyzes each query message in the query request to obtain one or more query modes corresponding to the at least one query message. The query information in the query request may be described according to a preset DSL (english: Domain-specific Languages, chinese: Domain specific Languages), the server analyzes the query information for the query request by using the corresponding DSL to obtain a query pattern corresponding to the query information, the query pattern may be understood as an attribute of data to be queried by the user, that is, a data format of a certain data column in the database, and the query pattern may have one or more, each query pattern corresponds to the data format of the certain data column in the database. The method comprises the steps that a user needs to search data containing an identity card number of 211123456789101234 AND a name of Li Ming in a database, a query request is sent to a server through a terminal, the query request comprises <211123456789101234> AND < Li Ming >, namely '211123456789101234' is query information, the 'Li Ming' is the query information, AND the server analyzes the two query information to obtain two query modes: 17 or 18 digits (namely the query mode corresponding to the identification number) and 2-4 Chinese characters (namely the query mode corresponding to the name).
Step 102, looking up whether a first row key matched with at least one query pattern exists in an index table.
For example, whether a first row key matching with all query patterns exists is looked up in an index table, the index table may contain patterns of some data columns (or referred to as fields) in various data tables in the database, and further includes that the data columns correspond to one or more row keys, and may also include a table name corresponding to each row key in the row keys, where the table name can uniquely identify the data table, and it should be noted that. The first row of keys may be zero, one or more. When the first row of keys does not exist (i.e. zero), it indicates that there are no data columns in the index table that completely match all the query patterns, and when the first row of keys is one or more, it indicates that there are data columns in the index table that completely match all the query patterns, and the row keys corresponding to these data columns are the first row of keys. The data columns matched with all query patterns can be understood as that the patterns of the data in the data columns correspond to the query patterns one by one, that is, all row keys matched with the query patterns in the index table are used as the first row key group according to the corresponding relation between the row keys and the query patterns in the index table. For example, if there are two data columns in the index table, which satisfy the 17-or 18-bit numeric pattern AND the 2-or 4-bit kanji pattern, it can be determined that these two data columns match the query pattern parsed by <211123456789101234> AND < lie >, AND the row key corresponding to these two data columns is the first row key. The data columns included in the index table may be corresponding data columns in the query pattern that has been queried before, or some data columns that are specified in advance.
And 103, when at least one first row key exists in the index table, searching a data row matched with at least one query message in the data row identified by the at least one first row key in the database.
And 104, sending the data line matched with the at least one piece of query information to the terminal as a query result.
For example, when one or more row keys exist in the index table, the table name corresponding to each first row key is determined according to the relationship between the row keys and the table names in the index table, the data table corresponding to each first row key is determined according to the table name corresponding to each first row key, the data rows identified by all the first row keys in the data table are acquired, then the data rows matched with at least one piece of query information are searched for in the data rows identified by all the first row keys, and finally the data rows matched with at least one piece of query information are sent to the terminal as query results. The number of the first row keys is greater than or equal to the number of the data tables, that is, one data table may correspond to one or more first row keys. For example, if the query request includes <211123456789101234> AND < Li Ming >, the analyzed query pattern is 17 or 18 digits AND 2-4 Chinese characters, that is, the query pattern is an identification number AND a name, AND if two data columns in the index table are respectively matched with two query patterns of 17 or 18 digits AND 2-4 Chinese characters, AND the two corresponding data columns correspond to three row keys, the three row keys are the first row keys (it can be understood that the identifier of the data row meeting the query condition in the query request is found), AND if the three first row keys are respectively: 1001101, 1100110 and 1100111, the three data rows identified by 1001101, 1100110 and 1100111 in the database can be fetched, and the data rows including "211123456789101234" and "Li Ming" are inquired in the three data rows and sent to the terminal as the inquiry result.
For example, population information of a certain city is stored in the database, data with the name "Wangming", the identity card number "610123456789101234" AND the gender "Man" in the database needs to be searched, a query request of < Wangming > AND <610123456789101234> AND < Man > can be input through the terminal, AND the terminal sends the query request to the server. After receiving the query request, the server analyzes the query request, and finds corresponding regular expressions for three query information "wangming", "610123456789101234" and "male" contained in the query request respectively to obtain three query patterns: 2-4 digits Chinese characters (a query mode corresponding to a name), 17 or 18 digits (a query mode corresponding to an identity card number), and 0 or 1 (a query mode corresponding to gender). Then, whether first row keys matched with all query patterns exist is searched in the index table, that is, whether data in three data columns exist in the query index table is searched, and the data respectively satisfy the patterns of 2-4-bit Chinese characters, 17 or 18-bit numbers, and 0 or 1, if so, row keys corresponding to the three data columns are first row keys, for example, three data columns correspond to two first row keys, which are respectively: 1111101 and 1100000, two data rows identified by 1111101 and 1100000 in the database are taken out, and finally the data rows including "Wangming", "610123456789101234" and "Man" in the two data rows are sent to the terminal as query results, for example, if the data row identified by 1100000 contains "Wangming" but does not contain "610123456789101234" and "Man", and the data row identified by 1111101 contains "Wangming", "610123456789101234" and "Man", the data row identified by 1111101 is taken out from the data table corresponding to the data row identified by 1111101 and is sent to the terminal as final query results.
In summary, the present disclosure first receives a query request sent by a terminal, analyzes the query request to obtain at least one query pattern corresponding to at least one query message included in the query request, then searches whether a first row key matching the at least one query pattern exists in an index table, when one or more first row keys exist in the index table, searches for a data row matching the at least one query message in data rows identified by all the first row keys, and finally sends the data row matching the at least one query message to the terminal as a query result. The distributed database can be queried, the query efficiency of the distributed database is improved, and storage resources are saved.
FIG. 2 is a flow chart illustrating another data query method according to an exemplary embodiment, and as shown in FIG. 2, step 103 may be implemented by:
and step 1031, when at least one first row key exists in the index table, taking the data row identified by the at least one first row key in the database as a target row.
Step 1032, finding a data line matching the at least one query information in the target line.
For example, when one or more row keys exist in the index table, the table name corresponding to each first row key is determined according to the relationship between the row key and the table name in the index table, the data table corresponding to each first row key is determined according to the table name corresponding to each first row key, the data rows identified by all the first row keys in the data table are taken as target rows, and then the data rows matched with at least one piece of query information are searched in the target rows.
Optionally, step 1031 may be implemented by:
1) when at least one first row key exists in the index table, determining a first table name corresponding to each first row key.
2) The data table identified by each first table name is looked up in a database.
3) At least one data row identified by at least one first row key is determined in all data tables.
4) At least one data line is taken as a target line.
For example, when at least one first row key exists in the index table, first, a first table name corresponding to each first row key is determined according to a corresponding relationship between the row keys and the table names in the index table, where the number of the first row keys is greater than or equal to the number of the first table names (that is, one first row key corresponds to one data table identified by the first table name, and one data table identified by the first table name may include a plurality of first row keys), then, the data tables identified by the first table names in the database are determined, then, all data rows identified by all the first row keys in all the data tables are obtained (the first row keys correspond to the data rows one to one), and finally, all the data rows are taken as target rows. For example, two data columns in the index table are respectively matched with the query pattern parsed by <211123456789101234> AND < lumin >, AND the two corresponding data columns correspond to three first row keys, which are: 1001101, 1100110 and 1100111, firstly determining the table names corresponding to three first row keys, wherein the table name of 1001101 is: the table names of 0x5211, 1100110 and 1100111 are all 0x7100, then the data tables corresponding to 0x5211 and 0x7100 are searched in the database, one data row corresponding to 1001101 is taken out from the data table identified by 0x5211, two data rows corresponding to 1100110 and 1100111 are taken out from the data table identified by 0x7100, and the three data rows are taken as target rows.
FIG. 3 is a flow chart illustrating another data query method according to an example embodiment, as shown in FIG. 3, step 101 may include:
step 1011, obtaining the regular expression matched with each query information according to at least one query information.
Step 1012, taking each regular expression matched with the query information as a query pattern.
For example, the query request may include one or more query messages, where the query messages may be in a text format, data corresponding to each query message is described according to rules of a Regular Expression (english: Regular Expression) to obtain a Regular Expression matched with each query message, and the Regular Expression matched with each query message is used as a query pattern, that is, one Regular Expression corresponds to one query pattern, and multiple Regular expressions correspond to multiple query patterns. Correspondingly, if the query pattern is matched with the data column, it can be understood that the regular expression corresponding to the data in the data column is the same as the regular expression corresponding to the query pattern. Taking the query request as < zhang-san > AND < man >, the server may remove the connection symbol (for example, AND, OR, etc.) in the query request, AND then analyze two query information contained in the query request: "zhangsan" and "man" describe the data corresponding to "man" according to the rule of regular expression, i.e. 0 or 1 (query mode corresponding to gender), describe the data corresponding to "zhangsan" according to the rule of regular expression, i.e. 2-4 bit Chinese characters (query mode corresponding to name), and use the two regular expressions corresponding to "name" and "gender" as two query modes.
FIG. 4 is a flow chart illustrating another method of data querying, according to an exemplary embodiment, as shown in FIG. 4, the method further comprising the steps of:
and 105, when the first row key does not exist in the index table, searching a target data column matched with the query pattern in the database, wherein the regular expression matched with the data in the target data column is the same as the query pattern.
For example, when the first row key does not exist in the index table, the data can be queried by looking up a target data column matching the query pattern in the database, wherein the regular expression matched with the data in the target data column is the same as the query pattern.
And 106, when at least one target data column exists in the database, determining at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key.
Step 107, the data table identified by each second table name is looked up in the database.
At step 108, at least one data row identified by at least one second row key is determined in all data tables.
And step 109, sending the data row matched with the at least one query information in the at least one data row identified by the at least one second row key to the terminal as a query result.
For example, when a target data column matching the query pattern exists in the database, a second row key corresponding to the target data column and a second table name corresponding to each second row key may be determined. The number of the second row of keys can be one or more, and the number of the second table names is less than or equal to the number of the second row of keys. And finally, sending the data rows matched with at least one query message in all the data rows (the second row keys are in one-to-one correspondence with the data rows) identified by all the second row keys in all the data tables as query results to the terminal. The above method for determining at least one data row identified by at least one second row key in all data tables, and determining a data row matched with at least one query message in the at least one data row identified by the second row key to send to the terminal is the same as the processing method for the at least one data row identified by the first row key in steps 103 and 104, and is not described again.
And step 110, updating the index table according to at least one second row key, the second table name corresponding to each second row key and the query mode.
For example, after the second row of keys and the second table name corresponding to each second row of keys are determined in step 106, the corresponding relationship between the query pattern and the second row of keys and the second table name is stored in the index table, and the index table is updated so that the query can directly obtain the query result according to the index table. The corresponding relationship between each second row key and the query pattern, the corresponding relationship between the query pattern and the target data column, and the corresponding relationship between the row key and the query pattern, the corresponding relationship between the query pattern and the data column in the database, and the corresponding relationship between the row key and the table name may be stored in the index table, where the row keys correspond to the data rows one to one, the table names correspond to the data tables one to one, and the data table may include one or more row keys.
FIG. 5 is a flow chart illustrating another data query method according to an example embodiment, and as shown in FIG. 5, step 109 may include the steps of:
step 1091, the at least one data row identified by the at least one second row key is taken as the target row.
Step 1092, sending the data row matched with the at least one query information in the target row as a query result to the terminal.
For example, when a target data column matching the query pattern exists in the database, a second row key corresponding to the target data column and a second table name corresponding to each second row key may be determined. The number of the second row of keys can be one or more, and the number of the second table names is less than or equal to the number of the second row of keys. And finally, all data rows (the second row keys are in one-to-one correspondence with the data rows) identified by all the second row keys in all the data tables are used as target rows, and the data rows matched with at least one piece of query information in the target rows are used as query results and sent to the terminal.
It should be noted that, when the index table is empty (i.e., when the query is performed for the first time), it is determined that there is no first row key in step 102, step 105 to step 106 are executed to query whether there is a target data column in the database, and if so, a second row key and a second table name corresponding to the query pattern and the target data column are stored in the index table, where the index table already includes index information corresponding to the query instruction in the query for the first time, so that when a terminal sends the same query instruction again later, the first row key can be directly searched from the index table. With the increase of the query times, the query modes contained in the index table are more and more (the query times are larger, and the query modes in the index table are finally maintained at a limited order of magnitude), so that in the embodiment, the index table does not need to be manually established in advance, the index table can be dynamically established in the data query process, the workload brought by manually establishing the index table is avoided, the structure of data in the database (namely the mode of the data in the data column) can be accurately identified, and the accuracy of establishing the index table and querying the data is improved. Furthermore, for the transverse expansion of the database, the index table does not need to be modified, the index table can be automatically adapted in the data query process, and the data query efficiency is improved.
Optionally, the method may further include the steps of:
and when the target data column does not exist in the database, sending prompt information to the terminal, wherein the prompt information is used for indicating that the query fails.
For example, when it is determined in step 105 that the target data column does not exist in the database, which indicates that there is no data row in the database that satisfies the query pattern, a prompt message may be sent to the terminal to prompt the user using the terminal that the query fails.
In summary, the present disclosure first receives a query request sent by a terminal, analyzes the query request to obtain at least one query pattern corresponding to at least one query message included in the query request, then searches whether a first row key matching the at least one query pattern exists in an index table, when one or more first row keys exist in the index table, searches for a data row matching the at least one query message in data rows identified by all the first row keys, and finally sends the data row matching the at least one query message to the terminal as a query result. The distributed database can be queried, the query efficiency of the distributed database is improved, and storage resources are saved.
Fig. 6 is a block diagram illustrating a data query apparatus according to an exemplary embodiment, and as shown in fig. 6, the apparatus 200 is applied to a server, and includes:
the parsing module 201 is configured to parse the query request sent by the terminal to obtain at least one query pattern corresponding to at least one query message in the query request.
A first lookup module 202, configured to lookup in the index table whether there is a first row key matching at least one query pattern.
And the second searching module 203 is used for searching the data row matched with the at least one query message in the data row identified by the at least one first row key in the database when the at least one first row key exists in the index table.
A sending module 204, configured to send the data line matched with the at least one piece of query information to the terminal as a query result.
Fig. 7 is a block diagram illustrating another data querying device according to an exemplary embodiment, and as shown in fig. 7, the second lookup module 203 includes:
the first lookup sub-module 2031 is configured to, when there is at least one first row key in the index table, use the data row identified by the at least one first row key in the database as the target row.
The second searching sub-module 2032 is configured to search the target row for a data row matching the at least one query message.
Optionally, the first lookup sub-module 2031 may be configured to perform the following steps:
1) when at least one first row key exists in the index table, determining a first table name corresponding to each first row key.
2) The data table identified by each first table name is looked up in a database.
3) At least one data row identified by at least one first row key is determined in all data tables.
4) At least one data line is taken as a target line.
Fig. 8 is a block diagram illustrating another data query apparatus according to an exemplary embodiment, and as shown in fig. 8, the parsing module 201 includes:
the parsing sub-module 2011 is configured to obtain, according to at least one query message, a regular expression matched with each query message.
The pattern determination sub-module 2012 is used for determining the regular expression matched with each query information as a query pattern.
Fig. 9 is a block diagram illustrating another data querying device according to an exemplary embodiment, and as shown in fig. 9, the device 200 further includes:
and the data column searching module 205 is configured to search, when the first row key does not exist in the index table, a target data column matched with the query pattern in the database, where a regular expression matched with data in the target data column is the same as the query pattern.
The data column searching module 205 is further configured to determine, when at least one target data column exists in the database, at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key.
The data column lookup module 205 is further configured to lookup the data table identified by each second table name in the database.
The data column lookup module 205 is further configured to determine at least one data row identified by at least one second row key in all data tables.
The sending module 204 is further configured to send, as a query result, a data row, which is matched with the at least one piece of query information, in the at least one data row identified by the at least one second row key to the terminal.
And the updating module 206 is configured to update the index table according to at least one second row key, a second table name corresponding to each second row key, and the query mode.
Fig. 10 is a block diagram illustrating another data querying device according to an exemplary embodiment, and as shown in fig. 10, the sending module 204 includes:
the query submodule 2041 is configured to use at least one data line identified by at least one second line key as a target line.
The sending submodule 2042 is configured to send a data line, which is matched with the at least one query message, in the target line to the terminal as a query result.
Optionally, the sending module 203 may further be configured to:
and when the target data column does not exist in the database, sending prompt information to the terminal, wherein the prompt information is used for indicating that the query fails.
Optionally, the update module 205 may be configured to implement the following steps:
and storing the corresponding relation between each second row key and the query mode and the corresponding relation between the query mode and the target data column into an index table.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
In summary, the present disclosure first receives a query request sent by a terminal, analyzes the query request to obtain at least one query pattern corresponding to at least one query message included in the query request, then searches whether a first row key matching the at least one query pattern exists in an index table, when one or more first row keys exist in the index table, searches for a data row matching the at least one query message in data rows identified by all the first row keys, and finally sends the data row matching the at least one query message to the terminal as a query result. The distributed database can be queried, the query efficiency of the distributed database is improved, and storage resources are saved.
FIG. 11 is a block diagram illustrating an electronic device 300 in accordance with an example embodiment. For example, the electronic device 300 may be provided as a server. Referring to fig. 11, the electronic device 300 comprises a processor 322, which may be one or more in number, and a memory 332 for storing computer programs executable by the processor 322. The computer program stored in memory 332 may include one or more modules that each correspond to a set of instructions. Further, the processor 322 may be configured to execute the computer program to perform the data query method described above.
Additionally, electronic device 300 may also include a power component 326 and a communication component 350, the power component 326 may be configured to perform power management of the electronic device 300, and the communication component 350 may be configured to enable communication, e.g., wired or wireless communication, of the electronic device 300. In addition, the electronic device 300 may also include input/output (I/O) interfaces 358. The electronic device 300 may operate based on an operating system stored in the memory 332, such as Windows Server, Mac OSXTM, UnixTM, LinuxTM, and the like.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the data query method described above. For example, the computer readable storage medium may be the memory 332 comprising program instructions executable by the processor 322 of the electronic device 300 to perform the data query method described above.
In summary, the present disclosure first receives a query request sent by a terminal, analyzes the query request to obtain at least one query pattern corresponding to at least one query message included in the query request, then searches whether a first row key matching the at least one query pattern exists in an index table, when one or more first row keys exist in the index table, searches for a data row matching the at least one query message in data rows identified by all the first row keys, and finally sends the data row matching the at least one query message to the terminal as a query result. The distributed database can be queried, the query efficiency of the distributed database is improved, and storage resources are saved.
Preferred embodiments of the present disclosure are described in detail above with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and other embodiments of the present disclosure may be easily conceived by those skilled in the art within the technical spirit of the present disclosure after considering the description and practicing the present disclosure, and all fall within the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. Meanwhile, any combination can be made between various different embodiments of the disclosure, and the disclosure should be regarded as the disclosure of the disclosure as long as the combination does not depart from the idea of the disclosure. The present disclosure is not limited to the precise structures that have been described above, and the scope of the present disclosure is limited only by the appended claims.

Claims (8)

1. A data query method is applied to a server, and comprises the following steps:
analyzing a query request sent by a terminal to obtain at least one query mode corresponding to at least one query message in the query request;
looking up whether a first row key matched with the at least one query pattern exists in an index table;
when at least one first row key exists in the index table, searching a data row matched with the at least one query message in a data row identified by the at least one first row key in a database;
sending the data line matched with the at least one piece of query information to the terminal as a query result;
the analyzing the query request sent by the terminal to obtain at least one query mode corresponding to at least one query message in the query request includes:
acquiring a regular expression matched with each query message according to the at least one query message;
taking each regular expression matched with the query information as one query pattern;
the method further comprises the following steps:
when the first row key does not exist in the index table, searching a target data column matched with the query pattern in the database, wherein a regular expression matched with data in the target data column is the same as the query pattern;
when at least one target data column exists in the database, determining at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key;
searching the database for the data table identified by each second table name;
determining at least one data row identified by the at least one second row key in all the data tables;
sending a data row matched with the at least one query information in the at least one data row identified by the at least one second row key as a query result to the terminal;
and updating the index table according to the at least one second row key, the second table name corresponding to each second row key and the query mode.
2. The method of claim 1, wherein the searching for the data row in the database that matches the at least one query information from the data rows identified by the at least one first row key comprises:
when at least one first row key exists in the index table, taking a data row identified by the at least one first row key in the database as a target row;
and searching the data row matched with the at least one query message in the target row.
3. The method according to claim 2, wherein the targeting the data row identified by at least one first row key in the database when the at least one first row key exists in the index table comprises:
when at least one first row key exists in the index table, determining a first table name corresponding to each first row key;
searching a database for the data table identified by each first table name;
determining at least one data row identified by the at least one first row key in all the data tables;
and taking the at least one data line as the target line.
4. The method according to claim 1, wherein the sending, as the query result, the data row matching the at least one query information in the at least one data row identified by the at least one second row key to the terminal comprises:
taking at least one data row identified by the at least one second row key as a target row;
and sending the data row matched with the at least one piece of query information in the target row as a query result to the terminal.
5. A data query apparatus, applied to a server, the apparatus comprising:
the analysis module is used for analyzing the query request sent by the terminal so as to obtain at least one query mode corresponding to at least one query message in the query request;
the first searching module is used for searching whether a first row key matched with the at least one query pattern exists in an index table;
the second searching and sending module is used for searching a data row matched with the at least one query message in a data row identified by at least one first row key in a database when the at least one first row key exists in the index table;
the sending module is used for sending the data line matched with the at least one piece of query information to the terminal as a query result;
the parsing module includes:
the analysis submodule is used for acquiring a regular expression matched with each query message according to the at least one query message;
the pattern determination sub-module is used for taking each regular expression matched with the query information as one query pattern;
the device further comprises:
a data column searching module, configured to search, when the first row key does not exist in the index table, a target data column matched with the query pattern in the database, where a regular expression matched with data in the target data column is the same as the query pattern;
the data column searching module is further configured to determine, when at least one target data column exists in the database, at least one second row key corresponding to the at least one target data column and a second table name corresponding to each second row key;
the data column searching module is further configured to search the database for the data table identified by each second table name;
the data column searching module is further configured to determine, in all the data tables, at least one data row identified by the at least one second row key;
the sending module is further configured to send, to the terminal, a data line, which is matched with the at least one query information, in the at least one data line identified by the at least one second line key, as a query result;
and the updating module is used for updating the index table according to the at least one second row key, the second table name corresponding to each second row key and the query mode.
6. The apparatus of claim 5, wherein the second lookup send module comprises:
the first lookup submodule is used for taking a data row identified by at least one first row key in the database as a target row when the index table has at least one first row key;
and the second searching sub-module is used for searching the data line matched with the at least one piece of query information in the target line.
7. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
8. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 4.
CN201811334227.4A 2018-11-09 2018-11-09 Data query method and device, storage medium and electronic equipment Active CN109299110B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811334227.4A CN109299110B (en) 2018-11-09 2018-11-09 Data query method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811334227.4A CN109299110B (en) 2018-11-09 2018-11-09 Data query method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN109299110A CN109299110A (en) 2019-02-01
CN109299110B true CN109299110B (en) 2020-09-25

Family

ID=65146366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811334227.4A Active CN109299110B (en) 2018-11-09 2018-11-09 Data query method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN109299110B (en)

Families Citing this family (36)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11281706B2 (en) 2016-09-26 2022-03-22 Splunk Inc. Multi-layer partition allocation for query execution
US20180089324A1 (en) 2016-09-26 2018-03-29 Splunk Inc. Dynamic resource allocation for real-time search
US11593377B2 (en) 2016-09-26 2023-02-28 Splunk Inc. Assigning processing tasks in a data intake and query system
US11294941B1 (en) 2016-09-26 2022-04-05 Splunk Inc. Message-based data ingestion to a data intake and query system
US11461334B2 (en) 2016-09-26 2022-10-04 Splunk Inc. Data conditioning for dataset destination
US11442935B2 (en) 2016-09-26 2022-09-13 Splunk Inc. Determining a record generation estimate of a processing task
US11250056B1 (en) 2016-09-26 2022-02-15 Splunk Inc. Updating a location marker of an ingestion buffer based on storing buckets in a shared storage system
US11321321B2 (en) 2016-09-26 2022-05-03 Splunk Inc. Record expansion and reduction based on a processing task in a data intake and query system
US11615104B2 (en) 2016-09-26 2023-03-28 Splunk Inc. Subquery generation based on a data ingest estimate of an external data system
US11580107B2 (en) 2016-09-26 2023-02-14 Splunk Inc. Bucket data distribution for exporting data to worker nodes
US11416528B2 (en) 2016-09-26 2022-08-16 Splunk Inc. Query acceleration data store
US11599541B2 (en) 2016-09-26 2023-03-07 Splunk Inc. Determining records generated by a processing task of a query
US11604795B2 (en) 2016-09-26 2023-03-14 Splunk Inc. Distributing partial results from an external data system between worker nodes
US11620336B1 (en) 2016-09-26 2023-04-04 Splunk Inc. Managing and storing buckets to a remote shared storage system based on a collective bucket size
US10956415B2 (en) 2016-09-26 2021-03-23 Splunk Inc. Generating a subquery for an external data system using a configuration file
US11567993B1 (en) 2016-09-26 2023-01-31 Splunk Inc. Copying buckets from a remote shared storage system to memory associated with a search node for query execution
US10353965B2 (en) 2016-09-26 2019-07-16 Splunk Inc. Data fabric service system architecture
US11874691B1 (en) 2016-09-26 2024-01-16 Splunk Inc. Managing efficient query execution including mapping of buckets to search nodes
US11860940B1 (en) 2016-09-26 2024-01-02 Splunk Inc. Identifying buckets for query execution using a catalog of buckets
US11232100B2 (en) 2016-09-26 2022-01-25 Splunk Inc. Resource allocation for multiple datasets
US11550847B1 (en) 2016-09-26 2023-01-10 Splunk Inc. Hashing bucket identifiers to identify search nodes for efficient query execution
US11562023B1 (en) 2016-09-26 2023-01-24 Splunk Inc. Merging buckets in a data intake and query system
US11663227B2 (en) 2016-09-26 2023-05-30 Splunk Inc. Generating a subquery for a distinct data intake and query system
US11586627B2 (en) 2016-09-26 2023-02-21 Splunk Inc. Partitioning and reducing records at ingest of a worker node
US11921672B2 (en) 2017-07-31 2024-03-05 Splunk Inc. Query execution at a remote heterogeneous data store of a data fabric service
US10896182B2 (en) 2017-09-25 2021-01-19 Splunk Inc. Multi-partitioning determination for combination operations
US11334543B1 (en) 2018-04-30 2022-05-17 Splunk Inc. Scalable bucket merging for a data intake and query system
CN109918472A (en) * 2019-02-27 2019-06-21 北京百度网讯科技有限公司 Method, apparatus, equipment and the medium of storage and inquiry data
WO2020220216A1 (en) 2019-04-29 2020-11-05 Splunk Inc. Search time estimate in data intake and query system
US11715051B1 (en) 2019-04-30 2023-08-01 Splunk Inc. Service provider instance recommendations using machine-learned classifications and reconciliation
US11494380B2 (en) 2019-10-18 2022-11-08 Splunk Inc. Management of distributed computing framework components in a data fabric service system
US11922222B1 (en) 2020-01-30 2024-03-05 Splunk Inc. Generating a modified component for a data intake and query system using an isolated execution environment image
CN111897840A (en) * 2020-08-14 2020-11-06 北京字节跳动网络技术有限公司 Data searching method and device, electronic equipment and storage medium
US11704313B1 (en) 2020-10-19 2023-07-18 Splunk Inc. Parallel branch operation using intermediary nodes
CN113297273B (en) * 2021-06-09 2024-03-01 北京百度网讯科技有限公司 Method and device for inquiring metadata and electronic equipment
CN113688150A (en) * 2021-07-27 2021-11-23 珠海金山办公软件有限公司 Keyword searching method and device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103810224B (en) * 2012-11-15 2017-04-12 阿里巴巴集团控股有限公司 information persistence and query method and device
CN103020204B (en) * 2012-12-05 2018-09-25 北京普泽创智数据技术有限公司 A kind of method and its system carrying out multi-dimensional interval query to distributed sequence list
CN104636389B (en) * 2013-11-14 2018-03-27 博雅网络游戏开发(深圳)有限公司 Realize the method and system of Hbase database real-time queries
CN104573022A (en) * 2015-01-12 2015-04-29 浪潮软件股份有限公司 Data query method and device for HBase
CN107515882B (en) * 2016-06-17 2020-12-25 阿里巴巴集团控股有限公司 Data query method and device
CN107506464A (en) * 2017-08-30 2017-12-22 武汉烽火众智数字技术有限责任公司 A kind of method that HBase secondary indexs are realized based on ES

Also Published As

Publication number Publication date
CN109299110A (en) 2019-02-01

Similar Documents

Publication Publication Date Title
CN109299110B (en) Data query method and device, storage medium and electronic equipment
CN107784044B (en) Table data query method and device
CN107590214B (en) Recommendation method and device for search keywords and electronic equipment
CN110929125B (en) Search recall method, device, equipment and storage medium thereof
US10140282B2 (en) Input string matching for domain names
KR20200104789A (en) Method, apparatus, device and medium for storing and querying data
CN103902535A (en) Method, device and system for obtaining associational word
CN112650858B (en) Emergency assistance information acquisition method and device, computer equipment and medium
US9965812B2 (en) Generating a supplemental description of an entity
CN111930891B (en) Knowledge graph-based search text expansion method and related device
CN111611343B (en) Searching system, method and equipment based on shortest path query of knowledge graph
CN113590756A (en) Information sequence generation method and device, terminal equipment and computer readable medium
CN113641769B (en) Data processing method and device
CN114579580A (en) Data storage method and data query method and device
AU2012261393B2 (en) Method and system for inputting information to mobile terminal as well as mobile terminal
CN115732052A (en) Case report table generation method and device based on structured clinical project
CN110515979B (en) Data query method, device, equipment and storage medium
CN116263770A (en) Method, device, terminal equipment and medium for storing business data based on database
CN111079027B (en) User recommendation method and device, readable storage medium and electronic equipment
CN113312540A (en) Information processing method, device, equipment, system and readable storage medium
CN113157722A (en) Data processing method, device, server, system and storage medium
CN113393288A (en) Order processing information generation method, device, equipment and computer readable medium
CN114238667B (en) Address management method and device, electronic equipment and storage medium
US11907275B2 (en) Systems and methods for processing text data for disabbreviation of text units
CN117009430A (en) Data management method, device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant