Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
In order to better realize index management, the embodiment of the application provides an index management system to realize independent deployment of index service and data service. In an embodiment, the index service and the data service may be provided by two independent devices, and referring to fig. 1a, the index management system provided in the embodiment of the present application may include an index device and an index management device, where the index device is configured to provide the index service, such as creating an index, modifying an index, and accessing an index, and the index management device is configured to provide the data service, such as reading and writing data. Specifically, the index management device may be deployed with a database for storing data, which may be a tcaplus database (also called tcaplus data base, tcaplus DB, Key-value database (KV database) developed by Tencent).
The indexing equipment can be deployed with an indexing system, and the indexing system deployed on the indexing equipment can be used for realizing the management of indexes, wherein the indexing system stores a plurality of indexes established according to fields and data synchronized to the indexes from a database in the indexing management equipment.
In addition, the index management system may further include a first terminal device and a second terminal device. The first terminal device is a service terminal, and is configured to provide a data query service and perform an operation on data, such as writing data, updating data, or deleting data. For example, in a financial transaction, when a transaction is paid, data related to the transaction needs to be written. For another example, in an application data storage service, when an application (e.g., an application game) receives an account registration request, data writing operation needs to be performed on account data related to the request. The second terminal device is an index terminal for index management, and is used for providing index services such as index creation, modification, reconstruction or deletion.
In another embodiment, the index service and the data service can be provided by the same device, for example, a database and an index system are deployed on the index management device through two independent processes, the database is used for providing the data service, and the index system is used for providing the index service. The index management system under this embodiment can be as shown in FIG. 1 b.
It should be understood that fig. 1a and 1b are only exemplary to represent the architecture of the index management system, and do not limit the specific architecture of the index management system. For convenience of illustration, the index management system mentioned later is illustrated by taking the index management system shown in fig. 1a as an example unless otherwise specified.
In an embodiment, applicable to the index management system shown in fig. 1a, an embodiment of the present application proposes an index management method, which may be executed by an index management device, an index device, a first terminal device, and a second terminal device, and referring to fig. 2, an interaction flow of the index management method may include the following steps:
s201, the second terminal device sends an index creating request aiming at the target field to the index management device.
S202, the index management equipment generates index indication information according to the index creation request and sends the index indication information to the index equipment.
S203, the index device creates a target index corresponding to the target field according to the indication of the index indication information.
S204, the index management equipment acquires historical data associated with the target field from the database and sends a first index synchronization request carrying the historical data to the index equipment.
S205, the index device synchronizes the historical data to the target index according to the indication of the first index synchronization request.
S206, after the historical data synchronization is completed, the index device returns a synchronization completion instruction to the index management device.
S207, the second terminal device sends a modification request aiming at the target field to the index management device, and the modification request comprises an index update field aiming at the target index.
And S208, the index management equipment generates an index updating request aiming at the target index according to the modification request and sends the index updating request to the index equipment.
S209, the index device receives the index updating request, creates a new index according to the index updating field, and deletes the target index.
S210, the index device returns index switching indication information to the index management device.
S211, the index management device receives the index switching indication information and switches the access of the target index to the new index according to the indication of the index switching indication information. The detailed implementation process of the above steps S201 to S211 can be referred to the following related description of steps S601 to S603.
S212, the first terminal device sends a data query request to the index management device.
S213, the index management device forwards the data query request to the index device.
S214, the index device queries query data meeting the query conditions according to the indication of the data query request.
S215, the index device returns the query data to the index management device.
S216, the index management device receives the returned query data, determines a data query type corresponding to the data query request, and determines target data according to the data query type and the query data.
S217, the index management device returns the target data to the first terminal device. The detailed implementation process of the above steps S212-S217 can refer to the following description of steps S301-S304.
By implementing the technical scheme of the application, the index can be created or modified so as to realize the management of the index and reduce the influence on the data service, the normal access of the original index can be ensured when the index is modified, and the query speed and efficiency can be accelerated by accessing the index when the data is queried.
In addition, the above-mentioned index management apparatus and index apparatus may be servers; the server mentioned here may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and artificial intelligence platform, and the like. And, the first terminal device and the second terminal device mentioned above may be, but are not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like. It is understood that, as the platform applied by the above proposed system is different, the corresponding terminal device may also be different accordingly. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein. The technical scheme provided by the embodiment of the application can realize the query of the data stored in the database and improve the data query efficiency through the index system. The Database (DB), which may be regarded as an electronic file cabinet in short, stores electronic files, and can perform operations such as adding, querying, updating, and deleting data in the files. A "database" is a collection of data that is stored together in a manner that can be shared by multiple users, has as little redundancy as possible, and is independent of the application. In addition, a Database Management System (DBMS) may be deployed in the index Management device, and the DBMS is a computer software System designed for managing a Database and generally has basic functions of storage, interception, security assurance, backup and the like. The database management system may be categorized according to the database model it supports, such as relational, Extensible Markup Language (XML); or classified according to the type of computer supported, e.g., server cluster, mobile phone; or classified according to the Query Language used, such as Structured Query Language (SQL), XML data Query Language (XQuery); or by performance impulse emphasis, e.g., maximum size, maximum operating speed; or other classification schemes. Regardless of the manner of classification used, some DBMSs are capable of supporting multiple query languages across categories, for example, simultaneously.
Optionally, data related to the present application, such as data in a database, and/or data in an index system, may be stored in a blockchain, such as by a blockchain distributed system, which is not limited in the present application.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer. The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after consensus on the valid request is completed, for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the service information to a shared account (network communication) completely and consistently after encryption, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme for the business participants to use. For example, in the present application, a data storage function may be provided through a blockchain, and the stored data may be provided to an advertiser, a data platform, and the like.
It can be understood that the index management scheme proposed in the embodiment of the present application can be applied to any scenario in which data needs to be queried or indexes need to be managed. The application scenario is not limited in the embodiment of the present application, and with the evolution of the system architecture and the appearance of a new service scenario, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
Based on the above description, the present application embodiment proposes a method for index management, which is applied to the above-mentioned index management device. As shown in fig. 3, a flow of the index management method in the embodiment of the present application may include:
s301, a data query request from the first terminal device is forwarded to the index device, and the data query request is used for indicating the index device to query data meeting conditions.
The index management device may include an access layer and a storage layer, where the access layer is configured to receive or forward a request from a first terminal device or a second terminal device, and is configured to receive or forward data from the storage layer or the index device; the storage layer is used for storing data.
In a possible implementation manner, when a first user wants to perform data query, the first user may send a data query request to the index management device through the first terminal device of the first user, and an access layer of the index management device forwards the data query request to the index device after receiving the data query request. The first user may be a user facing a service applied by the first terminal device.
And S302, receiving the query data returned by the indexing equipment.
In a possible implementation manner, the access layer of the index management device receives the query data returned by the index device. The specific way for the index device to obtain the query data may be that when the index device receives the data query request, the index device analyzes the data query request to obtain the query conditions and the corresponding data query types included in the data query request, and obtains the query data according to the query conditions and the data query types, and the index device sends the query data to the index management device after obtaining the query data. Further, the index device may send information of the data query request when sending the query data, where the information includes a data query type of the data query request.
In a possible implementation manner, a specific implementation manner of acquiring, by the indexing device, the query data according to the query condition and the data query type may be that, if the data query type of the data query request is an aggregated query type, an aggregated value meeting the query condition is acquired from the indexing system, and the aggregated value is determined as the query data. When the data query request is to query data associated with the indexed fields and obtain a value through calculation, the data query type of the data query request is an aggregated query type, for example, the aggregated query may include a total number of queries (count), a sum of queries (sum), a minimum number of queries (min), a maximum number of queries (max), an average number of queries (avg), and the like.
In a possible implementation manner, the index device may obtain the aggregation value meeting the query condition from the index system specifically by calculating the queried data through an aggregation function, so as to obtain the aggregation value meeting the query condition. It should be noted that only if all the query fields in the data query request are fields with indexes already established, it is further determined whether the query type of the data query request is the aggregation query type. The aggregation function may include, among others, count () (for calculating the total), sum () (for calculating the total), min () (for calculating the minimum), max () (for calculating the maximum), avg () (for calculating the average).
For example, the data table stores transaction record information, and fields therein have "transaction object", "transaction amount", "transaction time", "transaction channel", and indexes are established for the fields "transaction object" and "transaction amount", when the query condition in the data query request is how many people query the transaction amount "X", since the field "transaction amount" establishes the index, and the total number of people of the transaction amount "X" can be calculated by using the aggregation function count (), the data query type is the aggregation query type, and the aggregation value obtained by the aggregation function count () is used as query data; or when the query condition in the data query request is the total transaction amount of the query transaction object "a", because the fields "transaction object" and "transaction amount" both establish indexes and the aggregation function sum () can be used to calculate the total transaction amount of the transaction object "a", the data query type is the aggregation query type, and the aggregation value obtained by the aggregation function sum () is used as query data; or when the query condition in the data query request is the transaction time corresponding to the query maximum transaction amount, the data query type is a non-aggregation query type because the field 'transaction time' does not establish an index; or, when the query condition in the data query request is to query the complete transaction record with the transaction object "a", although the field "transaction object" establishes the index, since the query is not a numerical value, the aggregation function cannot be used for calculation, and thus the data query type is a non-aggregation query type.
In a possible implementation manner, a specific implementation manner of acquiring query data by the index device according to the query condition and the data query type may be that, if the data query type of the data query request is a non-aggregated query type, key value data meeting the query condition is acquired from the index system, and the key value data is determined as the query data. The key-value data is used for acquiring corresponding value data from the database. It is to be understood that the data query request is a non-aggregated query as long as it does not satisfy the requirements of the aggregated query. For example, the non-aggregated query may be a conditional query, and the conditional query may include a range query and a fuzzy query, where the range query is a query according to a specified range, and the fuzzy query is a query according to a keyword.
For example, the data table stores transaction record information, and fields therein have "transaction object", "transaction amount", "transaction time" and "transaction channel", and an index is established for the fields "transaction object" and "transaction amount", and when the query condition in the data query request is to query the complete transaction record for which the query transaction object is "a", the query is performed according to the keyword "a" in the index corresponding to the field "transaction object", and key value data meeting the condition is returned, which is fuzzy query, i.e. non-aggregated query; or when the query condition in the data query request is to query the complete transaction record with the transaction amount between 100 and 200, the query is performed in the index corresponding to the field transaction amount according to the range of x being more than or equal to 100 and less than 200, and the key value data meeting the condition is returned, which is range query, i.e. non-aggregated query.
S303, determining a data query type corresponding to the data query request, and determining target data according to the data query type and the query data.
Optionally, the index management device may determine the data query type corresponding to the data query request when receiving the data query request sent by the first terminal device, or may determine the data query type corresponding to the data query request when receiving query data returned by the index device, that is, may determine the data query type by receiving information of the data query request that is returned by the index device when returning the query data. The embodiments of the present application are not limited thereto.
In one possible implementation, the data query type is an aggregate query type, and the query data is an aggregate value that satisfies the query condition, and the query data is determined as the target data. Specifically, the access layer of the index management device determines that the data query type is an aggregated query type, and determines query data returned by the index device as target data when receiving the query data.
For example, as shown in fig. 4, fig. 4 is a specific process of determining target data when the data query type is an aggregation query type, a first user sends a data query request that the data query type is the aggregation query type to an index management device through a first terminal device, an access layer of the index management device receives and forwards the data query request to the index device, the index device obtains query data that satisfies the query request according to the data query request and returns the query data to the data query device, the query data is an aggregation value obtained by the index device by calculating data queried in an index system, and the access layer of the index management device receives the query data and determines the query data as the target data when the data query type is determined to be the aggregation query type.
In a possible implementation manner, the data query type is a non-aggregated query type, the query data is key-value data meeting the query condition, the value data corresponding to the key-value data is acquired from the database, and the value data is determined as the target data. Specifically, the access layer of the index management device determines that the data query type is a non-aggregated query type, and when receiving query data returned by the index device, sends a data acquisition request to the storage layer, the storage layer acquires, according to the data acquisition request, value data corresponding to the key-value data from the database, and returns the value data, and when receiving the value data, the access layer determines that the value data is the target data.
For example, as shown in fig. 5, fig. 5 is a specific process of determining target data when the data query type is a non-aggregation query type, a first terminal device sends a data query request that the data query type is the non-aggregation query type to an index management device, an access layer of the index management device receives and forwards the data query request to the index device, the index device obtains query data that satisfies the query request according to the data query request and returns the query data to the data query device, the query data is key-value data that satisfies query conditions and is obtained by the index device through query, the access layer of the index management device receives the query data and sends a data acquisition request to a storage tier when determining that the data query type is the non-aggregation query type, the data acquisition request is used to instruct the storage tier to acquire value data corresponding to the key-value data from a database, and returning value data, and the access stratum determines the value data as target data when receiving the value data returned by the storage layer.
S304, returning the target data to the first terminal device.
In a possible implementation manner, the index management device may specifically return the target data to the first terminal device, where the access layer of the index management device receives the target data from the index device or the storage layer in the index management device, and returns the target data to the first terminal device.
In the embodiment of the application, the index management device forwards a data query request from the first terminal device to the index device, receives query data returned by the index device, determines a data query type corresponding to the data query request, determines target data according to the data query type and the query data, and returns the target data to the first terminal device. By implementing the method, the influence on the data read-write service during the index access can be effectively reduced in the data query process.
Fig. 6 is a method for index management according to an embodiment of the present application, and the method is applied to the above-mentioned index management device. As shown in fig. 6, the flow of the index management method in the embodiment of the present application may include:
s601, generating index indication information according to the index creation request aiming at the target field sent by the second terminal device, and sending the index indication information to the index device.
The index indication information is used for indicating the index device to create a target index corresponding to the target field. The target field is one or more fields stored in a target data table of the database.
In one possible implementation, the index needs to be created in advance before the data query is implemented by accessing the index. The data is stored in the database in the form of data tables, in order to accelerate the speed of inquiring the data, indexes are built on the data tables, one data table corresponds to one index, one index can correspond to one or more fields, and when the fields for building the indexes are selected, the fields with higher inquiring times are generally selected, for example, for the data tables for storing transaction record information, the data tables are generally inquired through transaction objects or transaction amounts, so that the indexes can be built for the fields of transaction objects and transaction amounts, and inquiry can be rarely carried out through transaction channels, so that the indexes do not need to be built for the fields of transaction channels.
In a possible implementation manner, when an index needs to be created for the target data table, the second user may select a target field needing to create the index in the target data table through a creation page provided by the second terminal device, and initiate an index creation request for the target field, and after receiving the index creation request, the index management device generates index indication information and sends the index indication information to the index device. The second user may be a backend technician corresponding to the service applied by the first terminal device. For example, as shown in fig. 7, when an index needs to be created, the second user first selects a data table for which the index needs to be created on a creation page provided by the second terminal device and selects a target field from the data table, and when a plurality of fields are selected, may click the "+" button to add the field and initiate an index creation request by clicking the "submit" button. Optionally, the second user may create an index to an existing data table in the database, or may create an index for the table when creating the data table. In addition, the second user may CREATE the INDEX by a command, for example, using the command "CREATE INDEX", in addition to creating the INDEX by creating the page.
S602, acquiring historical data associated with the target field from the database.
In one possible implementation, when an index is created for a target data table in a database, the index management device may obtain historical data associated with the target field from the database. The history data may be referred to as stock data. Optionally, the obtaining of the historical data associated with the target field may specifically be traversing data of a target data table in the database, and obtaining data corresponding to the target field from the data.
Optionally, the index management device may obtain the history data associated with the target field from the database after generating the index indication information according to the index creation request for the target field sent by the second terminal device and sending the index indication information to the index device, or may obtain the history data associated with the target field from the database while generating the index indication information according to the index creation request for the target field sent by the second terminal device and sending the index indication information to the index device. The embodiments of the present application do not limit this.
S603, sending a first index synchronization request carrying historical data to the index device.
The first index synchronization request is used for indicating the index device to synchronize the historical data to the target index, and after the historical data synchronization is completed, a synchronization completion instruction is returned to the index management device. It is understood that when the index management device receives the synchronization completion instruction, it indicates that the target index creation is completed.
Further, in a possible implementation manner, after the index management device sends the index synchronization request carrying the historical data to the index device, and before the index management device detects the synchronization completion instruction, that is, in the process of creating the target index and synchronizing the historical data, there may be a case where data is written into the target data table, that is, if the index management device receives the data write request from the first terminal device, the data to be written carried in the data write request is obtained, the data to be indexed associated with the target field is obtained from the data to be written, and a second index synchronization request carrying the data to be indexed is sent to the index device. At this time, the data to be indexed before the creation of the target index is completed may also be referred to as incremental data. And the second index synchronization request is used for indicating the indexing equipment to synchronize the data to be indexed to the target index, and returning a write-in data synchronization completion instruction after the data to be indexed is synchronized.
Optionally, a specific implementation manner of acquiring, by the index management device, the data to be indexed associated with the target field from the data to be written may be that the index management device needs to write the data to be written into a data table of the database, and if the written data table is the target data table, acquire data corresponding to the target field in the data to be written, and determine data corresponding to the target field in the data to be written as the data to be indexed. It is understood that when the index management device receives the synchronization completion instruction and the write data synchronization completion indication, the target index creation is completed. Further, after the index management device determines that the target index creation is completed, an index creation success message may be returned to the second terminal device, where the index creation success message is used to notify the second user that the target index creation is completed.
In a possible implementation manner, after the target index is created, if the index management device receives a data write request from the first terminal device, the data to be written carried in the data write request is acquired, the data to be indexed associated with the target field is acquired from the data to be written, and a third index synchronization request carrying the data to be indexed is sent to the index device. At this time, the data to be indexed after the creation of the target index is completed is also referred to as normal data. The third index synchronization request is used for instructing the indexing equipment to synchronize the data to be indexed to the target index. The specific manner of acquiring the data to be indexed after the target index is created may refer to the related description of acquiring the data to be indexed before the target index is created, and details are not repeated here. It should be noted that, when the index management device obtains the write result in response to the data write request, the write result is returned to the first terminal device, and it is not necessary to wait for the data to be synchronized to the target index and then return the data.
For example, as shown in fig. 8, fig. 8 is a specific process of creating an index, a second user initiates an index creation request through a creation page provided by a second terminal device, and when receiving the index creation request, an index management device generates index indication information and completes synchronization of two types of data in the figure, that is, synchronization of history data and incremental data, which indicates that the index creation is successful, and after the index creation is completed, synchronization of normal data is performed.
For another example, as shown in fig. 9, fig. 9 is a specific process of normal data synchronization, where a first user initiates a data write request through a first terminal device, and when acquiring normal data related to the data write request, an index management device synchronizes the normal data to an index of an index system in real time.
It is understood that, the above only takes the first user initiating the data writing request as an example, and does not limit the operation of the first user, and the first user may also initiate a data updating request and a data deleting request. When the first user initiates a data update request or a data delete request, the steps performed by the index management apparatus may refer to the steps performed when the first user initiates a data write request.
Illustratively, taking the target index as an example after being created, when a first user initiates a data update request, obtaining update data carried in the data update request, updating, by an index management device, a data table in a database according to the update data, obtaining updated target field associated data if the target field associated data in the target data table is updated, and sending an index update request carrying the updated target field associated data to an index device, where the index update request is used to instruct the index device to update the target index according to the updated target field associated data. For example, the data table stores transaction record information, and the fields therein have "transaction object", "transaction amount", "transaction time" and "transaction channel", and an index is established for the fields "transaction object" and "transaction amount", and when the data update request is "transaction amount" for which the transaction object is "a", the index update request carrying the transaction amount data to be updated is sent to the index device, and the index device updates the corresponding transaction amount in the index. In addition, when the index management device responds to the data updating request to obtain the updating result, the updating result is returned to the first terminal device, and the index management device does not need to wait for updating the target index and then return.
Illustratively, taking the target index as an example after being created, when a first user initiates a data deletion request, obtaining data to be deleted carried in the data deletion request, deleting data in a data table according to the data to be deleted by an index management device, if the data table is a target data table, obtaining target field associated data to be deleted, and sending an index deletion request carrying the target field associated data to be deleted to an index device, where the index deletion request is used to instruct the index device to delete the data in the target index according to the target field associated data to be deleted. For example, the data table stores transaction record information, and the fields therein have "transaction object", "transaction amount", "transaction time" and "transaction channel", and an index is established for the fields "transaction object" and "transaction amount", when the data deletion request is to delete the transaction record of which the transaction object is "a", the index deletion request carrying the transaction object and the transaction amount data to be deleted is sent to the indexing device, and the indexing device deletes the corresponding transaction object and the transaction amount data in the index. In addition, when the index management device responds to the data deletion request to obtain a deletion result, the deletion result is returned to the first terminal device, and the index management device does not need to wait for the deletion of the data in the target index and then return the data.
In one possible embodiment, an index may be created for one or more fields in the data table when the index is created, and the created index may need to be modified when one or more fields need to be added or subtracted. For example, the fields of the established index are "a" and "B", and when the field "C" needs to be added or the field "a" needs to be deleted, the established index needs to be modified. Taking a modification example of the target index, after the target index is created, the second user may initiate a modification request for the target index to the index management device, and the index management device modifies the target index according to the modification request.
Optionally, the initiating, by the second user, the modification request for the target index to the index management device may specifically be that the second user selects an update field of the target index through a modification page provided by the second terminal device, and sends the modification request for the target index to the index management device, where the modification request includes an index update field for the target index.
Optionally, the index management device may specifically modify the target index according to the modification request, where the index management device generates an index update request according to the modification request, and the index update request is used to instruct the index device to: and when the index management equipment receives the index switching indication information, the access to the target index is switched to the new index according to the indication of the index switching indication information. The specific way of creating a new index according to the index update field may refer to the above-mentioned related steps of creating a target index according to the target field, which is not described herein again.
It will be appreciated that the target index modification is complete when the target index is deleted and access is switched to the new index. Further, after the index management device determines that the target index modification is completed, an index modification success message may be returned to the second terminal device, where the index modification success message is used to notify the second user that the target index modification is completed. For example, as shown in fig. 10, when the index needs to be modified, the second user first selects the index that needs to be modified and the index update field corresponding to the index on the modification page provided by the second terminal device, and when there are multiple index update fields, the "+" button addition field may be clicked, and the index modification request may be initiated by clicking "submit".
Optionally, the second user may also initiate an index deletion request or an index reconstruction request to the index management device through the second terminal device. The index deletion request is used for enabling the index management equipment to generate index deletion indication information and sending the index deletion indication information to the index equipment, and the index deletion indication information is used for indicating the index equipment to delete the specified index; the index reconstruction request is used to enable the index management device to generate index reconstruction indication information and send the index reconstruction indication information to the index device, where the index reconstruction indication information is used to indicate the index device to recreate the existing index, and the specific manner of reconstructing the existing index by the index device may refer to the above-mentioned related steps of creating the target index according to the target field, which is not described herein again.
For example, as shown in fig. 11, fig. 11 is a specific process of modifying an index, where a second user initiates a modification request for a target index through a modification page provided by a second terminal device, an index management device instructs an index device to create a new index and delete the target index after receiving the modification request, and the index management device switches access to the target index to the new index, which indicates that the index modification is successful.
S604, a data query request from the first terminal device is forwarded to the index device, and the data query request is used for indicating the index device to query data meeting the conditions.
And S605, receiving the query data returned by the index device.
S606, determining a data query type corresponding to the data query request, and determining target data according to the data query type and the query data.
S607, the target data is sent to the first terminal device. For specific implementation of steps S604 to S607, refer to steps S201 to S204 in the above embodiment.
Optionally, in a possible implementation, the target data may also be directly obtained from the database by the storage layer of the index management device according to the data query request. After the index is created, the data can be queried by accessing the index, so that the query efficiency is improved. However, since the index is only created for one or more fields in the data table, the index is not created for all the fields, that is, when the index management device receives the data query request from the first terminal device, the index management device may determine the query field corresponding to the data query request, if the corresponding query field is a field for which the index is already established, the steps S604 to S607 are performed, and if the corresponding query field is not a field for which the index is already established, the index management device forwards the data query request from the first terminal device to the database. For example, the data table stores transaction record information, and the fields therein have "transaction object", "transaction amount", "transaction time", "transaction channel", and indexes the fields "transaction object" and "transaction amount", when the field related to the query condition in the data query request is "transaction amount", such as query total transaction amount, the data query request is forwarded to the index device, and when the field related to the query condition in the data query request does not have the indexed field, such as query transaction channel is "WX" for all transaction records, the data query request is forwarded to the database.
In a possible implementation manner, a specific implementation manner of forwarding the data query request from the first terminal device to the database may be that, when the access layer of the index management device receives the data query request and determines that the corresponding query field is not a field in which an index is established, a data query instruction is generated and sent to the storage layer, where the data query instruction is used to instruct the storage layer to query data in the database and obtain target data meeting a query condition.
Further, if the query field includes a plurality of fields, and there are fields with indexes established and fields without indexes established, the access layer of the index management device may forward the data query request to the index device to obtain query data meeting a part of query conditions, where the query data is key value data, and then generate a data query instruction carrying the query data, and send the data query instruction carrying the query data to the storage layer, where the data query instruction carrying the query data is used to instruct the storage layer to query data in the database according to the query data, and obtain target data meeting the query conditions from the data query instruction. For example, the data table stores transaction record information, and the fields therein are "transaction object", "transaction amount", "transaction time", "transaction channel", and the fields "transaction object" and "transaction amount" are indexed, when the query condition in the data query request includes fields of "transaction object" and "transaction time", such as how much the transaction time of the query transaction object is "a", the data query request can be forwarded to the index device to obtain key value data corresponding to the query transaction object "a", the index management device sends a data query instruction carrying the query data to the storage layer when receiving the query data, the storage layer can query the transaction object "a" according to the key value data first, and inquiring the transaction time from the transaction information of the transaction object 'A', and taking the inquired transaction time as target data meeting the inquiry condition. Further, when the access layer of the index management device receives the target data acquired by the storage layer from the database, the target data is returned to the first terminal device.
In the embodiment of the application, the index management device generates index indication information according to an index creation request aiming at a target field sent by a second terminal device, sends the index indication information to the index device, acquires historical data associated with the target field from a database, and sends a first index synchronization request carrying the historical data to the index device to achieve the creation of the index; the index management equipment forwards a data query request from the first terminal equipment to the index equipment, receives query data returned by the index equipment, determines a data query type corresponding to the data query request, determines target data according to the data query type and the query data, and sends the target data to the first terminal equipment so as to realize the query of the data. By implementing the method, the management of the index can be realized, and the influence on the data read-write service during the index access can be effectively reduced in the data query process.
Please refer to fig. 12, which is a schematic structural diagram of an index management apparatus provided in the present application, configured in an index management device, for performing the method according to the embodiments shown in fig. 3 and fig. 6 of the present application, for convenience of description, only the portion related to the embodiments of the present application is shown, and details of the technology are not disclosed, and reference may be made to the embodiments shown in fig. 3 and fig. 6 of the present application. The apparatus 1200 for index management may include: a processing module 1201, a receiving module 1202, and a determining module 1203.
A processing module 1201, configured to forward a data query request from a first terminal device to an index device, where the data query request is used to instruct the index device to query data that meets a query condition;
a receiving module 1202, configured to receive the query data returned by the index device;
a determining module 1203, configured to determine a data query type corresponding to the data query request, and determine target data according to the data query type and the query data;
the processing module 1201 is further configured to return the target data to the first terminal device.
In a possible implementation manner, the data query type is a non-aggregated query type, the query data is key-value data that satisfies the query condition, and the determining module 1203 is further configured to:
and if the data query type is the non-aggregation query type, acquiring value data corresponding to the key value data from a database, and determining the value data as target data.
In a possible implementation manner, the data query type is an aggregate query type, the query data is an aggregate value that satisfies the query condition, and the determining module 1203 is further configured to:
and if the data query type is the aggregation query type, determining the query data as target data.
In a possible implementation, the processing module 1201 is further configured to, before being configured to forward the data query request from the first terminal device to the indexing device:
generating index indication information according to an index creation request aiming at a target field and sent by second terminal equipment, and sending the index indication information to the index equipment, wherein the index indication information is used for indicating the index equipment to create a target index corresponding to the target field;
obtaining historical data associated with the target field from the database;
and sending a first index synchronization request carrying the historical data to the index device, wherein the first index synchronization request is used for indicating the index device to synchronize the historical data to the target index, and returning a synchronization completion instruction after the historical data synchronization is completed.
In a possible implementation manner, after the processing module 1201 is configured to send the index synchronization request carrying the history data to the index device, the processing module is further configured to:
before the synchronous completion instruction is detected, if a data writing request from the first terminal device is received, acquiring data to be written carried in the data writing request;
acquiring data to be indexed associated with the target field from the data to be written;
and sending a second index synchronization request carrying the data to be indexed to the indexing equipment, wherein the second index synchronization request is used for indicating the indexing equipment to synchronize the data to be indexed to the target index, and returning a write-in data synchronization completion instruction after the data to be indexed is synchronized.
In a possible implementation, the processing module 1201 is further configured to:
receiving a modification request aiming at the target index sent by the second terminal equipment, wherein the modification request comprises an index update field aiming at the target index;
sending an index update request for the target index to the index device, wherein the index update request is used for instructing the index device to: creating a new index according to the index updating field, deleting the target index, and returning index switching indication information;
and receiving index switching indication information returned by the index equipment, and switching the access to the target index to the new index according to the indication of the index switching indication information.
In the embodiment of the application, a processing module forwards a data query request from a first terminal device to an index device, a receiving module receives query data returned by the index device, a determining module determines a data query type corresponding to the data query request, and determines target data according to the data query type and the query data, and the processing module returns the target data to the first terminal device. By implementing the scheme, the influence on the data read-write service during index access can be effectively reduced in the data query process.
The functional modules in the embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of software functional module, which is not limited in this application.
Please refer to fig. 13, which is a schematic structural diagram of an index management apparatus according to an embodiment of the present application. As shown in fig. 13, the index management apparatus 1300 includes: at least one process 1301, memory 1302. Optionally, the electronic device may further include a network interface 1303. Data can be interacted among the processor 1301, the memory 1302 and the network interface 1303, the network interface 1303 is controlled by the processor to receive and transmit messages, the memory 1302 is used for storing computer programs, the computer programs comprise program instructions, and the processor 1301 is used for executing the program instructions stored in the memory 1302. Wherein the processor 1301 is configured to call the program instructions to perform the method described above.
The memory 1302 may include volatile memory (volatile memory), such as random-access memory (RAM); the memory 1302 may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a solid-state drive (SSD), etc.; the memory 1302 may also include a combination of the above types of memory.
The processor 1301 may be a Central Processing Unit (CPU) 1301. In one embodiment, the processor 1301 may also be a Graphics Processing Unit (GPU) 1301. The processor 1301 may also be a combination of a CPU and a GPU.
In one embodiment, the memory 1302 is used to store program instructions. The processor 1301 can call the program instructions to perform the following steps:
forwarding a data query request from a first terminal device to an index device, wherein the data query request is used for indicating the index device to query data meeting query conditions;
receiving the query data returned by the index equipment;
determining a data query type corresponding to the data query request, and determining target data according to the data query type and the query data;
and returning the target data to the first terminal equipment.
In a possible implementation manner, the data query type is a non-aggregated query type, the query data is key-value data that satisfies the query condition, and the processor 1301 is further configured to:
and if the data query type is the non-aggregation query type, acquiring value data corresponding to the key value data from a database, and determining the value data as target data.
In a possible implementation manner, the data query type is an aggregate query type, the query data is an aggregate value that satisfies the query condition, and the processor 1301 is further configured to:
and if the data query type is the aggregation query type, determining the query data as target data.
In a possible implementation manner, the processor 1301, before being configured to forward the data query request from the first terminal device to the indexing device, is further configured to:
generating index indication information according to an index creation request aiming at a target field and sent by second terminal equipment, and sending the index indication information to the index equipment, wherein the index indication information is used for indicating the index equipment to create a target index corresponding to the target field;
obtaining historical data associated with the target field from the database;
and sending a first index synchronization request carrying the historical data to the index device, wherein the first index synchronization request is used for indicating the index device to synchronize the historical data to the target index, and returning a synchronization completion instruction after the historical data synchronization is completed.
In a possible implementation manner, after the processor 1301 is configured to send an index synchronization request carrying the history data to the index device, the processor 1301 is further configured to:
before the synchronous completion instruction is detected, if a data writing request from the first terminal device is received, acquiring data to be written carried in the data writing request;
acquiring data to be indexed associated with the target field from the data to be written;
and sending a second index synchronization request carrying the data to be indexed to the indexing equipment, wherein the second index synchronization request is used for indicating the indexing equipment to synchronize the data to be indexed to the target index, and returning a write-in data synchronization completion instruction after the data to be indexed is synchronized.
In one possible implementation, the processor 1301 is further configured to:
receiving a modification request aiming at the target index sent by the second terminal equipment, wherein the modification request comprises an index update field aiming at the target index;
sending an index update request for the target index to the index device, wherein the index update request is used for instructing the index device to: creating a new index according to the index updating field, deleting the target index, and returning index switching indication information;
and receiving index switching indication information returned by the index equipment, and switching the access to the target index to the new index according to the indication of the index switching indication information.
In specific implementation, the apparatus, the processor 1301, the memory 1302 and the like described in this embodiment of the present application may perform the implementation described in the above method embodiment, and may also perform the implementation described in this embodiment of the present application, which is not described herein again.
Also provided in embodiments of the present application is a computer (readable) storage medium storing a computer program comprising program instructions that, when executed by a processor, perform some or all of the steps performed in the above-described method embodiments. Alternatively, the computer storage media may be volatile or nonvolatile.
Reference herein to "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
It will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by a computer program, which may be stored in a computer storage medium, and the computer storage medium may be a computer readable storage medium, and when executed, the programs may include the processes of the above embodiments of the methods. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
While the present disclosure has been described with reference to particular embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present disclosure.