Query method and device of embedded database, storage medium and equipment

By sending access protocols and query requests based on the access protocols from the embedded database server, the problem of high development costs for embedded database access is solved, efficient data querying and updating are achieved, and memory resource consumption is reduced.

CN114661762BActive Publication Date: 2025-11-07ASIAINFO TECH (CHENGDU) INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210260229.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-16
Publication Date
2025-11-07
Estimated Expiration
2042-03-16

AI Technical Summary

Technical Problem

In existing technologies, the development cost of accessing embedded databases is relatively high, requiring developers to write a large amount of code to enable applications to access embedded databases.

Method used

By responding to the client's protocol format request on the server side, sending the embedded database access protocol, and generating a query request based on the access protocol, the server receives and processes the client's query request and directly sends the target data. The client only needs to send the protocol format request and the query request based on the access protocol, reducing development costs.

Benefits of technology

It reduces the development cost of client access to embedded databases, improves development efficiency, reduces memory resource consumption, and supports seamless querying during data updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661762B_ABST
    Figure CN114661762B_ABST
Patent Text Reader

Abstract

The application discloses a query method and device of an embedded database, a storage medium and equipment, relates to the technical field of embedded databases, and is used for reducing the development cost of a client accessing an embedded database. The method comprises the following steps: after a server receives a protocol format request sent by a client, the server sends an access protocol of an embedded database to the client. Then, the server receives a query request for querying target data sent by the client, and the query request is generated based on the access protocol. Further, the server judges whether the target data exists in the embedded database according to the query request; and in the case that the target data exists in the embedded database, the server sends the target data to the client.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of embedded database, and particularly relates to a query method and device of embedded database, a storage medium and equipment. BACKGROUND

[0002] As a kind of efficient compact database, embedded database is widely used in various electronic devices (such as smart phones, car navigation devices and set-top boxes). Embedded database can not only be embedded in the software of electronic device, but also can be embedded in the hardware structure of electronic device. At present, the operation of all data in embedded database by application program is carried out through application program interface (API).

[0003] In the above implementation mode, in order to realize the access of application program to embedded database, the developer needs to write a large amount of codes to realize the access of application program to embedded database when developing application program. Thus, the development cost of accessing embedded database is high. SUMMARY

[0004] The present application provides a query method and device of embedded database, a storage medium and equipment, which are used to reduce the development cost of client accessing embedded database.

[0005] In order to achieve the above purpose, the present application adopts the following technical scheme:

[0006] In a first aspect, a query method of embedded database is provided, which is applied to a server including embedded database, and the method comprises the following steps: in response to a protocol format request sent by a client, sending an access protocol of embedded database to the client; receiving a query request sent by the client; the query request is generated based on the access protocol; the query request is used to query target data in the embedded database; in response to the query request, judging whether the target data exists in the embedded database; in the case that the target data exists in the embedded database, sending the target data to the client.

[0007] The application provides a query method of an embedded database, which is applied to a server including an embedded database. The technical scheme of the application is based on a serialization protocol to access the embedded database. The server sends an access protocol of the embedded database to a client in response to a protocol format request sent by the client. The server receives a query request sent by the client, wherein the query request is generated based on the access protocol. In response to the query request, the server sends target data to the client in the case that the target data exists in the embedded database. In this way, the client only needs to obtain the access protocol of the embedded database and then sends a query request based on the access protocol, without the need of inputting a lot of codes to access the embedded database through each client, thereby reducing the development cost of the client to access the embedded database.

[0008] In a possible implementation, the method further includes: in the case that the Pattern file to be updated exists, generating a backup data set based on the Pattern file to be updated; and after the backup data set is generated, replacing the preset data set with the backup data set based on the backup data set. In this way, in the case that data is updated, the preset data set can still be used to query data in the process of generating a backup data set from the Pattern file to be updated. That is, data can still be queried without stopping the data query service when the data is updated. After the backup data set is generated after the data is updated, the backup data set is determined as the preset data set, thereby realizing the non-aware update.

[0009] In a possible implementation, the method further includes: in the case that the Pattern file to be updated exists, generating a backup data set based on the Pattern file to be updated; and after the backup data set is generated, replacing the preset data set with the backup data set based on the backup data set. In this way, in the case that data is updated, the preset data set can still be used to query data in the process of generating a backup data set from the Pattern file to be updated. That is, data can still be queried without stopping the data query service when the data is updated. After the backup data set is generated after the data is updated, the backup data set is determined as the preset data set, thereby realizing the non-aware update.

[0010] In a possible implementation, the determining whether the target data exists in the embedded database in response to the query request includes: determining whether the target data exists in the embedded database in response to the query request based on a single thread. In this way, the technical scheme of the present application uses a single thread to process the requirements of multiple clients, and obtains the target data of the requests of the multiple clients through multiplexing technology. Since the single thread technology is used, only one Pattern file needs to be loaded into the memory, thereby reducing the occupation of memory resources.

[0011] In a second aspect, a query method of an embedded database is provided, and the method is applied to a client. The method includes: generating a protocol format request, and sending the protocol format request to a server including an embedded database; the protocol format request is used to request an access protocol of the embedded database; receiving the access protocol sent by the server; generating a query request based on the access protocol, and sending the query request to the server; the query request is used to request querying target data in the embedded database; and receiving the target data sent by the server.

[0012] In a third aspect, a query device of an embedded database is provided, and the device is applied to a server including an embedded database. The device includes: a sending unit, a receiving unit and a determining unit. The sending unit is configured to send an access protocol of the embedded database to a client in response to a protocol format request sent by the client. The receiving unit is configured to receive a query request sent by the client after the sending unit sends the access protocol to the client. The query request is generated based on the access protocol. The query request is used to query target data in the embedded database. The determining unit is configured to determine whether the target data exists in the embedded database in response to the query request received by the receiving unit. The sending unit is further configured to send the target data to the client in the case that the target data exists in the embedded database.

[0013] In a possible implementation, the determining unit is specifically configured to: determine whether the query request includes a preset identifier in response to the query request. The preset identifier is used to indicate querying the target data from a preset data set included in the embedded database. The preset data set is obtained based on at least one Pattern file.

[0014] In the case that the query request includes the preset identifier, it is determined whether the target data exists in the preset data set.

[0015] In a possible implementation, the query device further includes: a generating unit and a replacing unit. The generating unit is configured to generate a backup data set based on a to-be-updated Pattern file in the case that the to-be-updated Pattern file exists. The replacing unit is configured to replace the preset data set based on the backup data set after the backup data set is generated.

[0016] In a possible implementation, the judging unit is specifically configured to judge whether the target data exists in the embedded database based on the single thread in response to the query request.

[0017] In a fourth aspect, a query device of an embedded database is provided, and the device is applied to a client. The device comprises a generating unit, a sending unit and a receiving unit. The generating unit is configured to generate a protocol format request. The protocol format request is used to request an access protocol of the embedded database. The sending unit is configured to send the protocol format request generated by the generating unit to a server. The server comprises the embedded database. The receiving unit is configured to receive the access protocol of the embedded database sent by the server after the sending unit sends the protocol format request to the server. The generating unit is further configured to generate a query request based on the access protocol received by the receiving unit. The query request is used to query target data in the embedded database. The sending unit is further configured to send the query request generated by the generating unit to the server. The receiving unit is further configured to receive the target data sent by the server.

[0018] In a fifth aspect, a computer readable storage medium is provided. The computer readable storage medium stores instructions. When the instructions are executed, the query method of the embedded database in the first aspect or the second aspect is implemented.

[0019] In a sixth aspect, a server is provided. The server comprises a processor, a memory and a communication interface. The communication interface is configured to communicate with devices and networks. The memory is configured to store one or more programs comprising computer execution instructions. When the server is running, the processor executes the computer execution instructions stored in the memory, so that the electronic device executes the query method of the embedded database in the first aspect.

[0020] In a seventh aspect, a client is provided. The client comprises a processor, a memory and a communication interface. The communication interface is configured to communicate with devices and networks. The memory is configured to store one or more programs comprising computer execution instructions. When the client is running, the processor executes the computer execution instructions stored in the memory, so that the electronic device executes the query method of the embedded database in the second aspect. BRIEF DESCRIPTION OF DRAWINGS

[0021] Figure 1 A structural schematic diagram of a query system of an embedded database provided for an embodiment of the application;

[0022] Figure 2 A flowchart of a query method of an embedded database provided for an embodiment of the application;

[0023] Figure 3Flowchart II of a query method of an embedded database according to an embodiment of the present application;

[0024] Figure 4 Flowchart III of a query method of an embedded database according to an embodiment of the present application;

[0025] Figure 5 Flowchart IV of a query method of an embedded database according to an embodiment of the present application;

[0026] Figure 6 Flowchart V of a query method of an embedded database according to an embodiment of the present application;

[0027] Figure 7 Flowchart VI of a query method of an embedded database according to an embodiment of the present application;

[0028] Figure 8 Structure diagram of a query device of an embedded database according to an embodiment of the present application;

[0029] Figure 9 Structure diagram of another query device of an embedded database according to an embodiment of the present application;

[0030] Figure 10 Structure diagram of a server according to an embodiment of the present application;

[0031] Figure 11 Structure diagram of a server according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, the same items or similar items with basically the same functions and effects are distinguished by using "first", "second", etc. For example, the first filtering strategy and the second filtering strategy are only used to distinguish different indication information, and do not limit the sequence. Those skilled in the art can understand that "first", "second", etc. do not limit the quantity and execution sequence, and "first", "second", etc. also do not necessarily mean different.

[0033] It should be noted that in the present application, "exemplary" or "for example" is used to represent an example, illustration or description. Any embodiment or design scheme described as "exemplary" or "for example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the use of "exemplary" or "for example" is intended to present the relevant concept in a specific manner.

[0034] In the present application, "at least one" means one or more, and "multiple" means two or more.

[0035] "and / or" describes the association relationship of associated objects, which means that there can be three kinds of relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b, or c can represent a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple. Before describing the embodiments of the present application, some concepts related to the embodiments of the present application are briefly introduced:

[0036] RESP: A serialization communication protocol based on a remote dictionary service (Redis), which can serialize different data types such as integers, strings, and arrays. In addition, the protocol is binary safe and does not need to handle the size of block data transmitted from one process to another, as it uses a prefix length method to transmit block data.

[0037] Pattern: A custom binary file that starts with a file header including a magic number, version information identification bits, etc., followed by a number of data segments storing data, and ends with attribute information of each data segment.

[0038] Embedded database: Unlike a database that can run independently as a daemon process, an embedded database runs in the same program as an application, with the advantages of customization and small size.

[0039] Localized query engine: A query engine that encapsulates encrypted Pattern as a locally built-in core data based on its own business logic, providing application programming interface (API) usage and implementation rules.

[0040] Dynamic library: Also known as dynamic link library (DLL), it is a library that contains code and data that can be used by multiple programs simultaneously. DLL is not an executable file.

[0041] Instance: An instance is a collection of "memory" and "background processes".

[0042] Hash table: composed of key-value, such as a key-value pair (Zhang San, 1318888999) in the hash table, "Zhang San" is the key, and 1318888999 is the value; the key and the value are both elements in the hash table.

[0043] A handle is a unique integer value used to identify different objects in an application and different instances of the same class, such as a window, button, icon, scroll bar, output device, control, or file.

[0044] The above is the introduction of some concepts involved in the embodiments of the application, which will not be described below.

[0045] With the rapid development of data storage, the scope of database application is more in-depth and specific. The database technology originally only applicable to personal computers, which is bulky and has a long delay, cannot meet the development needs of embedded systems with stronger pertinence. With the increasing memory and permanent storage medium capacity of embedded systems, the data processing capacity of embedded systems is also increasing. In order to process the increasing data, a new database product-embedded database is produced.

[0046] When developing each application program, the developer needs to input a lot of codes to obtain the related information of the embedded database interface; after obtaining the related parameters of the embedded database interface, the developer needs to input a lot of codes according to the related parameters of the embedded database, and these codes constitute operation instructions. Then, the embedded database is accessed through the embedded database interface according to the operation instructions. In this way, the development efficiency of the application program is low, and the development cost is increased.

[0047] In order to solve the above technical problems, the technical scheme of the present application is that the server sends the access protocol of the embedded database to the client in response to the protocol format request sent by the client. The server receives the query request sent by the client, wherein the query request is generated based on the access protocol. In response to the query request, the server sends the target data to the client in the case that the target data exists in the embedded database. That is, the technical scheme of the present application is that the developer encapsulates the API based on the access protocol on the query engine of the embedded database of the server. According to the query request based on the access protocol sent by the client, the server interacts with the embedded database through the API of the access protocol. In this way, the client only needs to send the protocol format request and the query request based on the access protocol to query the data of the embedded database, and does not need to input a lot of codes through the API of the embedded database to query the data, thereby reducing the development cost of the client accessing the embedded database.

[0048] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0049] The system architecture and business scenarios described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of network architecture and the appearance of new business scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0050] The query method of the embedded database applied in the embodiments of the present application can be applied to a query system. Figure 1 A structural schematic diagram of the query system is shown. As shown in the figure, the query system 10 is used to reduce the development cost of the client accessing the embedded database. The query system 10 includes a server 11 and a client 12. The server 11 and the client 12 can be connected in a wired manner or in a wireless manner, and the embodiments of the present application do not make a limitation in this regard. Figure 1 The server 11 can be a mobile terminal or a personal computer (PC) used by a user, such as a smart phone, a personal digital assistant (PDA), a tablet computer, a notebook computer, a carputer, smart glasses, a smart watch, a wearable device, a virtual display device or a display enhancement device (such as Google Glass, Oculus Rift, Hololens, Gear VR), etc.

[0051] The server 11 is used to receive a data query request sent by the client 12 and feed back the query result to the client 12. The server includes a storage module, which is used to store a Pattern file.

[0052] It should be noted that the server 11 and the client 12 can be independent devices or can be integrated in the same device, and the present application does not make a specific limitation in this regard.

[0053] When the client 12 and the server 11 are integrated in the same device, the communication mode between the server 11 and the client 12 is the communication between the internal modules of the device. In this case, the communication process between the two is the same as the communication process between the server 11 and the client 12 when they are independent of each other.

[0054] In the following embodiments provided by the present application, the server 11 and the client 12 are taken as an example to be described.

[0055]

[0056] ​In actual application, the query method of the embedded database provided by the embodiment of the present application can be applied to a server and can also be applied to an electronic device. In the following, the query method of the embedded database provided by the embodiment of the present application is described by taking the case that the query method of the embedded database is applied to a server as an example.

[0057] The query method of the embedded database provided by the embodiment of the present application is described. The actions and terms involved between the embodiments of the present application can be mutually referred to and are not limited. The message name or parameter name in the message exchanged between the devices in the embodiments of the present application is only an example, and other names can also be used in the specific implementation, which is not limited.

[0058] Figure 2 The query method of the embedded database provided by the embodiment of the present application is applied to a server and a client comprising an embedded database. The method comprises the following S201-S207.

[0059] S201, the client generates a protocol format request.

[0060] The protocol format request is used to request an access protocol of the embedded database.

[0061] As a possible implementation manner, the client generates the protocol format request based on the identification of the server and a preset message format.

[0062] For example, the preset message format can be a multi-protocol label switching (MPLS) message format, which is not limited by the embodiment of the present application.

[0063] It should be noted that the protocol format request is generated based on the data input by the user in the client. The input data at least comprises the identification of the server and the protocol format identification.

[0064] S202, the client sends the protocol format request to the server comprising the embedded database.

[0065] As a possible implementation manner, the client sends the protocol format request to the server based on a preset communication protocol.

[0066] For example, the preset communication protocol can be a user datagram protocol (UDP), and can also be a transmission control protocol (TCP), which is not limited by the embodiment of the present application.

[0067] Correspondingly, the server receives the protocol format request sent by the client.

[0068] It should be noted that the service end can be a redis service end or other types of service ends, and the embodiments of the present application are not limited

[0069] It can be understood that when a user as a program developer develops a program, a lot of code needs to be input to query the related parameter information of the API of the embedded database. In the present application, the user as a program developer encapsulates the query engine of the embedded database in the API generated based on the access protocol. Furthermore, when accessing the embedded database, the embedded database can be queried through the query request based on the access protocol. The client only needs to input a line of protocol format request instruction for querying the access protocol for accessing the embedded database before querying the embedded database.

[0070] Correspondingly, the service end receives the protocol format request sent by the client.

[0071] S203, the service end sends the access protocol of the embedded database to the client in response to the protocol format request sent by the client.

[0072] As a possible implementation manner, the service end acquires the access protocol of the embedded database according to the protocol format request sent by the client, generates a message containing the access protocol of the embedded database, and then sends the message containing the access protocol of the embedded database to the client.

[0073] It should be noted that the access protocol can be stored in the service end in advance. The service end can also determine the access protocol of the embedded database in real time. The embodiments of the present application are not limited.

[0074] Illustratively, the access protocol can be the Redis serialization protocol RESP.

[0075] Correspondingly, the client receives the access protocol of the embedded database sent by the service end.

[0076] S204, the client generates a query request based on the access protocol.

[0077] The query request is used to query the target data in the embedded database.

[0078] As a possible implementation manner, the client generates a query request based on the access protocol according to the access protocol.

[0079] It should be noted that the query request can include the identifier of the server and the query value corresponding to the target data in the embedded database.

[0080] Illustratively, the client generates a query request including "GET Zhang San" based on RESP.

[0081] S205, the client sends a query request to the server.

[0082] Correspondingly, the server receives the query request sent by the client.

[0083] S206, the server judges whether the target data exists in the embedded database in response to the query request.

[0084] As a possible implementation, after receiving the query request sent by the client, the server parses the query request and further obtains the identification of the target data. Further, the server queries whether the target data exists in the embedded database based on the identification of the target data through the query engine of the embedded database.

[0085] Illustratively, the server parses the query request sent by the client and parses out that the target data is "Zhang San". The server queries whether the target data corresponding to "Zhang San" exists in the embedded database through the query engine of the embedded database.

[0086] The specific implementation of this step can refer to the subsequent description of the embodiments of the application, which will not be described here.

[0087] S207, the server sends the target data to the client in the case that the target data exists in the embedded database.

[0088] As a possible implementation, the server obtains the target data in the case that the target data is queried. The server generates a data packet based on the target data and the identification of the client and sends the data packet to the client through a preset communication protocol.

[0089] Illustratively, the preset communication protocol is user datagram protocol (UDP), and can also be transmission control protocol (TCP), which is not limited by the embodiments of the application.

[0090] For example, based on the query request "GET Zhang San", the server queries the telephone number "198xxxxxxxx" corresponding to "Zhang San". The server obtains "198xxxxxxxx" and sends it to the client, and generates a data packet based on "198xxxxxxxx" and the identification "192.168.xxx.xxx" of the client. The server sends the data packet to the client through TCP.

[0091] As another case, if the embedded database does not include the target data, the server sends a query failure message to the client.

[0092] Correspondingly, the client receives the target data sent by the server.

[0093] The application provides a query method of an embedded database, which is applied to a server including an embedded database. The technical scheme of the application is based on a serialization protocol to access the embedded database. The server sends an access protocol of the embedded database to a client in response to a protocol format request sent by the client. The server receives a query request sent by the client, wherein the query request is generated based on the access protocol. In response to the query request, the server sends target data to the client in the case that the target data exists in the embedded database. That is, the technical scheme of the application is that a user who is a program developer encapsulates a query engine of the embedded database in an API generated based on the access protocol. According to a query request based on the access protocol sent by the client, the server interacts with the embedded database through the API of the access protocol. In this way, the client only needs to send a protocol format request and a query request based on the access protocol to query data of the embedded database, and does not need to input a lot of codes to query data through the query engine of the embedded database, thereby reducing the development cost of the client to access the embedded database.

[0094] In a design, in order to be able to judge whether target data exists in the embedded database, as shown in FIG. 6, the embodiment of the application provides S206, which can specifically include the following S2061-S2062. Figure 3

[0095] S2061, the server judges whether the preset identifier is included in the query request in response to the query request.

[0096] The preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database, and the preset data set is obtained according to at least one Pattern file.

[0097] As a possible implementation manner, the server parses the query request and judges whether the preset identifier is included in a preset field in the query request.

[0098] It should be noted that the preset identifier is defined in advance by the server and the client.

[0099] It can be understood that the file in which the embedded database of the application stores data is a Pattern file, so that the embedded database does not need to depend on a database service, and only needs to store the Pattern file and the dynamic library in which the query method is encapsulated. Therefore, the embedded database of the application only needs to be put into the server with the Pattern file and the dynamic library in which the query method is encapsulated, and does not need to migrate data in the database.

[0100] S2062, in the case that the preset identifier is included in the query request, the server judges whether the target data exists in the preset data set. ​

[0101] As a possible implementation manner, in the case that the preset identifier is included in the query request, the server parses the query key Key of the query request, and queries whether the target data corresponding to the query key exists in the preset data set based on the Key through the query engine of the embedded database.

[0102] Specifically, in the case that the preset identifier is included in the query request, the server needs to query the target data from the preset data set stored in the Pattern memory through the Pattern query engine.

[0103] The Pattern memory is a memory for storing the preset data set. The Pattern query engine is used to query the preset data set in the Pattern memory.

[0104] It should be noted that before the target data is queried from the preset data set in the Pattern memory through the Pattern query engine, the server needs to load the Pattern file and build the query engine. Figure 4 A flowchart for loading a Pattern file and building a query engine is shown, as shown in FIG. 1. Figure 4 The loading process of the Pattern file includes: S301, the server acquires the storage space occupied by the Pattern file, and based on the storage space occupied by the Pattern file, applies the Pattern memory for storing the Pattern file in the memory. The space of the Pattern memory is greater than the storage space occupied by the Pattern file. S302, the server loads the Pattern file into the Pattern memory. S303, the server decrypts the Pattern file based on the Pattern file, and calls the decryption algorithm corresponding to the Pattern file from the dynamic library to decrypt the Pattern file (the Pattern file is encrypted by the algorithm in the dynamic library). S304, the server judges whether the decryption of the Pattern file is successful. S305, if the decryption of the Pattern file is successful, the server constructs a hash table in the Pattern memory according to the categories of the contents in the Pattern file using the key-value Key-Value structure. If the server needs to construct a hash table for exact query, the Key is a determined value; if the server needs to construct a hash table for range query, the Key needs to include two kinds of information: the minimum value of the range and the maximum value of the range. S306, after the server constructs the hash table in the Pattern memory, it means that the query engine is successfully built this time. S307, if the decryption of the Pattern file fails, the initialization of the Pattern file fails. S308, the server exits the loading process of the Pattern file and returns an identifier indicating that the loading fails.

[0105] Furthermore, in this embodiment of the invention, after the server successfully constructs a hash table in the requested Pattern memory, the query engine built based on the hash table in Pattern memory can query the target data from the hash table in Pattern memory in two ways: exact query and range query.

[0106] In one scenario, if the query request is an exact query, i.e., querying the value of a specific key, the server will directly retrieve the value corresponding to that key from the hash table based on the key in the query request.

[0107] In another scenario, if the query request is a range query, meaning the query content falls within the maximum and minimum value range of a certain key, then a binary search is used. The server retrieves the corresponding value from the hash table in the Pattern memory based on the query value x in the query request. The keys in the hash table are arranged sequentially as [Key1, Key2, Key3... Key...]. n There are n keys in total, satisfying Key i [max] < Key i+1 [min], 1≤i≤n, Key i [max] is the maximum value in the range of the i-th Key. i+1 [min] is the minimum value in the range of the (i+1)th key.

[0108] like Figure 5 As shown, the binary search query process is as follows: S309, the server determines the query value x to be requested. S310, the server determines the current query sequence [Key1, Key2, Key3...Key... n Does it meet the Key requirement? low <Key mid Among them, Key low Key represents the minimum value in the query sequence. mid This represents the middle value of the query sequence. S311, if the Key is not satisfied... low <Key mid If the Key is satisfied, the server will terminate the query process. S312. low <Key mid Then the server determines whether x is in the Key. mid [min] to Key mid Within the range of [max], i.e., Key mid [min] < x < Key mid [max]. S313, If Key is satisfied... mid [min] < x < Key midIf [max], the server returns the Key. mid The corresponding Value is returned, and the query ends. S314. If the Key is not satisfied... mid [min] < x < Key mid [max], then if x < Key mid [min], the server updates the query sequence for this query, which includes [Key1, Key2, ..., Key]. [n / 2] ]

[0109] Key high and Key mid If x > Key mid [max], then the server updates the query sequence for this query, including [Key]. [n / 2] Key [n / 2]+1 ,...,Key n Key low and Key mid After multiple binary search queries, the key is found. mid [min] < x < Key mid [max], the server returns the Key. mid The corresponding Value is returned, ending the current query. Here, Key... high Key represents the maximum value of the query sequence. mid [min] represents Key mid Minimum value, Key mid [max] represents the Key mid The maximum value of Key mid =Key [n / 2] [*] indicates rounding down.

[0110] In another scenario, if the query request does not include a preset identifier, the server determines whether the target data exists in the server's dataset.

[0111] As one possible approach, if the query request does not include a preset identifier, the server determines whether the target data exists in the server's dataset based on the query value of the query request.

[0112] Subsequently, if the target data exists in the server's dataset, the server retrieves the target data and sends it to the client.

[0113] In one design, to enable data querying during data updates and achieve seamless updates of the embedded database, such as... Figure 6 As shown, the embedded database query method provided in this embodiment of the invention further includes the following steps S208-S211.

[0114] S208, the server detects whether there is a Pattern file to be updated.

[0115] As a possible implementation, the server periodically or in real time detects the identification of the Pattern file to be updated, and determines whether there is a Pattern file to be updated based on the identification of the Pattern file to be updated.

[0116] For example, the server periodically detects the value of the identification of the Pattern file to be updated. If the value of the identification of the Pattern file to be updated is "1", the server determines that there is a Pattern file to be updated. If the value of the identification of the Pattern file to be updated is "0", the server determines that there is no Pattern file to be updated.

[0117] S209, in the case where it is detected that there is a Pattern file to be updated, the server acquires the Pattern file to be updated.

[0118] As a possible implementation, in the case where it is determined based on the identification of the Pattern file to be updated that there is a Pattern file to be updated, the server acquires the Pattern file to be updated from the storage module.

[0119] S210, the server generates a backup data set based on the Pattern file to be updated.

[0120] As a possible implementation, after the server decrypts the Pattern file to be updated, the server loads the Pattern file to be updated into the memory, and generates a backup data set in the memory based on the Pattern file to be updated.

[0121] Specifically, for the Pattern file to be updated, the server loads the Pattern file to be updated into the memory using a reserved file handle, and generates a backup data set after the loading is successful.

[0122] It should be noted that the present application provides two file handles. One file handle is used as a current file handle to identify a preset data set. The other file handle is used as a reserved file handle to load the Pattern file to be updated when the Pattern file is updated.

[0123] In one case, in the process of generating a backup data set based on the Pattern file to be updated, the server determines whether a query request including a preset identification is received. If the server receives a query request including a preset identification, the server determines whether there is target data in the preset data set.

[0124] It can be understood that, since the data stored in the Pattern file has high business value and practicality, the server needs to frequently update the Pattern file. At present, the server cannot query data during the update of the Pattern file. Moreover, since the content of the Pattern file is encrypted, the server needs a long time to decrypt and load the updated Pattern file. Therefore, the user cannot query data for a long time. In the embodiment of the present application, in the case that the data in the Pattern file needs to be updated, for the Pattern file to be updated, the server can still query whether the target data exists through the preset data set during the process of loading the updated Pattern file into the memory. Therefore, during the update of the Pattern file, the data can still be queried.

[0125] In another case, during the process of generating the backup data set according to the Pattern file to be updated, if the server does not receive the query request including the preset identifier, the backup data set is generated.

[0126] S211, after the backup data set is generated, the server replaces the preset data set based on the backup data set.

[0127] Specifically, after the backup data set is generated by using the reserved file handle, the server sets the reserved file handle as the currently used handle. Correspondingly, the server sets the currently used handle used to identify the preset data set as the reserved file handle.

[0128] It can be understood that, the present application sets two file handles. One file handle is used as the currently used file handle to identify the preset data set. The other file handle is used as the reserved file handle. When the Pattern file is updated, the server loads the Pattern file to be updated by using the reserved file handle. Therefore, when the Pattern file to be updated is loaded by using the reserved file handle, the preset data set still exists in the memory. During the process of generating the backup data set, if the user needs to query data, the server queries data by using the preset data set. After the backup data set is generated, the server sets the reserved file handle as the currently used file handle. That is, the server determines the backup data set as the preset data set. Therefore, during the process of generating the backup data set, the user can also query data, and the update is realized without awareness.

[0129] Further, in order to make a complete description of the method shown in S208-S211, for example, Figure 7FIG. 4 is a flow chart illustrating another embodiment of the method for querying the embedded database according to the present application. S315, the server periodically or in real time detects whether there is an updated Pattern file. S316, if no updated Pattern file is detected, the server continues to use the current Pattern file. S317, if an updated Pattern file is detected, the server loads the updated Pattern file into the memory. The server determines whether the loading of the updated Pattern file is successful. S318, if the loading is unsuccessful, the server continues to use the current Pattern file. S319, if the loading is successful, the server generates a new data set, enables the new data set, and changes the pointer of the current data set to the pointer of the new data set. S320, the server stops using the current data set and releases the memory occupied by the current data set. S321, the server ends the updating process.

[0130] In one design, to reduce the memory resource occupation, the embodiment of the present application provides S206, which further includes the following S2063.

[0131] S2063, in response to the query request based on the single thread, the server determines whether the embedded database has the target data.

[0132] As one possible implementation, after receiving the multiple query requests, the server processes the multiple query requests based on the multiplexing technology and the single thread, so as to query the embedded database based on one query request each time to determine whether the embedded database has the target data.

[0133] For example, the server receives two query requests at the same time, and then puts the two query requests into the task queue of the single thread. Further, the server processes the query request 1 based on the single thread. After obtaining the query result of the query request 1, the server processes the query request 2 based on the single thread, and queries the embedded database based on the query request 2 to determine whether the embedded database has the target data.

[0134] It can be understood that, in order to query the embedded database with high performance, the user needs to start multiple query service instances on the server, and each instance needs to occupy a memory. This results in a large memory resource occupation. In the embodiment of the present application, the server processes the multiple query requests based on the multiplexing technology and the single thread, that is, the query thread only needs one. In this way, only one Pattern file needs to be loaded into the memory, thereby reducing the memory resource occupation.

[0135] More specifically, in order to test the effects of single-thread processing query requests and multi-thread processing query requests, the user of the program developer deploys single-thread processing mode and multi-thread processing query request mode on the server, and writes a test script on another server. Under the condition of the same concurrency (1500) and test time 1 hour, the performance of the two modes is shown in Table 1:

[0136] Table 1

[0137] Performance measurement Single-threaded processing Multi-threaded processing Average throughput 45623 30915

[0138] Based on the test results in Table 1, it can be seen that, in the embodiment of the application, the server uses multiplexing technology to process multiple query requests in single thread, which not only reduces the occupation of memory resources, but also improves the query performance and the average throughput.

[0139] The above mainly introduces the scheme provided by the embodiment of the application from the perspective of method. In order to realize the above functions, it contains the hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed in the present text, the embodiment of the application can be realized in the form of hardware or the combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driven hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiment of the application.

[0140] The embodiment of the application can divide the above device into functional modules according to the above method examples, for example, each functional module can be divided according to each function, or two or more functions can be integrated in one processing module. The above integrated module can be realized in the form of hardware or software functional module. Optionally, the division of the module in the embodiment of the application is illustrative, and is only a logical functional division. In actual implementation, there can be another division method.

[0141] Figure 8 A query device of an embedded database is provided in the embodiment of the application. As shown in Figure 8 , the query device 40 can be located in the above server. The query device 40 includes a sending unit 401, a receiving unit 402 and a judging unit 403.

[0142] The sending unit 401 is configured to send an access protocol of the embedded database to the client in response to a protocol format request sent by the client. For example, in combination with Figure 2 , the sending unit 401 can be configured to execute S203.

[0143] The receiving unit 402 is configured to receive a query request sent by the client after the sending unit sends the access protocol to the client; the query request is generated based on the access protocol; and the query request is used to query the target data.

[0144] The judging unit 403 is configured to judge whether the target data exists in the embedded database in response to the query request received by the receiving unit 402. For example, in combination with Figure 2 , the judging unit 403 can be configured to perform S206.

[0145] The sending unit 401 is further configured to send the target data to the client in the case that the target data exists in the embedded database. For example, in combination with Figure 2 , the sending unit 401 can be configured to perform S207.

[0146] Optionally, the judging unit 403 is specifically configured to judge whether the preset identifier is included in the query request in response to the query request; the preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database; the preset data set is obtained according to at least one Pattern file; and in the case that the preset identifier is included in the query request, it is judged whether the target data exists in the preset data set. For example, in combination with Figure 3 , the judging unit 403 can be configured to perform S2061-S2063.

[0147] Optionally, as shown in Figure 8 , the query device 40 further includes a generating unit and a replacing unit.

[0148] The query device further includes a generating unit 404 and a replacing unit 405.

[0149] The generating unit 404 is configured to generate a backup data set based on a to-be-updated Pattern file in the case that the to-be-updated Pattern file exists. For example, in combination with Figure 6 , the generating unit 404 can be configured to perform S210.

[0150] The replacing unit 405 is configured to replace the preset data set based on the backup data set after the backup data set is generated. For example, in combination with Figure 6 , the replacing unit 405 can be configured to perform S211.

[0151] Optionally, the judging unit 403 is further specifically configured to judge whether the target data exists in the embedded database in response to the query request based on single-thread. For example, the judging unit 403 can be configured to perform S2064.

[0152] Figure 9 A query device of an embedded database is provided for the embodiment of the application. As Figure 9As shown, the query device 50 can be located in the above-mentioned client. The query device 50 comprises a generating unit 501, a sending unit 502 and a receiving unit 503.

[0153] The generating unit 501 is configured to generate a protocol format request, wherein the protocol format request is used to request an access protocol of the embedded database. For example, in combination with Figure 2 The generating unit 501 can be configured to perform S201.

[0154] The sending unit 502 is configured to send the protocol format request generated by the generating unit 501 to a server, wherein the server comprises the embedded database. For example, in combination with Figure 2 The sending unit 502 can be configured to perform S202.

[0155] The receiving unit 503 is configured to receive an access protocol of the embedded database sent by the server after the sending unit sends the protocol format request to the server.

[0156] The generating unit 501 is further configured to generate a query request based on the access protocol received by the receiving unit 503, wherein the query request is used to query target data in the embedded database. For example, in combination with Figure 2 The generating unit 501 can be configured to perform S204.

[0157] The sending unit 502 is further configured to send the query request generated by the generating unit 501 to the server. For example, in combination with Figure 2 The sending unit 502 can be configured to perform S205.

[0158] The receiving unit 503 is further configured to receive the target data sent by the server.

[0159] In the case of implementing the functions of the above-mentioned integrated modules in the form of hardware, the embodiment of the present application provides a possible structural diagram of the server involved in the above-mentioned embodiments. As shown in the figure, the server 60 comprises a processor 601, a memory 602 and a bus 603. The processor 601 and the memory 602 can be connected through the bus 603. Figure 10

[0160] The processor 601 is the control center of the communication device, which can be one processor or a general term of multiple processing elements. For example, the processor 601 can be a general central processing unit (CPU), or other general-purpose processors, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0161] As an embodiment, the processor 601 can comprise one or more CPUs, for example Figure 10 ​CPU 0 and CPU 1 shown in FIG. 1.

[0162] The memory 602 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM), or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a magnetic disk storage medium, or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.

[0163] As one possible implementation, the memory 602 can exist independently of the processor 601, and the memory 602 can be connected to the processor 601 through the bus 603 for storing instructions or program code. When the processor 601 invokes and executes the instructions or program code stored in the memory 602, the sensor determination method provided by the embodiments of the present application can be implemented.

[0164] In another possible implementation, the memory 602 can also be integrated with the processor 601.

[0165] The bus 603 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, Figure 10 In FIG. 1, only one thick line is used to represent the bus, but this does not mean that there is only one bus or only one type of bus.

[0166] It should be noted that Figure 10 The structure shown does not constitute a limitation on the server 60. In addition to Figure 10 The server 60 can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0167] As an example, the function implemented by the determination unit 403 in the query device 40 is the same as the function of the processor 601 in the server 60. Figure 8 Figure 10 As an example, the function implemented by the determination unit 403 in the query device 40 is the same as the function of the processor 601 in the server 60.​

[0168] Optionally, the server 60 provided in this embodiment of the invention may further include a communication interface 604.

[0169] Communication interface 604 is used to connect with other devices via a communication network. This communication network can be Ethernet, a wireless access network, a wireless local area network (WLAN), etc. Communication interface 604 may include a receiving unit for receiving data and a transmitting unit for transmitting data.

[0170] In one design, the communication interface in the server provided by this embodiment of the invention can also be integrated into the processor.

[0171] Figure 11 Another hardware structure for the server in an embodiment of the present invention is shown. For example... Figure 11 As shown, the server 70 may include a processor 701 and a communication interface 702. The processor 701 is coupled to the communication interface 702.

[0172] The functions of processor 701 can be referred to in the description of processor 601 above. In addition, processor 701 also has storage functions, which can be referred to in the description of memory 602 above.

[0173] The communication interface 702 is used to provide data to the processor 701. The communication interface 702 can be an internal interface of the communication device or an external interface of the communication device.

[0174] It should be pointed out that, Figure 11 The structure shown does not constitute a limitation on server 70, except Figure 11 In addition to the components shown, the server 70 may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.

[0175] Meanwhile, the hardware structure diagram of the client provided in this embodiment of the invention can also be referred to the above. Figure 10 or Figure 11 The description of the server-side will not be repeated here.

[0176] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional units is used as an example. In practical applications, the above functions can be assigned to different functional units as needed, that is, the internal structure of the device can be divided into different functional units to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0177] The embodiment of the present application also provides a computer readable storage medium, which stores instructions, and when a computer executes the instructions, the computer executes each step in the query method flow of the embedded database shown in the method embodiment.

[0178] The embodiment of the present application also provides a computer program product containing instructions, which, when executed on a computer, cause the computer to execute the query method of the embedded database in the method embodiment.

[0179] The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a register, a hard disk, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any other suitable combination of the above, or any other form of computer readable storage medium. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. Of course, the storage medium can be a component of the processor. Suitable processors include, by way of example, both general and special purpose microprocessors. The processor can be coupled to memory, which can be the computer readable storage medium. The memory can be used for storing information and instructions for use by the processor. The exemplary memory can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), an erasable programmable read-only memory (EPROM), or a register. The exemplary storage medium can be, but is not limited to, a compact disc read-only memory (CD-ROM), a compact disc read / write (CD-R / W), a digital versatile disc (DVD), a Blu-ray disc, a magnetic disk, or another suitable medium of the like that is coupled to the processor by a suitable interface for providing instructions and data to and from the processor.

[0180] The server, the client, the computer readable storage medium, and the computer program product in the embodiment of the present application can be applied to the above method, and the technical effects that can be obtained are also referable to the method embodiment, which will not be described here in the embodiment of the present application.

[0181] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited to this, any change or replacement within the technical scope disclosed in the present application should be covered in the protection scope of the present application.

Claims

1. A query method of an embedded database, characterized by, The application is applied to a server including the embedded database, the embedded database stores a Pattern file and a dynamic library encapsulating a query method, and the method includes: In response to a protocol format request sent by a client through a preset communication protocol, an access protocol of the embedded database is sent to the client; the protocol format request is used to request the access protocol of the embedded database; A query request sent by the client is received; the query request is generated based on the access protocol; the query request is used to query target data in the embedded database; In response to the query request, it is judged whether the target data exists in the embedded database; In the case that the target data exists in the embedded database, the target data is sent to the client; In response to the query request, it is judged whether the target data exists in the embedded database, including: In response to the query request, it is judged whether the query request includes a preset identifier; the preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database; the preset data set is obtained according to at least one Pattern file; In the case that the query request includes the preset identifier, it is judged whether the target data exists in the preset data set.

2. The query method of claim 1, wherein, The method further includes: In the case that there is a Pattern file to be updated, a backup data set is generated based on the Pattern file to be updated; After the backup data set is generated, the preset data set is replaced based on the backup data set.

3. The query method of claim 1 or 2, characterized in that, In response to the query request, it is judged whether the target data exists in the embedded database based on a single thread. The application is applied to a client, and the method includes:

4. A query method of an embedded database, characterized by, A protocol format request is generated, and the protocol format request is sent to a server including the embedded database through a preset communication protocol; the protocol format request is used to request an access protocol of the embedded database; the embedded database stores a Pattern file and a dynamic library encapsulating a query method; The access protocol sent by the server is received; Based on the access protocol, a query request is generated, and the query request is sent to the server; the query request is used to request to query target data in the embedded database; the query request includes a preset identifier, and the preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database; the preset data set is obtained according to at least one Pattern file; The target data sent by the server is received. The application is applied to a server including the embedded database, the embedded database stores a Pattern file and a dynamic library encapsulating a query method, and the device includes a sending unit, a receiving unit and a judging unit; 5. An apparatus for querying an embedded database, characterized in that ​ The sending unit is configured to send, in response to a protocol format request sent by a client through a preset communication protocol, an access protocol of the embedded database to the client, where the protocol format request is used to request the access protocol of the embedded database. The receiving unit is configured to receive a query request sent by the client after the sending unit sends the access protocol to the client, where the query request is generated based on the access protocol, and the query request is used to query target data in the embedded database. The judging unit is configured to judge whether the target data exists in the embedded database in response to the query request received by the receiving unit. The sending unit is further configured to send the target data to the client in a case where the target data exists in the embedded database. The judging unit is specifically configured to: judge whether the preset identifier is included in the query request in response to the query request, where the preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database, and the preset data set is obtained according to at least one Pattern file; and judge whether the target data exists in the preset data set in a case where the preset identifier is included in the query request.

6. The query apparatus according to claim 5, wherein, The query device further includes a generating unit and a replacing unit. The generating unit is configured to generate a backup data set based on a to-be-updated Pattern file in a case where the to-be-updated Pattern file exists. The replacing unit is configured to replace the preset data set based on the backup data set after the backup data set is generated.

7. The query apparatus according to claim 5 or 6, characterized by The judging unit is further specifically configured to judge whether the target data exists in the embedded database in response to the query request based on single-threading.

8. An apparatus for querying an embedded database, characterized in that The device is applied to a client and includes a generating unit, a sending unit and a receiving unit. The generating unit is configured to generate a protocol format request, where the protocol format request is used to request an access protocol of an embedded database, and the embedded database stores a Pattern file and a dynamic library encapsulating a query method. The sending unit is configured to send the protocol format request generated by the generating unit to a server including the embedded database through a preset communication protocol. The receiving unit is configured to receive the access protocol sent by the server after the sending unit sends the protocol format request to the server. The generating unit is further configured to generate a query request based on the access protocol received by the receiving unit, where the query request is used to query target data in the embedded database, the query request includes a preset identifier, the preset identifier is used to indicate that the target data is queried from a preset data set included in the embedded database, and the preset data set is obtained according to at least one Pattern file. The sending unit is further configured to send the query request generated by the generating unit to the server. The receiving unit is further configured to receive the target data sent by the server.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores instructions which, when executed by an electronic device, enable the electronic device to perform the query method of the embedded database as claimed in any one of claims 1 to 3 or claim 4.

10. A server, characterized by, Comprise: a processor, a memory and a communication interface; wherein the communication interface is used for communication of the communication device and other devices or network communication; The memory is used for storing one or more programs, the one or more programs comprising computer execution instructions, when the server is running, the processor executes the computer execution instructions stored in the memory, so that the server executes the query method of the embedded database as claimed in any one of claims 1 to 3.

11. A client, characterized in that, Comprise: a processor, a memory and a communication interface; wherein the communication interface is used for communication of the communication device and other devices or network communication; The memory is used for storing one or more programs, the one or more programs comprising computer execution instructions, when the server is running, the processor executes the computer execution instructions stored in the memory, so that the server executes the query method of the embedded database as claimed in any one of claims 1 to 3. Comprise: a processor, a memory and a communication interface; wherein the communication interface is used for communication of the communication device and other devices or network communication; The memory is used for storing one or more programs, the one or more programs comprising computer execution instructions, when the server is running, the processor executes the computer execution instructions stored in the memory, so that the server executes the query method of the embedded database as claimed in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Remote access method and device for embedded database, equipment and medium

    CN112351053A

  • Method and device for reconstructing data from file system to object storage

    CN113157209A