A data processing method and apparatus
By processing key-value pairs in parallel, the performance bottleneck of the Jedis client library in high-concurrency environments is resolved, achieving efficient data processing and improving application performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2026-03-31
AI Technical Summary
Existing Jedis client libraries suffer from performance bottlenecks in high-concurrency environments, cannot achieve non-blocking and asynchronous operations, and require additional connection pool configuration, leading to increased development complexity.
A data processing method and apparatus are provided, which receive data processing instructions from a client to process key-value pair data in parallel. By leveraging the multi-core performance advantages of key-value databases, efficient parallel data processing is achieved, improving application performance and reducing operation latency.
It achieves efficient parallel data processing, improves client performance, reduces operation latency and data processing costs, and enhances user experience.
Smart Images

Figure CN118760718B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a data processing method and apparatus. Background Technology
[0002] NoSQL databases are a type of database that emerged outside of relational databases, designed to address the challenges of large-scale data storage and high-concurrency access that traditional relational databases struggle to handle. Key-value databases are a major type of NoSQL database; they store data in key-value pairs, suitable for simple data models and fast read / write operations. Redis, in particular, as an in-memory key-value database, is widely used due to its fast read / write operations and rich features (such as publish / subscribe, transactions, and pipelining).
[0003] In the Java development field, with the rapid development of internet applications, the demand for high performance, scalability, and flexibility is increasing daily. Traditional relational databases may face performance bottlenecks when handling large amounts of data and high concurrency requests, so developers have begun to seek alternatives. The emergence of key-value databases fills this gap and provides Java developers with more options. Java is a widely used programming language applied in enterprise, network, mobile, and embedded systems. Many enterprise applications and microservice architectures are based on the Java technology stack. Developing Java interfaces for key-value databases enables these applications to easily access and manipulate key-value databases, meeting the needs of various application scenarios.
[0004] Key-value databases typically feature high performance and scalability because they are based on a simple key-value pair data model, allowing for fast read and write operations. Through Java interfaces, developers can leverage the performance advantages of key-value databases for applications requiring caching, session management, and real-time data processing. Developing Java interfaces for key-value databases simplifies the development process by abstracting and encapsulating database operations. Developers can interact with key-value databases using familiar Java APIs without needing to delve into the underlying database implementation. This simplification helps improve development efficiency and reduce the probability of errors.
[0005] In the current technology landscape, Jedis is a Java client library for Redis, providing comprehensive support and direct mapping for Redis commands. Jedis provides wrappers for Redis commands, including string, hash, list, set, sorted set, transaction, publish / subscribe, and more. It also provides an API that allows developers to interact with Redis using native commands.
[0006] Jedis operates synchronously, meaning it blocks while waiting for a Redis response. This can lead to performance bottlenecks, especially in high-concurrency environments. Because of its synchronous nature, Jedis is unsuitable for scenarios requiring non-blocking and asynchronous operations. Jedis does not come with a built-in connection pool; additional configuration is needed to manage connections, which can increase development complexity. Therefore, there is a pressing need for a method that enables Java clients to efficiently connect to key-value databases in high-concurrency environments. Summary of the Invention
[0007] This invention provides a data processing method and apparatus that enables clients to efficiently connect to a key-value database using preset data processing instructions. It allows for parallel data processing of key-value pairs within the database, achieving efficient parallel data processing. This improves application performance, enhances client performance, reduces operational latency, and ultimately increases data processing efficiency, lowers data processing costs, and enhances the user experience of data processing.
[0008] In a first aspect, the present invention provides a data processing method, the method being applied to a solid-state drive corresponding to a key-value database, the method comprising:
[0009] Receive at least one data processing instruction sent by the client; wherein each data processing instruction includes: target string type data and target operation type;
[0010] Parallel data processing is performed on the at least one data processing instruction to obtain data processing results corresponding to each of the at least one data processing instruction; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; data processing corresponding to the target operation type is performed on the target key-value pair data to obtain the data processing result corresponding to the data processing instruction;
[0011] The data processing results corresponding to each of the at least one data processing instruction are fed back to the client.
[0012] In a second aspect, the present invention provides a data processing apparatus applied to a solid-state drive corresponding to a key-value database, the apparatus comprising:
[0013] The first unit is used to receive at least one data processing instruction sent by the client; wherein each data processing instruction includes: target string type data and target operation type;
[0014] The second unit is used to perform parallel data processing on the at least one data processing instruction to obtain data processing results corresponding to each of the at least one data processing instruction; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; data processing corresponding to the target operation type is performed on the target key-value pair data to obtain the data processing result corresponding to the data processing instruction;
[0015] The third unit is used to feed back the data processing results corresponding to each of the at least one data processing instruction to the client.
[0016] Thirdly, the present invention provides a readable medium including executable instructions, which, when executed by a processor of an electronic device, cause the electronic device to perform any of the methods described in the first aspect.
[0017] Fourthly, the present invention provides an electronic device including a processor and a memory storing execution instructions, wherein when the processor executes the execution instructions stored in the memory, the processor performs the method as described in any of the first aspects.
[0018] As can be seen from the above technical solution, the method provided by the present invention can be applied to solid-state drives corresponding to key-value databases. The method includes: receiving at least one data processing instruction sent by a client; wherein each data processing instruction includes: target string type data and target operation type; performing parallel data processing on the at least one data processing instruction to obtain data processing results corresponding to each of the at least one data processing instruction; wherein, for each data processing instruction, determining target key-value pair data in the key-value database based on the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; performing data processing on the target key-value pair data corresponding to the target operation type to obtain data processing results corresponding to the data processing instruction; and feeding back the data processing results corresponding to each of the at least one data processing instruction to the client. In this application, key-value pairs in a key-value database can be processed in parallel according to at least one data processing instruction to obtain the data processing result corresponding to each of the at least one data processing instruction. The data processing result corresponding to each of the at least one data processing instruction is then fed back to the client. Therefore, this application can use preset data processing instructions to enable the client to efficiently connect to the key-value database and perform parallel data processing on the key-value pairs in the key-value database. This achieves efficient parallel data processing, thereby improving the performance of the application and the client, reducing operation latency, and ultimately improving the efficiency of data processing, reducing data processing costs, and improving the user experience of data processing.
[0019] The further effects of the aforementioned non-conventional preferred method will be explained below in conjunction with specific embodiments. Attached Figure Description
[0020] To more clearly illustrate the embodiments of the present invention or the existing technical solutions, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0022] Figure 2 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0023] Figure 3This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0024] Figure 4 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0025] Figure 5 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0026] Figure 6 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0027] Figure 7 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0028] Figure 8 This is a schematic diagram of the structure of a data processing device according to an embodiment of the present invention;
[0029] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0031] Various non-limiting embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0032] See Figure 1 This paper illustrates a data processing method according to an embodiment of the present invention. The method can be applied to a solid-state drive corresponding to a key-value database. In this embodiment, the method may include, for example, the following steps:
[0033] Step 1: Receive at least one data processing instruction sent by the client.
[0034] In this embodiment, when a client needs to process key-value pairs in a key-value database via a solid-state drive (SSD), the client can send at least one data processing instruction to the SSD corresponding to the key-value database. In one implementation, the client can be a Java client, and the key-value database can be a combined key-value database (i.e., a HetuKV key-value database).
[0035] Each data processing instruction may include: target string type data and target operation type. The target string type data can be understood as information related to the string type to be processed, such as the key and / or value of the key-value pair to be processed. The target operation type can be understood as the operation to be performed on the key-value pair to be processed, such as query, delete, update, etc.
[0036] It should be noted that the key-value pairs in the key-value database can be relevant data from fields such as artificial intelligence, content recommendation, image rendering, financial risk control, the Internet of Things, game development, and big data analysis. For example, in the field of artificial intelligence, the solution provided in this application can be used to train and deploy machine learning and deep learning models. Applications include: reading and processing large amounts of training data, rapidly preprocessing data, caching intermediate results, and storing trained models in a high-speed cache for real-time inference and prediction. In the field of content recommendation systems, which typically require rapid access to and processing of large amounts of user and content data to generate personalized recommendations, the solution provided in this application can be used to cache user preferences, recommendation history, and popular content to reduce database read pressure and improve the real-time performance and accuracy of the recommendation system. In the field of image rendering and processing, rapid access to and caching of intermediate results is crucial for performance. The solution provided in this application can be used to store and cache intermediate data generated during the rendering process, such as textures, image slices, and rendering results, helping to accelerate the rendering process and reduce computational load. Financial institutions need to rapidly process and analyze large amounts of transaction and user data to detect fraudulent activities and... For risk management, the solution provided in this application can be used to cache and quickly access transaction records, account information, risk assessment results, etc., thereby improving the real-time response capability and data processing performance of the risk control system. In the Internet of Things (IoT) field, IoT devices generate a large amount of data, and the rapid processing and analysis of this data is crucial for system stability and performance. The solution provided in this application can be used to store and cache sensor data, device status, real-time events, etc., helping IoT systems to respond quickly to events and instructions and ensuring the real-time performance of the system. Game development requires processing a large amount of real-time data, including game status, player information, and game events. The solution provided in this application can be used to cache game status, player data, leaderboards, etc., to improve the game's response speed and performance. Big data analysis requires the rapid processing and analysis of large amounts of data to obtain valuable insights. The solution provided in this application can be used as a data processing relay station to help realize the rapid import, processing, and caching of data, thereby improving the performance of the analysis system.
[0037] Step 2: Perform parallel data processing on the at least one data processing instruction to obtain the data processing result corresponding to each of the at least one data processing instruction.
[0038] In this embodiment, if multiple data processing instructions are received simultaneously, these instructions can be processed in parallel to obtain the data processing results corresponding to each of the at least one instruction. For example, when the client is a Java client and the key-value database is a HetuKV key-value database, the multi-core performance advantage of the HetuKV key-value database can be utilized to achieve efficient parallel data processing, thereby improving the performance of the application. The HetuKV key-value database supports multi-core parallelism, and the Java client supports and can implement multi-threading. Therefore, multiple CPU cores can be activated, with each core processing a single data processing instruction. For example, when storing a large String file in a multi-core environment, the file can be split into multiple parts, with each core storing a separate portion of the data, allowing for simultaneous and non-interfering processing. This multi-core parallel processing method can greatly improve data processing performance.
[0039] Specifically, for each data processing instruction, the target key-value pair data in the key-value database can be determined first based on the target string type data. That is, the target key-value pair data corresponding to the target string type data can be queried from the key-value database. Each key-value pair data in the key-value database includes a key and at least one value, and each value is a string.
[0040] Then, the target key-value pair data can be processed according to the target operation type to obtain the data processing result corresponding to the data processing instruction. In other words, the target key-value pair data is processed according to the data processing method corresponding to the target operation type, and the processed data processing result is obtained. For example, the target operation type is a key-value operation such as set, get, del, exist, etc., which ensures fast and efficient key-value data storage and retrieval.
[0041] Step 3: Feed back the data processing results corresponding to each of the at least one data processing instruction to the client.
[0042] After obtaining the data processing results corresponding to at least one data processing instruction, the system can send the data processing results corresponding to at least one data processing instruction back to the client.
[0043] As can be seen from the above technical solution, the method provided by the present invention can be applied to solid-state drives corresponding to key-value databases. The method includes: receiving at least one data processing instruction sent by a client; wherein each data processing instruction includes: target string type data and target operation type; performing parallel data processing on the at least one data processing instruction to obtain data processing results corresponding to each of the at least one data processing instruction; wherein, for each data processing instruction, determining target key-value pair data in the key-value database based on the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; performing data processing on the target key-value pair data corresponding to the target operation type to obtain data processing results corresponding to the data processing instruction; and feeding back the data processing results corresponding to each of the at least one data processing instruction to the client. In this application, key-value pairs in a key-value database can be processed in parallel according to at least one data processing instruction to obtain the data processing result corresponding to each of the at least one data processing instruction. The data processing result corresponding to each of the at least one data processing instruction is then fed back to the client. Therefore, this application can use preset data processing instructions to enable the client to efficiently connect to the key-value database and perform parallel data processing on the key-value pairs in the key-value database. This achieves efficient parallel data processing, thereby improving the performance of the application and the client, reducing operation latency, and ultimately improving the efficiency of data processing, reducing data processing costs, and improving the user experience of data processing.
[0044] Next, we will introduce examples for different target string data types and target operation types.
[0045] In one implementation, the target string type data includes the key and value of the key-value pair to be processed, and the target operation type is an update key-value pair operation.
[0046] In this embodiment, the specific implementation of determining the target key-value pair data in the key-value database based on the target string type data can be as follows:
[0047] If the key and value of the key-value pair to be processed meet the preset string type and preset threshold conditions, a key-value pair class is generated using the key and value of the key-value pair to be processed;
[0048] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0049] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0050] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is used as the target key-value pair data.
[0051] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0052] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the value in the target key-value pair data is updated to the value in the key-value pair to be processed, and the data processing result corresponding to the data processing instruction is determined to be a successful data update;
[0053] If the target key-value pair data is the empty key-value pair data, update the key and value in the empty key-value pair data to the key and value in the key-value pair to be processed, and the data processing result corresponding to the data processing instruction is data insertion successful.
[0054] Next, combine Figure 2 Provide examples. For instance... Figure 2 As shown, the target string data includes the key and value of the key-value pairs to be processed; the target operation type is an update key-value pair operation set, that is, inserting the corresponding key-value pair according to the parameter key-value pair, and updating the corresponding value if the key exists. Specifically, it includes the following steps:
[0055] S101: Accepts two parameters: key and value.
[0056] For S101, key and value are the key and value of the key-value pair to be processed, respectively. The key is a unique identifier for the value, and both key and value are String type data.
[0057] S102: Determine whether the parameters are valid, that is, determine whether the key and value of the key-value pair to be processed conform to the preset string type and preset threshold conditions.
[0058] For S102, it checks whether the parameters conform to the String data type and whether the parameter size is reasonable. That is, it checks whether the key and value of the key-value pair to be processed conform to the preset string type. If so, proceed to S103; otherwise, proceed to S104. To prevent overflow in storage, both the key and value have specified upper limits on size. Here, it is necessary to check whether these two parameters do not exceed the maximum value. For example, the preset threshold condition is that the data size in the key does not exceed 64kb and the data size in the value does not exceed 16mb.
[0059] S103: Initialize a HetuItem (i.e., a key-value pair class) using parameters.
[0060] For S103, valid parameters will be passed here to initialize a HetuItem object.
[0061] S104: End and return an error code.
[0062] For S104, if the two parameters received by the set method are invalid, the process will terminate and an error code will be returned.
[0063] S105: Update using HetuItem.
[0064] For S105, use the initialized HetuItem to update the HetuKV object. If it does not exist, perform the insertion operation; if it exists, update the existing key-value pair.
[0065] S106: Determine if the update was successful.
[0066] When performing the update operation in S105, HetuKV will return an operation result. Step 106 will determine whether the update was successful. If so, proceed to S107; otherwise, proceed to S108.
[0067] S107: End and return "OK".
[0068] Step 107 indicates that the key-value pair with the key and value has been successfully updated. The process ends and returns an "OK" flag indicating that the operation was successfully completed.
[0069] S108: End and return an error code.
[0070] For step 108, it indicates that an error occurred when updating the key-value pair with key and value as keys. The process ends and returns the corresponding error code to indicate that the set operation failed. The reason for the error is obtained based on the error code.
[0071] In one implementation, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a first query key-value pair operation.
[0072] In this embodiment, determining the target key-value pair data in the key-value database based on the target string type data includes:
[0073] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0074] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0075] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0076] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0077] The value in the target key-value pair data is used as the data processing result corresponding to the data processing instruction.
[0078] Next, combine Figure 3 Provide examples. For instance... Figure 3 As shown, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a first query key-value pair operation get, that is, querying the value corresponding to the key according to the parameters. Specifically, it includes the following steps:
[0079] S201: Receive parameters, i.e., determine whether the key of the key-value pair to be processed conforms to the preset string type and preset threshold conditions.
[0080] For step 201, receive a parameter key, which represents the key of the key-value pair to be queried.
[0081] S202: Determine if the parameter is valid.
[0082] For step 202, determine whether the parameter is of the String data type and whether the size of the parameter does not exceed the maximum value limited by the key. If yes, proceed to step S203; otherwise, proceed to step S207.
[0083] S203: Initialize a HetuItem using parameters.
[0084] For step 203, valid parameters will be passed here to initialize a HetuItem object.
[0085] S204: Use HetuItem to query objects in HetuKV.
[0086] For step 204, query the HetuKV object based on the key of HetuItem.
[0087] S205: Determine whether the query was successful.
[0088] For step 205, determine whether the query was successful based on the query result of S204. If it was, proceed to S206; otherwise, proceed to S207.
[0089] S206: End and return value.
[0090] For step 205, after a successful query, S204 will return the value corresponding to the parameter key. Here, this value will be returned and the operation will end, indicating that the operation was executed correctly and a return value was obtained.
[0091] S207: End and return an error code.
[0092] Step 207 is entered after S202 and S205 fail, indicating that the operation has failed and cannot be performed. It ends and returns the corresponding error code, and the reason for the error is obtained based on the error code.
[0093] In one implementation, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a delete key-value pair operation.
[0094] In this embodiment, determining the target key-value pair data in the key-value database based on the target string type data includes:
[0095] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed; wherein, it may include the keys of multiple key-value pairs to be processed;
[0096] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0097] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0098] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0099] Delete the target key-value pair data from the key-value database;
[0100] The deletion result of the target key-value pair data is used as the data processing result corresponding to the data processing instruction.
[0101] Next, combine Figure 4 Provide examples. For instance... Figure 4 As shown, the target string type data includes the keys of the key-value pairs to be processed, and the target operation type is the delete key-value pair operation del, that is, deleting one or more key-value pairs. Specifically, it includes the following steps:
[0102] S301: Receive parameters.
[0103] For S301, one or more parameters key[1,2...n] are received, representing the keys of the n key-value pairs to be deleted.
[0104] S302: Determine if the parameter is valid.
[0105] For S302, check if the parameters in S301 are valid, where all keys must be of String data type and their size must not exceed the maximum value specified for the key. If valid, execute S303; otherwise, execute S307.
[0106] S303: Initialize a HetuItem using parameters.
[0107] For S303, a valid key will be passed here to initialize one or more HetuItem objects.
[0108] S304: Use HetuItem to update the HetuKV object and delete key-value pairs.
[0109] For step 304, use these HetuItems to update the HetuKV object, loop through the HetuItems initialized with parameters, and delete key-value pairs in the HetuKV object based on their keys.
[0110] S305: Determine whether the deletion was successful.
[0111] For S305, determine whether the deletion was successful based on the deletion result of S304. If successful, proceed to S306; otherwise, proceed to S307.
[0112] S306: Returns the number of items deleted.
[0113] For S306, a successful deletion operation increments a counter, indicating that a key-value pair has been successfully deleted. Finally, the number of successfully deleted key-value pairs is returned.
[0114] S307: Error code returned.
[0115] Step 307 is entered when S302 and S305 fail, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will end.
[0116] In one implementation, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a second query key-value pair operation.
[0117] In this embodiment, determining the target key-value pair data in the key-value database based on the target string type data includes:
[0118] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0119] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0120] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0121] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, then null values will be used as the target key-value pair data.
[0122] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0123] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, the successful query result will be used as the data processing result corresponding to the data processing instruction.
[0124] If the target key-value pair data is empty, the query failure result will be used as the data processing result corresponding to the data processing instruction.
[0125] Next, combine Figure 5 Provide examples. For instance... Figure 5As shown, the target string type data includes the key of the key-value pairs to be processed, and the target operation type is the second query key-value pair operation `exists`, which queries whether these keys exist based on the keys in the parameters. Specifically, it includes the following steps:
[0126] S401: Receive parameters.
[0127] For S401, it receives a parameter key, which represents the key of the key-value pair to be queried.
[0128] S402: Determine if the parameter is valid.
[0129] For S402, check if the parameters in S401 are valid, where the keys must be of String data type and their size must not exceed the maximum value specified by the key. If valid, execute S403; otherwise, execute S409.
[0130] S403: Initialize a HetuItem using parameters.
[0131] For S403, a valid key will be passed here to initialize a HetuItem object.
[0132] S404: Use HetuItem to query a HetuKV object.
[0133] For S404, use HetuItem to query the HetuKV object. Here, it is not necessary to return the value; only check whether the key-value pair with the corresponding key exists.
[0134] S405: Determine whether the query was executed successfully.
[0135] For S405, determine whether the query was executed successfully based on the execution result of S404. If it was, execute S406; otherwise, execute S409.
[0136] S406: Determine if the query result exists.
[0137] For S406, determine whether HetuItem exists based on the execution result of S404. If it does, execute S407; otherwise, execute S408.
[0138] S407: Returns "true".
[0139] For S407, based on the judgment result of S406, if HetuItem exists, return "true".
[0140] S408: Returns "false".
[0141] For S408, based on the judgment result of S406, if HetuItem does not exist, return "false".
[0142] S409: Error code returned.
[0143] Entering S409, S402, and S405 indicates an error and the operation cannot proceed. In this case, the corresponding error code will be returned and the operation will be terminated.
[0144] In one implementation, the target string type data includes the key and value of the key-value pair to be processed, and the target operation type is a query update key-value pair operation.
[0145] In this embodiment, determining the target key-value pair data in the key-value database based on the target string type data includes:
[0146] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0147] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0148] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0149] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is used as the target key-value pair data.
[0150] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0151] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, the value in the target key-value pair data is stored in a preset temporary variable; the value in the key-value pair class is updated to the value of the key-value pair to be processed, resulting in an updated key-value pair class; the target key-value pair data is updated using the updated key-value pair class, resulting in updated target key-value pair data, wherein the key and value in the updated target key-value pair data are the same as the value of the key-value pair to be processed; and the value stored in the preset temporary variable is used as the data processing result corresponding to the data processing instruction.
[0152] If the target key-value pair data is empty, update the value in the key-value pair class with the value of the key-value pair to be processed to obtain the updated key-value pair class; update the key and value in the target key-value pair data with the key and value in the updated key-value pair class, and take the key-value pair to be processed that does not exist in the key-value database as the data processing result corresponding to the data processing instruction.
[0153] Next, combine Figure 6 Provide examples. For instance... Figure 6 As shown, the target string data includes the key and value of the key-value pair to be processed, and the target operation type is a getset operation for querying and updating key-value pairs, that is, querying the key-value pair and then updating it with the new value. Specifically, it includes the following steps:
[0154] S501: Receive parameters.
[0155] For S501, it receives two parameters: key and value. The key is the target key to be queried, and the value is the value to be updated.
[0156] S502: Determine if the parameter is valid.
[0157] For S502, the parameters should meet the following conditions: the key's data type is String, and its size does not exceed the maximum value specified for the key; the value's data type is String, and its size does not exceed the maximum value specified for the value. If this is the case, execute S503; otherwise, execute S515.
[0158] S503: Initialize a HetuItem using parameters.
[0159] For S503, a valid key will be passed here to initialize a HetuItem object.
[0160] S504: Use HetuItem to query HetuKV
[0161] For S504, search for key-value pairs with the same key in HetuKV based on the key of HetuKVItem.
[0162] S505: Determine whether the query was successful.
[0163] For S505, determine whether the query was successful based on the execution result of S504. If it was, execute S506; otherwise, execute S511.
[0164] S506: Save the value of HetuKVItem.
[0165] For S506, a temporary variable is used to store the retrieved value, which is then used as the old value.
[0166] S507: Set a new value for HetuKVItem.
[0167] For S507, update the value of HetuKVItem to the new value using the parameter value.
[0168] S508: Update the HetuKV object using HetuItem.
[0169] For S508, the updated HetuKV object is updated using the updated HetuItem, that is, after finding the key-value pair with the same key, its value is updated to the value of HetuItem.
[0170] S509: Determine if the update was successful.
[0171] For S509, the result of S508 is evaluated to determine whether the update was successful. If yes, proceed to S510; otherwise, proceed to S515.
[0172] S510: Returns the saved old value.
[0173] For S510, once it is confirmed that the operation of updating the HetuKV object using HetuItem has been successfully executed, the old value saved in S506 will be returned.
[0174] S511: Set a new value for HetuKVItem.
[0175] After the query operations performed in S511, S504, and S505 fail, the process proceeds to S511, indicating that the key-value pair does not exist in HetuKV. At this point, the new value is set to HetuKVItem to facilitate the subsequent insertion of the key-value pair.
[0176] S512: Update the HetuKV object using HetuItem.
[0177] For S512, the HetuKV object is updated using the pre-set value of HetuItem, that is, the new Item is inserted.
[0178] S513: Determine if the update was successful.
[0179] For S513, determine whether the update was successful based on the execution result of S512. If successful, execute S514; otherwise, execute S515.
[0180] S514: Returns NULL.
[0181] For S514, NULL is returned after the operations of S512 and S513 are executed successfully, indicating that there is no key-value pair specified by the parameter in the HetuKv object.
[0182] S515: Returns an error code.
[0183] If S515, S502, S509, and S513 all fail, it indicates that the operation has failed and cannot be performed. In this case, the corresponding error code will be returned and the operation will be terminated.
[0184] In one implementation, the target string type data includes the key of the key-value pair to be processed, the start position and the end position of the value to be queried, and the target operation type is a third query key-value pair operation.
[0185] In this embodiment, determining the target key-value pair data in the key-value database based on the target string type data includes:
[0186] If the key of the key-value pair to be processed and the start and end positions of the value to be queried meet the preset string type conditions and preset threshold conditions, a key-value pair class is generated using the key of the key-value pair to be processed and the start and end positions of the value to be queried.
[0187] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0188] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0189] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0190] The values in the target key-value pair data that correspond to the start and end positions of the value to be queried are used as the data processing results corresponding to the data processing instructions.
[0191] Next, combine Figure 7 Provide examples. For instance... Figure 7As shown, the target string type data includes the key of the key-value pair to be processed, the startOffset of the value to be queried, and the endOffset of the value to be queried. That is, key is the target key to be queried, startOffset is the starting position of the query, and endOffset is the ending position of the query (both start from 0 by default). The target operation type is the third query key-value pair operation getrange, which queries the value between the specified positions according to the parameter value. Specifically, it includes the following steps:
[0192] S601: Receive parameters.
[0193] For S601, it receives three parameters: key, startOffset, and endOffset. Key is the target key to be queried, startOffset is the starting position of the query, and endOffset is the ending position of the query (both start from 0 by default).
[0194] S602: Determine if the parameter is valid.
[0195] For S602, the parameters should meet the following conditions: the data type of key is String, and its size does not exceed the maximum value limited to key; the data types of startOffset and endOffset are both long, not less than 0, and startOffset is not greater than endOffset. If this is the case, execute S603; otherwise, execute S607. That is, the default string type condition is that the data type of key is String, and the data types of startOffset and endOffset are both long. The default threshold condition is that the size of key does not exceed the maximum value limited to key, and both startOffset and endOffset are not less than 0 and startOffset is not greater than endOffset.
[0196] S603: Initialize a HetuItem using parameters.
[0197] For S603, a valid key will be passed here to initialize a HetuItem object.
[0198] S604: Query based on HetuKVItem.
[0199] For S604, search for key-value pairs with the same key in HetuKV based on the key of HetuKVItem.
[0200] S605: Determine if the query was successful.
[0201] For S605, determine whether the query was successful based on the execution result of S604. If it was, execute S606; otherwise, execute S607.
[0202] S606: End and return value.
[0203] For S606, reaching this S indicates that the value corresponding to the parameter key has been found. After returning the value, the operation ends with the indication that it was successfully executed.
[0204] S607: End and return an error code.
[0205] For S607, if the parameters are invalid or the query fails, the operation will fail and return the corresponding error code to indicate that the operation failed.
[0206] In one embodiment, prior to the step of receiving at least one data processing instruction sent by the client, the method further includes:
[0207] Receive a call instruction sent by the client; wherein the call instruction includes a target solid-state drive identifier;
[0208] The solid-state drive (SSD) corresponding to the target SSD identifier is invoked according to the target SSD identifier, and the SSD corresponding to the target SSD identifier is used as the SSD corresponding to the key-value database, and the state of the SSD corresponding to the key-value database is adjusted to a locked state.
[0209] Accordingly, after the step of feeding back the data processing results corresponding to each of the at least one data processing instruction to the client, the method further includes:
[0210] Release the memory of the solid-state drive corresponding to the key-value database, and adjust the state of the solid-state drive corresponding to the key-value database to an idle state.
[0211] As an example, when using a Java client to call the HetuKV key-value database, a specific solid-state drive (SSD) is specified and locked. This lock is released after the call ends, leveraging HetuKV's garbage collection mechanism to promptly release the memory occupied by the SSD. During the SSD locking process, other processes cannot use the SSD. Furthermore, in this embodiment, offloading data computation to the SSD reduces memory dependency and optimizes resource utilization through garbage collection. Locking the SSD ensures data security and reliability, thereby achieving resource optimization and security assurance. This leverages HetuKV's advantages to optimize resource utilization, ensure data security and reliability, reduce memory dependency, optimize hardware resource utilization, lower memory consumption, and make the system more resilient. Additionally, it enhances security and control, providing complete control and strengthening data security, ensuring data security for enterprise applications.
[0212] Thus, this embodiment, combined with a specific application scenario, implements the data processing method's processing procedure. It should be noted that the above scenario is merely exemplary and does not constitute a limitation on the method provided by this invention. The method provided by this invention can be extended to other data processing methods based on the same principles.
[0213] like Figure 8 The image shows a specific embodiment of the data processing apparatus described in this application. The apparatus described in this embodiment is a physical device used to execute the method described in the above embodiments. Its technical solution is essentially the same as that of the above embodiments, and the corresponding descriptions in the above embodiments are also applicable to this embodiment. In this embodiment, the apparatus is applied to a solid-state drive corresponding to a key-value database. The apparatus includes:
[0214] The first unit 801 is used to receive at least one data processing instruction sent by the client; wherein each data processing instruction includes: target string type data and target operation type;
[0215] The second unit 802 is used to perform parallel data processing on the at least one data processing instruction to obtain data processing results corresponding to each of the at least one data processing instruction; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; data processing corresponding to the target operation type is performed on the target key-value pair data to obtain the data processing result corresponding to the data processing instruction;
[0216] The third unit 803 is used to feed back the data processing results corresponding to each of the at least one data processing instruction to the client.
[0217] Optionally, the target string type data includes the key and value of the key-value pair to be processed, and the target operation type is an update key-value pair operation.
[0218] Optionally, the second unit 802 is used for:
[0219] If the key and value of the key-value pair to be processed meet the preset string type and preset threshold conditions, a key-value pair class is generated using the key and value of the key-value pair to be processed;
[0220] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0221] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0222] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is used as the target key-value pair data.
[0223] Optionally, the second unit 802 is used for:
[0224] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the value in the target key-value pair data is updated to the value in the key-value pair to be processed, and the data processing result corresponding to the data processing instruction is determined to be a successful data update;
[0225] If the target key-value pair data is the empty key-value pair data, update the key and value in the empty key-value pair data to the key and value in the key-value pair to be processed, and the data processing result corresponding to the data processing instruction is data insertion successful.
[0226] Optionally, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a first query key-value pair operation.
[0227] Optionally, the second unit 802 is used for:
[0228] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0229] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0230] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0231] Optionally, the second unit 802 is used to: use the value in the target key-value pair data as the data processing result corresponding to the data processing instruction.
[0232] Optionally, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a delete key-value pair operation.
[0233] Optionally, the second unit 802 is used to: if the key of the key-value pair to be processed conforms to a preset string type and a preset threshold condition, generate a key-value pair class using the key of the key-value pair to be processed;
[0234] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0235] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0236] Optionally, the second unit 802 is used to: delete the target key-value pair data from the key-value database;
[0237] The deletion result of the target key-value pair data is used as the data processing result corresponding to the data processing instruction.
[0238] Optionally, the target string type data includes the key of the key-value pair to be processed, and the target operation type is a second query key-value pair operation.
[0239] Optionally, the second unit 802 is used for:
[0240] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0241] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0242] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0243] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, then null values will be used as the target key-value pair data.
[0244] Optionally, the second unit 802 is used to: if the target key-value pair data is the key-value pair data corresponding to the key-value pair class, use the query success result as the data processing result corresponding to the data processing instruction;
[0245] If the target key-value pair data is empty, the query failure result will be used as the data processing result corresponding to the data processing instruction.
[0246] Optionally, the target string type data includes the key and value of the key-value pair to be processed, and the target operation type is a query update key-value pair operation.
[0247] Optionally, the second unit 802 is used for:
[0248] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed;
[0249] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0250] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class shall be used as the target key-value pair data.
[0251] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is used as the target key-value pair data.
[0252] Optionally, the second unit 802 is used for:
[0253] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, the value in the target key-value pair data is stored in a preset temporary variable; the value in the key-value pair class is updated to the value of the key-value pair to be processed, resulting in an updated key-value pair class; the target key-value pair data is updated using the updated key-value pair class, resulting in updated target key-value pair data, wherein the key and value in the updated target key-value pair data are the same as the value of the key-value pair to be processed; and the value stored in the preset temporary variable is used as the data processing result corresponding to the data processing instruction.
[0254] If the target key-value pair data is empty, update the value in the key-value pair class with the value of the key-value pair to be processed to obtain the updated key-value pair class; update the key and value in the target key-value pair data with the key and value in the updated key-value pair class, and take the key-value pair to be processed that does not exist in the key-value database as the data processing result corresponding to the data processing instruction.
[0255] Optionally, the target string type data includes the key of the key-value pair to be processed, the start position and end position of the value to be queried, and the target operation type is a third query key-value pair operation.
[0256] Optionally, the second unit 802 is used to: if the start and end positions of the key and the value to be queried in the key-value pair to be processed meet the preset string type conditions and the preset threshold conditions, generate a key-value pair class using the key and the start and end positions of the value to be queried in the key-value pair to be processed;
[0257] Determine whether key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed;
[0258] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data.
[0259] Optionally, the second unit 802 is used to: take the value in the target key-value pair data corresponding to the start position and end position of the value to be queried as the data processing result corresponding to the data processing instruction.
[0260] Optionally, the client is a Java client, and the key-value database is a HetuKV key-value database.
[0261] Optionally, the apparatus further includes a fourth unit for: performing the following steps prior to the step of receiving at least one data processing instruction sent by the client:
[0262] Receive a call instruction sent by the client; wherein the call instruction includes a target solid-state drive identifier;
[0263] The solid-state drive (SSD) corresponding to the target SSD identifier is invoked according to the target SSD identifier, and the SSD corresponding to the target SSD identifier is used as the SSD corresponding to the key-value database, and the state of the SSD corresponding to the key-value database is adjusted to a locked state.
[0264] The fourth unit is further configured to: after the step of feeding back the data processing results corresponding to each of the at least one data processing instruction to the client, perform the following steps:
[0265] Release the memory of the solid-state drive corresponding to the key-value database, and adjust the state of the solid-state drive corresponding to the key-value database to an idle state.
[0266] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include main memory, such as high-speed random-access memory (RAM), or it may also include non-volatile memory, such as at least one disk storage device. Of course, the electronic device may also include other hardware required for other services.
[0267] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 9 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0268] Memory is used to store instructions for execution. Specifically, instructions for execution are computer programs that can be executed. Memory can include main memory and non-volatile memory, and it provides the processor with execution instructions and data.
[0269] In one possible implementation, the processor reads the corresponding execution instructions from non-volatile memory into main memory and then executes them. Alternatively, it may obtain the corresponding execution instructions from other devices to form a data processing device at the logical level. The processor executes the execution instructions stored in the memory to implement the data processing method provided in any embodiment of the present invention through the executed instructions.
[0270] The above is as described in the present invention. Figure 1The methods executed by the data processing apparatus provided in the illustrated embodiments can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above methods can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.
[0271] The steps of the method disclosed in the embodiments of this invention can be directly manifested as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0272] This invention also proposes a readable medium that stores execution instructions. When the stored execution instructions are executed by the processor of an electronic device, the electronic device can execute the data processing method provided in any embodiment of this invention, and specifically execute the method described above for data querying.
[0273] The electronic devices described in the foregoing embodiments may be computers.
[0274] Those skilled in the art will understand that embodiments of the present invention can be provided as methods or computer program products. Therefore, the present invention can be implemented in a completely hardware embodiment, a completely software embodiment, or a combination of software and hardware.
[0275] The various embodiments in this invention are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0276] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0277] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A data processing method, characterized by, The method is applied to a solid state disk corresponding to a key-value database, wherein the key-value database is a coexistence key-value database, and key-value pair data in the coexistence key-value database includes at least one of the following: related data in the field of artificial intelligence, and the method includes: Receiving at least one data processing instruction sent by a client; wherein each data processing instruction includes: target string type data, and a target operation type; Parallel data processing is performed on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively; wherein for each data processing instruction, target key-value pair data in the key-value database is determined according to the target string type data, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; data processing corresponding to the target operation type is performed on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction; The data processing result corresponding to each of the at least one data processing instruction is fed back to the client; The coexistence key-value database is multi-core parallel, can enable multiple cores of a CPU, and each core processes a data processing instruction individually; The target string type data includes a key and a value of a key-value pair to be processed, and the target operation type is a query and update key-value pair operation; and the determination of the target key-value pair data in the key-value database according to the target string type data includes: If the key of the key-value pair to be processed meets a preset string type and a preset threshold condition, a key-value pair class is generated by using the key of the key-value pair to be processed; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the key-value pair to be processed; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data; If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is taken as the target key-value pair data; The data processing corresponding to the target operation type is performed on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction, which includes: If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, the value in the target key-value pair data is stored in a preset temporary variable; the value in the key-value pair class is updated to the value of the key-value pair to be processed to obtain an updated key-value pair class; the target key-value pair data is updated by using the updated key-value pair class to obtain updated target key-value pair data, wherein the key and the value in the updated target key-value pair data are the value of the key-value pair to be processed; and the value stored in the preset temporary variable is taken as the data processing result corresponding to the data processing instruction. If the target key-value pair data is empty key-value pair data, updating the value in the key-value pair class as the value of the to-be-processed key-value pair to obtain an updated key-value pair class; updating the key and the value in the target key-value pair data as the key and the value in the updated key-value pair class, and taking the to-be-processed key-value pair that does not exist in the key-value database as the data processing result corresponding to the data processing instruction; The target string type data includes a key of a to-be-processed key-value pair, a start position and an end position of a value to be queried, and the target operation type is a third query key-value pair operation; and the determining, according to the target string type data, of target key-value pair data in the key-value database includes: If the key of the to-be-processed key-value pair, the start position and the end position of the value to be queried meet preset string type conditions and preset threshold conditions, generating a key-value pair class by using the key of the to-be-processed key-value pair, the start position and the end position of the value to be queried; determining whether the key-value database includes key-value pair data corresponding to the key-value pair class, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value database includes the key-value pair data corresponding to the key-value pair class, taking the key-value pair data corresponding to the key-value pair class as target key-value pair data; and the performing, on the target key-value pair data, data processing corresponding to the target operation type to obtain a data processing result corresponding to the data processing instruction includes: taking, as the data processing result corresponding to the data processing instruction, a value in the target key-value pair data corresponding to the start position and the end position of the value to be queried.
2. The method of claim 1, wherein, The target string type data includes a key and a value of a to-be-processed key-value pair, and the target operation type is an update key-value pair operation.
3. The method of claim 2, wherein, The determining, according to the target string type data, of target key-value pair data in the key-value database includes: If the key and the value of the to-be-processed key-value pair meet preset string type conditions and preset threshold conditions, generating a key-value pair class by using the key and the value of the to-be-processed key-value pair; determining whether the key-value database includes key-value pair data corresponding to the key-value pair class, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value database includes the key-value pair data corresponding to the key-value pair class, taking the key-value pair data corresponding to the key-value pair class as target key-value pair data; If the key-value database does not include the key-value pair data corresponding to the key-value pair class, creating an empty key-value pair data in the key-value database, and taking the empty key-value pair data as target key-value pair data.
4. The method of claim 3, wherein, The performing, on the target key-value pair data, data processing corresponding to the target operation type to obtain a data processing result corresponding to the data processing instruction includes: If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, updating a value in the target key-value pair data as a value in the to-be-processed key-value pair, and determining that the data processing result corresponding to the data processing instruction is a data update success. If the target key-value pair data is the empty key-value pair data, the key and the value in the empty key-value pair data are updated as the key and the value in the to-be-processed key-value pair, and the data processing result corresponding to the data processing instruction is data insertion success.
5. The method of claim 1, wherein, The target string type data includes a key of a to-be-processed key-value pair, and the target operation type is a first query key-value pair operation.
6. The method of claim 5, wherein, The target key-value pair data in the key-value database is determined according to the target string type data, including: If the key of the to-be-processed key-value pair meets a preset string type and a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
7. The method of claim 6, wherein, The target key-value pair data is processed according to the target operation type, and a data processing result corresponding to the data processing instruction is obtained, including: The value in the target key-value pair data is taken as the data processing result corresponding to the data processing instruction.
8. The method of claim 1, wherein, The target string type data includes a key of a to-be-processed key-value pair, and the target operation type is a delete key-value pair operation.
9. The method of claim 8, wherein, The target key-value pair data in the key-value database is determined according to the target string type data, including: If the key of the to-be-processed key-value pair meets a preset string type and a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
10. The method of claim 9, wherein, The target key-value pair data is processed according to the target operation type, and a data processing result corresponding to the data processing instruction is obtained, including: The target key-value pair data is deleted from the key-value database; A deletion result of the target key-value pair data is taken as the data processing result corresponding to the data processing instruction.
11. The method of claim 1, wherein, The target string type data includes a key of a to-be-processed key-value pair, and the target operation type is a second query key-value pair operation.
12. The method of claim 11, wherein, The target key-value pair data in the key-value database is determined according to the target string type data, including: If the key of the to-be-processed key-value pair meets a preset string type and a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data; If the key-value pair data corresponding to the key-value pair class pair does not exist in the key-value database, an empty value is taken as the target key-value pair data.
13. The method of claim 12, wherein, The data processing corresponding to the target operation type is performed on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction, including: If the target key-value pair data is the key-value pair data corresponding to the key-value pair class pair, a query success result is taken as the data processing result corresponding to the data processing instruction; If the target key-value pair data is an empty value, a query failure result is taken as the data processing result corresponding to the data processing instruction.
14. The method of any one of claims 1-13, wherein, The client is a Java client, and the key-value database is a coexistence key-value database.
15. The method of any one of claims 1-13, wherein, Before the step of receiving at least one data processing instruction sent by the client, the method further includes: receiving a calling instruction sent by the client; wherein the calling instruction includes a target solid state disk identifier; According to the target solid state disk identifier, the solid state disk corresponding to the target solid state disk identifier is called, and the solid state disk corresponding to the target solid state disk identifier is taken as the solid state disk corresponding to the key-value database, and the state of the solid state disk corresponding to the key-value database is adjusted to a locked state.
16. The method of claim 15, wherein, After the step of feeding back the data processing result corresponding to each of the at least one data processing instruction to the client, the method further includes: releasing the memory of the solid state disk corresponding to the key-value database, and adjusting the state of the solid state disk corresponding to the key-value database to an idle state.
17. A data processing apparatus, characterized by The device is applied to a solid state disk corresponding to a key-value database, the key-value database is a coexistence key-value database, and the coexistence key-value database has multi-core parallelism and can enable multiple cores of a CPU, each core processing a data processing instruction independently; wherein the key-value pair data in the coexistence key-value database includes at least one of the following: related data in the field of artificial intelligence, and the device includes: A first unit for receiving at least one data processing instruction sent by a client; wherein each data processing instruction includes: target string type data, and a target operation type; A second unit for performing parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction; wherein for each data processing instruction, according to the target string type data, target key-value pair data in the key-value database is determined, wherein each key-value pair data in the key-value database includes a key and at least one value, and each value is a string; the data processing corresponding to the target operation type is performed on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction; A third unit for feeding back the data processing result corresponding to each of the at least one data processing instruction to the client; The target string type data includes the key and value of the key-value pair to be processed, the target operation type is a query and update key-value pair operation, and the target key-value pair data in the key-value database is determined according to the target string type data, including: If the key of the to-be-processed key-value pair meets a preset string type and a preset threshold condition, a key-value pair class is generated using the key of the to-be-processed key-value pair; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data; If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is taken as target key-value pair data; The target operation type corresponding to the target key-value pair data is processed to obtain a data processing result corresponding to the data processing instruction, comprising: If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, the value in the target key-value pair data is stored in a preset temporary variable; the value in the key-value pair class is updated to the value of the to-be-processed key-value pair to obtain an updated key-value pair class; the target key-value pair data is updated using the updated key-value pair class to obtain updated target key-value pair data, wherein the key and the value in the updated target key-value pair data are the value of the to-be-processed key-value pair; and the value stored in the preset temporary variable is taken as the data processing result corresponding to the data processing instruction; If the target key-value pair data is an empty key-value pair data, the value in the key-value pair class is updated to the value of the to-be-processed key-value pair to obtain an updated key-value pair class; the key and the value in the target key-value pair data are updated to the key and the value in the updated key-value pair class, and the to-be-processed key-value pair that does not exist in the key-value database is taken as the data processing result corresponding to the data processing instruction; The target string type data includes the key of the to-be-processed key-value pair, the start position and the end position of the to-be-queried value, and the target operation type is a third query key-value pair operation; and the target key-value pair data in the key-value database is determined according to the target string type data, comprising: If the key of the to-be-processed key-value pair, the start position and the end position of the to-be-queried value meet a preset string type condition and a preset threshold condition, a key-value pair class is generated using the key of the to-be-processed key-value pair, the start position and the end position of the to-be-queried value; It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair; If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data; and the target key-value pair data is processed to obtain a data processing result corresponding to the data processing instruction, comprising: The value corresponding to the start position and the end position of the to-be-queried value in the target key-value pair data is taken as the data processing result corresponding to the data processing instruction.
18. A readable medium comprising execution instructions, when a processor of an electronic device executes the execution instructions, the electronic device performs the method of any one of claims 1 to 16.
19. An electronic device comprising a processor and a memory storing execution instructions, when the processor executes the execution instructions stored in the memory, the processor performs the method of any one of claims 1 to 16.
Citation Information
Patent Citations
KV database data management method and device, computing equipment and storage medium
CN114328453A
Data query method and related device
CN116955421A