Data sorting method and device

By dividing the cache space of the data to be sorted into multiple data buckets on the computable storage device side, and sending the cache blocks of each data bucket to the memory space of the electronic device, the problem of low sorting efficiency caused by missing CPU cache is solved, and more efficient data sorting is achieved.

CN113986980BActive Publication Date: 2025-06-03RUIZHE (HANGZHOU) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111300648.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-04
Publication Date
2025-06-03
Estimated Expiration
2041-11-04

AI Technical Summary

Technical Problem

When the amount of data to be sorted is large, relying solely on the computer's CPU to sort data easily leads to a large number of CPU cache missing, thus failing to fully utilize the performance advantages of the electronic device CPU, and there may be a problem of low sorting efficiency.

Method used

By dividing the data to be sorted into the cache space of multiple data buckets on the computable storage device side, and sending the cache block of each data bucket to the memory space of the electronic device, the electronic device sorts the data to be sorted in each memory space, and splicing the sub-sorting results to obtain the final sorting result.

Benefits of technology

This method improves the efficiency of data sorting through splitting the data sorting process, fully utilizes the performance advantages of the electronic device CPU, and reduces the load of the computer CPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113986980B_ABST
    Figure CN113986980B_ABST
Patent Text Reader

Abstract

The present application provides a data sorting method and apparatus. The method includes: for a computable storage device, by receiving a sorting instruction sent by an electronic device, dividing the data to be sorted into the cache spaces of at least two data buckets according to the identifiers of the data to be sorted and the first numerical ranges corresponding to each data bucket established in advance, generating at least two cache blocks, and sending the cache blocks in the cache spaces of each data bucket to the corresponding memory spaces in the electronic device. In this technical solution, the computable storage device classifies and divides the data to be sorted according to at least two data buckets, thereby completing the preprocessing process of the data to be sorted, facilitating subsequent sorting of each divided data to be sorted by the electronic device, improving the efficiency of data sorting, and giving full play to the performance advantages of the CPU of the electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and in particular, to a data sorting method and apparatus. Background Art

[0002] Data sorting is to arrange data in a certain order so that users can discover some obvious features or trends by browsing the arranged data, thereby finding clues to solve problems. In addition, sorting data helps to check and correct errors in the data and facilitates processing such as reclassification or grouping. Therefore, how to sort data is the key.

[0003] Currently, sorting data is usually achieved by a user interacting with a computer to select the data to be sorted and the sorting method (such as from largest to smallest or from smallest to largest, etc.). The computer responds to the user's operation to generate a sorting instruction, and the Central Processing Unit (CPU) calls the corresponding sorting algorithm according to the sorting instruction to sort the data to be sorted, thereby obtaining a sorting result.

[0004] However, when the amount of data to be sorted is large, relying solely on the CPU of the computer for data sorting is likely to cause a large number of CPU cache misses, thus unable to fully utilize the performance advantages of the CPU of the electronic device, and there may be a problem of low sorting efficiency. Summary of the Invention

[0005] This application provides a data sorting method and apparatus to solve the problem in the prior art that relying solely on the CPU of the computer for data sorting is likely to cause a large number of CPU cache misses, thus unable to fully utilize the performance advantages of the CPU of the electronic device, and there may be a problem of low sorting efficiency.

[0006] In a first aspect, an embodiment of this application provides a data sorting method applied to a computable storage device. The method includes:

[0007] Receiving a sorting instruction sent by an electronic device, where the sorting instruction includes an identifier of the data to be sorted;

[0008] According to the identifier of the data to be sorted and a first numerical range corresponding to each data bucket established in advance, dividing the data to be sorted into the cache spaces of at least two data buckets to generate at least two cache blocks, where the numerical ranges of the data to be sorted in the cache blocks in different cache spaces are different;

[0009] Sending the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device.

[0010] In a possible design of the first aspect, the sorting instruction includes the identifiers of at least two data buckets; after receiving the sorting instruction sent by the receiving electronic device, the method further includes:

[0011] Create the at least two data buckets and the cache space corresponding to each data bucket according to the identifiers of the at least two data buckets;

[0012] Determine the first numerical range corresponding to each data bucket according to the data to be sorted and the number of data buckets.

[0013] Optionally, the determining the first numerical range corresponding to each data bucket according to the data to be sorted and the number of data buckets includes:

[0014] Obtain the data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range;

[0015] Determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets.

[0016] Optionally, the obtaining the data statistical information of the data to be sorted includes:

[0017] Perform sampling processing on the data to be sorted, and obtain the data statistical information of the data to be sorted according to the sampling result.

[0018] Optionally, the sorting instruction includes the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device; then, sending the cache block in the cache space of each data bucket to the corresponding memory space in the electronic device includes:

[0019] Send the cache block in the cache space of each data bucket to the corresponding memory space in the electronic device according to the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device.

[0020] In another possible design of the first aspect, the generating at least two cache blocks includes:

[0021] When the total amount of data to be sorted in any data bucket exceeds the preset data amount, determine the data to be sorted in the cache space of the data bucket as a cache block;

[0022] Create a new cache space for the data bucket, and determine the new cache space as the cache space of the data bucket;

[0023] After all the data to be sorted are partitioned into data buckets, determine the data to be sorted currently cached in each data bucket as a cache block.

[0024] In a second aspect, an embodiment of the present application provides a data sorting method, which is applied to an electronic device. The method includes:

[0025] Receive cache blocks sent by a computable storage device to different memory spaces in the electronic device. The value ranges of the data to be sorted in the cache blocks in different memory spaces are different;

[0026] For any memory space, sort the data to be sorted in each cache block in the memory space in ascending order of value to obtain a sub-sorting result;

[0027] Concatenate the sub-sorting results in each memory space according to a preset concatenation rule to obtain the sorting result of the data to be sorted.

[0028] In a possible design of the second aspect, before receiving the cache blocks sent by the computable storage device to different memory spaces in the electronic device, the method further includes:

[0029] In response to a user's operation on the electronic device, generate a sorting instruction, where the sorting instruction includes an identifier of the data to be sorted.

[0030] In a third aspect, an embodiment of the present application provides a data sorting device, which is applied to a computable storage device. The device includes:

[0031] A receiving module, configured to receive a sorting instruction sent by an electronic device, where the sorting instruction includes an identifier of the data to be sorted;

[0032] A processing module, configured to partition the data to be sorted into the cache spaces of at least two data buckets according to the identifier of the data to be sorted and a first value range corresponding to each data bucket established in advance, and generate at least two cache blocks. The value ranges of the data to be sorted in the cache blocks in different cache spaces are different;

[0033] A sending module, configured to send the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device.

[0034] In a possible design of the third aspect, the sorting instruction includes identifiers of at least two data buckets; after receiving the sorting instruction sent by the electronic device, the processing module is further configured to:

[0035] Create the at least two data buckets and the cache space corresponding to each data bucket according to the identifiers of the at least two data buckets;

[0036] Determine a first numerical range corresponding to each data bucket according to the data to be sorted and the number of data buckets.

[0037] Optionally, the processing module is specifically configured to:

[0038] Obtain data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range;

[0039] Determine a first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets.

[0040] Optionally, the processing module is specifically configured to:

[0041] Perform sampling processing on the data to be sorted, and obtain data statistical information of the data to be sorted according to the sampling result.

[0042] Optionally, the sorting instruction includes a mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device; then the sending module is specifically configured to:

[0043] According to the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device, send the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device.

[0044] In another possible design of the third aspect, the processing module is specifically configured to:

[0045] When the total amount of data to be sorted in any data bucket exceeds a preset data amount, determine the data to be sorted in the cache space of the data bucket as a cache block;

[0046] Create a new cache space for the data bucket, and determine the new cache space as the cache space of the data bucket;

[0047] After all the data to be sorted are partitioned into data buckets, determine the data to be sorted currently cached in each data bucket as a cache block.

[0048] In a fourth aspect, an embodiment of the present application may provide a data sorting device, which is applied to an electronic device, and the device includes:

[0049] A receiving module, configured to receive cache blocks sent by a computable storage device to different memory spaces in the electronic device, where the numerical ranges of the data to be sorted in the cache blocks in different memory spaces are different;

[0050] A processing module, configured to sort the data to be sorted in each cache block in any memory space in ascending order of numerical value, and obtain a sub-sorting result;

[0051] A processing module, configured to splice the sub-sorting results in each memory space according to a preset splicing rule, and obtain a sorting result of the data to be sorted.

[0052] In another possible design of the fourth aspect, before receiving the cache blocks sent by the computable storage device to different memory spaces in the electronic device, the processing module is further configured to:

[0053] In response to a user's operation on the electronic device, generate a sorting instruction, where the sorting instruction includes an identifier of the data to be sorted.

[0054] The data sorting method and device provided by the embodiments of the present application are directed to a computable storage device. By receiving a sorting instruction sent by an electronic device, according to the identifier of the data to be sorted and a first numerical range corresponding to each data bucket established in advance, the data to be sorted is divided into the cache spaces of at least two data buckets, at least two cache blocks are generated, and the cache blocks in the cache space of each data bucket are sent to the corresponding memory space in the electronic device. This solution splits the data sorting process into two processes: preprocessing and sorting. On the side of the computable storage device, the computable storage device classifies and divides the data to be sorted according to at least two data buckets, thereby completing the preprocessing process of the data to be sorted, so as to facilitate the subsequent electronic device to sort each divided data to be sorted respectively, improving the efficiency of data sorting and giving full play to the performance advantages of the CPU of the electronic device. Description of the Drawings

[0055] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present application, and are used together with the description to explain the principles of the present application.

[0056] Figure 1 A schematic diagram of the principle of the data sorting method provided by the embodiments of the present application;

[0057] Figure 2 A flowchart of the first embodiment of the data sorting method provided by the embodiments of the present application;

[0058] Figure 3 A schematic diagram of the data statistical information of the data to be sorted provided by the embodiments of the present application;

[0059] Figure 4 A flowchart of generating cache blocks provided by the embodiments of the present application;

[0060] Figure 5Schematic flowchart of the second embodiment of the data sorting method provided by the embodiment of the present application;

[0061] Figure 6 Schematic diagram of the first numerical range of each data bucket provided by the embodiment of the present application;

[0062] Figure 7 Schematic flowchart of the third embodiment of the data sorting method provided by the embodiment of the present application;

[0063] Figure 8 Schematic diagram of the principle of the data sorting method provided by the embodiment of the present application;

[0064] Figure 9 Schematic structural diagram of the first embodiment of the data sorting device provided by the embodiment of the present application;

[0065] Figure 10 Schematic structural diagram of the second embodiment of the data sorting device provided by the embodiment of the present application;

[0066] Figure 11 Schematic structural diagram of the computable storage device provided by the embodiment of the present application;

[0067] Figure 12 Schematic structural diagram of the electronic device provided by the embodiment of the present application.

[0068] Through the above-mentioned drawings, specific embodiments of the present disclosure have been shown, and more detailed descriptions will be given later. These drawings and text descriptions are not intended to limit the scope of the concept of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. Detailed implementation manners

[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0070] Before introducing the embodiments of the present application, the application background of the embodiments of the present application will be explained first:

[0071] Data sorting is a basic operation in the field of computer science and is widely used in various systems. For example, in database systems, query records are sorted, and in search engine systems, search results are sorted, etc., so that users can discover some obvious features or trends by browsing the sorted data, thereby finding clues to solve problems. A good sorting method can effectively improve the sorting speed, enhance the sorting effect, help check and correct errors in the data, and facilitate processing such as reclassification or grouping. Therefore, how to sort data is the key.

[0072] Currently, to sort data, usually the user selects the data to be sorted and sets the sorting method. The computer responds to the user's operation, generates a sorting instruction, and according to this sorting instruction, the CPU calls the corresponding sorting algorithm to perform sorting processing on the data to be sorted, thereby obtaining the sorting result.

[0073] However, although various sorting algorithms with different complexities and different resource occupancy rates have been derived for sorting, when the amount of data to be sorted is large, the sorting process itself is still a performance bottleneck in most systems. Simply relying on the computer's own CPU to sort data easily causes a large number of CPU cache misses, thus unable to fully utilize the performance advantages of the CPU of the electronic device, and there may be problems with low sorting efficiency.

[0074] In view of the above problems, the inventive concept of this application is as follows: Since the computer's own CPU resources are limited, and the computable storage device has a certain computing power, the computable storage device can partially offload some computing tasks of the computer CPU. Based on this, the inventors found that the computable storage device can classify the data to be sorted according to the numerical size of the data to be sorted and the corresponding first numerical range of each data bucket, divide the data to be sorted into the cache spaces of the corresponding data buckets, and send the data to be sorted in each cache space to the corresponding memory space in the electronic device. The electronic device sorts the data to be sorted in each memory space in ascending order and splices the obtained sub-sorting results, which can solve the problem of low sorting efficiency in the prior art, thereby reducing the CPU load of the computer, being able to make more full use of the computing power of each component inside the entire system, and further improving the performance of the application.

[0075] Exemplarily, the data sorting method provided in the embodiments of this application can be applied to Figure 1 a schematic diagram of a principle as shown. Figure 1 This is a schematic diagram of a principle of the data sorting method provided in the embodiments of this application, used to solve the above technical problems. As Figure 1 shown, Figure 1 it includes: a computable storage device and an electronic device.

[0076] In an embodiment, the electronic device may generate a sorting instruction in response to a user's operation and send the sorting instruction to the computable storage device. After receiving the sorting instruction, the computable storage device sends the sorting instruction to the storage controller through the drive of the computable storage device. The storage controller reads the data to be sorted from the storage medium according to the address information of the data to be sorted in the sorting instruction. After successful reading, the storage controller performs data bucket allocation on the data to be sorted, divides the data to be sorted into the cache spaces of n + 1 data buckets, and sends the cache blocks in the cache spaces of each data bucket to the electronic device. The electronic device receives the cache blocks sent by the computable storage device to different memory spaces and performs further sorting processing on them to determine the sorting result of the data to be sorted.

[0077] Next, the technical solution of the present application will be described in detail through specific embodiments.

[0078] It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0079] Figure 2 It is a schematic flowchart of the first embodiment of the data sorting method provided by the embodiment of the present application. As Figure 2 shown, for the computable storage device, the data sorting method and device method may include the following steps:

[0080] S21. Receive the sorting instruction sent by the electronic device

[0081] Among them, the sorting instruction includes the identifier of the data to be sorted. For example, the identifier of the data to be sorted may be the address information of the data to be sorted stored in the computable storage device.

[0082] Optionally, the data to be sorted may be data pre-input by the user. For example, it may be the employee numbers of all employees in a company input by the user, and each employee number is a data to be sorted.

[0083] Optionally, the data to be sorted may also be obtained according to the split data instruction and the original data sent by the electronic device. The split data instruction includes the address information and type information of the original data stored in the computable storage device, and the type information is used to indicate the number of digits of the data to be sorted after splitting. For example, the original data is a string of numbers, such as 1234567891234567, the type information in the split data instruction is the employee number, and the corresponding number of digits of the data to be sorted is 4 digits. Then, according to the split data instruction, the original data is processed into multiple data to be sorted (1234, 5678, 9123, 4567 respectively), and each data to be sorted includes 4 digits.

[0084] Further, the data to be sorted may carry data statistical information of the data to be sorted, which is used to describe the distribution of the data to be sorted. The data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range.

[0085] Figure 3 This is a schematic diagram of the data statistical information of the data to be sorted provided by the embodiments of the present application. As Figure 3 shown, there are a total of 54 data to be sorted, among which the minimum value of the data to be sorted is 0, the maximum value is 48, and there are 12 second numerical ranges, which are [0, 4), [4, 8), [8, 12), [12, 16), [16, 20), [20, 24), [24, 28), [28, 32), [32, 36), [36, 40), [40, 44), [44, 48], and the corresponding numbers of the data to be sorted are 4, 2, 8, 8, 4, 4, 16, 2, 4, 0, 0, 2 respectively.

[0086] Among them, the data statistical information of the data to be sorted can be at the data block / data page level or at the file level.

[0087] S22. According to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, divide the data to be sorted into the cache spaces of at least two data buckets to generate at least two cache blocks.

[0088] Among them, the first numerical ranges corresponding to each data bucket are different, and the numerical ranges of the data to be sorted in the cache blocks in different cache spaces are different.

[0089] Among them, the computable storage device determines the first numerical range corresponding to the numerical size according to the numerical size of each data to be sorted, and divides the data to be sorted into the cache space of the data bucket corresponding to the first numerical range. For example, the computable storage device has 4 data buckets, namely data bucket 0, data bucket 1, data bucket 2, and data bucket 3, and the corresponding first numerical ranges are [0, 12), [12, 22), [22, 27), [27, 48]. When the data to be sorted is 30, the data to be sorted is divided into the cache space of data bucket 3.

[0090] Further, in an implementable manner, after traversing all the data to be sorted and dividing all the data to be sorted, the computable storage device can determine the data to be sorted in each cache space as a cache block, that is, there are at least two cache blocks in total.

[0091] In another implementable manner, when the total amount of data to be sorted in any data bucket exceeds a preset data amount, the data to be sorted in the cache space of the data bucket is determined as a cache block; a new cache space for the data bucket is created, and the new cache space is determined as the cache space of the data bucket; after all the data to be sorted is divided into the data buckets, the data to be sorted currently cached in each data bucket is determined as a cache block.

[0092] Taking the preset data amount as 100 bytes as an example, when the total amount of data to be sorted in any data bucket reaches 100 bytes, the data to be sorted in the cache space of the data bucket is determined as a cache block. Then, a new cache space will be opened for the data bucket inside the computable storage device, and the new cache space is determined as the cache space of the data bucket to receive the data to be sorted divided into the data bucket later. When the total amount of data to be sorted in the data bucket is less than 100 bytes and all the data to be sorted has been divided, the current data to be sorted in the data bucket is determined as a cache block.

[0093] Figure 4 This is a schematic flowchart of the process for generating cache blocks provided by the embodiments of this application. As Figure 4 shown, according to the values of the data to be sorted and the first value range corresponding to each data bucket, the data to be sorted is allocated to data buckets, and the data to be sorted is divided into the cache spaces of the data buckets. Since the number of data to be sorted in data bucket 1 exceeds the preset number of data, the data to be sorted in the cache space of data bucket 1 is determined as a cache block, and a new cache space for data bucket 1 is created, and the new cache space of data bucket 1 is determined as the cache space of data bucket 1.

[0094] S23. Send the cache blocks in the cache spaces of each data bucket to the corresponding memory spaces in the electronic device.

[0095] Among them, according to the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device, the cache blocks in the cache spaces of each data bucket are sent to the corresponding memory spaces in the electronic device.

[0096] Among them, the computable storage device can send the cache block to the corresponding memory space in the electronic device after generating a cache block, or can send all the cache blocks to the corresponding memory spaces in the electronic device after all the data to be sorted is completely divided.

[0097] Optionally, this mapping relationship can be obtained from the sorting instruction, can also be preset by the computable storage device, can also be generated by the computable storage device according to the identifier of the data bucket and the identifier of the memory space in the electronic device, and can be set according to the actual situation. The embodiments of this application do not specifically limit this.

[0098] For example, the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device can be represented by Table 1.

[0099] Table 1

[0100]

[0101]

[0102] Taking the mapping relationship shown in Table 1 as an example, assuming that the identifier of the data bucket is Data Bucket 2, the computable storage device can calculate and send the cache blocks in the cache space of Data Bucket 2 to Memory Space 2 of the electronic device according to the mapping relationship shown in Table 1.

[0103] The data sorting method provided in the embodiments of the present application is applied to a computable storage device. By receiving a sorting instruction sent by an electronic device, according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, the data to be sorted is divided into the cache spaces of at least two data buckets to generate at least two cache blocks, and the cache blocks in the cache space of each data bucket are sent to the corresponding memory space in the electronic device. This solution splits the data sorting process into two processes: preprocessing and sorting. On the side of the computable storage device, the computable storage device classifies and divides the data to be sorted according to at least two data buckets, thereby completing the preprocessing process of the data to be sorted, so as to facilitate the subsequent electronic device to sort each divided data to be sorted respectively, improving the data sorting efficiency and giving full play to the performance advantages of the CPU of the electronic device.

[0104] Figure 5 It is a schematic flowchart of the second embodiment of the data sorting method provided in the embodiments of the present application. As Figure 5 shown, on the basis of the above embodiment, for the computable storage device, the sorting instruction may further include the identifiers of at least two data buckets. Then, after S21, the data sorting method and apparatus may include the following steps:

[0105] S51. Create at least two data buckets and the corresponding cache space for each data bucket according to the identifiers of at least two data buckets.

[0106] Exemplarily, when the identifiers of the data buckets are Data Bucket 0, Data Bucket 1, Data Bucket 2, and Data Bucket 3 respectively, the computable storage device creates 4 data buckets and names the 4 data buckets Data Bucket 0, Data Bucket 1, Data Bucket 2, and Data Bucket 3 respectively. After creating the data buckets, the computable storage device allocates corresponding cache spaces for each data bucket inside to receive the data to be sorted subsequently divided into this cache space.

[0107] S52. Determine the first numerical range corresponding to each data bucket according to the data to be sorted and the number of data buckets.

[0108] Among them, the computable storage device can obtain the data statistical information of the data to be sorted, and determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets.

[0109] Among them, the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range.

[0110] Among them, the data statistical information of the data to be sorted can be the information carried by the data to be sorted itself, or the computable storage device can perform sampling processing on the data to be sorted and obtain the data statistical information of the data to be sorted according to the sampling result.

[0111] Exemplarily, assume that there are 10,000 data to be sorted. The computable storage device can sample the data to be sorted using an existing sampling method, obtain 1,000 sampling data from the data to be sorted, perform statistics on the sampling data, obtain the data statistical information, and determine the data statistical information as the data statistical information of the data to be sorted.

[0112] In a realizable manner, the computable storage device can determine the first numerical range corresponding to each data bucket according to the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data buckets. For example, assume that the maximum value of the data to be sorted is 48, the minimum value is 0, and the number of data buckets is 4. Then the second numerical ranges of the data buckets are [0, 12), [12, 24), [24, 36), [36, 48] respectively.

[0113] In another realizable manner, when the number of preset second numerical ranges in the data statistical information is the same as the number of data buckets, the preset second numerical range can be determined as the first numerical range of each data bucket. When the number of preset second numerical ranges in the data statistical information is different from the number of data buckets, the first numerical range of each data bucket can be determined according to the numerical size of the data to be sorted.

[0114] Figure 6 This is the schematic diagram of the first numerical range of each data bucket provided by the embodiment of the present application. As Figure 6As shown, there are a total of 54 data to be sorted. The minimum value of the data to be sorted is 0, and the maximum value is 48. There are 12 in the second numerical range, and the number of data buckets is 4. It can be assumed that the number of data to be sorted in each data bucket is roughly the same (for example, each data bucket can contain 14 data to be sorted, which can be the rounded-up quantity here, and it should be understood that it can also be the rounded-down quantity here). The data to be sorted is evenly distributed within each second numerical range. Then, the preset second numerical ranges of the 4 data buckets can be obtained as [0, 12), [12, 22), [22, 27), [27, 48].

[0115] In any of the above realizable ways, assuming that the data statistical information is obtained by sampling the data to be sorted, then -∝ can be used to replace the minimum value, and +∝ can be used to replace the maximum value. For example, in Figure 6 , if the data statistical information is obtained by sampling the data to be sorted, then the preset second numerical ranges of the 4 data buckets obtained are [-∝, 12), [12, 22), [22, 27), [27, +∝].

[0116] Optionally, in some embodiments, the sorting instruction may further include the identifiers of at least two data buckets and the first numerical range corresponding to each data bucket. The computing storage device may create at least two data buckets and the corresponding cache space for each data bucket according to the identifiers of the data buckets in the sorting instruction, and determine the first numerical range corresponding to each data bucket according to the sorting instruction.

[0117] Among them, the first numerical range corresponding to each data bucket in the sorting instruction may be a numerical range preset by the electronic device, or may be determined by the electronic device according to the data statistical information obtained in advance for the data to be sorted, and can be determined according to the actual situation. The embodiments of the present application do not specifically limit this.

[0118] The above embodiments show that the first numerical range corresponding to each data bucket can be determined according to the data to be sorted, ensuring that the number of data to be sorted in each data bucket differs slightly, that is, ensuring that the number of data to be sorted in each cache block differs slightly, so that the subsequent processing time of each cache block by the electronic device is similar, avoiding the situation where the cache blocks in some memory spaces have been processed, while the cache blocks in other memory spaces still need a long time to be processed, further ensuring the efficiency of data sorting and saving processing time.

[0119] Figure 7 This is a schematic flowchart of the third embodiment of the data sorting method provided by the embodiments of the present application. As Figure 7 shown, for the electronic device, the data sorting method and device method may include the following steps:

[0120] S71. Receive the cache blocks sent by the computable storage device to different memory spaces in the electronic device.

[0121] Among them, the numerical ranges of the data to be sorted in the cache blocks in different memory spaces are different. Each memory space may store one cache block, or may store two or more cache blocks.

[0122] S72. For any memory space, sort the data to be sorted in each cache block in the memory space in ascending order of value to obtain a sub-sorting result.

[0123] In an implementable manner, assume that there is one cache block in the memory space, then sort the data to be sorted in the cache block of the memory space in ascending order of value to obtain a sub-sorting result.

[0124] In another implementable manner, assume that there are at least two cache blocks in the memory space, then sort the data to be sorted in each cache block in ascending order of value, and perform a merge sort on at least two sorted cache blocks to obtain a sub-sorting result.

[0125] S73. Concatenate the sub-sorting results in each memory space according to a preset concatenation rule to obtain the sorting result of the data to be sorted.

[0126] Among them, the preset concatenation rule can be based on the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device.

[0127] Exemplarily, taking the mapping relationship shown in Table 1 as an example, it can be sorted in ascending order of the first numerical range of each data bucket, and the sorting order is Data Bucket 0, Data Bucket 1, Data Bucket 2, Data Bucket 3. According to the mapping relationship shown in Table 1, the sorting order of the memory spaces is the same as that of the data buckets, that is, Memory Space 0, Memory Space 1, Memory Space 2, Memory Space 3. Determine the sorting order of the memory spaces as the preset concatenation rule.

[0128] In the above example, the electronic device concatenates the sub-sorting results in each memory space in the order of Memory Space 0, Memory Space 1, Memory Space 2, Memory Space 3, so as to obtain the sorting result.

[0129] Figure 8 This is a schematic diagram of the principle of the data sorting method provided by the embodiments of this application. As Figure 8As shown, there are a total of n - 1 memory spaces, namely memory space 1, memory space 2, ……, memory space n + 1. Among them, there are m + 1 cache blocks in memory space 1, j + 1 cache blocks in memory space 2, ……, and k + 1 cache blocks in memory space n + 1. Here, n, m, j, and k are positive integers greater than 1. The electronic device sorts the data to be sorted in each cache block of each memory space in ascending order of value, and performs a merge sort on the sorted cache blocks to obtain a sub-sorting result. Then, each sub-sorting result is concatenated in the order of memory space 1, memory space 2, ……, memory space n + 1 to obtain the sorting result.

[0130] The data sorting method provided by the embodiment of the present application is applied to an electronic device. By receiving the cache blocks sent by the computable storage device to different memory spaces in the electronic device, for any memory space, the data to be sorted in each cache block in the memory space is sorted in ascending order of value to obtain a sub-sorting result, and the sub-sorting results in each memory space are concatenated according to a preset concatenation rule to obtain the sorting result of the data to be sorted. The electronic device processes each memory space separately and concatenates the obtained sub-sorting results, thereby obtaining the sorting result of the data to be sorted, effectively reducing the processing time and improving the processing efficiency.

[0131] Optionally, in some embodiments, before S71, the electronic device may also generate a sorting instruction in response to a user's operation on the electronic device. The sorting instruction includes the identifier of the data to be sorted, and the sorting instruction is sent to the computable storage device.

[0132] Exemplarily, the sorting instruction may further include the identifiers of at least two data buckets, may include the first numerical range of each data bucket, and may also include the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device. The embodiment of the present application does not specifically limit this.

[0133] Exemplarily, the first numerical range corresponding to each data bucket in the sorting instruction may be a numerical range preset by the electronic device, or may be determined by the electronic device according to the pre-acquired data statistical information of the data to be sorted, and can be determined according to the actual situation. The embodiment of the present application does not specifically limit this.

[0134] Among them, the method of determining the first numerical range corresponding to each data bucket according to the pre-acquired data statistical information of the data to be sorted can refer to the method shown in S52 and will not be elaborated here.

[0135] Optionally, in some embodiments, before S71, the electronic device may obtain the identifier of the data to be sorted (i.e., the address information of the data to be sorted in the computable storage device) from the computable storage device at a preset frequency. Further, it may also obtain the data statistical information of the sorted data.

[0136] The following is an embodiment of the apparatus of the present application, which can be used to execute the method embodiment of the present application. For the details not disclosed in the apparatus embodiment of the present application, please refer to the method embodiment of the present application.

[0137] Figure 9 FIG. 1 is a schematic structural diagram of the first embodiment of the data sorting apparatus provided by the embodiment of the present application. As Figure 9 shown, the data sorting apparatus includes:

[0138] A receiving module 91, configured to receive a sorting instruction sent by an electronic device, where the sorting instruction includes an identifier of the data to be sorted;

[0139] A processing module 92, configured to divide the data to be sorted into the cache spaces of at least two data buckets according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, and generate at least two cache blocks. The numerical ranges of the data to be sorted in the cache blocks in different cache spaces are different;

[0140] A sending module 93, configured to send the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device.

[0141] In a possible design of the embodiment of the present application, the sorting instruction includes identifiers of at least two data buckets; after receiving the sorting instruction sent by the electronic device, the processing module 92 is further configured to:

[0142] Create at least two data buckets and the corresponding cache space for each data bucket according to the identifiers of at least two data buckets;

[0143] Determine the first numerical range corresponding to each data bucket according to the data to be sorted and the number of data buckets.

[0144] Optionally, the processing module 92 is specifically configured to:

[0145] Obtain the data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range;

[0146] Determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets.

[0147] Optionally, the processing module 92 is specifically configured to:

[0148] Sample the data to be sorted, and obtain the data statistical information of the data to be sorted according to the sampling result.

[0149] Optionally, the sorting instruction includes the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device; then the sending module 93 is specifically configured to:

[0150] According to the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device, send the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device.

[0151] In another possible design of the embodiment of the present application, the processing module 92 is specifically configured to:

[0152] When the total amount of the data to be sorted in any data bucket exceeds the preset data amount, determine the data to be sorted in the cache space of the data bucket as a cache block;

[0153] Create a new cache space for the data bucket, and determine the new cache space as the cache space of the data bucket;

[0154] After all the data to be sorted are divided into data buckets, determine the data to be sorted currently cached in each data bucket as a cache block.

[0155] The data sorting device provided by the embodiment of the present application can be used to execute the data sorting method on the side of the computable storage device in any of the above embodiments. The implementation principle and technical effect are similar and will not be elaborated here.

[0156] Figure 10 It is a schematic structural diagram of the second embodiment of the data sorting device provided by the embodiment of the present application. As Figure 10 shown, the data sorting device includes:

[0157] A receiving module 101, configured to receive the cache blocks sent by the computable storage device to different memory spaces in the electronic device, and the numerical ranges of the data to be sorted in the cache blocks in different memory spaces are different;

[0158] A processing module 102, configured to, for any memory space, sort the data to be sorted in each cache block in the memory space in ascending order of value to obtain a sub-sorting result;

[0159] The processing module 102 is configured to splice the sub-sorting results in each memory space according to a preset splicing rule to obtain the sorting result of the data to be sorted.

[0160] In a possible design of the embodiment of the present application, before receiving the cache blocks sent by the computable storage device to different memory spaces in the electronic device, the processing module 102 is further configured to:

[0161] In response to a user's operation on an electronic device, a sorting instruction is generated, and the sorting instruction includes an identifier of data to be sorted.

[0162] The data sorting device provided by the embodiments of the present application can be used to execute the data sorting method on the electronic device side in any of the above embodiments. The implementation principles and technical effects are similar and will not be elaborated here.

[0163] It should be noted that it should be understood that the division of each module of the above device is only a logical function division. In actual implementation, it can be fully or partially integrated into a physical entity, or physically separated. And these modules can all be implemented in the form of software called by a processing element; they can also all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together or can be independently implemented. Here, the processing element can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the integrated logic circuit in the processor element or the instruction in the form of software.

[0164] Figure 11 It is a schematic structural diagram of a computable storage device provided by an embodiment of the present application. As Figure 11 shown, the electronic device may include: a processor 111, a transceiver 112, a memory 113, and computer program instructions stored in the memory 113 and executable on the processor 111. When the processor 111 executes the computer program instructions, it implements the data sorting method on the computable storage device side provided in any of the foregoing embodiments.

[0165] The transceiver 112 is used to communicate with the electronic device, and the transceiver 112 constitutes a communication interface.

[0166] Optionally, the above-mentioned components of the computable storage device can be connected through a system bus.

[0167] Optionally, in terms of hardware implementation, the Figure 9 shown in the above embodiments: the receiving module 91 and the sending module 93 correspond to the transceiver 112 in this embodiment, and the Figure 9 shown in the above embodiments: the processing module 92 corresponds to the processor 111 in this embodiment.

[0168] The computable storage device provided by the embodiments of the present application can be used to execute the data sorting method on the computable storage device side provided in any of the above method embodiments. The implementation principles and technical effects are similar and will not be elaborated here.

[0169] Figure 12This is a schematic structural diagram of the electronic device provided by the embodiment of the present application. As Figure 12 shown, the electronic device may include: a processor 121, a memory 122, and computer program instructions stored on the memory 122 and executable on the processor 121. When the processor 121 executes the computer program instructions, it implements the data sorting method on the electronic device side provided in any of the foregoing embodiments.

[0170] Optionally, the electronic device may further include an interface for interacting with other devices.

[0171] Optionally, the various components of the electronic device may be connected through a system bus.

[0172] The above Figure 10 The processing module 102 in the embodiment shown corresponds to the processor 121 in this embodiment.

[0173] The electronic device provided by the embodiment of the present application can be used to execute the data sorting method on the electronic device side provided in any of the foregoing method embodiments. The implementation principle and technical effects are similar and will not be elaborated here.

[0174] The memory may be a separate storage unit or an integrated storage unit in the processor. The number of processors is one or more.

[0175] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the present application can be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.

[0176] The system bus can be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The system bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity, only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus. The memory may include a Random Access Memory (RAM), and may also include a Non-Volatile Memory (NVM), such as at least one disk memory.

[0177] All or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable memory. When the program is executed, it performs the steps including the above method embodiments; and the foregoing memory (storage medium) includes: Read-Only Memory (ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.

[0178] The embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions run on a computer, the computer is enabled to execute the above data sorting method.

[0179] For the above computer-readable storage medium, the above-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory, electrically erasable programmable read-only memory, erasable programmable read-only memory, programmable read-only memory, read-only memory, magnetic memory, flash memory, disk or optical disc. The readable storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0180] Optionally, the readable storage medium is coupled to the processor, so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an Application Specific Integrated Circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in the device.

[0181] An embodiment of the present application further provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium, and when the at least one processor executes the computer program, the above data sorting method can be implemented.

[0182] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A data sorting method, characterized in that, applied to a computable storage device, the method includes: Receiving a sorting instruction sent by an electronic device, the sorting instruction including an identifier of data to be sorted; Obtaining data statistical information of the data to be sorted, the data statistical information including a maximum value of the data to be sorted, a minimum value of the data to be sorted, and the number of data to be sorted in each preset second numerical range; Determining a first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets, the first numerical ranges corresponding to each data bucket being different, the first numerical range being used to make the difference in the quantity of the data to be sorted in each data bucket smaller; Dividing the data to be sorted into the cache spaces of at least two data buckets according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, generating at least two cache blocks, the numerical ranges of the data to be sorted in the cache blocks in different cache spaces being different, the data bucket corresponding to one or more storage spaces, each storage space corresponding to a cache block, and the total amount of the data to be sorted in the cache block being less than or equal to a preset data amount; Sending the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device, so that the electronic device sorts the data to be sorted in each cache block in the memory space in ascending order of value to obtain a sub-sorting result, and splicing the sub-sorting results in each memory space according to a preset splicing rule to obtain a sorting result of the data to be sorted.

2. The method according to claim 1, characterized in that, the sorting instruction includes identifiers of at least two data buckets; then after receiving the sorting instruction sent by the electronic device, the method further includes: Creating the at least two data buckets and the cache space corresponding to each data bucket according to the identifiers of the at least two data buckets.

3. The method according to claim 1, characterized in that, the obtaining of the data statistical information of the data to be sorted includes: Performing a sampling process on the data to be sorted, and obtaining the data statistical information of the data to be sorted according to the sampling result.

4. The method according to claim 2, characterized in that, the sorting instruction includes a mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device; then the sending the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device includes: Sending the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device according to the mapping relationship between the identifier of the data bucket and the identifier of the memory space in the electronic device.

5. The method according to any one of claims 1-4, characterized in that, the generating of at least two cache blocks includes: When the total amount of the data to be sorted in any data bucket exceeds the preset data amount, determining the data to be sorted in the cache space of the data bucket as a cache block; Create a new cache space for the data bucket and determine the new cache space as the cache space of the data bucket; After all the data to be sorted are partitioned into data buckets, determine the data to be sorted currently cached in each data bucket as a cache block.

6. A data sorting method, characterized in that, applied to an electronic device, the method includes: Receiving cache blocks sent by a computable storage device to different memory spaces in the electronic device, where the numerical ranges of the data to be sorted in the cache blocks in different memory spaces are different; For any memory space, sort the data to be sorted in each cache block in the memory space in ascending order of numerical value to obtain a sub-sorting result; Concatenate the sub-sorting results in each memory space according to a preset concatenation rule to obtain the sorting result of the data to be sorted; wherein, the cache block is determined by the computable storage device in the following manner: according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, partition the data to be sorted into the cache spaces of at least two data buckets to generate at least two cache blocks, each data bucket corresponds to one or more storage spaces, each storage space corresponds to a cache block, and the total amount of the data to be sorted in the cache block is less than or equal to a preset data volume; The first numerical range corresponding to each data bucket is determined by the following method: obtain the data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of the data to be sorted in each preset second numerical range; determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets, and the first numerical ranges corresponding to each data bucket are different, and the first numerical range is used to make the difference in the number of the data to be sorted in each data bucket smaller.

7. The method according to claim 6, characterized in that, Before receiving the cache blocks sent by the computable storage device to different memory spaces in the electronic device, the method further includes: Responding to an operation of the user on the electronic device, generating a sorting instruction, where the sorting instruction includes the identifier of the data to be sorted; Sending the sorting instruction to the computable storage device.

8. A data sorting device, characterized in that, applied to a computable storage device, the device includes: A receiving module, configured to receive a sorting instruction sent by an electronic device, where the sorting instruction includes the identifier of the data to be sorted; Obtain the data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of the data to be sorted in each preset second numerical range; Determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets, and the first numerical ranges corresponding to each data bucket are different, and the first numerical range is used to make the difference in the number of the data to be sorted in each data bucket smaller; A processing module, configured to divide the data to be sorted into the cache spaces of at least two data buckets according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, generate at least two cache blocks, and the numerical ranges of the data to be sorted in the cache blocks in different cache spaces are different. Each data bucket corresponds to one or more storage spaces, each storage space corresponds to a cache block, and the total amount of the data to be sorted in the cache block is less than or equal to a preset data volume; A sending module, configured to send the cache blocks in the cache space of each data bucket to the corresponding memory space in the electronic device, so that the electronic device sorts the data to be sorted in each cache block in the memory space in ascending order of numerical value to obtain a sub-sorting result, and splices the sub-sorting results in each memory space according to a preset splicing rule to obtain the sorting result of the data to be sorted.

9. A data sorting device characterized in that it is applied to an electronic device, and the device includes: A receiving module, configured to receive the cache blocks sent by the computable storage device to different memory spaces in the electronic device, and the numerical ranges of the data to be sorted in the cache blocks in different memory spaces are different; A processing module, configured to, for any memory space, sort the data to be sorted in each cache block in the memory space in ascending order of numerical value to obtain a sub-sorting result; A processing module, configured to splice the sub-sorting results in each memory space according to a preset splicing rule to obtain the sorting result of the data to be sorted; wherein, the cache block is determined by the computable storage device in the following manner: divide the data to be sorted into the cache spaces of at least two data buckets according to the identifier of the data to be sorted and the first numerical range corresponding to each data bucket established in advance, generate at least two cache blocks, each data bucket corresponds to one or more storage spaces, each storage space corresponds to a cache block, and the total amount of the data to be sorted in the cache block is less than or equal to a preset data volume; The first numerical range corresponding to each data bucket is determined by the following method: obtain the data statistical information of the data to be sorted, where the data statistical information includes the maximum value of the data to be sorted, the minimum value of the data to be sorted, and the number of the data to be sorted in each preset second numerical range; determine the first numerical range corresponding to each data bucket according to the data statistical information of the data to be sorted and the number of data buckets, and the first numerical ranges corresponding to each data bucket are different, and the first numerical range is used to make the difference in the number of the data to be sorted in each data bucket smaller.

Citation Information

Patent Citations

  • Sorting method and device applied to database and related equipment

    CN110704424A