A data processing method and apparatus
By processing key-value pairs in parallel, Jedis's performance bottleneck and connection complexity issues in high-concurrency environments are resolved, achieving efficient data processing and performance improvement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN PENGLAI SMART NUMBER TECH CO LTD
- Filing Date
- 2024-06-25
- Publication Date
- 2026-04-21
AI Technical Summary
Existing Jedis client libraries suffer from performance bottlenecks and blocking issues in high-concurrency environments, and lack built-in connection pools, leading to increased development complexity and failing to meet the needs of Java developers for efficient connection and operation in high-concurrency environments.
A data processing method and apparatus are provided, which receives data processing instructions from a client and processes key-value pair data in parallel. By utilizing the multi-core performance of the key-value database, efficient parallel data processing is achieved, improving application performance and reducing operation latency.
It enables clients to connect to key-value databases efficiently, improving data processing efficiency, reducing operation latency and costs, and enhancing user experience.
Smart Images

Figure CN118708636B_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 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 existing technologies, Jedis is a Java client library for Redis, providing comprehensive support and direct mapping to 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 hash table type data and target hash table operation type;
[0010] Parallel data processing is performed 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; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target hash table type data, wherein each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one data record, each data record including the value corresponding to each field in the hash table; data processing corresponding to the target hash table 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, characterized in that the apparatus is 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 hash table type data and target hash table operation type;
[0014] The second unit is used to 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; wherein, for each data processing instruction, the target key-value pair data in the key-value database is determined according to the target hash table type data, wherein each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one data record, and each data record includes the value corresponding to each field in the hash table; the target key-value pair data is processed according to the data processing type corresponding to the target hash table 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 hash table type data and target hash table 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 instructions; wherein, for each data processing instruction, determining target key-value pair data in the key-value database based on the target hash table type data, wherein each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one piece of data, each piece of data including the value corresponding to each field in the hash table; performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result 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, and the data processing result corresponding to each of the at least one data processing instruction can be 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, thereby achieving efficient parallel data processing, improving the performance of the application, enhancing the performance of the client, reducing operation latency, and thus improving the efficiency of data processing, reducing data processing costs, and ultimately 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 3 This 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 flowchart illustrating a data processing method according to an embodiment of the present invention.
[0029] Figure 9 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0030] Figure 10 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0031] Figure 11 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0032] Figure 12 This is a flowchart illustrating a data processing method according to an embodiment of the present invention.
[0033] Figure 13 This is a schematic diagram of the structure of a data processing device according to an embodiment of the present invention;
[0034] Figure 14 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0035] 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 some embodiments of this invention, and not all embodiments.
[0036] Various non-limiting embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0037] See Figure 1This 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:
[0038] Step 1: Receive at least one data processing instruction sent by the client.
[0039] 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).
[0040] Each data processing instruction may include: target hash table type data and target hash table operation type. The target hash table type data can be understood as string-type information to be processed, such as the key and / or value of the key-value pair to be processed. The target hash table 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.
[0041] 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.
[0042] 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.
[0043] 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.
[0044] 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 hash table type data. That is, the target key-value pair data corresponding to the target hash table type data is queried from the key-value database. Each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one data entry, with each data entry including the value corresponding to each field in the hash table. It can be understood that in this embodiment, the value corresponding to the key in each key-value pair data is at least one hash table; that is, key-value storage is used to store a hashmap (hash table), which can be understood as storing a table. The key is the unique identifier of this hash table, and the value is the hash table itself. The table has multiple fields, and each field corresponds to a value. Simply put, the key is the name of an Excel sheet, and the value corresponding to this key is the Excel sheet.
[0045] Then, the target key-value pair data can be processed according to the data processing method corresponding to the target hash table 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 hash table operation type, and the processed data processing result is obtained. For example, the target hash table operation type is a hashmap operation that performs key-value operations, including hset, hget, hgetAll, hkeys, etc., which ensures fast and efficient key-value data storage and retrieval.
[0046] Step 3: Feed back the data processing results corresponding to each of the at least one data processing instruction to the client.
[0047] 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.
[0048] 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 hash table type data and target hash table 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 instructions; wherein, for each data processing instruction, determining target key-value pair data in the key-value database based on the target hash table type data, wherein each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one piece of data, each piece of data including the value corresponding to each field in the hash table; performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result 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, and the data processing result corresponding to each of the at least one data processing instruction can be 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, thereby achieving efficient parallel data processing, improving the performance of the application, enhancing the performance of the client, reducing operation latency, and thus improving the efficiency of data processing, reducing data processing costs, and ultimately improving the user experience of data processing.
[0049] Next, we will introduce examples for different target hash table data types and target hash table operation types.
[0050] In one implementation, the target hash table type data includes the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field, wherein the target hash table operation type is a first update key-value pair operation.
[0051] In this embodiment, the specific implementation of determining the target key-value pair data in the key-value database based on the target hash table type data can be as follows:
[0052] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field;
[0053] 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;
[0054] 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.
[0055] 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.
[0056] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0057] 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 converted into a hash table, the hash table field and the value corresponding to the hash table field in the hash table are updated to the target hash table field and the value corresponding to the target hash table field in the key-value pair to be processed, and the updated hash table is converted into a value; and, the data processing result corresponding to the data processing instruction is determined to be data update successful;
[0058] If the target key-value pair data is the empty key-value pair data, a hash table is generated based on the target hash table field in the key-value pair to be processed and the value corresponding to the target hash table field. The hash table is converted into a value, and the value and the key in the key-value pair to be processed are used as the key and value in the empty key-value pair data. The data processing result corresponding to the data processing instruction is that the data insertion is successful.
[0059] Next, combine Figure 2 Provide examples. For instance... Figure 2 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed, the field (field) of the target hash table, and the value (value) corresponding to the field (value) of the target hash table; the target hash table operation type is an update key-value pair operation (hset), that is, setting a value for a specific field and key. Specifically, it includes the following steps:
[0060] S101: Receive parameters.
[0061] For S101, three parameters are received: key, field, and value, where key is the key-value pair to be stored, and field and value are the field and value of the hashmap to be stored, respectively.
[0062] S102: Determine whether the parameters are valid, that is, determine whether the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and whether the target hash table field of the key-value pair to be processed meets the preset string type.
[0063] For S102, determine whether the parameters accepted by S101 are valid. The key must be of String data type and its size must not exceed the maximum value specified for the key. The value must also be of String data type and its size must not exceed the maximum value specified for the value. The field must also be of String data type. If valid, proceed to S103; otherwise, proceed to S113. For example, the preset threshold conditions are that the data size in the key does not exceed 64kb and the data size in the value does not exceed 16mb.
[0064] S103: Initialize a HetuItem (i.e., a key-value pair class) using parameters.
[0065] For S103, valid parameters will be passed here to initialize a HetuItem object.
[0066] S104: Determine if HetuItem exists in HetuKV. That is, determine if the key-value pair data corresponding to the key-value pair class exists in the key-value database.
[0067] For S104, use the key of HetuItem to query whether the corresponding key-value pair exists in HetuKV. If it does, proceed to S105; otherwise, proceed to S106.
[0068] S105: Query the value of HetuItem.
[0069] For S105, based on the result of S104, if the key-value pair exists, extract its value.
[0070] S106: Set up a hashmap.
[0071] For S106, after converting the value to a hashmap type, the field and value are extracted using the field parameter and modified accordingly. That is, the values in the target key-value pair data are converted into a hash table, and the hash table fields and their corresponding values are updated to the target hash table fields and their corresponding values in the key-value pair to be processed.
[0072] S107: Initialize HetuKVItem with parameter key as key and hashmap as value.
[0073] For S107, the modified hashmap is converted to a String type and used as the value, along with the key parameter, to update the HetuKVItem. In other words, the updated hash table is converted into a value.
[0074] S108: Update the HetuKV object using HetuItem.
[0075] For S108, update HetuKV using HetuKVItem and insert a new key-value pair.
[0076] S109: Determine if the update was successful.
[0077] For S109, determine whether the update was successful based on the result of S108. If successful, proceed to S110; otherwise, proceed to S113.
[0078] S110: Determine if value is a new value.
[0079] For S110, an identifier is used to determine whether the updated value is a new value. If it is, 1 is returned; otherwise, 0 is returned.
[0080] S111: Returns "1".
[0081] For S111, based on the judgment result of S111, return "1", indicating that a new field has been successfully updated.
[0082] S112: Returns "0".
[0083] For S111, based on the judgment result of S111, return "1", indicating that an old field has been successfully updated.
[0084] S113: Error code returned.
[0085] Entering S113, S102, and S109 indicates an error and the operation cannot proceed. In this case, the corresponding error code will be returned and the operation will be terminated.
[0086] In one implementation, the target hash table type data includes the key of the key-value pair to be processed and the hash table field to be queried, and the target hash table operation type is a first query key-value pair operation.
[0087] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0088] If the key of the key-value pair to be processed conforms to the preset string type and the preset threshold condition, and the hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed and the hash table field to be queried;
[0089] 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;
[0090] 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.
[0091] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0092] Determine whether the value in the target key-value pair data is null;
[0093] If the value in the target key-value pair data is not empty, the value in the target key-value pair data is queried according to the field of the hash table to be queried, and the value in the target key-value pair data that corresponds to the field of the hash table to be queried is obtained; the value corresponding to the field of the hash table to be queried is used as the data processing result corresponding to the data processing instruction.
[0094] Next, combine Figure 3 Provide examples. For instance... Figure 3 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed and the field (field) of the hash table to be queried. The target hash table operation type is the first query key-value pair operation hget, which retrieves the value of a specific field. Specifically, it includes the following S:
[0095] S201: Receive parameters
[0096] For S201, it accepts two parameters: key and field. The key represents the key to retrieve, and the field represents the field to retrieve.
[0097] S202: Determine if the parameters are valid. That is, determine whether the key of the key-value pair to be processed conforms to the preset string type and the preset threshold condition, and whether the target hash table field of the key-value pair to be processed conforms to the preset string type.
[0098] For S202, determine whether the parameters accepted by S201 are valid. The key must be of String data type and its size must not exceed the maximum value specified for the key. The field must also be of String data type. In other words, the key must be of String data type and its size must not exceed the maximum value specified for the key, and the field must also be of String data type. For example, the preset threshold condition is that the data size in the key cannot exceed 64kb. If it meets the condition, proceed to S203; otherwise, proceed to S209.
[0099] S203: Initialize a HetuItem using parameters.
[0100] For S203, valid parameters will be passed here to initialize a HetuItem object.
[0101] S204: Determine whether the HetuItem query was successful.
[0102] For S204, use HetuKVItem to query HetuKV based on its key and determine whether the query was successful, that is, determine 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 yes, proceed to S205; otherwise, proceed to S209.
[0103] S205: Determine whether its value is NULL, that is, determine whether the value in the target key-value pair data is empty.
[0104] For S205, based on the result obtained from S204, determine whether the value is NULL. If it is, execute S208; otherwise, execute S206.
[0105] S206: Get the value corresponding to the field.
[0106] For S206, a query is performed in the value field based on the field to be queried to find the corresponding value field_value. That is, based on the field of the hash table to be queried, the value in the target key-value pair data is queried to obtain the value in the target key-value pair data that corresponds to the field of the hash table to be queried.
[0107] S207: Returns field_value.
[0108] For S207, the field_value corresponding to the field will be returned.
[0109] S208: Returns NULL.
[0110] For S208, when value is NULL, NULL will be returned, indicating that there is no field_value corresponding to the field.
[0111] S209: Error code returned.
[0112] Entering S209, S202, and S204 indicates an error and the operation cannot proceed. In this case, the corresponding error code will be returned and the operation will be terminated.
[0113] In one implementation, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a second query key-value pair operation.
[0114] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0115] 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;
[0116] 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;
[0117] 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.
[0118] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0119] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table, and the hash table is used as the data processing result corresponding to the data processing instruction.
[0120] Next, combine Figure 4 Provide examples. For instance... Figure 4 As shown, the target hash table type data includes the key of the key-value pair to be processed, and the target hash table operation type is the second query key-value pair operation hgetAll, which retrieves the entire hashmap hash table corresponding to the key. Specifically, it includes the following S:
[0121] S301: Receive parameters.
[0122] For S301, it receives a parameter key, indicating that the entire hashmap corresponding to the key should be extracted.
[0123] S302: Determine if the parameter is valid.
[0124] For S302, determine if the parameter conforms to the type requirement. The key must be of the String data type and its size must not exceed the maximum value specified by the key. In other words, the key must be of the String data type and its size must not exceed the maximum value specified by the key. For example, the preset threshold condition is that the data size in the key cannot exceed 64kb. If yes, execute S303; otherwise, execute S308.
[0125] S303: Initialize a HetuItem using parameters.
[0126] For S303, valid parameters will be passed here to initialize a HetuItem object.
[0127] S304: Determine if HetuKVItem exists.
[0128] For S304, query HetuKVItem in HetuKV (i.e., the key-value database) to determine if it exists. If it does, execute S305; otherwise, execute S307.
[0129] S305: Get the corresponding value.
[0130] For S305, use HetuItem to query the value corresponding to the key in HetuKV.
[0131] S306: Returns the decoded hashmap.
[0132] For S306, the value is converted to a hashmap type for easier manipulation in Java. That is, the values in the target key-value pair data are converted into a hash table.
[0133] S307: Returns an empty hashmap.
[0134] For S307, an empty hashmap will be returned if the key does not exist.
[0135] S308: Error code returned.
[0136] S308 is entered when S302 fails, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0137] In one implementation, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a third query key-value pair operation.
[0138] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0139] 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;
[0140] 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;
[0141] 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.
[0142] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0143] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0144] Determine whether the hash table is empty;
[0145] If the hash table is not empty, the hash table field in the hash table is used as the data processing result corresponding to the data processing instruction.
[0146] If the hash table is empty, the empty value is used as the data processing result corresponding to the data processing instruction.
[0147] Next, combine Figure 5 Provide examples. For instance... Figure 5 As shown, the target hash table type data includes the key of the key-value pairs to be processed, and the target hash table operation type is the third query key-value pair operation hkeys, which retrieves all fields corresponding to the key. Specifically, it includes the following S:
[0148] S401: Receive parameters.
[0149] For S401, it receives a parameter key, indicating that all fields corresponding to the key should be retrieved.
[0150] S402: Determine if the parameter is valid
[0151] For S402, check if the parameter is valid, where the key must be of String data type and its size cannot exceed the maximum value specified by the key. If valid, execute S403; otherwise, execute S409.
[0152] S403: Initialize a HetuKVItem using parameters.
[0153] For S403, valid parameters will be passed here to initialize a HetuItem object.
[0154] S404: Determine if HetuKVItem exists.
[0155] For S404, the system will check if the key exists in HetuKV using HetuItem. If it does, proceed to S405; otherwise, proceed to S408.
[0156] S405: Get the corresponding value.
[0157] For S405, the value corresponding to the key will be queried and saved.
[0158] S406: Determine if the decoded hashmap is empty.
[0159] For S406, after converting the value to a hashmap type, check if the hashmap is empty. That is, if the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then convert the value in the target key-value pair data into a hash table; check if the hash table is empty; if yes, execute S408, otherwise execute S407.
[0160] S407: Returns a hashset of all keys after decoding.
[0161] For S407, the hashset (i.e., the hash table field in the hash table) corresponding to all keys in the hashmap will be returned.
[0162] S408: Returns an empty hashset.
[0163] For S408, if S406 is true, proceed and return an empty hashset, indicating that the key does not exist.
[0164] S409: Error code returned.
[0165] S409 is entered when S402 fails, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0166] In one implementation, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a fourth query key-value pair operation.
[0167] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0168] 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;
[0169] 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;
[0170] 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.
[0171] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0172] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0173] Determine whether the hash table is empty;
[0174] If the hash table is not empty, the values corresponding to all hash table fields in the hash table are used as the data processing results corresponding to the data processing instructions.
[0175] If the hash table is empty, the empty value is used as the data processing result corresponding to the data processing instruction.
[0176] Next, combine Figure 6 Provide examples. For instance... Figure 6 As shown, the target hash table type data includes the key of the key-value pairs to be processed, and the target hash table operation type is the fourth query key-value pair operation hvals, which retrieves all values corresponding to the key. Specifically, it includes the following S:
[0177] S501: Receive parameters.
[0178] For S501, it receives a parameter key, indicating that all values corresponding to key should be retrieved.
[0179] S502: Determine if the parameter is valid.
[0180] For S502, the key must be of String data type and its size must not exceed the maximum value specified by the key. If this is the case, execute S503; otherwise, execute S509.
[0181] S503: Initialize a HetuKVItem using parameters.
[0182] For S503, valid parameters will be passed here to initialize a HetuItem object.
[0183] S504: Determine if HetuKVItem exists.
[0184] For S504, the system will check if the key-value pair corresponding to the key is in HetuKV using HetuItem. If it is, proceed to S505; otherwise, proceed to S508.
[0185] S505: Get the corresponding value.
[0186] For S505, after a successful query, extract the value corresponding to the key.
[0187] S506: Determine if the decoded hashmap is empty.
[0188] For S506, after converting the value extracted in S505 to a hashmap type, check if the hashmap is empty. If it is, execute S508; otherwise, execute S507.
[0189] S507: Returns an array list of all decoded values.
[0190] For S507, if a hashmap that is not empty is checked in S507, it will return all the ArrayLists in it (i.e., the values corresponding to all hash table fields in the hash table).
[0191] S508: Returns an empty Array List.
[0192] For S508, when the hashmap is empty, it returns an empty array list, indicating that the queried hashmap has no content.
[0193] S509: Error code returned.
[0194] S509 is entered after S502 fails, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0195] In one implementation, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a fifth query key-value pair operation.
[0196] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0197] 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;
[0198] 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;
[0199] 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.
[0200] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0201] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0202] Determine whether the hash table is empty;
[0203] If the hash table is not empty, the number of hash table fields in the hash table will be used as the data processing result corresponding to the data processing instruction.
[0204] If the hash table is empty, 0 will be used as the data processing result corresponding to the data processing instruction.
[0205] Next, combine Figure 7 Provide examples. For instance... Figure 7 As shown, the target hash table type data includes the key of the key-value pairs to be processed, and the target hash table operation type is the fifth query key-value pair operation hlen, which obtains the number of fields corresponding to the key. Specifically, it includes the following S:
[0206] S601: Receive parameters.
[0207] For S601, it accepts a parameter key, which indicates the number of hashmap fields corresponding to the key to be retrieved.
[0208] S602: Determine if the parameter is valid.
[0209] For S602, the key must be of String data type and its size must not exceed the maximum value specified by the key. If this is the case, execute S603; otherwise, execute S609.
[0210] S603: Initialize a HetuKVItem using parameters.
[0211] For S603, valid parameters will be passed here to initialize a HetuItem object.
[0212] S604: Determine if HetuKVItem exists.
[0213] For S604, query whether the corresponding key-value pair exists in HetuKV using the key of HetuItem. If it does, execute S605; otherwise, execute S608.
[0214] S605: Get the corresponding value.
[0215] For S605, after a successful query, extract the value corresponding to the key.
[0216] S606: Determine if the decoded hashmap is empty.
[0217] For S606, after converting the value to a hashmap type, check if the hashmap is empty. If it is, execute S608; otherwise, execute S607.
[0218] S607: Returns the length of the map (i.e., the number of hash table fields in the hash table).
[0219] For S607, if the hashmap is not empty, the length of the hashmap will be returned.
[0220] S608: Returns 0.
[0221] For S608, if the hashmap is empty, return 0.
[0222] S609: Error code returned.
[0223] S609 is entered after S602 fails, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0224] In one implementation, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is a field value deletion operation.
[0225] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0226] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed;
[0227] 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;
[0228] 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.
[0229] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0230] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0231] Iterate through all fields in the hash table and determine whether all fields in the hash table include at least one field from the target hash table.
[0232] If all fields in the hash table include at least one target hash table field, delete the at least one target hash table field to obtain an adjusted hash table, and determine the number of fields successfully deleted;
[0233] The adjusted hash table is updated with the values in the target key-value pair data, and the number of successfully deleted fields is used as the data processing result corresponding to the data processing instruction.
[0234] Next, combine Figure 8 Provide examples. For instance... Figure 8 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed and the target hash table field (field). The target hash table operation type is a field value deletion operation (hdel), which deletes the value of a specific field. Specifically, it includes the following S:
[0235] S701: Receive parameters.
[0236] For S701, it will accept at least two parameters, such as key and fields, where key represents the key and fields represent the fields in the hashmap. hdel will delete the values of the input fields.
[0237] S702: Determine if the parameter is valid.
[0238] For S702, determine if the input parameters are valid. The key must be of String data type and its size must not exceed the maximum value specified by the key. The field must also be of String data type. If valid, proceed to S703; otherwise, proceed to S716.
[0239] S703: Initialize a HetuKVItem using parameters.
[0240] For S703, valid parameters will be passed here to initialize a HetuItem object.
[0241] S704: Set the key for HetuKVItem.
[0242] For S704, set the key of the HetuItem object as the input parameter.
[0243] S705: Determine if HetuKVItem exists.
[0244] For S705, the system will check if the key exists in HetuKV using HetuItem. If it does, proceed to S706; otherwise, proceed to S715.
[0245] S706: Get the corresponding value, count = 0.
[0246] For S706, if a key exists, the existing value is retrieved first, and the count is set to 0.
[0247] S707: Whether to iterate through all the input fields.
[0248] For S707, begin iterating through all fields.
[0249] S708: Query whether a hashmap contains a field.
[0250] For S708, check if the hashmap contains the input field. If it does, execute S709; otherwise, execute S707.
[0251] S709: Count +1.
[0252] For S709, increment the count by 1 for each deleted field.
[0253] S710: If the count > 0.
[0254] For S710, if the count is > 0, execute S711; otherwise, execute S715.
[0255] S711: Set the value of item to the updated hashmap (i.e., the adjusted hash table).
[0256] For S711, update the value of HetuKVItem to the new hashmap (i.e., the adjusted hash table).
[0257] S712: Update via HetuKVItem.
[0258] For S712, the database is updated via HetuKVItem.
[0259] S713: Update successful.
[0260] For S713, determine whether the update was successful. If successful, execute S714; otherwise, execute S716.
[0261] S714: Return count.
[0262] For S714, return the number of fields that were successfully deleted.
[0263] S715: Returns 0.
[0264] For S715, 0 indicates that no field was deleted.
[0265] S716: Returns an error code.
[0266] If S716, S702, or S713 fails to execute, it indicates that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0267] In one implementation, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is the sixth query key-value pair operation.
[0268] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0269] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed;
[0270] 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;
[0271] 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.
[0272] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0273] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0274] Iterate through all fields in the hash table and determine whether all fields in the hash table include the target hash table field;
[0275] If all fields in the hash table include the target hash table field, then all fields in the hash table including the target hash table field are used as the data processing result corresponding to the data processing instruction.
[0276] If all fields in the hash table do not include the target hash table field, then all fields in the hash table excluding the target hash table field are taken as the data processing result corresponding to the data processing instruction.
[0277] Next, combine Figure 9 Provide examples. For instance... Figure 9 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed and the field (field) of the hash table to be queried. The target hash table operation type is the sixth key-value pair query operation (hexists), which queries whether the target field exists. Specifically, it includes the following S:
[0278] S801: Receive parameters.
[0279] For S801, it accepts two parameters: key and field. The key represents the key, and the field represents the field of the hashmap. This operation checks if the target field exists.
[0280] S802: Determine if the parameter is valid.
[0281] For S802, determine if the input parameters are valid. The key must be of String data type and its size must not exceed the maximum value specified by the key. The field must also be of String data type. If valid, proceed to S803; otherwise, proceed to S810.
[0282] S803: Initialize a HetuKVItem using parameters.
[0283] For S803, valid parameters will be passed here to initialize a HetuItem object.
[0284] S804: Set the key for HetuKVItem.
[0285] For S804, set the key of the HetuItem object as the input parameter.
[0286] S805: Determine if HetuKVItem exists.
[0287] For S805, the key will be checked in HetuKV using HetuItem. If it is, S806 will be executed; otherwise, S809 will be executed.
[0288] S806: Get the corresponding value.
[0289] For S806, the value corresponding to the key will be retrieved.
[0290] S807: Determine whether the decoded hashmap contains fields.
[0291] For S807, after converting the value to a hashmap type, check if the hashmap contains the field. If it does, execute S809; otherwise, execute S808.
[0292] S808: Returns True.
[0293] For S808, it returns "true", indicating that the field exists.
[0294] S809: Returns False.
[0295] For S809, "false" is returned, indicating that the field does not exist.
[0296] S810: Returns an error code.
[0297] For S810, if S802 fails to execute, it indicates that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0298] In one implementation, the target hash table type data includes the key of the key-value pair to be processed, the field of the target hash table, and the value corresponding to the field of the target hash table, and the target hash table operation type is a second update key-value pair operation.
[0299] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0300] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field; and the identifier is preset to a failure flag.
[0301] 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;
[0302] 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.
[0303] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0304] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0305] Iterate through all fields in the hash table and determine whether all fields in the hash table include the target hash table field;
[0306] If none of the fields in the hash table include the target hash table field, then the identifier will be used as the data processing result corresponding to the data processing instruction.
[0307] If all fields in the hash table include the target hash table field, then the value corresponding to the target hash table field in the hash table is updated to the value corresponding to the target hash table field in the key-value pair to be processed, and the updated hash table is converted into a value; the identifier is set as a success identifier, and the identifier is used as the data processing result corresponding to the data processing instruction.
[0308] Next, combine Figure 10 Provide examples. For instance... Figure 10 As shown, the target hash table type data includes the key of the key-value pair to be processed, the field of the target hash table, and the value corresponding to the field of the target hash table. The target hash table operation type is the second update key-value pair operation hsetnx, that is, inserting a new value if the field does not exist. Specifically, it includes the following S:
[0309] S901: Receive parameters.
[0310] For S901, it accepts three parameters: key, field, and value. The key represents the key, and the field and value correspond to the fields and values in the hashmap. This operation modifies the value of the corresponding field in the target key.
[0311] S902: Determine if the parameter is valid.
[0312] For S902, determine if the input parameters are valid. The key must be of String data type and its size must not exceed the maximum value specified for the key. The field and value must also be of String data type. If valid, proceed to S903; otherwise, proceed to S914.
[0313] S903: Initialize a HetuKVItem using parameters.
[0314] For S903, valid parameters will be passed here to initialize a HetuItem object.
[0315] S904: Set the key for HetuKVItem.
[0316] For S904, set the key of the HetuItem object as the input parameter.
[0317] S905: Identifier = False.
[0318] For S905, set the identifier to False.
[0319] S906: Determine if HetuKVItem exists.
[0320] For S906, the key will be checked in HetuKV using HetuItem. If it is, S907 will be executed; otherwise, S908 will be executed.
[0321] S907: Get the corresponding value.
[0322] For S907, the value corresponding to the key will be retrieved.
[0323] S908: Determine whether the decoded hashmap contains the input field.
[0324] For S908, after converting the value to a hashmap type, check if the hashmap contains the field. If it does, execute S909; otherwise, execute S913.
[0325] S909: Update the input value to the field.
[0326] For S909, update the value to the corresponding field.
[0327] S910: The identifier is set to True.
[0328] For S910, set the identifier to True.
[0329] S911: Update the modified hashmap to the database.
[0330] For S911, the hashmap is converted into a value and then stored in the database.
[0331] S912: Update successful.
[0332] For S912, determine whether the update was successful. If successful, execute S913; otherwise, execute S914.
[0333] S913: Return identifier.
[0334] For S913, an identifier is returned after a successful update.
[0335] S914: Returns an error code.
[0336] Entering S914 after S902 and S912 fail indicates an operation error and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0337] In one implementation, the target hash table type data includes the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field, wherein the target hash table operation type is a third update key-value pair operation.
[0338] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0339] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field;
[0340] 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;
[0341] 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.
[0342] 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.
[0343] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0344] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table; the fields and corresponding values in the hash table are updated to the target hash table fields and corresponding values of the key-value pair to be processed, resulting in an updated hash table; the updated hash table is converted into a value, and the value is used as the value in the target key-value pair data; and the data processing result corresponding to the data processing instruction is determined to be a successful data update.
[0345] If the target key-value pair data is the empty key-value pair data, a hash table is generated based on the target hash table field of the key-value pair to be processed and the corresponding value of the target hash table field; the hash table is converted into a value, and the value and the key of the key-value pair to be processed are used as the key and value in the empty key-value pair data; the data processing result corresponding to the data processing instruction is determined to be data insertion success.
[0346] Next, combine Figure 11 Provide examples. For instance... Figure 11 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed, the field (field) of the target hash table, and the value (value) corresponding to the field (value) of the target hash table. The target hash table operation type is the third update key-value pair operation hmset, which directly stores a hashmap (i.e., a hash table generated by the field (field) of the target hash table and the value (value) corresponding to the field (value) of the target hash table) into the target key. Specifically, it includes the following S:
[0347] S1001: Receive parameters.
[0348] For S1001, two parameters are accepted: key and hashmap. key represents the key, and hashmap is a hash table of type Map. This operation directly stores the hashmap into the target key.
[0349] S1002: Determine if the parameter is valid.
[0350] For S1002, determine if the input parameters are valid. The key must be of String data type and its size must not exceed the maximum value limit for the key. The size of the hashmap must not exceed the maximum value limit for the value. If valid, proceed to S1003; otherwise, proceed to S1012.
[0351] S1003: Initialize a HetuKVItem using parameters.
[0352] For S1003, valid parameters will be passed here to initialize a HetuItem object.
[0353] S1004: Set the key for HetuKVItem.
[0354] For S1004, set the key of the HetuItem object as the input parameter.
[0355] S1005: Determine if HetuKVItem exists.
[0356] For S1005, the system will check if the key is in HetuKV using HetuItem. If it is, S1006 will be executed; otherwise, S1007 will be executed.
[0357] S1006: Get the corresponding value.
[0358] For S1006, the value corresponding to the key will be queried.
[0359] S1007: Modify the input map to the local map.
[0360] For S1007, make the corresponding modifications to the local hashmap.
[0361] S1008: Set the value of HetuKVItem to the local value.
[0362] For S1008, modify the value of HetuKVItem accordingly.
[0363] S1009: Update the database via HetuKVItem.
[0364] For S1009, the changes will be updated in the database.
[0365] S1010: Update successful.
[0366] For S1010, determine whether the update was successful. If successful, execute S1011; otherwise, execute S1012.
[0367] S1011: Returns "OK".
[0368] For S1011, if the update is successful, it will return OK.
[0369] S1012: Error code returned.
[0370] Entering this state after S1012, S1002, and S1010 fail indicates an error and the operation cannot proceed. At this point, the corresponding error code will be returned and the operation will terminate.
[0371] In one implementation, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is the eighth query key-value pair operation.
[0372] In this embodiment, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0373] If the key of the key-value pair to be processed conforms to the preset string type and the preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field;
[0374] 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;
[0375] 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.
[0376] Accordingly, the step of performing data processing on the target key-value pair data corresponding to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0377] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0378] Iterate through all fields in the hash table and determine whether all fields in the hash table include at least one field from the target hash table.
[0379] If all fields in the hash table include at least one target hash table field, the value corresponding to the at least one target hash table field is stored in a preset data queue.
[0380] The preset data queue is used as the data processing result corresponding to the data processing instruction.
[0381] Next, combine Figure 12 Provide examples. For instance... Figure 12 As shown, the target hash table type data includes the key (key) of the key-value pair to be processed and the field (field) of the target hash table. The target hash table operation type is the eighth query key-value pair operation hmget, which returns the value of a specific field. Specifically, it includes the following S:
[0382] S1101: Receive parameters.
[0383] For S1101, it accepts at least two parameters: key and fields. The key represents the key, and the fields represent the fields in the hashmap. This operation returns the value of the specified field.
[0384] S1102: Determine if the parameter is valid.
[0385] For S1102, determine if the input parameters are valid. The key must be of String data type and its size must not exceed the maximum value specified by the key. The field must also be of String data type. If valid, proceed to S1103; otherwise, proceed to S1112.
[0386] S1103: Initialize a HetuKVItem using parameters.
[0387] For S1103, valid parameters will be passed here to initialize a HetuItem object.
[0388] S1104: Set the key for HetuKVItem.
[0389] For S1104, set the key of the HetuItem object as the input parameter.
[0390] S1105: Determine if HetuKVItem exists.
[0391] For S1105, the system will check if the key is in HetuKV using HetuItem. If it is, S1106 will be executed; otherwise, S1111 will be executed.
[0392] S1106: Get the corresponding value.
[0393] For S1106, the value corresponding to the key will be retrieved.
[0394] S1107: Iterate through all the input fields.
[0395] For S1107, determine whether all fields have been traversed. If not, execute S1108; if traversal is complete, execute S1110.
[0396] S1108: Returns the value or null corresponding to the field.
[0397] For S1108, return the stored value corresponding to the field.
[0398] S1109: Add to ArrayList (i.e., the default data queue).
[0399] For S1109, add the value to the ArrayList.
[0400] S1110: Returns an ArrayList.
[0401] For S1110, return an ArrayList.
[0402] S1111: Returns a NullArrayList containing the corresponding number of fields.
[0403] For S1111, if it does not exist, return a NullArrayList with the corresponding number of fields.
[0404] S1112: Error code returned.
[0405] S1112 is entered after S1102 fails, indicating that the operation has failed and cannot be performed. At this time, the corresponding error code will be returned and the operation will be terminated.
[0406] 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.
[0407] Thus, this embodiment, combined with a specific application scenario, implements the data processing method. 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.
[0408] like Figure 13 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:
[0409] The first unit 1301 is used to receive at least one data processing instruction sent by the client; wherein each data processing instruction includes: target hash table type data and target hash table operation type;
[0410] The second unit 1302 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 hash table type data, wherein each key-value pair data in the key-value database includes a key and at least one hash table, and each hash table includes at least one piece of data, each piece of data including the value corresponding to each field in the hash table; data processing corresponding to the target hash table operation type is performed on the target key-value pair data to obtain the data processing result corresponding to the data processing instruction;
[0411] The third unit 1303 is used to feed back the data processing results corresponding to each of the at least one data processing instruction to the client.
[0412] Optionally, the target hash table type data includes the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field, and the target hash table operation type is a first update key-value pair operation.
[0413] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0414] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field;
[0415] 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;
[0416] 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.
[0417] 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.
[0418] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0419] 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 converted into a hash table, the hash table field and the value corresponding to the hash table field in the hash table are updated to the target hash table field and the value corresponding to the target hash table field in the key-value pair to be processed, and the updated hash table is converted into a value; and, the data processing result corresponding to the data processing instruction is determined to be data update successful;
[0420] If the target key-value pair data is the empty key-value pair data, a hash table is generated based on the target hash table field in the key-value pair to be processed and the value corresponding to the target hash table field. The hash table is converted into a value, and the value and the key in the key-value pair to be processed are used as the key and value in the empty key-value pair data. The data processing result corresponding to the data processing instruction is that the data insertion is successful.
[0421] Optionally, the target hash table type data includes the key of the key-value pair to be processed and the hash table field to be queried, and the target hash table operation type is a first query key-value pair operation.
[0422] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0423] If the key of the key-value pair to be processed conforms to the preset string type and the preset threshold condition, and the hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed and the hash table field to be queried;
[0424] 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;
[0425] 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.
[0426] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0427] Determine whether the value in the target key-value pair data is null;
[0428] If the value in the target key-value pair data is not empty, the value in the target key-value pair data is queried according to the field of the hash table to be queried, and the value in the target key-value pair data that corresponds to the field of the hash table to be queried is obtained; the value corresponding to the field of the hash table to be queried is used as the data processing result corresponding to the data processing instruction.
[0429] Optionally, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a second query key-value pair operation.
[0430] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0431] 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;
[0432] 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;
[0433] 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.
[0434] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0435] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table, and the hash table is used as the data processing result corresponding to the data processing instruction.
[0436] Optionally, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a third query key-value pair operation.
[0437] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0438] 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;
[0439] 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;
[0440] 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.
[0441] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0442] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0443] Determine whether the hash table is empty;
[0444] If the hash table is not empty, the hash table field in the hash table is used as the data processing result corresponding to the data processing instruction.
[0445] If the hash table is empty, the empty value is used as the data processing result corresponding to the data processing instruction.
[0446] Optionally, the target hash table type data includes the keys of the key-value pairs to be processed, and the target hash table operation type is a fourth query key-value pair operation.
[0447] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0448] 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;
[0449] 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;
[0450] 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.
[0451] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0452] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0453] Determine whether the hash table is empty;
[0454] If the hash table is not empty, the values corresponding to all hash table fields in the hash table are used as the data processing results corresponding to the data processing instructions.
[0455] If the hash table is empty, the empty value is used as the data processing result corresponding to the data processing instruction.
[0456] Optionally, the target hash table type data includes the key of the key-value pair to be processed, and the target hash table operation type is the fifth query key-value pair operation.
[0457] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0458] 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;
[0459] 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;
[0460] 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.
[0461] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0462] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0463] Determine whether the hash table is empty;
[0464] If the hash table is not empty, the number of hash table fields in the hash table will be used as the data processing result corresponding to the data processing instruction.
[0465] If the hash table is empty, 0 will be used as the data processing result corresponding to the data processing instruction.
[0466] Optionally, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is a field value deletion operation.
[0467] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0468] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed;
[0469] 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;
[0470] 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.
[0471] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0472] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0473] Iterate through all fields in the hash table and determine whether all fields in the hash table include at least one field from the target hash table.
[0474] If all fields in the hash table include at least one target hash table field, delete the at least one target hash table field to obtain an adjusted hash table, and determine the number of fields successfully deleted;
[0475] The adjusted hash table is updated with the values in the target key-value pair data, and the number of successfully deleted fields is used as the data processing result corresponding to the data processing instruction.
[0476] Optionally, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is the sixth query key-value pair operation.
[0477] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0478] If the key of the key-value pair to be processed conforms to the preset string type and preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed;
[0479] 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;
[0480] 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.
[0481] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0482] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0483] Iterate through all fields in the hash table and determine whether all fields in the hash table include the target hash table field;
[0484] If all fields in the hash table include the target hash table field, then all fields in the hash table including the target hash table field are used as the data processing result corresponding to the data processing instruction.
[0485] If all fields in the hash table do not include the target hash table field, then all fields in the hash table excluding the target hash table field are taken as the data processing result corresponding to the data processing instruction.
[0486] Optionally, the target hash table type data includes the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field, and the target hash table operation type is a second update key-value pair operation.
[0487] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0488] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field; and the identifier is preset to a failure flag.
[0489] 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;
[0490] 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.
[0491] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0492] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0493] Iterate through all fields in the hash table and determine whether all fields in the hash table include the target hash table field;
[0494] If none of the fields in the hash table include the target hash table field, then the identifier will be used as the data processing result corresponding to the data processing instruction.
[0495] If all fields in the hash table include the target hash table field, then the value corresponding to the target hash table field in the hash table is updated to the value corresponding to the target hash table field in the key-value pair to be processed, and the updated hash table is converted into a value; the identifier is set as a success identifier, and the identifier is used as the data processing result corresponding to the data processing instruction.
[0496] Optionally, the target hash table type data includes the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field, and the target hash table operation type is a third update key-value pair operation.
[0497] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0498] If the key of the key-value pair to be processed and the value corresponding to the target hash table field meet the preset string type and preset threshold conditions, and the target hash table field of the key-value pair to be processed meets the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field and the value corresponding to the target hash table field;
[0499] 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;
[0500] 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.
[0501] 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.
[0502] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0503] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table; the fields and corresponding values in the hash table are updated to the target hash table fields and corresponding values of the key-value pair to be processed, resulting in an updated hash table; the updated hash table is converted into a value, and the value is used as the value in the target key-value pair data; and the data processing result corresponding to the data processing instruction is determined to be a successful data update.
[0504] If the target key-value pair data is the empty key-value pair data, a hash table is generated based on the target hash table field of the key-value pair to be processed and the corresponding value of the target hash table field; the hash table is converted into a value, and the value and the key of the key-value pair to be processed are used as the key and value in the empty key-value pair data; the data processing result corresponding to the data processing instruction is determined to be data insertion success.
[0505] Optionally, the target hash table type data includes the key of the key-value pair to be processed and the target hash table field, and the target hash table operation type is the eighth query key-value pair operation.
[0506] Optionally, determining the target key-value pair data in the key-value database based on the target hash table type data includes:
[0507] If the key of the key-value pair to be processed conforms to the preset string type and the preset threshold condition, and the target hash table field of the key-value pair to be processed conforms to the preset string type, a key-value pair class is generated using the key of the key-value pair to be processed, the target hash table field, and the value corresponding to the target hash table field;
[0508] 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;
[0509] 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.
[0510] Optionally, performing data processing on the target key-value pair data according to the target hash table operation type to obtain the data processing result corresponding to the data processing instruction includes:
[0511] If the target key-value pair data is the key-value pair data corresponding to the key-value pair class, then the values in the target key-value pair data are converted into a hash table;
[0512] Iterate through all fields in the hash table and determine whether all fields in the hash table include at least one field from the target hash table.
[0513] If all fields in the hash table include at least one target hash table field, the value corresponding to the at least one target hash table field is stored in a preset data queue.
[0514] The preset data queue is used as the data processing result corresponding to the data processing instruction.
[0515] Optionally, the client is a Java client, and the key-value database is a HetuKV key-value database.
[0516] 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:
[0517] Receive a call instruction sent by the client; wherein the call instruction includes a target solid-state drive identifier;
[0518] 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.
[0519] 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:
[0520] 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.
[0521] Figure 14 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.
[0522] 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 14 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.
[0523] 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.
[0524] 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.
[0525] 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.
[0526] 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.
[0527] 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, specifically for executing the data query method described above.
[0528] The electronic devices described in the foregoing embodiments may be computers.
[0529] 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 take the form of a completely hardware embodiment, a completely software embodiment, or a combination of software and hardware.
[0530] 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.
[0531] 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.
[0532] 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 in that, The method is applied to a solid-state drive corresponding to a key-value database, wherein the key-value database is a combined key-value database, and the key-value pair data in the combined key-value database includes at least one of the following: data related to the field of artificial intelligence, and the method includes: 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; 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; The data processing results corresponding to each of the at least one data processing instruction are fed back to the client. The shared key-value database is multi-core parallel, capable of activating multiple CPU cores, with each core processing a single data processing instruction. The target string type data includes the key and value of the key-value pairs to be processed, and the target operation type is a query update key-value pair operation; determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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. 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. 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: 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. If the target key-value pair data is an empty key-value pair data, update the value in the key-value pair class with the value of the key-value pair to be processed to obtain an 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; 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-order query key-value pair operation; determining the target key-value pair data in the key-value database based on the target string type data includes: If the key of the key-value pair to be processed, the start position of the value to be queried, and the end position meet the preset string type conditions and the preset threshold conditions, a key-value pair class is generated using the key of the key-value pair to be processed, the start position of the value to be queried, and the end position of the value to be queried. 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; If the key-value database contains key-value pair data corresponding to the key-value pair class, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data; 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: 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.
2. The method according to claim 1, characterized in that, 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.
3. The method according to claim 2, characterized in that, The step of determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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. 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.
4. The method according to claim 3, characterized in that, 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: 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; 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.
5. The method according to claim 1, characterized in that, The target string type data includes the keys of the key-value pairs to be processed, and the target operation type is a first query key-value pair operation.
6. The method according to claim 5, characterized in that, The step of determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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.
7. The method according to claim 6, characterized in that, 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: The value in the target key-value pair data is used as the data processing result corresponding to the data processing instruction.
8. The method according to claim 1, characterized in that, The target string type data includes the keys of the key-value pairs to be processed, and the target operation type is a delete key-value pair operation.
9. The method according to claim 8, characterized in that, The step of determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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.
10. The method according to claim 9, characterized in that, 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: Delete the target key-value pair data from the key-value database; The deletion result of the target key-value pair data is used as the data processing result corresponding to the data processing instruction.
11. The method according to claim 1, characterized in that, 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.
12. The method according to claim 11, characterized in that, The step of determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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. 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.
13. The method according to claim 12, characterized in that, 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: 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. 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.
14. The method according to any one of claims 1-13, characterized in that, The client is a Java client, and the key-value database is a combined key-value database.
15. The method according to any one of claims 1-13, characterized in that, Prior to the step of receiving at least one data processing instruction sent by the client, the method further includes: Receive a call instruction sent by the client; wherein the call instruction includes a target solid-state drive identifier; 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.
16. The method according to claim 15, characterized in that, 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: 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.
17. A data processing apparatus, characterized in that, The device is applied to a solid-state drive corresponding to a key-value database. The key-value database is a combined key-value database, which is multi-core parallel, capable of utilizing multiple CPU cores, each of which independently processes a data processing instruction. The key-value pair data in the combined key-value database includes at least one of the following: data related to the field of artificial intelligence. The device includes: 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; 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; 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. The target string type data includes the key and value of the key-value pairs to be processed, and the target operation type is a query update key-value pair operation; determining the target key-value pair data in the key-value database based on the target string type data includes: 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; 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; 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. 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. 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: 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. If the target key-value pair data is an empty key-value pair data, update the value in the key-value pair class with the value of the key-value pair to be processed to obtain an 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; 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-order query key-value pair operation; determining the target key-value pair data in the key-value database based on the target string type data includes: If the key of the key-value pair to be processed, the start position of the value to be queried, and the end position meet the preset string type conditions and the preset threshold conditions, a key-value pair class is generated using the key of the key-value pair to be processed, the start position of the value to be queried, and the end position of the value to be queried. 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; If the key-value database contains key-value pair data corresponding to the key-value pair class, the key-value pair data corresponding to the key-value pair class is used as the target key-value pair data; 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: 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.
18. A readable medium comprising executable instructions, wherein when a processor of an electronic device executes the executable instructions, the electronic device performs the method as described in any one of claims 1 to 16.
19. An electronic device comprising 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 one of claims 1 to 16.
Citation Information
Patent Citations
Data query method, data query device, electronic equipment and storage medium
CN113051268A
KV database data management method and device, computing equipment and storage medium
CN114328453A
Data query method and related device
CN116955421A