Data processing method and device
By processing key-value pair data in parallel, the performance bottleneck of Jedis in a high-concurrency environment is resolved, efficient data processing is achieved, and application performance and user experience are improved.
Patent Information
- Application Number
- CN202510850313.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2025-10-17
AI Technical Summary
The existing Jedis client has performance bottlenecks in high-concurrency environments, cannot implement non-blocking and asynchronous operations, and requires additional configuration of connection pools, which increases development complexity.
Provided are a data processing method and device, which processes key-value pair data in parallel by receiving data processing instructions from a client, utilizing the multi-core performance advantages of a key-value database to achieve efficient parallel data processing, improve application performance and reduce operation latency.
It enables efficient client connection to the key-value database, improves data processing efficiency, reduces operation latency, and enhances user experience and performance.
Smart Images

Figure CN120804190A_ABST
Abstract
Description
[0001] This application is a divisional application of the invention application with the application date of June 25, 2024, the Chinese application number of 202410829376.7, and the invention name of "a data processing method and device". TECHNICAL FIELD
[0002] The present application relates to the technical field of data processing, and particularly relates to a data processing method and device. BACKGROUND
[0003] NoSQL databases are a type of database that emerged in addition to relational databases, aiming to solve the challenges of large-scale data storage and high-concurrency access that traditional relational databases cannot handle. Key-value databases are a major type of NoSQL databases, which store data in the form of key-value pairs, suitable for simple data models and fast read-write operations. In particular, Redis, 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, pipelines, etc.).
[0004] In the field of Java development, with the rapid development of Internet applications, the demand for high performance, scalability and flexibility is growing. Traditional relational databases may face performance bottlenecks when handling large amounts of data and high concurrency requests, so developers have begun to seek alternative solutions. The emergence of key-value databases fills this demand gap and provides Java developers with more choices. Java is a widely used programming language that is applied in enterprise, web, mobile and embedded systems. Many enterprise-level applications and microservice architectures are based on Java technology stacks. Developing Java interfaces for key-value databases allows these applications to easily access and manipulate key-value databases, meeting the needs of application scenarios.
[0005] Key-value databases usually have high performance and scalability characteristics because they are based on a simple key-value pair data model, allowing fast read-write operations. Through Java interfaces, developers can take advantage of the performance of key-value databases for application scenarios that require caching, session management, real-time data processing, etc. Developing Java interfaces for key-value databases can simplify the development process by abstracting and encapsulating database operations. Developers can interact with key-value databases using familiar Java APIs without delving into the underlying implementation of the database. This simplification helps improve development efficiency and reduce the probability of errors.
[0006] In the prior art, Jedis is a Java client library for Redis, providing comprehensive support and direct mapping of Redis commands. Jedis provides encapsulation of Redis commands, including strings, hashes, sets, collections, ordered collections, transactions, publish / subscribe, etc. APIs are also provided to allow developers to interact with Redis using native commands.
[0007] Jedis runs synchronously, which means that Jedis blocks while waiting for a Redis response. This can cause performance bottlenecks, especially in high-concurrency environments. Since Jedis is synchronous, it is not suitable for scenarios that require non-blocking and asynchronous operations. Jedis does not come with a connection pool and requires additional configuration of a connection pool to manage connections. This can increase development complexity. Therefore, there is an urgent need for a method that can be applied to high-concurrency environments and allows Java clients to efficiently connect to key-value databases. SUMMARY
[0008] The present application provides a data processing method and device, which can realize efficient connection of the client to the key-value database using the preset data processing instruction, and can perform parallel data processing on the key-value pair data in the key-value database, realizing efficient parallel data processing, thereby improving the performance of the application program, improving the performance of the client, reducing the operation delay, and thereby improving the efficiency of data processing and reducing the cost of data processing, thereby improving the user experience of data processing.
[0009] In a first aspect, the present application provides a data processing method, which is applied to a solid state disk corresponding to a key-value database, and the method comprises:
[0010] receiving at least one data processing instruction sent by a client; wherein each data processing instruction comprises: target set type data, target set operation type;
[0011] performing parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively; wherein for each data processing instruction, according to the target set type data, determining target key-value pair data in the key-value database, wherein each key-value pair data in the key-value database comprises a key and at least one value, each value comprises at least one ordered set, and each ordered set comprises at least one element, wherein each element comprises at least one field and data values corresponding to each field, and a plurality of elements in each ordered set are sorted according to the data values corresponding to a preset field; performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction;
[0012] feedback the data processing result corresponding to each data processing instruction to the client.
[0013] In a second aspect, the present application provides a data processing device, which is applied to a solid state disk corresponding to a key-value database, and the device comprises:
[0014] A first unit is configured to receive at least one data processing instruction sent by a client, wherein each data processing instruction comprises target set type data and target set operation type.
[0015] A second unit is configured to perform parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each data processing instruction respectively, wherein for each data processing instruction, target key-value pair data in the key-value database is determined according to the target set type data, wherein each key-value pair data in the key-value database comprises one key and at least one value, each value comprises at least one ordered set, and each ordered set comprises at least one element, wherein each element comprises at least one field and data values corresponding to each field, and a plurality of elements in each ordered set are sorted according to data values corresponding to a preset field; the target key-value pair data is subjected to data processing corresponding to the target set operation type to obtain a data processing result corresponding to the data processing instruction.
[0016] A third unit is configured to feedback the data processing result corresponding to each data processing instruction to the client.
[0017] In a third aspect, the present application provides a readable medium comprising execution instructions, when a processor of an electronic device executes the execution instructions, the electronic device executes the method according to any one of the first aspect.
[0018] In a fourth aspect, the present application provides an electronic device comprising a processor and a memory storing execution instructions, when the processor executes the execution instructions stored in the memory, the processor executes the method according to any one of the first aspect.
[0019] It can be seen from the above technical solution that the method provided by the present invention can be applied to a solid-state hard disk corresponding to a key-value database, and the method includes: receiving at least one data processing instruction sent by a client; wherein each data processing instruction includes: target set type data, target set operation type; performing parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instructions; wherein, for each data processing instruction, the target key-value pair data in the key-value database is determined according to the target set type data, wherein each key-value pair data in the key-value database includes a key and at least one value, each value includes at least one ordered set, and each ordered set includes at least one element, wherein each element includes at least one field and data values corresponding to each field, and multiple elements in each ordered set are sorted according to the data values corresponding to preset fields; performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction; and feeding back the data processing result corresponding to each of the at least one data processing instructions to the client. Since in the present application, the key-value pair data in the key-value database can be processed in parallel according to at least one data processing instruction, and the data processing results corresponding to each of the at least one data processing instructions can be obtained, and the data processing results corresponding to each of the at least one data processing instructions can be fed back to the client, therefore, the present application can use the preset data processing instructions to enable the client to efficiently connect to the key-value database, and can perform parallel data processing on the key-value pair data in the key-value database, thereby realizing efficient parallel data processing, thereby improving the performance of the application, improving the performance of the client, reducing operation delays, and thus achieving improved data processing efficiency, reduced data processing costs, and thus improved user experience of data processing.
[0020] The further effects of the above-mentioned non-conventional preferred embodiment will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the existing technical solutions, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A flowchart of a data processing method provided by one embodiment of the present invention;
[0023] Figure 2A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0024] Figure 3 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0025] Figure 4 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0026] Figure 5 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0027] Figure 6 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0028] Figure 7 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0029] Figure 8 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0030] Figure 9 A flowchart of a data processing method provided by an embodiment of the present application is shown in FIG. 1.
[0031] Figure 10 A structural diagram of a data processing device provided by an embodiment of the present application is shown in FIG. 1.
[0032] Figure 11 A structural diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 1. DETAILED DESCRIPTION
[0033] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described below in detail with specific embodiments and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0034] The various non-limiting embodiments of the present application will be described in detail below with reference to the drawings.
[0035] Referring to FIG. 1, a data processing method in an embodiment of the present application is shown, which can be applied to a solid state disk corresponding to a key-value database. In the embodiment, the method may, for example, include the following steps: Figure 1
[0036] Step 1: receiving at least one data processing instruction sent by the client.
[0037] In this embodiment, when the client needs to perform data processing on the key-value pair data in the key-value database through the solid state disk, the client can send at least one data processing instruction to the solid state disk corresponding to the key-value database. In an implementation manner, the client can be a Java client, and the key-value database can be a HetuKV key-value database.
[0038] Each data processing instruction can include target set type data and target set operation type. The target set type data can be understood as the related information of the data set and / or the elements in the data set that need to be processed, for example, the key and / or value of the key-value pair to be processed. It should be noted that each key-value pair data in the key-value database includes a key and at least one value, each value includes at least one sorted set, and each sorted set includes at least one element, wherein each element includes at least one field and the data value corresponding to each field, and the multiple elements in each sorted set are sorted according to the data value corresponding to the preset field. The sorted set is a kind of data structure, which has the characteristics of unique elements and ordered elements. A ranking table of scores is a sorted set. The target set operation type can be understood as the operation mode of the key-value pair to be processed, for example, query, delete, add, etc.
[0039] It should be noted that the key-value pair data in the key-value database can be related data in the fields of artificial intelligence, content recommendation, image rendering, financial risk control, Internet of Things, game development, big data analysis, etc. For example, in the field of artificial intelligence, the scheme provided in the present application can be used for training and deploying machine learning and deep learning models, and the application mode is: used for reading and processing a large amount of training data, quickly performing data preprocessing, caching intermediate results, and storing the trained model in the cache for real-time inference and prediction; in the field of content recommendation system, the content recommendation system usually needs to quickly access and process a large amount of user and content data to generate personalized recommendations, and the scheme provided in the present application can be used to cache user preferences, recommendation history, popular content, etc. to reduce the read pressure of the database and improve the real-time performance and accuracy of the recommendation system; in the field of image rendering and processing, fast access and caching of intermediate results are crucial to performance, and the scheme provided in the present application can be used to store and cache intermediate data generated during the rendering process, such as textures, image slices, rendering results, etc. to help speed up the rendering process and reduce computational load; financial institutions need to quickly process and analyze a large amount of transaction and user data to detect fraudulent behavior and manage risks, and the scheme provided in the present application can be used to cache and quickly access transaction records, account information, risk assessment results, etc. to improve the real-time response capability and data processing performance of the risk control system; in the field of Internet of Things (IoT), Internet of Things devices generate a large amount of data, and fast processing and analysis of these data are crucial to system stability and performance, and the scheme provided in the present application can be used to store and cache sensor data, device status, real-time events, etc. to help the Internet of Things system quickly respond to events and instructions and ensure the real-time performance of the system; game development needs to process a large amount of real-time data, including game state, player information and game events, and the scheme provided in the present application can be used to cache game state, player data, leaderboard, etc. to improve the response speed and performance of the game; big data analysis needs to quickly process and analyze a large amount of data to obtain valuable insights, and the scheme provided in the present application can be used as a data processing transfer station to help realize fast import, processing and caching of data, thereby improving the performance of the analysis system.
[0040] Step 2: performing parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively.
[0041] In this embodiment, if multiple data processing instructions are received at the same time, the multiple data processing instructions can be processed in parallel to obtain data processing results corresponding to each of the at least one data processing instruction respectively. 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 program. The HetuKV key-value database is multi-core parallel, and the Java client supports and can implement multi-threading, so that multiple cores of the CPU can be enabled, and each core processes a data processing instruction separately. For example, when storing a large String file in a multi-core environment, the file can be split into multiple parts, and each core stores a part of the data separately, and the cores can operate simultaneously without interfering with each other. This multi-core parallel processing method can greatly improve the performance of data processing.
[0042] Specifically, for each data processing instruction, the target key-value pair data in the key-value database can be determined according to the target set type data, that is, the target key-value pair data corresponding to the target set type data is queried from the key-value database according to the target set type data. Each key-value pair data in the key-value database includes a key and at least one value, each value includes at least one ordered set, and each ordered set includes at least one element, each element includes at least one field and a data value corresponding to each field, and the multiple elements in each ordered set are sorted according to the data value corresponding to a preset field. It can be understood that in this embodiment, the value corresponding to the key in each key-value pair data is at least one ordered set (i.e., sorted set), that is, an ordered set (i.e., sorted set) is stored using key-value storage. The key is the unique identifier of the ordered set (i.e., sorted set), and the value is the ordered set (i.e., sorted set). The ordered set (i.e., sorted set) has multiple elements, each element includes at least one field and a data value corresponding to each field, and the multiple elements in each ordered set are sorted according to the data value corresponding to a preset field. Simply put, the key is the name of an ordered set, and the value corresponding to the key is the element (member) in the ordered set. For example, taking the ranking of students' test scores as an example, the following is a ranking table (i.e., an ordered set):
[0043] 1st| student a | 100;
[0044] 2nd| student b | 98;
[0045] 3rd| student c | 97;
[0046] 4th | student d | 95;
[0047] 5th | student e | 94;
[0048] 6th | student f | 90.
[0049] Then, the target key-value pair data can be processed according to the data processing mode corresponding to the target set operation type, and a data processing result corresponding to the data processing instruction can be obtained. That is, the target key-value pair data is processed according to the data processing mode corresponding to the target set operation type, and a processed data processing result is obtained. For example, the target set operation type is a sorted set operation of performing a key-value operation, which can include zadd, zcard, zrange, zrangebyscore, etc. In this way, fast and efficient key-value data storage and retrieval can be ensured.
[0050] Step 3: feeding back the data processing result corresponding to each of the at least one data processing instruction to the client.
[0051] After obtaining the data processing result corresponding to each of the at least one data processing instruction, the data processing result corresponding to each of the at least one data processing instruction can be fed back to the client.
[0052] It can be seen from the technical scheme that the method provided by the application can be applied to a solid state disk corresponding to a key-value database, and the method comprises the following steps: receiving at least one data processing instruction sent by a client; wherein each data processing instruction comprises target set type data and a target set operation type; performing parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively; wherein for each data processing instruction, target key-value pair data in the key-value database is determined according to the target set type data, wherein each key-value pair data in the key-value database comprises one key and at least one value, each value comprises at least one ordered set, and each ordered set comprises at least one element, wherein each element comprises at least one field and a data value corresponding to each field, and a plurality of elements in each ordered set are sorted according to the data value corresponding to a preset field; performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction; and feeding back the data processing result corresponding to each of the at least one data processing instruction to the client respectively. In the application, the key-value pair data in the key-value database can be processed in parallel according to at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively, and the data processing result corresponding to each of the at least one data processing instruction is fed back to the client, so that the client can be connected to the key-value database efficiently by using a preset data processing instruction, and the key-value pair data in the key-value database can be processed in parallel, efficient parallel data processing is realized, the performance of an application program is improved, the performance of the client is improved, the operation delay is reduced, the efficiency of data processing is improved, the cost of data processing is reduced, and the user experience of data processing is improved.
[0053] Next, embodiments in different target set type data and target set operation type cases are introduced respectively.
[0054] In an implementation manner, the target set type data comprises a key of a key-value pair to be processed, a target field and a data value corresponding to the target field, and the target set operation type is a first adding operation.
[0055] In this embodiment, the specific implementation manner of determining the target key-value pair data in the key-value database according to the target set type data can be:
[0056] If the key of the to-be-processed key-value pair, the target field, and the data value corresponding to the target field all meet the respective corresponding preset string type, the key of the to-be-processed key-value pair meets the preset threshold condition, and each target field has a corresponding data value, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the target field, and the data value corresponding to the target field.
[0057] It is determined whether the key-value database has the key-value pair data corresponding to the key-value pair class; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0058] If the key-value database has the key-value pair data corresponding to the key-value pair class, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0059] If the key-value database does not have the key-value pair data corresponding to the key-value pair class, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is taken as the target key-value pair data.
[0060] Correspondingly, the target key-value pair data is subjected to the data processing corresponding to the target set operation type to obtain the data processing result corresponding to the data processing instruction, which includes:
[0061] The value in the target key-value pair data is converted into tree graph class data.
[0062] The target field and the data value corresponding to the target field are inserted into the tree graph class data as an element to obtain updated tree graph class (TreeMap) data.
[0063] The updated tree graph class data is converted into the value in the target key-value pair data.
[0064] It is determined that the data processing result corresponding to the data processing instruction is element addition success, and the number of added successful elements is taken as the data processing result corresponding to the data processing instruction.
[0065] Next, combined with Figure 2 illustration. As Figure 2As shown, the target set type data includes the key key of the key-value pair to be processed, the target field in the target element member, and the data value (e.g. score) corresponding to the target field, the target set operation type is the first addition operation zadd, the specified member with the specified score is added to the sorted set stored at key, if the member is already a member of the sorted set, the score will be updated, and the element will be re-inserted into the correct position to ensure sorting; if the key does not exist, a new sorted set with the specified member as the only member will be created. For example, it can be understood that an element has a standard (weight) for comparison, there are three people respectively named Zhang San, Li Si and Wang Wu, the height of Zhang San is 160, the height of Li Si is 180, and the height of Wang Wu is 175, in the queue from high to low, the height is used for comparison, and the order of the three people after the queue is formed is: Li Si, Wang Wu, Zhang San, the queue is an ordered set, and the three people in the queue are members of the ordered set. Specifically, the following steps are included:
[0066] S101: accept parameters
[0067] For step 101, three parameters are accepted: key, score, and member, key is the key value corresponding to the sorted list to be stored, score and member are the score and element of the sorted list, the sorted list is sorted in ascending order of score, and multiple pairs of score and member are accepted.
[0068] S102: determine whether the parameter is even.
[0069] For step 102, determine whether the parameter is even, one score and one member form a pair, if yes, execute S103, if no, execute S115.
[0070] S103: initialize a HetuItem using the parameters.
[0071] For step 103, the legal parameters will be passed here to initialize a HetuItem object.
[0072] S104: initialize a TreeMap.
[0073] For step 104, TreeMap is a class in Java, which is used for adding and changing TreeMap data in Java.
[0074] S105: determine whether the key exists.
[0075] For step 105, the program will first determine whether there is an input key. If there is, execute S106, otherwise execute S107.
[0076] S106: Return the Value corresponding to the key and decode it into TreeMap.
[0077] For step 106, if the key exists, the value corresponding to the key will be called from HetuKV. This value is stored in the form of ByteStream, so it needs to be converted into the corresponding TreeMap for easy operation in Java.
[0078] S107: Determine whether the parameter is Double and String.
[0079] For step 107, Double and String completely correspond to Score and Member, so the program needs to determine whether the parameters are legal to continue the subsequent operation. If yes, execute S108, otherwise execute S115.
[0080] S108: Determine whether the parameter to be added exists.
[0081] For step 108, the program will query whether the input parameter Member exists in the TreeMap obtained in step 106. If not, execute S109, otherwise execute S110.
[0082] S109: Count + 1.
[0083] For step 109, the program will record the number of new Members.
[0084] S110: Store the input parameter in TreeMap.
[0085] For step 110, the program will update Score and Member in TreeMap.
[0086] S111: Convert TreeMap to ByteStream.
[0087] For step 111, the program will convert TreeMap to ByteStream.
[0088] S112: Set a new Value for HetuKVItem.
[0089] For step 112, the program will update the Value of HetuKVItem.
[0090] S113: Determine whether the update is successful.
[0091] For step 113, the object of HetuKV is updated using the updated HetuItem. If the update is successfully performed S114, failure is performed S115.
[0092] S114: return the count.
[0093] For step 114, the count of the new Member is returned.
[0094] S115: return the error code.
[0095] For step 115, S102, S107 and S113 are entered when the operation fails, indicating that the operation is wrong and cannot be performed, at which time the corresponding error code is returned and the operation is ended.
[0096] For example, there are three people, namely Zhang San, Li Si and Wang Wu, the height of Zhang San is 160, the height of Li Si is 180, and the height of Wang Wu is 175. In the queue from high to low, the height is used as the standard for comparison. After the three people are queued, the order is: Li Si, Wang Wu, Zhang San. This queue is an ordered set, and the three people in the queue are members in the ordered set.
[0097] In an implementation mode, the target set type data includes a key of a to-be-processed key-value pair, and the target set operation type is a first query operation.
[0098] In this embodiment, the specific implementation mode of determining the target key-value pair data in the key-value database according to the target set type data can be:
[0099] If the key of the to-be-processed key-value pair conforms to a preset string type and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair.
[0100] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0101] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0102] Correspondingly, the data processing corresponding to the data processing instruction is obtained by performing the data processing corresponding to the target set operation type on the target key-value pair data, and the data processing result corresponding to the data processing instruction includes:
[0103] The value in the target key-value pair data is converted into tree graph class data.
[0104] The number of elements in the tree graph class data is determined.
[0105] The number of elements in the tree graph class data is taken as the data processing result corresponding to the data processing instruction.
[0106] Next, combined with Figure 3 Illustrate. As Figure 3 Indicated, the target set type data includes the key key of the key-value pair to be processed, and the target set operation type is the first query operation zcard, that is, the number of elements of the sorted set is returned, and if the key does not exist, 0 is returned, just like an empty sorted set. Specifically, the following steps are included:
[0107] S201: Receive parameters: key.
[0108] For step 201, a parameter key is received. The key is the key corresponding to the sorted list to be queried.
[0109] S202: Initialize a HetuItem using the parameter.
[0110] For step 202, a legal parameter will be passed here to initialize a HetuItem object.
[0111] S203: Initialize a TreeMap.
[0112] For step 203, TreeMap is a class in Java, which is used for adding and changing TreeMap data in Java, etc.
[0113] S204: Whether to successfully return the Value corresponding to the key.
[0114] For step 204, the program will first determine whether the query instruction is successfully run. If successful, S205 is executed, otherwise S207 is executed.
[0115] S205: Return the Value corresponding to the key and decode it into a TreeMap.
[0116] For step 205, the Value value corresponding to the key will be called from the HetuKV in the case of existing key. This Value value is stored in the form of ByteStream, so it needs to be converted into the corresponding TreeMap for easy operation in Java.
[0117] S206: Return the length of the TreeMap.
[0118] For step 206, the length of the TreeMap, that is, the number of elements of the sorted set, will be returned.
[0119] S207: Determine whether the error information is Item Not Found.
[0120] For step 207, it will be further determined whether the error reason is due to not finding the key. If found, S109 is executed, and if not found, S108 is executed.
[0121] S208: Return an error code.
[0122] For step 208, S207 is entered when it fails, indicating that the operation is wrong and cannot be performed. At this time, the corresponding error code will be returned and the operation will be ended.
[0123] S209: Return "0".
[0124] For step 209, when the input is a new key that is not stored, "0" will be returned.
[0125] In an implementation mode, the target set type data includes a key of a to-be-processed key-value pair, an element start position, and an element end position, and the target set operation type is a second query operation.
[0126] In this embodiment, the target key-value pair data in the key-value database is determined according to the target set type data, including:
[0127] If the key of the to-be-processed key-value pair, the element start position, and the element end position conform to a preset string type, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0128] It is determined whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0129] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0130] Correspondingly, the target key-value pair data is subjected to data processing corresponding to the target set operation type to obtain a data processing result corresponding to the data processing instruction, including:
[0131] The value in the target key-value pair data is converted into a tree graph class data;
[0132] It is determined whether the sorting manner of the element in the tree graph class data is the same as the sorting manner corresponding to the element start position and the element end position.
[0133] If the sorting manner of the elements in the tree graph type data is different from the sorting manner corresponding to the element start position and the element end position, the elements in the tree graph type data are arranged in reverse order to obtain adjusted tree graph type data; if the sorting manner of the elements in the tree graph type data is the same as the sorting manner corresponding to the element start position and the element end position, the elements in the tree graph type data are not adjusted;
[0134] The element corresponding to the element start position and the element corresponding to the element end position are determined in the tree graph type data according to the element start position and the element end position by using a binary search method; and the element corresponding to the element start position to the element corresponding to the element end position are taken as a target element set.
[0135] If the data values corresponding to the preset fields in each element in the target element set are all integer types, the data values corresponding to the preset fields in each element in the target element set are taken as the data processing result corresponding to the data processing instruction.
[0136] Next, combined with Figure 4 illustrate. As Figure 4 shown, the target set type data includes a key key of a key-value pair to be processed, an element start position start, and an element end position stop, and the target set operation type is a second query operation zrange, that is, finding values in a given index range of a sorted set in a key / sorted set pair. Specifically, the following steps are included:
[0137] S301: receiving parameters.
[0138] For step 301, three parameters key, start and stop are received. Wherein key represents the key of the ordered set to be queried, start represents the starting value of the index range, and stop represents the ending value of the index range.
[0139] S302: initializing HetuKVItem.
[0140] For step 302, the legal parameters will be passed here to initialize a HetuItem object.
[0141] S303: initializing a TreeMap.
[0142] For step 303, a TreeMap is initialized to facilitate editing operations in java.
[0143] S304: querying whether HetuKVItem is successful.
[0144] For step 304, use HetuKVItem to query in HetuKV according to its key and judge whether the query is successful. If yes, execute S305, otherwise execute S320.
[0145] S305: return the Value corresponding to the key and decode it into TreeMap.
[0146] For step 305, return the value and decode it into TreeMap type.
[0147] S306: extract and initialize input parameters.
[0148] For step 306, initialize input parameters.
[0149] S307: traverse all input parameters.
[0150] For step 307, traverse all input parameters and judge whether to end the traversal.
[0151] S308: judge whether it is String.
[0152] For step 308, judge whether the input parameter is String. If yes, execute S313, otherwise execute S318.
[0153] S309: judge whether it contains "REV".
[0154] For step 309, judge whether the input parameter is REV. If yes, execute S310, otherwise execute S307.
[0155] S310: arrange all data in reverse order.
[0156] For step 310, if "REV" appears, arrange all data in reverse order.
[0157] S311: apply binary search to range boundary.
[0158] For step 311, apply binary search to range boundary.
[0159] S312: return elements in specified range.
[0160] For step 312, return sorted set values in the given score range.
[0161] S313: whether it contains "LIMIT".
[0162] For step 313, judge whether the input parameter is LIMIT. If yes, execute S314, otherwise execute S307.
[0163] S314: Return a sublist of the specified range.
[0164] For step 314, if LIMIT appears, return a sublist of the specified range.
[0165] S315: Determine if "WITHSCORES" is included.
[0166] For step 315, determine if the input parameter is WITHSCORES. If yes, execute S316, otherwise execute S317.
[0167] S316: Return list and score.
[0168] For step 316, if WITHSCORES appears, return the value along with the score.
[0169] S317: Return list.
[0170] For step 317, if WITHSCORES does not appear, only return the value.
[0171] S318: Determine if it is an Integer.
[0172] For step 318, determine if it is an integer type. If yes, execute S319, otherwise execute S311.
[0173] S319: Add integer to limitnumber.
[0174] For step 319, if it is an integer type, add this integer type to the limitnumber variable.
[0175] S320: Return error code.
[0176] For step 320, enter when S304 fails, indicating that the operation is incorrect and cannot be performed. At this time, the corresponding error code will be returned and the operation will end.
[0177] For example, taking the ranking of students' exam scores as an example, the following is a ranking table (that is, an ordered set):
[0178] 1st| Student a | 100;
[0179] 2nd| Student b | 98;
[0180] 3rd| Student c | 97;
[0181] 4th| Student d | 95;
[0182] 5th| Student e | 94;
[0183] Rank 6 | Student f | 90;
[0184] To find the students between rank 2 and rank 5 (i.e. find the elements in the ordered set with index 1 to index 4, where index starts from 0), the result is: [b, c, d, e].
[0185] In an implementation manner, the target set type data comprises a key of a to-be-processed key-value pair, a target field, a data value start position corresponding to the target field, and a data value end position, and the target set operation type is a third query operation.
[0186] In this embodiment, the determining the target key-value pair data in the key-value database according to the target set type data comprises:
[0187] If the key of the to-be-processed key-value pair, the target field, the data value start position corresponding to the target field, and the data value end position all conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0188] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0189] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0190] Correspondingly, the performing data processing on the target key-value pair data according to the target set operation type to obtain the data processing result corresponding to the data processing instruction comprises:
[0191] Converting the value in the target key-value pair data into a tree graph class data;
[0192] It is judged whether the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field.
[0193] If the sorting manner of the elements in the tree graph class data is not the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are not adjusted.
[0194] Using a binary search method, according to the target field, the starting position of the data value corresponding to the target field, and the ending position of the data value, determining in the tree graph data a target element whose data value of the target field is greater than or equal to the starting position of the data value corresponding to the target field and less than or equal to the ending position of the data value corresponding to the target field;
[0195] If the data values corresponding to the target fields in the target element are all integer types, the data values corresponding to the preset fields in the target element are used as the data processing results corresponding to the data processing instructions.
[0196] Next, combine Figure 5 Let’s give an example. Figure 5 As shown, the target set type data includes the key of the key-value pair to be processed, the target field, the starting position min of the data value corresponding to the target field, and the ending position max of the data value. The target set operation type is the third query operation zrangebyscore, that is, finding the sorted set value of a given score range in the key / sorted set pair. The target field can be a score, the score can be understood as the weight corresponding to the element, and the index can be understood as the position of the element in the list. Taking the ranking of student test scores as an example, the following is a score ranking table (that is, an ordered set):
[0197] No. 1 | Student A | 100
[0198] 2nd place | Student B | 98
[0199] 3rd place | Student C | 97
[0200] 4th place | Student D | 95
[0201] No. 5|Student e|94
[0202] The third query operation zrangebyscore searches for students with scores between 90 and 96, and the result is [d, e, f]. Specifically, the following steps are included:
[0203] S401: Receive parameters.
[0204] For step 401, five parameters are received: key, min, max, offset, and count. Key represents the key of the sorted set to be queried, min represents the starting value of the score range, max represents the ending value of the score range, offset represents the initial value of the sorted set limit index, and count represents the sorted set limit value.
[0205] S402: Initialize HetuKVItem.
[0206] For step 402, the legal parameters will be passed here to initialize a HetuItem object.
[0207] S403: Initialize a TreeMap.
[0208] For step 403, initialize a TreeMap to facilitate editing operations in Java.
[0209] S404: Query HetuKVItem for success.
[0210] For step 404, use HetuKVItem to query HetuKV based on its key and determine if the query is successful. If yes, execute S405, otherwise execute S420.
[0211] S405: Return the key corresponding Value and decode it as a TreeMap.
[0212] For step 405, return the value and decode it as a TreeMap type.
[0213] S406: Extract and initialize input parameters.
[0214] For step 406, initialize input parameters.
[0215] S407: Iterate through all input parameters.
[0216] For step 407, iterate through all input parameters and determine if the iteration is complete.
[0217] S408: Determine if it is a String.
[0218] For step 408, determine if the input parameter is a String. If yes, execute S413, otherwise execute S418.
[0219] S409: Determine if it contains "REV".
[0220] For step 409, determine if the input parameter is REV. If yes, execute S410, otherwise execute S407.
[0221] S410: Arrange all data in reverse order.
[0222] For step 410, if "REV" appears, arrange all data in reverse order.
[0223] S411: Apply binary search to range boundaries.
[0224] For step 411, apply binary search to range boundaries.
[0225] S412: Return elements in the specified range.
[0226] For step 412, return the sorted set values in the given score range.
[0227] S413: Check if "LIMIT" is included.
[0228] For step 413, check if the input parameter is LIMIT. If yes, execute S414, otherwise execute S407.
[0229] S414: Return sub-list in the specified range.
[0230] For step 414, if LIMIT is present, return one sub-list in the specified range.
[0231] S415: Check if "WITHSCORES" is included.
[0232] For step 415, check if the input parameter is WITHSCORES. If yes, execute S416, otherwise execute S417.
[0233] S416: Return list and score.
[0234] For step 416, if WITHSCORES is present, return the values along with the scores.
[0235] S417: Return list.
[0236] For step 417, if WITHSCORES is not present, only return the values.
[0237] S418: Check if it is an Integer.
[0238] For step 418, check if it is an integer type. If yes, execute S419, otherwise execute S411.
[0239] S419: Add integer to limitnumber.
[0240] For step 419, if it is an integer type, add this integer type to the limitnumber variable.
[0241] S420: Return error code.
[0242] For step 420, enter when S404 fails, indicating that the operation cannot be performed due to an error. At this time, the corresponding error code will be returned and the operation will end.
[0243] In an implementation manner, the target set type data comprises a key of a to-be-processed key-value pair, a target field, a data value start position corresponding to the target field, and a data value end position corresponding to the target field, and the target set operation type is a fourth query operation.
[0244] In this embodiment, the determining, according to the target set type data, of target key-value pair data in the key-value database comprises:
[0245] If the key of the to-be-processed key-value pair, the target field, the data value start position corresponding to the target field, and the data value end position corresponding to the target field all conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0246] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0247] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0248] Correspondingly, the performing, on the target key-value pair data, of data processing corresponding to the target set operation type to obtain a data processing result corresponding to the data processing instruction comprises:
[0249] The value in the target key-value pair data is converted into tree graph class data.
[0250] It is judged whether the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field.
[0251] If the sorting manner of the elements in the tree graph class data is not the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are not adjusted.
[0252] By using a binary search manner, a target element whose data value of the target field is greater than or equal to the data value start position corresponding to the target field and less than or equal to the data value end position corresponding to the target field is determined in the tree graph class data according to the target field, the data value start position corresponding to the target field, and the data value end position corresponding to the target field.
[0253] The number of target elements is taken as the data processing result corresponding to the data processing instruction.
[0254] Next, combined with Figure 6 illustrate. As Figure 6 shown, the target set type data includes the key key of the key value pair to be processed, the target field, the data value start position start corresponding to the target field, and the data value end position end, and the target set operation type is the fourth query operation zcount, that is, checking the size of the ordered set in the given score range in the key / sorting set pair. Taking the ranking of students' test scores as an example, the following is a score ranking table (that is, an ordered set):
[0255] 1st| student a| 100
[0256] 2nd| student b| 98
[0257] 3rd| student c| 97
[0258] 4th| student d| 95
[0259] 5th| student e| 94
[0260] 6th| student f| 90; The fourth query operation zcount is to find out how many students between 90 and 96 points, and the search result is: 3. Specifically, the following steps are included:
[0261] S501: Receive parameters.
[0262] For step 501, three parameters key, start and end are received. Wherein key represents the key of the ordered set to be queried, start represents the starting value of the score range, and end represents the end value of the score range.
[0263] S502: Initialize HetuKVItem.
[0264] For step 502, the legal parameters will be passed here to initialize a HetuItem object.
[0265] S503: Set the key of HetuKVItem.
[0266] For step 503, set the input parameter as the key of HetuKVItem.
[0267] S504: Query whether it is successful.
[0268] For step 504, HetuKVItem is used to query in HetuKV according to its key and judge whether the query is successful. If yes, execute S505, otherwise execute S507.
[0269] S505: If the input is double type.
[0270] For step 505, determine whether the input is double type. If yes, execute S506, otherwise execute S508.
[0271] S506: Return the set length.
[0272] For step 506, return the set length.
[0273] S507: Return error code.
[0274] For step 507, enter when S504 fails, indicating that the operation is wrong and cannot be performed. At this time, the corresponding error code is returned and the operation is ended.
[0275] S508: If the input is String type.
[0276] For step 508, determine whether the input is String type. If yes, execute S509, otherwise execute S510.
[0277] S509: Return the set length.
[0278] For step 509, return the set length.
[0279] S510: Return "0".
[0280] For step 510, return 0 if it is not String type and not Double type.
[0281] In an implementation mode, the target set type data includes a key of a to-be-processed key-value pair, a target field, and a target element position, and the target set operation type is a fifth query operation.
[0282] In this embodiment, the target key-value pair data in the key-value database is determined according to the target set type data, including:
[0283] If the key of the to-be-processed key-value pair, the target field, the data value start position corresponding to the target field, and the data value end position all conform to the respective corresponding preset string type, and the key of the to-be-processed key-value pair conforms to the preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0284] 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 to-be-processed key-value pair.
[0285] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0286] Correspondingly, the data processing instruction corresponding to the data processing instruction is obtained by performing the data processing corresponding to the target set operation type on the target key-value pair data, including:
[0287] Converting the value in the target key-value pair data into tree graph class data;
[0288] According to the target element position, the target element corresponding to the target element position is determined from the tree graph class data;
[0289] The data value corresponding to the target field in the target element is taken as the data processing result corresponding to the data processing instruction.
[0290] Next, combined with Figure 7 illustrate. As Figure 7 shown, the target set type data includes the key key of the key-value pair to be processed, the target field, the target element position member, and the target set operation type is the fifth query operation zscore, that is, the score of the specified element in the sorted set at the keyword is returned. If the specified element does not exist in the sorted set, or the key does not exist at all, a special "empty" value will be returned. Taking the ranking of students' test scores as an example, the following is a score ranking table (that is, an ordered set):
[0291] 1st| student a | 100
[0292] 2nd| student b | 98
[0293] 3rd| student c | 97
[0294] 4th| student d | 95
[0295] 5th| student e | 94
[0296] 6th| student f | 90; The fifth query operation zscore is to find the score of student a, and the search result is: 100, and the score of student H is found, and the search result is: null. Specifically, it includes the following steps:
[0297] S601: Receive parameters.
[0298] For step 601, two parameters key and member are received. Wherein key represents the key of the ordered set to be queried, and member represents the target member.
[0299] S602: Initialize HetuKVItem.
[0300] For step 602, the legal parameters will be passed here to initialize a HetuItem object.
[0301] S603: Set the key of HetuKVItem.
[0302] For step 603, set the input parameter as the key of HetuKVItem.
[0303] S604: Query whether it is successful.
[0304] For step 604, query in HetuKV according to the key of HetuKVItem and judge whether the query is successful. If yes, execute S605, otherwise execute S606.
[0305] S605: Return the score of the member.
[0306] For step 605, when the query is successful, directly return the score corresponding to the member.
[0307] S606: If the item does not exist.
[0308] For step 606, judge whether the item exists. If yes, execute S608, otherwise execute S607.
[0309] S607: Return Null.
[0310] For step 607, return Null in the case that the item does not exist.
[0311] S608: Return error code.
[0312] For step 608, enter when S606 fails, indicating that the operation is wrong and cannot be performed. At this time, the corresponding error code will be returned and the operation will be ended.
[0313] In an implementation mode, the target set type data includes a key of a to-be-processed key-value pair and a target element position, and the target set operation type is a deletion operation.
[0314] In this embodiment, the target key-value pair data in the key-value database is determined according to the target set type data, and includes:
[0315] If the key of the to-be-processed key-value pair and the target field both conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair and the target field.
[0316] Determine whether there is key-value pair data corresponding to the key-value pair class 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;
[0317] If 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.
[0318] Accordingly, performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction includes:
[0319] Convert the value in the target key-value pair data into tree graph data;
[0320] Deleting the target element corresponding to the target element position in the tree graph data;
[0321] The number of successfully deleted target elements is used as the data processing result corresponding to the data processing instruction.
[0322] Next, combine Figure 8 Let’s give an example. Figure 8 As shown, the target set type data includes the key of the key-value pair to be processed, the target element position member, and the target set operation type is the delete operation zrem, that is, deleting the specified member from the sorted set value stored at key. If the member is not in the sorted set, no operation is performed. If the key does not contain a set value, an error message is returned. Taking the ranking of student exam scores as an example, the following is a score ranking table (that is, an ordered set):
[0323] No. 1 | Student A | 100
[0324] 2nd place | Student B | 98
[0325] 3rd place | Student C | 97
[0326] 4th place | Student D | 95
[0327] No. 5|Student e|94
[0328] 6th place|student f|90;
[0329] The delete operation zrem is to reorder the records of student b to be deleted. After the operation is completed, a new score ranking table is obtained:
[0330] No. 1 | Student A | 100
[0331] 2nd place | Student C | 97
[0332] 3rd place | Student D | 95
[0333] Rank 4 | student e | 94
[0334] Rank 5 | student f | 90. Specifically, the following steps are included:
[0335] S701: Receive parameters.
[0336] For step 701, two parameters, key and member, are received. Wherein key represents the key of the ordered set to be queried, and member represents the target member.
[0337] S702: Initialize HetuKVItem.
[0338] For step 702, a valid parameter will be passed here to initialize a HetuItem object.
[0339] S703: Set the key of HetuKVItem.
[0340] For step 703, the input parameter is set as the key of HetuKVItem.
[0341] S704: Query whether it is successful.
[0342] For step 704, HetuKVItem is used to query in HetuKV according to its key, and it is judged whether the query is successful. If yes, S705 is executed, otherwise S712 is executed.
[0343] S705: Set count = 0.
[0344] For step 705, the count is initialized to 0.
[0345] S706: Traverse all objects to be deleted.
[0346] For step 706, it is judged whether all objects to be deleted are traversed. If yes, S710 is executed, otherwise S707 is executed.
[0347] S707: If the Treemap contains the object.
[0348] For step 707, if the Treemap contains the object to be deleted, S708 is executed, otherwise S706 is executed.
[0349] S708: Delete the object.
[0350] For step 708, the object is deleted in the Treemap.
[0351] S709: Count + 1.
[0352] For step 709, the number of record deletion objects is recorded.
[0353] S710: Update the Treemap into HetuKV.
[0354] For step 710, update the Treemap that has completed operation into HetuKV.
[0355] S711: Return the count.
[0356] For step 711, return the count.
[0357] S712: Return the error code.
[0358] For step 712, enter when S704 fails, indicating that the operation is wrong and cannot be performed, at which time the corresponding error code is returned and the operation is ended.
[0359] In an implementation mode, the target set type data includes a key of a to-be-processed key-value pair, a target field, a data value start position and a data value end position corresponding to the target field, an index start position, and an index element number, and the target set operation type is a sixth query operation.
[0360] In this embodiment, the target key-value pair data in the key-value database is determined according to the target set type data, including:
[0361] If the key of the to-be-processed key-value pair, the target field, the data value start position and the data value end position corresponding to the target field, the index start position, and the index element number all conform to the respective corresponding preset string type, and the key of the to-be-processed key-value pair conforms to the preset threshold condition, a key-value pair class is generated by using the key, the target field, the data value start position and the data value end position corresponding to the target field, the index start position, and the index element number.
[0362] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0363] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0364] Correspondingly, the target key-value pair data is subjected to data processing corresponding to the target set operation type to obtain a data processing result corresponding to the data processing instruction, including:
[0365] The value in the target key-value pair data is converted into a tree graph class data.
[0366] Determine whether the sorting mode of the elements in the tree graph data is the same as the sorting mode corresponding to the starting position and the ending position of the data value corresponding to the target field;
[0367] If the sorting mode of the elements in the tree graph data is different from the sorting mode corresponding to the starting position and the end position of the data value corresponding to the target field, the elements in the tree graph data are sorted in reverse order to obtain the adjusted tree graph data; if the sorting mode of the elements in the tree graph data is the same as the sorting mode corresponding to the starting position and the end position of the data value corresponding to the target field, the elements in the tree graph data are not adjusted;
[0368] Determine a target element set in the tree graph data using a binary search method based on the target field, a starting position of a data value corresponding to the target field, and an ending position of a data value, wherein the data value of the target field of each target element in the target element set is greater than or equal to the starting position of the data value corresponding to the target field and less than or equal to the ending position of the data value corresponding to the target field;
[0369] If the data values corresponding to the target fields in the target elements are all integer types, the target element corresponding to the index starting position in the target element set is used as the starting point, the target elements of the index element quantity are determined, and the target elements of the index element quantity are used as the data processing results corresponding to the data processing instruction.
[0370] Next, combine Figure 9 Let’s give an example. Figure 9 As shown, the target set type data includes the key of the key-value pair to be processed, the target field, the starting position min and ending position max of the data value corresponding to the target field, the index starting position offset, and the number of index elements count. The target set operation type is the sixth query operation zrangebylex, which is to find the value in the sorted set of the given part-of-speech range in the key / sorted set pair. For example, there is an ordered set [a, b, c, d, e, f, g]. According to the scores min and max, the subset [b, c, d, e, f] of this ordered set is filtered out. Offset represents the index position of this subset, and count represents how many elements to search from this index position. For example: offset = 0, count = 2, the search result is [b, c]; offset = 1, count = 1, the search result is [c]; offset = 1, count = 2, the search result is [c, d]; offset = 2, count = 3, the search result is [d, e, f]; offset = 2, count = 5, the search result is [d, e, f]. Specifically, the following steps are included:
[0371] S801: Receive parameters.
[0372] For step 801, key is the target key, min is the start value of the score range, max is the end value of the score range, offset is the initial value of the number of ordered sets limit index, and count is the value of the number of ordered sets limit. The function is to find the number of ordered sets in the given score range in the key / ordered set pair. Min, max, offset, and count are all used to limit the range of the search. Min and max are the minimum and maximum values of the closed interval, which are used to perform a preliminary search in the ordered set to obtain a subset of the ordered set. Offset and count are used to further search in this subset of the ordered set.
[0373] S802: Initialize HetuKVItem.
[0374] For step 802, valid parameters will be passed here to initialize a HetuItem object.
[0375] S803: Initialize a TreeMap.
[0376] For step 803, initialize a TreeMap to facilitate editing operations in Java.
[0377] S804: Query whether HetuKVItem is successful.
[0378] For step 804, use HetuKVItem to query in HetuKV according to its key and judge whether the query is successful. If yes, execute S805, otherwise execute S820.
[0379] S805: Return the value corresponding to the key and decode it as a TreeMap.
[0380] For step 805, return the value and decode it as a TreeMap type.
[0381] S806: Extract and initialize input parameters.
[0382] For step 806, initialize input parameters.
[0383] S807: Traverse all input parameters.
[0384] For step 807, traverse all input parameters and judge whether to end the traversal.
[0385] S808: Judge whether it is a String.
[0386] For step 808, determine if the input parameter is String. If so, execute S813, else execute S818.
[0387] S809: Determine if "REV" is present.
[0388] For step 809, determine if the input parameter is REV, if so, execute S810, else execute S807.
[0389] S810: Sort all data in reverse order.
[0390] For step 810, if "REV" is present, sort all data in reverse order.
[0391] S811: Apply binary search to range bounds.
[0392] For step 811, apply binary search to range bounds.
[0393] S812: Return elements in specified range.
[0394] For step 812, return sorted set values for a given score range.
[0395] S813: Determine if "LIMIT" is present.
[0396] For step 813, determine if the input parameter is LIMIT, if so, execute S814, else execute S807.
[0397] S814: Return sub-list for specified range.
[0398] For step 814, if "LIMIT" is present, return one sub-list for the specified range.
[0399] S815: Determine if "WITHSCORES" is present.
[0400] For step 815, determine if the input parameter is WITHSCORES, if so, execute S816, else execute S817.
[0401] S816: Return list and score.
[0402] For step 816, if "WITHSCORES" is present, return values with scores.
[0403] S817: Return list.
[0404] For step 817, if "WITHSCORES" is not present, return values only.
[0405] S818: Is it an Integer.
[0406] For step 818, it is determined whether it is an integer type. If yes, S819 is executed, and if not, S811 is executed.
[0407] S819: Add integer to limitnumber.
[0408] For step 819, if it is an integer type, this integer type is added to the limitnumber variable.
[0409] S820: Return an error code.
[0410] For step 820, S804 is entered when the execution fails, indicating that the operation is wrong and cannot be performed. At this time, the corresponding error code is returned and the operation is ended.
[0411] In an embodiment, before the step of receiving at least one data processing instruction sent by the client, the method further comprises:
[0412] Receiving a calling instruction sent by the client; wherein the calling instruction comprises a target solid state disk identifier;
[0413] According to the target solid state disk identifier, calling the solid state disk corresponding to the target solid state disk identifier, and taking the solid state disk corresponding to the target solid state disk identifier as the solid state disk corresponding to the key-value database, and adjusting the state of the solid state disk corresponding to the key-value database to a locked state.
[0414] Correspondingly, after the step of feeding back the data processing result corresponding to each of the at least one data processing instruction to the client respectively, the method further comprises:
[0415] Releasing the memory of the solid state disk corresponding to the key-value database, and adjusting the state of the solid state disk corresponding to the key-value database to an idle state.
[0416] As an example, when calling the HetuKV key-value database using the java client, a certain solid state disk is specified and locked, and after the call is ended, the memory occupied by the solid state disk is released, that is, the garbage collection mechanism of the HetuKV key-value database is used to release the memory occupied by the solid state disk in a timely manner. During the process of locking the solid state disk, other processes cannot use the solid state disk. In the embodiment, the data calculation is downgraded to the solid state disk, which can reduce the dependence on memory, and the garbage collection mechanism is used to optimize resource utilization, and the solid state disk is locked to ensure the safety and reliability of data, so that resource optimization and safety protection can be realized, that is, through the advantages of HetuKV, resource utilization is optimized, the safety and reliability of data are ensured, the dependence on memory is reduced, hardware resource utilization is optimized, memory consumption is reduced, the system is more flexible, in addition, the safety and control right are enhanced, complete control right is provided, and the safety of data is enhanced, and the safety of data of enterprise-level applications is ensured.
[0417] So far, the embodiment has realized the processing process of the data processing method in combination with a specific application scenario. Of course, it should be considered that the above-mentioned scenario is only an exemplary scenario and does not limit the method provided by the present application. The method provided by the present application can be applied in other data processing method processing processes with the same principle.
[0418] As Figure 10 shown, it is a specific embodiment of the data processing apparatus described in the present application. The apparatus described in the embodiment, that is, the entity apparatus for executing the method described in the above-mentioned embodiment. The technical scheme of the embodiment is essentially consistent with the above-mentioned embodiment, and the corresponding description in the above-mentioned embodiment is also applicable to the embodiment. In the embodiment, the apparatus is applied to the solid state disk corresponding to the key-value database, and the apparatus comprises:
[0419] The first unit 1001 is configured to receive at least one data processing instruction sent by a client; wherein each data processing instruction comprises target set type data and target set operation type.
[0420] The second unit 1002 is configured to perform parallel data processing on the at least one data processing instruction to obtain a data processing result corresponding to each of the at least one data processing instruction respectively; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target set type data, wherein each key-value pair data in the key-value database comprises a key and at least one value, each value comprises at least one ordered set, and each ordered set comprises at least one element, wherein each element comprises at least one field and a data value corresponding to each field, and a plurality of elements in each ordered set are sorted according to the data value corresponding to a preset field; the target key-value pair data is subjected to data processing corresponding to the target set operation type to obtain a data processing result corresponding to the data processing instruction;
[0421] The third unit 1003 is configured to feed back the data processing result corresponding to each of the at least one data processing instruction to the client.
[0422] Optionally, the target set type data comprises a key of a to-be-processed key-value pair, a target field, and a data value corresponding to the target field, and the target set operation type is a first adding operation.
[0423] Optionally, the second unit 1002 is configured to:
[0424] If the key of the to-be-processed key-value pair, the target field, and the data value corresponding to the target field all meet the respective preset string type, the key of the to-be-processed key-value pair meets a preset threshold condition, and each target field has a data value corresponding thereto, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the target field, and the data value corresponding to the target field.
[0425] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein, the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0426] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0427] If the key-value pair data corresponding to the key-value pair class does not exist in the key-value database, an empty key-value pair data is created in the key-value database, and the empty key-value pair data is taken as the target key-value pair data.
[0428] Optionally, the second unit 1002 is configured to:
[0429] The value in the target key-value pair data is converted into a tree graph class data.
[0430] Insert the target field and the data value corresponding to the target field as an element into the tree graph type data to obtain updated tree graph type data;
[0431] Convert the updated tree graph type data into a value in the target key-value pair data;
[0432] Determine that the data processing result corresponding to the data processing instruction is element addition success, and the number of elements added successfully is the data processing result corresponding to the data processing instruction.
[0433] Optionally, the target set type data includes a key of a to-be-processed key-value pair, and the target set operation type is a first query operation.
[0434] Optionally, the second unit 1002 is configured to:
[0435] If the key of the to-be-processed key-value pair meets a preset string type and the key of the to-be-processed key-value pair meets a preset threshold condition, generate a key-value pair class by using the key of the to-be-processed key-value pair;
[0436] Determine whether the key-value database includes key-value pair data corresponding to the key-value pair class, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair;
[0437] If the key-value database includes the key-value pair data corresponding to the key-value pair class, use the key-value pair data corresponding to the key-value pair class as target key-value pair data.
[0438] Optionally, the second unit 1002 is configured to:
[0439] Convert a value in the target key-value pair data into tree graph type data;
[0440] Determine the number of elements in the tree graph type data;
[0441] Use the number of elements in the tree graph type data as the data processing result corresponding to the data processing instruction.
[0442] Optionally, the target set type data includes a key of a to-be-processed key-value pair, a start position of an element, and an end position of the element, and the target set operation type is a second query operation.
[0443] Optionally, the second unit 1002 is configured to:
[0444] If the key of the to-be-processed key-value pair, the start position of the element, and the end position of the element meet a preset string type, and the key of the to-be-processed key-value pair meets a preset threshold condition, generate a key-value pair class by using the key of the to-be-processed key-value pair, the start position of the element, and the end position of the element;
[0445] determining whether the key-value pair data corresponding to the key-value pair class exists in the key-value database; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair;
[0446] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data.
[0447] Optionally, the second unit 1002 is configured to:
[0448] convert the value in the target key-value pair data into tree graph class data;
[0449] determine whether the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the element start position and the element end position;
[0450] If the sorting manner of the elements in the tree graph class data is not the same as the sorting manner corresponding to the element start position and the element end position, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the element start position and the element end position, the elements in the tree graph class data are not adjusted;
[0451] determine the element corresponding to the element start position and the element corresponding to the element end position in the tree graph class data according to the element start position and the element end position by using a binary search manner; and take the element corresponding to the element start position to the element corresponding to the element end position as a target element set;
[0452] If the data values of the preset fields in each element in the target element set are all of integer type, the data values of the preset fields in each element in the target element set are taken as the data processing result corresponding to the data processing instruction.
[0453] Optionally, the target set type data includes the key of the to-be-processed key-value pair, a target field, a data value start position and a data value end position of the target field, and the target set operation type is a third query operation.
[0454] Optionally, the second unit 1002 is configured to:
[0455] If the key of the to-be-processed key-value pair, the target field, the data value start position and the data value end position of the target field all conform to the respective preset string type, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position and the element end position.
[0456] determining whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair;
[0457] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as the target key-value pair data.
[0458] Optionally, the second unit 1002 is configured to:
[0459] convert the value in the target key-value pair data into tree graph class data;
[0460] determine whether the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position of the target field;
[0461] If the sorting manner of the elements in the tree graph class data is not the same as the sorting manner corresponding to the data value start position and the data value end position of the target field, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position of the target field, the elements in the tree graph class data are not adjusted;
[0462] determine, by using a binary search manner, a target element in the tree graph class data according to the target field, the data value start position and the data value end position corresponding to the target field, wherein the data value of the target field is greater than or equal to the data value start position corresponding to the target field and is less than or equal to the data value end position corresponding to the target field;
[0463] If the data values of the target field in the target element are all integer types, the data values of the preset field in the target element are taken as the data processing result corresponding to the data processing instruction.
[0464] Optionally, the target set type data includes the key of the to-be-processed key-value pair, the target field, the data value start position and the data value end position corresponding to the target field, and the target set operation type is a fourth query operation.
[0465] Optionally, the second unit 1002 is configured to:
[0466] If the key of the to-be-processed key-value pair, the target field, the data value start position corresponding to the target field, and the data value end position corresponding to the target field all conform to the respective corresponding preset string type, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0467] It is determined whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, where the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0468] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data.
[0469] Optionally, the second unit 1002 is configured to:
[0470] The value in the target key-value pair data is converted into tree graph class data.
[0471] It is determined whether the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position of the target field.
[0472] If the sorting manner of the elements in the tree graph class data is not the same as the sorting manner corresponding to the data value start position and the data value end position of the target field, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the sorting manner of the elements in the tree graph class data is the same as the sorting manner corresponding to the data value start position and the data value end position of the target field, the elements in the tree graph class data are not adjusted.
[0473] By using a binary search manner, the target element whose data value of the target field is greater than or equal to the data value start position corresponding to the target field and less than or equal to the data value end position corresponding to the target field is determined in the tree graph class data according to the target field, the data value start position corresponding to the target field, and the data value end position corresponding to the target field.
[0474] The number of target elements is taken as a data processing result corresponding to the data processing instruction.
[0475] Optionally, the target set type data includes a key of a to-be-processed key-value pair, a target field, and a target element position, and the target set operation type is a fifth query operation.
[0476] Optionally, the second unit 1002 is configured to:
[0477] If the key of the to-be-processed key-value pair, the target field, the data value start position corresponding to the target field, and the data value end position corresponding to the target field all conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair, the element start position, and the element end position.
[0478] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0479] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data.
[0480] Optionally, the second unit 1002 is configured to:
[0481] The value in the target key-value pair data is converted into tree graph class data.
[0482] According to the target element position, a target element corresponding to the target element position is determined from the tree graph class data.
[0483] The data value corresponding to the target field in the target element is taken as a data processing result corresponding to the data processing instruction.
[0484] Optionally, the target set type data includes a key of a to-be-processed key-value pair and a target element position, and the target set operation type is a deletion operation.
[0485] Optionally, the second unit 1002 is configured to:
[0486] If the key of the to-be-processed key-value pair and the target field all conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key of the to-be-processed key-value pair and the target field.
[0487] It is judged whether the key-value pair data corresponding to the key-value pair class exists in the key-value database, wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0488] If the key-value pair data corresponding to the key-value pair class exists in the key-value database, the key-value pair data corresponding to the key-value pair class is taken as target key-value pair data.
[0489] Optionally, the second unit 1002 is configured to:
[0490] The value in the target key-value pair data is converted into tree graph class data.
[0491] delete the target element corresponding to the target element position in the tree graph class data;
[0492] the number of successfully deleted target elements as a data processing result corresponding to the data processing instruction.
[0493] Optionally, the target set type data includes a key of a to-be-processed key-value pair, a target field, a data value start position and a data value end position corresponding to the target field, an index start position, and an index element number, and the target set operation type is a sixth query operation.
[0494] Optionally, the second unit 1002 is configured to:
[0495] If the key of the to-be-processed key-value pair, the target field, the data value start position and the data value end position corresponding to the target field, the index start position, and the index element number all conform to respective corresponding preset string types, and the key of the to-be-processed key-value pair conforms to a preset threshold condition, a key-value pair class is generated by using the key, the target field, the data value start position and the data value end position corresponding to the target field, the index start position, and the index element number.
[0496] It is determined whether the key-value database contains a key-value pair data corresponding to the key-value pair class; wherein the key in the key-value pair data is the same as the key of the to-be-processed key-value pair.
[0497] If the key-value database contains the key-value pair data corresponding to the key-value pair class, the key-value pair data corresponding to the key-value pair class is taken as a target key-value pair data.
[0498] Optionally, the second unit 1002 is configured to:
[0499] convert a value in the target key-value pair data into tree graph class data;
[0500] It is determined whether an ordering manner of elements in the tree graph class data is the same as an ordering manner corresponding to the data value start position and the data value end position corresponding to the target field.
[0501] If the ordering manner of the elements in the tree graph class data is not the same as the ordering manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are arranged in reverse order to obtain adjusted tree graph class data; if the ordering manner of the elements in the tree graph class data is the same as the ordering manner corresponding to the data value start position and the data value end position corresponding to the target field, the elements in the tree graph class data are not adjusted.
[0502] determining a target element set from the tree graph data according to the target field, a data value start position corresponding to the target field and a data value end position corresponding to the target field by using a binary search method, wherein a data value of the target field of each target element in the target element set is greater than or equal to the data value start position corresponding to the target field and less than or equal to the data value end position corresponding to the target field;
[0503] if the data values corresponding to the target field in the target elements are all integer types, taking a target element corresponding to the index start position in the target element set as a start point, determining target elements of the index element quantity, and taking the target elements of the index element quantity as the data processing result corresponding to the data processing instruction.
[0504] Optionally, the client is a Java client, and the key-value database is a coexistence key-value database.
[0505] Optionally, the apparatus further comprises a fourth unit configured to:
[0506] receiving the calling instruction sent by the client; wherein the calling instruction comprises a target solid state disk identifier;
[0507] calling the solid state disk corresponding to the target solid state disk identifier according to the target solid state disk identifier, taking the solid state disk corresponding to the target solid state disk identifier as the solid state disk corresponding to the key-value database, and adjusting the state of the solid state disk corresponding to the key-value database to a locked state.
[0508] Optionally, the fourth unit is configured to, after the step of feeding back the data processing result corresponding to each of the at least one data processing instruction to the client respectively, the method further comprises:
[0509] releasing the memory of the solid state disk corresponding to the key-value database, and adjusting the state of the solid state disk corresponding to the key-value database to an idle state.
[0510] Figure 11 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. At the hardware level, the electronic device comprises a processor, and optionally further comprises an internal bus, a network interface and a memory. The memory can contain a memory, such as a high-speed random access memory (RAM), and can also comprise a non-volatile memory, such as at least one disk memory. Of course, the electronic device can also comprise other hardware required by the business.
[0511] The processor, the network interface and the memory can be connected with each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus or the like. The bus can be divided into an address bus, a data bus, a control bus and the like. For the convenience of representation, Figure 11 Only one bidirectional arrow is used to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0512] The memory is used to store execution instructions. Specifically, the execution instructions are computer programs that can be executed. The memory can include an internal memory and a non-volatile memory, and provides the processor with execution instructions and data.
[0513] In a possible implementation manner, the processor reads corresponding execution instructions from the non-volatile memory into the internal memory and then runs, or obtains corresponding execution instructions from other devices to form a data processing apparatus at a logical level. The processor executes the execution instructions stored in the memory to implement the data processing method provided in any of the embodiments of the present application through the executed execution instructions.
[0514] The data processing apparatus provided in the embodiments of the present application Figure 1 The method executed by the data processing apparatus provided in the embodiments of the present application can be applied to a processor or implemented by the processor. The processor can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The processor mentioned above can be a general processor, including a central processing unit (CPU), a network processor (NP) and the like; or can 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, discrete hardware components. Each method, step and logic block diagram disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor or the like.
[0515] The steps of the method disclosed in the embodiments of the present application can be directly embodied as hardware code processing executed by a processor, or a combination of hardware and software modules in the code processing. The software module can be located in a storage medium such as random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), electrically programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, or the like. The storage medium is located in the storage, and the processor reads information in the storage medium and combines hardware to complete the steps of the above method.
[0516] The embodiments of the present application further provide a readable storage medium, which stores execution instructions. When the execution instructions are executed by a processor of an electronic device, the electronic device can execute the data processing method provided in any of the embodiments of the present application, and is specifically used to execute the method for data query.
[0517] The electronic device described in each of the foregoing embodiments can be a computer.
[0518] Those skilled in the art should understand that the embodiments of the present application can be provided as a method or a computer program product. Therefore, the present application can be in the form of a completely hardware embodiment, a completely software embodiment, or a combination of software and hardware.
[0519] Each of the embodiments of the present application is described in a progressive manner, and the same or similar parts of each of the embodiments can be referred to each other. Each of the embodiments mainly explains the difference from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the related parts can be referred to the part of the method embodiments.
[0520] It should be further understood that the terms "comprise", "comprise", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or other elements inherent to such a process, method, article, or device. Without more limitations, the element defined by the statement "comprises a" does not exclude the presence of additional identical elements in the process, method, article, or device including the element.
[0521] The above only describes the embodiments of the present application and is not intended to limit the present application. Those skilled in the art can make various modifications and changes to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the scope of the claims of the present application.
Claims
1. A data processing method, characterized in that: The method is applied to a solid-state hard disk corresponding to a key-value database, and the method includes: Receive at least one data processing instruction sent by a client; wherein each data processing instruction includes: target set type data and target set 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 according to the target set type data, wherein each key-value pair data in the key-value database includes a key and at least one value, each value includes at least one ordered set, and each ordered set includes at least one element, wherein each element includes at least one field and data values corresponding to each field, and multiple elements in each ordered set are sorted according to data values corresponding to preset fields; performing data processing corresponding to the target set operation type on the target key-value pair data to obtain data processing results corresponding to the data processing instruction; Feedback the data processing results corresponding to each of the at least one data processing instructions to the client.
2. The method according to claim 1, characterized in that The target set type data includes the key of the key-value pair to be processed, the target field, the data value starting position and the data value ending position corresponding to the target field, and the target set operation type is the fourth query operation.
3. The method according to claim 2, characterized in that The determining, according to the target set type data, target key-value pair data in the key-value database includes: If the key of the key-value pair to be processed, the target field, the starting position of the data value corresponding to the target field, and the ending position of the data value all conform to their respective corresponding preset string types, and the key of the key-value pair to be processed meets the preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed, the starting position of the element, and the ending position of the element; Determine whether there is key-value pair data corresponding to the key-value pair class 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 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.
4. The method according to claim 3, characterized in that The performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction includes: Convert the value in the target key-value pair data into tree graph data; Determine whether the sorting mode of the elements in the tree graph data is the same as the sorting mode corresponding to the starting position and the ending position of the data value corresponding to the target field; If the sorting mode of the elements in the tree graph data is different from the sorting mode corresponding to the starting position and the end position of the data value corresponding to the target field, the elements in the tree graph data are sorted in reverse order to obtain the adjusted tree graph data; if the sorting mode of the elements in the tree graph data is the same as the sorting mode corresponding to the starting position and the end position of the data value corresponding to the target field, the elements in the tree graph data are not adjusted; Using a binary search method, according to the target field, the starting position of the data value corresponding to the target field, and the ending position of the data value, determining in the tree graph data a target element whose data value of the target field is greater than or equal to the starting position of the data value corresponding to the target field and less than or equal to the ending position of the data value corresponding to the target field; The number of target elements is used as the data processing result corresponding to the data processing instruction.
5. The method according to claim 1, wherein The target set type data includes the key, target field, and target element position of the key-value pair to be processed, and the target set operation type is the fifth query operation.
6. The method according to claim 5, characterized in that The determining, according to the target set type data, target key-value pair data in the key-value database includes: If the key of the key-value pair to be processed, the target field, the starting position of the data value corresponding to the target field, and the ending position of the data value all conform to their respective corresponding preset string types, and the key of the key-value pair to be processed meets the preset threshold condition, a key-value pair class is generated using the key of the key-value pair to be processed, the starting position of the element, and the ending position of the element; Determine whether there is key-value pair data corresponding to the key-value pair class 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 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 performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction includes: Convert the value in the target key-value pair data into tree graph data; According to the target element position, determining the target element corresponding to the target element position from the tree graph data; The data value corresponding to the target field in the target element 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 set type data includes the key of the key-value pair to be processed and the target element position, and the target set operation type is a delete operation.
9. The method according to claim 8, characterized in that The determining, according to the target set type data, target key-value pair data in the key-value database includes: If the key and target field of the key-value pair to be processed both conform to their corresponding preset string types, and the key of the key-value pair to be processed meets the preset threshold condition, a key-value pair class is generated using the key and target field of the key-value pair to be processed; Determine whether there is key-value pair data corresponding to the key-value pair class 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 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 performing data processing corresponding to the target set operation type on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction includes: Convert the value in the target key-value pair data into tree graph data; Deleting the target element corresponding to the target element position in the tree graph data; The number of successfully deleted target elements is used as the data processing result corresponding to the data processing instruction.
11. The method according to any one of claims 1 to 10, characterized in that: The client is a Java client, and the key-value database is a co-located key-value database.
12. The method according to any one of claims 1 to 10, characterized in that: Before the step of receiving at least one data processing instruction sent by the client, the method further includes: Receiving a call instruction sent by the client; wherein the call instruction includes a target solid state drive identifier; According to the target solid-state hard disk identifier, the solid-state hard disk corresponding to the target solid-state hard disk identifier is called, and the solid-state hard disk corresponding to the target solid-state hard disk identifier is used as the solid-state hard disk corresponding to the key-value database, and the state of the solid-state hard disk corresponding to the key-value database is adjusted to a locked state.
13. The method according to claim 12, characterized in that After the step of feeding back to the client the data processing results corresponding to each of the at least one data processing instructions, the method further includes: The memory of the solid-state hard disk corresponding to the key-value database is released, and the state of the solid-state hard disk corresponding to the key-value database is adjusted to an idle state.
14. A data processing device, characterized in that: The device is applied to a solid-state hard disk corresponding to a key-value database, and the device includes: The first unit is configured to receive at least one data processing instruction sent by a client; wherein each data processing instruction includes: target set type data and target set operation type; The second unit is configured 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 instructions; wherein, for each data processing instruction, target key-value pair data in the key-value database is determined according to the target set type data, wherein each key-value pair data in the key-value database includes a key and at least one value, each value includes at least one ordered set, and each ordered set includes at least one element, wherein each element includes at least one field and data values corresponding to each field, and multiple elements in each ordered set are sorted according to data values corresponding to preset fields; data processing corresponding to the target set operation type is performed on the target key-value pair data to obtain a data processing result corresponding to the data processing instruction; The third unit is configured to feed back the data processing results corresponding to each of the at least one data processing instructions to the client.
Citation Information
Cited By
Data processing method and device
CN120804191A
A data processing method and apparatus
CN120804191B