CN-116303566-B - Data query method and device
Abstract
The invention discloses a data query method and device, and relates to the technical field of big data. The method comprises the steps of responding to a data query request, obtaining data quantity to be queried and query information, comparing the data quantity to be queried with a preset quantity threshold value, determining that a data query mode is asynchronous query under the condition that the data quantity to be queried is larger than the quantity threshold value, otherwise, determining that the data query mode is synchronous query, and querying result data corresponding to the data query request according to the data query mode and the query information. According to the method and the device for inquiring the real estate web label information, synchronous inquiry and asynchronous inquiry are comprehensively considered, the applicable scene of real estate web label information inquiry is expanded, the problems of low inquiry efficiency and failure inquiry caused by overlarge inquiry data quantity are avoided, the inquiry efficiency and the inquiry success rate are improved, and the use experience of a user is improved.
Inventors
- ZHANG BANGWEN
Assignees
- 中国建设银行股份有限公司
- 建信金融科技有限责任公司
Dates
- Publication Date
- 20260505
- Application Date
- 20230222
Claims (10)
- 1. A method of data querying, comprising: responding to a data query request about house web label information, and acquiring data quantity to be queried and query information; comparing the data quantity to be queried with a preset quantity threshold value, and determining that the data query mode is asynchronous query under the condition that the data quantity to be queried is larger than the quantity threshold value, or determining that the data query mode is synchronous query; Generating a query service identifier according to the query information acquired by the query request, and querying a corresponding storage record from a result set table of a query system storing query results according to the query service identifier; for the queried storage record corresponding to the query service identifier, if the data query request has no aging requirement, using the storage record as result data corresponding to the data query request, or querying the result data corresponding to the data query request according to the data query mode and the query information; If the data query request has an aging requirement, judging whether the aging of the data information in the storage record meets the aging requirement, if the aging of the data information meets the aging requirement, taking the storage record as result data corresponding to the data query request, and if the aging of the data information does not meet the aging requirement, querying the result data corresponding to the data query request according to the data query mode and the query information; Under the condition of inquiring result data corresponding to the data inquiry request according to the data inquiry mode and the inquiry information, the synchronous inquiry and the asynchronous inquiry realize the occupation and release of threads through a counter, the synchronous inquiry and the asynchronous inquiry respectively run on a main thread and a sub thread, and the counter of the main thread is initialized to be 1; when the data query mode is synchronous query, after the obtained query result and the corresponding query service identifier are stored in a result set in an associated manner, resetting the value of a counter of a main thread, releasing the main thread, and allowing the main thread to respond to other requests; splitting the query information into a plurality of query sub-information, wherein each query sub-information is provided with a batch number, and the batch number is provided with data quantity information; querying result data corresponding to the data query request, including: determining the quantity of the completed information of the current completed inquiry according to the batch number, determining the quantity of the completed data of the current completed inquiry according to the quantity of the data corresponding to each quantity of the information, and determining the inquiry progress according to the quantity of the completed data and the quantity of the data to be inquired; after determining the query progress according to the completion data amount and the data amount to be queried, the method further comprises the steps of responding to a query result obtaining request, judging whether the completion data amount is equal to the data amount to be queried, calling a query progress message to obtain the current query progress under the condition that the completion data amount is not equal to the data amount to be queried, predicting the residual query time according to the current query progress, returning the query progress and the predicted residual query time, and returning the result under the condition that the completion data amount is equal to the data amount to be queried.
- 2. The method according to claim 1, wherein, in the case where the data query manner is an asynchronous query, querying result data corresponding to the data query request according to the data query manner and the query information, comprises: And generating an asynchronous message and a query progress message, wherein the asynchronous message is used for asynchronously querying result data corresponding to the data query request.
- 3. The method according to claim 1, wherein the method further comprises: and after inquiring the result data corresponding to the data inquiry request according to the data inquiry mode and the inquiry information, storing an inquiry service identifier and the result data in an associated mode, wherein the inquiry service identifier is determined according to the inquiry information.
- 4. A method according to claim 3, wherein the query service identity and the result data are stored in the form of key-value pairs.
- 5. The method according to claim 1, wherein the method further comprises: And under the condition that the data query mode is synchronous query, querying result data corresponding to the data query request according to the data query mode and the query information, wherein the step of synchronously querying query results corresponding to the data query request according to the data query mode and the query information, storing a query service identifier and the query results in an associated mode to obtain the result data, and then generating a message for indicating the completion of query, wherein the query service identifier is determined according to the query information.
- 6. An apparatus for querying data, comprising: the system comprises a data quantity acquisition module to be queried, a data query module and a data query module, wherein the data quantity acquisition module is used for responding to a data query request about house web sign information to acquire the data quantity to be queried and query information; The query mode determining module is used for comparing the data quantity to be queried with a preset quantity threshold value, and determining that the data query mode is asynchronous query under the condition that the data quantity to be queried is larger than the quantity threshold value, or determining that the data query mode is synchronous query; The storage record determining module is used for generating a query service identifier according to the query information acquired by the query request, and querying a corresponding storage record from a result set table of the query result stored in the query system according to the query service identifier; The data query module is used for querying the queried storage records corresponding to the query service identifier, and if the data query request does not have an aging requirement, the storage records are used as the result data corresponding to the data query request, or the result data corresponding to the data query request is queried according to the data query mode and the query information; If the data query request has an aging requirement, judging whether the aging of the data information in the storage record meets the aging requirement, if the aging of the data information meets the aging requirement, taking the storage record as result data corresponding to the data query request, and if the aging of the data information does not meet the aging requirement, querying the result data corresponding to the data query request according to the data query mode and the query information; Under the condition of inquiring result data corresponding to the data inquiry request according to the data inquiry mode and the inquiry information, the synchronous inquiry and the asynchronous inquiry realize the occupation and release of threads through a counter, the synchronous inquiry and the asynchronous inquiry respectively run on a main thread and a sub thread, and the counter of the main thread is initialized to be 1; when the data query mode is synchronous query, after the obtained query result and the corresponding query service identifier are stored in a result set in an associated manner, resetting the value of a counter of a main thread, releasing the main thread, and allowing the main thread to respond to other requests; splitting the query information into a plurality of query sub-information, wherein each query sub-information is provided with a batch number, and the batch number is provided with data quantity information; the data query module is further configured to: determining the quantity of the completed information of the current completed inquiry according to the batch number, determining the quantity of the completed data of the current completed inquiry according to the quantity of the data corresponding to each quantity of the information, and determining the inquiry progress according to the quantity of the completed data and the quantity of the data to be inquired; the query result acquisition module is used for judging whether the completion data amount is equal to the data amount to be queried or not according to the completion data amount and the data amount to be queried after determining the query progress, calling a query progress message to acquire the current query progress under the condition that the completion data amount is not equal to the data amount to be queried, predicting the residual query time according to the current query progress, returning the query progress and the predicted residual query time, and returning the result under the condition that the completion data amount is equal to the data amount to be queried.
- 7. The apparatus of claim 6, wherein the device comprises a plurality of sensors, The data query device further comprises a result data storage module, wherein the result data storage module is used for storing a query service identifier and result data in an associated mode after querying the result data corresponding to the data query request according to the data query mode and the query information, and the query service identifier is determined according to the query information.
- 8. A mobile electronic device terminal, comprising: One or more processors; storage means for storing one or more programs, When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
- 9. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-5.
- 10. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-5.
Description
Data query method and device Technical Field The present invention relates to the field of big data technologies, and in particular, to a method and an apparatus for querying data. Background With popularization and popularization of internet technology, web tag information of a house property is used as important evaluation information, and is not only used for house property transaction, but also used for aspects of seal checking, mortgage, specific crowd identification and the like. At present, the inquiry of personal web tag information generally adopts synchronous inquiry, and subsequent business processes are carried out after the inquiry result is obtained, and in certain functional institutions, the inquiry of multi-person batch web tag information is generally carried out by inputting all inquired person information at one time according to business requirements. In the process of implementing the present invention, the inventor finds that the following problems exist in the prior art: In the scenario of batch web label information inquiry, for the situation of large inquiry data volume, the increase of inquiry time consumption not only occupies more waiting time of users, but also can exceed the maximum response time set by the system, so that inquiry failure is caused, and inquiry efficiency and user experience are affected. Disclosure of Invention In view of the above, the embodiments of the present invention provide a method and an apparatus for querying data, which determine whether a data query mode is synchronous query or asynchronous query according to the amount of data to be queried obtained by a data query request, and then combine query information obtained by the query request to perform data query, so as to comprehensively consider the synchronous query and the asynchronous query, thereby expanding the applicable scenario of real estate web tag information query, avoiding the problems of low query efficiency and query failure caused by excessive query data amount, improving query efficiency and query success rate, and improving user experience. To achieve the object, according to an aspect of an embodiment of the present invention, there is provided a method for querying data, including: Responding to a data query request, and acquiring the data quantity to be queried and query information; comparing the data quantity to be queried with a preset quantity threshold value, and determining that the data query mode is asynchronous query under the condition that the data quantity to be queried is larger than the quantity threshold value, or determining that the data query mode is synchronous query; and inquiring result data corresponding to the data inquiry request according to the data inquiry mode and the inquiry information. Optionally, under the condition that the data query mode is asynchronous query, querying the result data corresponding to the data query request according to the data query mode and the query information comprises generating an asynchronous message and a query progress message, wherein the asynchronous message is used for asynchronously querying the result data corresponding to the data query request. Optionally, querying the result data corresponding to the data query request comprises splitting the query information into a plurality of query sub-information, performing data query according to each query sub-information to obtain a query result corresponding to the query sub-information, and generating the result data according to the query result corresponding to each query sub-information. Optionally, the method further comprises the step of storing a query service identifier and the result data in an associated mode after querying the result data corresponding to the data query request according to the data query mode and the query information, wherein the query service identifier is determined according to the query information. Optionally, the query service identification and the result data are stored in the form of key-value pairs. Optionally, the method further comprises the steps of inquiring result data corresponding to the data inquiry request according to the data inquiry mode and the inquiry information under the condition that the data inquiry mode is synchronous inquiry, synchronously inquiring inquiry results corresponding to the data inquiry request according to the data inquiry mode and the inquiry information, storing inquiry service identifiers and the inquiry results in an associated mode to obtain the result data, and then generating information for indicating inquiry completion, wherein the inquiry service identifiers are determined according to the inquiry information. Optionally, each inquiry sub-information is provided with a batch number, the batch number is provided with data volume information, after data inquiry is carried out according to each inquiry sub-information to obtain an inquiry result corresponding to the inquiry sub-informa