Data processing method and device, equipment, storage medium and program product
By sorting multi-field and multi-sorting methods based on the sorting rule information of the data object set in memory, the response speed and accuracy problems under the complex sorting requirements in the existing technology are solved, and efficient and stable business processing is achieved. in various data field types.
Patent Information
- Application Number
- CN202410766577.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-12-17
AI Technical Summary
The prior art responds slowly and is not accurate enough when dealing with complex sorting requirements, especially in the case of multiple sorting fields and multiple sorting methods, which affects business processing efficiency and stability, and common methods require database operations or field mapping. , low versatility.
By determining the sorting rules information of the data object set, including the arrangement order and sorting method of multiple data fields, the multi-field and multi-sorting methods are directly sorted in memory without database operations. Dynamic field processing is adapted to different types of fields, achieving rapid , accurate sorting.
It improves sorting efficiency and accuracy, enhances the stability and versatility of business processing, and can meet diverse sorting needs, regardless of the data field type, and is highly applicable.
Smart Images

Figure CN119149529A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, device, equipment, storage medium and program product. Background Art
[0002] In the process of business processing, there are often complex sorting requirements for a large number of objects, such as multiple sorting fields and multiple sorting methods. The response speed and accuracy of complex sorting requirements will have a great impact on the business processing effect. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a data processing method, apparatus, device, storage medium and program product for improving the sorting efficiency and accuracy in the business processing process, thereby improving the business processing effect.
[0004] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions:
[0005] In a first aspect, an embodiment of the present application provides a data processing method, including:
[0006] Determine sorting rule information of the data object set, wherein the sorting rule information includes a first arrangement order of the M data fields in the data object and a sorting method of each data field;
[0007] Determine a target data field of the target data object group based on the first arrangement order and a value of the data field of the target data object group;
[0008] The data object set is sorted based on the value of the target data field and the sorting method of the target data field.
[0009] In a second aspect, an embodiment of the present application provides a data processing device, including:
[0010] A first determination module, configured to determine sorting rule information of a data object set, wherein the sorting rule information includes a first arrangement order of M data fields in the data object and a sorting method of each data field;
[0011] A second determination module, configured to determine a target data field of the target data object group based on the first arrangement order and a value of a data field of the target data object group, wherein the target data object group is any two data objects in the data object set;
[0012] The sorting module is used to sort the data objects in the data object set based on the value of the target data field and the sorting method of the target data field.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0014] processor;
[0015] a memory for storing instructions executable by the processor;
[0016] The processor is configured to execute the instructions to implement the data processing method provided in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the data processing method provided in the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the data processing method provided in the first aspect.
[0019] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0020] For any two data objects in the data object set, based on the first arrangement order of the M data fields and the values of the two objects in each data field, the target M fields for comparing the two objects are determined from the M data fields, so that the values of the two objects in the target data fields can reflect the size relationship between the two objects; then, based on the values of any two objects in the data object set in the target data fields and the sorting method of the target data fields, the data object set is sorted, thereby realizing complex sorting of multiple fields and multiple sorting methods for the data object set, and this sorting method only needs to specify the arrangement order of the M data fields and the sorting method of each data field for the data object set to be sorted, without the need for database operation implementation, and can be implemented in memory, thereby improving sorting efficiency and accuracy, as well as improving business stability; in addition, there is no need to perform field mapping, and it can be applicable regardless of whether the multiple data fields are of a single type or multiple types, with high versatility, and can better meet diverse sorting needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 A flowchart of a data processing method provided for one embodiment of the present application;
[0023] Figure 2 A flowchart of a data processing method provided for another embodiment of the present application;
[0024] Figure 3 A schematic diagram of the structure of a data processing device provided for one embodiment of the present application;
[0025] Figure 4 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0027] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0028] In the process of business processing, there are often complex sorting requirements for a large number of data objects, such as involving multiple data fields and multiple sorting methods. For example, a large number of data objects are first sorted in descending order according to data field 1. If the values in data field 1 are the same, they are sorted in ascending order according to data field 2; if the values in data field 2 are the same, they are sorted in descending order according to data field 3, and so on.
[0029] In the related art, a common method is to use database sorting, that is, to associate multiple data tables to obtain the fields that need to be sorted, and sort them in the database through Structured Query Language (SQL). However, when there are many sorting fields, it is necessary to associate multiple data tables to obtain values, which is very inefficient and slow to query data, thereby affecting business processing efficiency. In addition, this complex sorting method, when executed at the data layer, will bring great pressure to the database and affect the stability of the business system.
[0030] Another commonly used method is to convert multiple data fields into strings and then concatenate them into one data field, and then sort them in memory. However, after multiple data fields are concatenated into one data field, only one sorting method can be specified, such as ascending or descending sorting. Different sorting methods cannot be specified according to different data fields, and diverse sorting requirements cannot be met. In addition, when the types of different data fields are different, it is necessary to first map the values of different types of data fields in order to concatenate different data fields. This reduces the versatility of this method and makes its implementation complex. It also has the problem of being unable to meet diverse and complex sorting requirements and low sorting efficiency.
[0031] In view of this, the embodiment of the present application proposes a data processing method, for any two data objects in the data object set, based on the first arrangement order of M data fields and the values of the two objects in each data field, the target M fields for comparing the two objects are determined from the M data fields, so that the values of the two objects in the target data field can reflect the size relationship between the two objects; then, based on the values of any two objects in the data object set in the target data field and the sorting method of the target data field, the data object set is sorted, so that a complex sorting of multiple fields and multiple sorting methods of the data object set is realized, and this sorting method only needs to specify the arrangement order of M data fields and the sorting method of each data field for the data object set to be sorted, without the need for database operation implementation, and can be implemented in memory, thereby improving sorting efficiency and accuracy, and improving business stability; in addition, there is no need to perform field mapping, whether multiple data fields are of a single type or multiple types, it can be applied, with high versatility, and can better meet diverse sorting requirements. The sorting result of the data object set can be used for business processing of the data object set, which helps to improve business processing efficiency and accuracy, meet diverse business processing requirements, and improve business stability.
[0032] It should be understood that the data processing method provided in the embodiments of the present application can be executed by an electronic device. The electronic devices referred to herein may include terminal devices, such as smart phones, tablet computers, laptop computers, desktop computers, intelligent voice interaction devices, smart home appliances, smart watches, vehicle terminals, aircraft, etc.; or, the electronic devices may also include servers, such as independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide cloud computing services.
[0033] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0034] Please refer to Figure 1 , is a flow chart of a data processing method provided by an embodiment of the present application, the method comprising the following steps:
[0035] S102: Determine sorting rule information of the data object set.
[0036] The data object set includes multiple data objects to be sorted. The data object is the data required for business processing, such as a data record obtained from a database table, which includes the field values of M data fields, where M is an integer greater than 1. As an example, in a telephone sales scenario, the data object can be a user list, which includes the field values of multiple data fields such as object name, available cash installment amount, number of days in stock, list level, number of artificial intelligence (AI) calls, number of manual calls, etc. The following Table 1 shows an example of a data object set in a telephone sales scenario, and each row of data record in Table 1 is a data object.
[0037] Table 1
[0038]
[0039] Sorting rule information refers to the rules used to sort the data object set. The sorting rule information includes the first sorting order of M data fields and the sorting method of each data field. The first sorting order indicates the sorting priority of the M data fields, and the sorting method includes ascending or descending. For example, taking the data object set shown in Table 1 above as an example, the sorting rule can be to sort in descending order according to the available cash installment amount first, and then sort in ascending order according to the number of days in the warehouse if the available cash installment amount is the same; if the number of days in the warehouse is the same, then sort in descending order according to the list level. In this case, the M data fields include the available cash installment amount, the number of days in the warehouse, and the list level. The first sorting order of these data fields and the sorting method of each data field are shown in Table 2 below, where false indicates descending sorting and true indicates ascending sorting. That is, the first sorting order is: available cash installment amount->number of days in the warehouse->list level, etc. The sorting method of the available cash installment amount is descending sorting, the sorting method of the number of days in the warehouse is ascending sorting, and the sorting method of the list level is descending sorting.
[0040] Table 2
[0041] First sort order sort by Available cash installment amount false Days in stock true List Level false
[0042] S104: Determine a target data field of the target data object group based on the first arrangement order and the value of the data field of the target data object group.
[0043] The target data object group includes any two data objects in the data object set. The target data field of the target data object group refers to a data field in the above multiple data fields that can be used to distinguish the size of the data objects in the target data object group. Since different data objects have different values in the same data field, the target row data segments of different target data object groups are different.
[0044] Taking into account the sorting requirements of multiple data fields and multiple sorting methods, the data object set is usually sorted according to the first arrangement order of the multiple data fields and the sorting method of each data field in turn. Therefore, for any two data objects, the first data field with different values can distinguish the sizes of the two data objects, and then the first data object with different values can be used as the target data field of the two data objects.
[0045] Specifically, in one embodiment, the above S104 includes the following steps:
[0046] S141, traverse the M data fields based on the first arrangement order.
[0047] As an example, the M data fields in the sorting rule information are traversed based on the first arrangement order.
[0048] As another example, a chained hash list is generated based on the sorting rule information, and by traversing the keys in the chained hash list and utilizing the orderliness of the chained hash list, the M data fields are traversed based on the first arrangement order to ensure the orderliness of the traversal, thereby accurately determining the target data field, and providing reliable data support for the subsequent rapid and accurate sorting of the data object set. In this case, before the above S141, the data processing method provided by the embodiment of the present application may also include the following steps: for each data field in the above M data fields, the field name of the data field is used as the key (key), and the sorting method of the data field is used as the value (value) to obtain the key-value pair of the data field; based on the first arrangement order and the key-value pairs of multiple data fields, a chained hash list is generated.
[0049] Among them, the chained hash list can have various structures, such as LinkedHashMap, etc., which is not limited in the embodiments of the present application.
[0050] It is worth mentioning that in order to accurately determine the target data field, before traversing the keys in the chained hash list, the data object set and the chained hash list are also verified, such as whether the data object set is a set type, whether the structure of the chained hash list is correct, and whether the data field in the chained hash list is the data field contained in the data object in the data object set.
[0051] In the above traversal method, since the key-value pairs in the chained hash list are stored in the first arrangement order, the ordered traversal of the M data fields can be achieved by traversing the keys in the chained hash list without the need for more record information and sorting processing, thereby reducing complexity and facilitating generalization and expansion.
[0052] S142, determining the value of the traversed data field of the data object in the target data object group.
[0053] For each data object in the target data object group, if the traversed data field belongs to the static field in the data object, the data object is reflected to obtain the value of the data object in the data field; if the traversed data field does not belong to the static field in the data object, based on the matching result of the field name of the subfield in the dynamic field of the data object and the field name of the traversed data field, the value of the data object in the data field is obtained from the dynamic field.
[0054] The reflection processing of the data object can be realized by using Java reflection technology. By reflecting the object, the field value of the data field can be taken out from the data object as the value of the data field of the data object.
[0055] The data fields in the data object can be divided into static fields and dynamic fields, depending on whether the data field is a pre-set fixed field or a newly added field in the subsequent data processing process. Static fields refer to pre-set fixed fields, such as the object name, available cash installment amount, number of days in stock, list level, number of AI calls, and number of manual calls in Table 1 above. Dynamic fields are used to store newly added fields in the subsequent data processing process, that is, these newly added fields can be used as subfields in dynamic fields. This type of subfield changes dynamically and can be deleted or modified. In actual applications, dynamic fields can use a mapping structure to store subfields and their field values.
[0056] Since in actual applications, it is often necessary to sort the newly added fields, in the related technology, it is necessary to redevelop and launch the newly added fields, which is not only time-consuming and labor-intensive, but also has the problem of cumbersome operations. To this end, the data processing method provided in the embodiment of the present application also sets a corresponding dynamic field for each data object in the data object set to store the newly added fields of the object and their field values. Specifically, before determining the value of the traversed data field of the data object in the target data object group, the data processing method provided in the embodiment of the present application also includes: creating dynamic fields for the data objects, and in response to the field addition instruction of the data object, creating corresponding sub-fields and field values of the sub-fields for the fields to be added in the dynamic fields.
[0057] For example, taking the data object set shown in Table 1 above as an example, a corresponding dynamic field named dynamicSortFieldMap is created for each data object. If a field addition instruction is received to add a "answering rate" field and its field value for each data object, a subfield of "answering rate" and its field value are added to the dynamic field of each data object.
[0058] In this case, when comparing list 1 and list 2, if the currently traversed data field is the available cash installment amount, list 1 is reflected and the field value 20000 of the available cash installment amount is taken out from list 1 as the value of list 1 in the data field, and list 2 is reflected and the field value 30000 of the available cash installment amount is taken out from list 2 as the value of list 2 in the data field.
[0059] If the data field currently traversed is the connection rate, since this data field is not a static field, the field value of the subfield that matches the "connection rate" is read from the dynamic field of List 1 as the value of List 1 in this field, and the field value of the subfield that matches the "connection rate" is read from the dynamic field of List 2 as the value of List 2 in this data field.
[0060] It can be seen that by creating a dynamic field for each data object to store the newly added fields and their field values, and when the traversed data field is a newly added data field, the value of the data object in the newly added field is read from the dynamic field of the object, a more flexible dynamic field sorting can be achieved. There is no need to redevelop and launch the newly added data field, nor is there any need to modify each data object. The implementation is convenient, efficient, and has high versatility.
[0061] S143: If the data objects in the target data object group have different values in the traversed data field, stop traversing and determine the data field as the target data field of the target data object group.
[0062] For example, take the data object set shown in Table 1 and the sorting rule information shown in Table 2 as an example. First, take List 1 and List 2 as two data objects to be compared. When traversing to the available cash installment amount, since List 1 and List 2 have the same value in this data field, the traversal continues. Since List 1 and List 2 have different values in this data field, the traversal stops, and it is determined that the target data field for comparing List 1 and List 2 is the number of days in stock.
[0063] Next, list 2 and list 3 are taken as two data objects to be compared. When traversing to the available cash installment amount, since the values of list 1 and list 2 in this data field are different, the traversal is stopped, and it is determined that the target data field used to compare list 2 and list 3 is the available cash installment amount.
[0064] The embodiment of the present application shows some implementation methods of the above S104. Of course, it should be understood that the above S104 can also be implemented in other ways, which are not limited in the embodiment of the present application.
[0065] S106, sorting the data object set based on the value of the target data field and the sorting method of the target data field.
[0066] Since the values of the two objects in the target data field can reflect the size relationship between the two objects, the data fields in the data object set are sorted based on the values of the two objects in the target data field and the sorting method of the target data field, thereby realizing complex sorting of multiple fields and multiple sorting methods for the data object set. This sorting method only needs to specify the arrangement order of M data fields and the sorting method of each data field for the data object set to be sorted, without the need for database operation implementation, thereby improving sorting efficiency and accuracy, as well as improving business stability.
[0067] In one embodiment, the above S106 includes the following steps:
[0068] S161, comparing the values of the target data fields of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group.
[0069] As an example, the values of the target data fields of the data objects in the target data object group may be directly compared to obtain the size relationship between the data objects in the target data object group.
[0070] As another example, considering that different types of values are applied in different comparison methods, such as the comparison method for dates is different from the comparison method for decimals, and the value of a data object in a target data field is usually of type Object, which cannot be accurately used for size comparison. Therefore, in order to more accurately determine the size relationship between different data objects, if the values of two data objects in the target data field are non-null values, the values of the two objects in the target data field are type-converted to obtain a first value and a second value, and the first value and the second value are compared to obtain the size relationship between the two objects.
[0071] Specifically, you can use the instanceof keyword in Java to determine which comparable type the value of each data object to be compared belongs to, such as integer, long, float, double, date, BigDecimal, and string, and based on the judgment result, restore each data object to its comparable type to obtain the corresponding value, and then compare the values of the two data objects to be compared to obtain the size relationship between the two data objects.
[0072] For example, continuing to take the data object set shown in Table 1 above as an example, first compare list 1 and list 2, the target data field of both is the number of days in stock. Use the instanceof keyword to convert the value of the number of days in stock of list 1 into an integer type value, and obtain the first value 3, and use the instanceof keyword to convert the value of the number of days in stock of list 2 into an integer type value, and obtain the second value 2; then, compare the first value and the second value, and you can get the size relationship between list 1 and list 2: list 1>list 2.
[0073] Then compare list 2 and list 3, the target data field of both is the available cash installment amount. Use the instanceof keyword to convert the value of the available cash installment amount in list 2 into a BigDecimal value, and get the first value 20000, and use the instanceof keyword to convert the value of the available cash installment amount in list 3 into a BigDecimal value, and get the second value 30000; then, compare the first value with the second value, and you can get the size relationship between list 2 and list 3: list 2 < list 3.
[0074] In another example, considering that some data objects in some data fields may have null values in actual applications, these data are often dirty data. In the sorting process of multiple fields and multiple sorting methods, the accuracy of sorting may be affected because the null value and the non-null value cannot be compared, and even the program reports an error, resulting in the interruption of the business processing process. Therefore, if the value of any data object in the target data field is a null value, the size relationship between the data objects in the target data object group is determined based on the sorting method of the target data field.
[0075] For example, if the sorting method of the target data field is ascending, it is determined that the data object with a null value is greater than the data object with a non-null value; if the sorting method of the target data field is descending, it is determined that the data object with a null value is less than the data object with a non-null value. In this way, no matter what sorting method the target data field is, the data object with a null value will be placed at the back, thereby avoiding the null value affecting the sorting accuracy, and avoiding the interruption of the business processing process due to the inability to compare the size between the null value and the non-null value, thereby improving the sorting accuracy and business stability.
[0076] It is worth noting that if the values of a certain data field of each data object in the target data object group are all null values, it is determined that the values of the two in the data field are the same, and then the traversal continues to the next data field.
[0077] S162: Determine a second arrangement order of the target data object group based on the size relationship and the sorting method of the target data field.
[0078] Specifically, if the target data field is sorted in descending order, the larger ones in the target data object group are sorted before the smaller ones; if the target data field is sorted in ascending order, the smaller ones in the target data object group are sorted after the larger ones.
[0079] For example, continuing to take the data object set shown in Table 1 and the sorting rule information shown in Table 2 as an example, if list 1>list 2, and the sorting method of the target data field "number of days in stock" is ascending, then the second sorting order between list 1 and list 2 is determined to be: list 2->list 1. If list 2<list 3, and the sorting method of the target data field "available cash installment amount" is descending, then the second sorting order between list 2 and list 3 is determined to be: list 3->list 2.
[0080] In practical applications, the size relationship between two data objects can be marked by the comparison identifier res, and then the comparison identifier can be modified based on the sorting method of the target data field to determine the second arrangement order between the two data objects. For example, if list 1 = list 2, the comparison identifiers of the two are set to 0; if list 1 < list 2, the comparison identifiers of the two are set to -1; if list 1 > list 2, the comparison identifiers of the two are set to 1. Furthermore, if the sorting method of the target data field is ascending, the comparison identifier res is kept unchanged; if the sorting method of the target data field is descending, the comparison identifier is inverted.
[0081] S163, sorting the data objects in the data object set based on the second arrangement order to obtain a third arrangement order of the data object set, and sorting the data objects in the data object set according to the third arrangement order.
[0082] Through the above S161 to S162, the third arrangement order between the two data objects in the data object set can be obtained; then, the data objects in the data object set are sorted using the Collections.sort method provided by java jdk to obtain the third arrangement order of the data object set.
[0083] For example, continuing to take the data object set shown in Table 1 and the sorting rule information shown in Table 2 as an example, through S161 to S162, it is determined that the sorting order between list 1 to list 3 is: list 2 -> list 1, list 3 -> list 2. Further, through S163, the third sorting order among the three can be obtained as: list 3 -> list 2 -> list 1, and then the re-sorted data object set shown in Table 3 is obtained.
[0084] Table 3
[0085]
[0086] The embodiment of the present application shows some implementation methods of the above S106. Of course, it should be understood that the above S106 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0087] In another embodiment of the present application, after the above S106, the data processing method provided in the embodiment of the present application may further include the following steps:
[0088] S108: Perform business processing on the data object set based on the third arrangement order.
[0089] For example, in a telephone sales scenario, the data object set includes multiple lists. After obtaining the third ranking order of the data object set, the top 50% of the lists can be assigned to AI for intelligent outbound calls, and the bottom 50% of the lists can be assigned to manual agents for outbound calls.
[0090] For another example, in a service recommendation scenario, the data object set includes multiple users. After obtaining the third arrangement order of the data object set, for each user, based on the arrangement order of the user in the data object set, a suitable time period can be selected to push service messages to the user.
[0091] In the data processing method provided in the embodiment of the present application, the sub-method for comparing any two data objects in the data object set can be encapsulated as a general comparison module, and an interface is provided for calling.
[0092] Specifically, if Figure 2As shown, first, the business party determines the data object set and its sorting rule information and verifies it. After the verification is passed, the interface of the comparison module is called to traverse the data fields in the sorting rule information based on the first arrangement order, and the values of the two data objects to be compared in the traversed data fields are recorded as V1 and V2; if the data field belongs to the static fields in the two data objects, the two data objects are reflected respectively to obtain the values of the two data objects in the data field and update V1 and V2; if the data field does not belong to the static fields of the two data objects, the field values of the subfields that match the field name of the data field are read from the dynamic fields of the two data objects respectively and V1 and V2 are updated.
[0093] Next, the dirty data processing logic is started. If both V1 and V2 are null values, the next data field is traversed. If one of V1 and V2 is null and the other is non-null, the traversed data field is determined as the target data field, and the traversal is stopped. Based on the sorting method of the target data field, the size relationship between the two data objects is determined.
[0094] If both V1 and V2 are non-null values, V1 and V2 are type-converted and compared. If they are the same, continue to traverse the next data field; if they are different, stop traversing and get the size relationship between the two data objects.
[0095] Further, based on the size relationship between the two data objects and the sorting method of the target data field, a second arrangement order between the two data objects is determined and returned to the business party.
[0096] Finally, the business party sorts the data object set based on the third arrangement order between every two data objects in the data object set to obtain the third arrangement order of the data object set, and performs business processing on the data object set based on the third arrangement order.
[0097] One or more embodiments of the present application provide a data processing method, for any two data objects in a data object set, based on the first arrangement order of the M data fields and the values of the two objects in each data field, determine the target M fields for comparing the two objects from the M data fields, so that the values of the two objects in the target data fields can reflect the size relationship between the two objects; then, based on the values of any two objects in the data object set in the target data fields and the sorting method of the target data fields, the data object set is sorted, thereby realizing a complex sorting of multiple fields and multiple sorting methods for the data object set, and this sorting method only needs to specify the arrangement order of the M data fields and the sorting method of each data field for the data object set to be sorted, without the need for database operation implementation, and can be implemented in memory, thereby improving sorting efficiency and accuracy, as well as improving business stability; in addition, there is no need to perform field mapping, and it is applicable regardless of whether the multiple data fields are of a single type or multiple types, with high versatility, and can better meet diverse sorting needs.
[0098] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0099] Based on the same inventive concept, the present application embodiment also provides a data processing device. Figure 3 , is a structural diagram of a data processing device provided in an embodiment of the present application, the device 300 includes:
[0100] The first determination module 310 is used to determine the sorting rule information of the data object set, wherein the sorting rule information includes a first arrangement order of the M data fields in the data object and a sorting method of each data field.
[0101] The second determination module 320 is used to determine the target data field of the target data object group based on the first arrangement order and the value of the data field of the target data object group, and the target data object group is any two data objects in the data object set.
[0102] The sorting module 330 is used to sort the data objects in the data object set based on the value of the target data field and the sorting method of the target data field.
[0103] In another embodiment, the determining module is used to:
[0104] Traversing the M data fields based on the first arrangement order;
[0105] Determine the value of the traversed data field of the data object in the target data object group;
[0106] If the data objects in the target data object group have different values in the traversed data fields, the traversal is stopped, and the traversed data fields are determined as the target data fields of the target data object group.
[0107] In another embodiment, the step of the determining module traversing the M data fields based on the first arrangement order is implemented by traversing the keys in a chained hash list;
[0108] The data processing device further comprises:
[0109] A generating module, for obtaining a key-value pair of each data field in the M data fields by using the field name of the data field as a key and the sorting mode of the data field as a value;
[0110] A rule conversion module is used to generate the chain hash list based on the first arrangement order and the key-value pairs of the M data fields.
[0111] In another embodiment, the determining unit performs the following steps when determining the value of the traversed data field of the data object in the target data object group:
[0112] For each data object in the target data object group, if the traversed data field belongs to a static field in the data object, reflection processing is performed on the data object to obtain the value of the data object in the data field;
[0113] If the traversed data field does not belong to the static field in the data object, based on the matching result between the field name in the dynamic field of the data object and the field name of the data field, the value of the data object in the data field is obtained from the dynamic field.
[0114] In another embodiment, the determining module is further configured to:
[0115] creating a dynamic field for the data object;
[0116] In response to an instruction to add a field to the data object, a corresponding subfield and a field value of the subfield are created in the dynamic field for the field to be added.
[0117] In another embodiment, the sorting module is used to:
[0118] Comparing the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group;
[0119] Determining a second arrangement order of the target data object group based on the size relationship and the sorting manner of the target data fields;
[0120] Based on the second arrangement order, the data objects in the data object set are sorted to obtain a third arrangement order of the data object set, and the data objects in the data object set are sorted according to the third arrangement order.
[0121] In another embodiment, when the sorting module compares the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group, the sorting module performs the following steps:
[0122] If the value of the target data field of any data object in the target data object group is a null value, the size relationship between the data objects in the target data object group is determined based on the sorting method of the target data field.
[0123] In another embodiment, when the sorting module compares the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group, the sorting module performs the following steps:
[0124] If the value of the target data object group in the target data field is a non-null value, performing type conversion on the value of the target data object group in the target data field to obtain a first value and a second value;
[0125] The first value and the second value are compared to obtain a size relationship between data objects in the target data object group.
[0126] Obviously, the data processing device 300 provided in the embodiment of the present application can be used as the above Figure 1 The execution subject of the data processing method shown in the figure can thus realize the data processing device in Figure 1 The functions realized are as follows. Since the principles are the same, they will not be described in detail.
[0127] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 4At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0128] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0129] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0130] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0131] Determine sorting rule information of the data object set, wherein the sorting rule information includes a first arrangement order of the M data fields in the data object and a sorting method of each data field;
[0132] Determine a target data field of the target data object group based on the first arrangement order and a value of the data field of the target data object group;
[0133] The data object set is sorted based on the value of the target data field and the sorting method of the target data field.
[0134] The above application Figure 1The method performed by the data processing device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. 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 above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. 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 conjunction with the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0135] The electronic device may also perform Figure 1 The method and the data processing device are implemented in Figure 1 , Figure 2 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0136] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0137] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:
[0138] Determine sorting rule information of the data object set, wherein the sorting rule information includes a first arrangement order of the M data fields in the data object and a sorting method of each data field;
[0139] Determine a target data field of the target data object group based on the first arrangement order and a value of the data field of the target data object group;
[0140] The data object set is sorted based on the value of the target data field and the sorting method of the target data field.
[0141] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the data processing method provided in the embodiment of the present application.
[0142] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0143] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0144] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0145] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0146] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A data processing method, characterized in that: include: Determine sorting rule information of the data object set, wherein the sorting rule information includes a first arrangement order of the M data fields in the data object and a sorting method of the data fields; Determine the target data field of the target data object group based on the first arrangement order and the value of the data field of the target data object group, the target data object group being any two data objects in the data object set; The data objects in the data object set are sorted based on the value of the target data field and the sorting method of the target data field.
2. The method according to claim 1, characterized in that The determining the target data field of the target data object group based on the first arrangement order and the value of the data field of the target data object group includes: Traversing the M data fields based on the first arrangement order; Determine the value of the traversed data field of the data object in the target data object group; If the data objects in the target data object group have different values in the traversed data fields, the traversal is stopped, and the traversed data fields are determined as the target data fields of the target data object group.
3. The method according to claim 2, characterized in that The step of traversing the M data fields based on the first arrangement order is implemented by traversing the keys in the chain hash list; Before determining the target data field of the target data object group based on the first arrangement order and the value of the data field of the target data object group, the method further includes: For each data field in the M data fields, the field name of the data field is used as a key, and the sorting method of the data field is used as a value to obtain a key-value pair of the data field; The chained hash list is generated based on the first arrangement order and the key-value pairs of the M data fields.
4. The method according to claim 2, characterized in that: The determining of the value of the traversed data field of the data object in the target data object group includes: For each data object in the target data object group, if the traversed data field belongs to a static field in the data object, reflection processing is performed on the data object to obtain the value of the data object in the data field; If the traversed data field does not belong to the static field in the data object, based on the matching result between the field name in the dynamic field of the data object and the field name of the data field, the value of the data object in the data field is obtained from the dynamic field.
5. The method according to claim 4, characterized in that Before determining the value of the traversed data field of the data object in the target data object group, the method further includes: creating a dynamic field for the data object; In response to an instruction to add a field to the data object, a corresponding subfield and a field value of the subfield are created in the dynamic field for the field to be added.
6. The method according to claim 1, characterized in that The sorting of the data objects in the data object set based on the value of the target data field and the sorting mode of the target data field includes: Comparing the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group; Determining a second arrangement order of the target data object group based on the size relationship and the sorting manner of the target data fields; A third arrangement order of the data objects in the data object set is determined based on the second arrangement order, and the data objects in the data object set are sorted according to the third arrangement order.
7. The method according to claim 6, characterized in that The step of comparing the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group includes: If the value of the target data field of any data object in the target data object group is a null value, the size relationship between the data objects in the target data object group is determined based on the sorting method of the target data field.
8. The method according to claim 6, characterized in that The step of comparing the values of the target data field of the data objects in the target data object group to obtain the size relationship between the data objects in the target data object group includes: If the value of the target data object group in the target data field is a non-null value, performing type conversion on the value of the target data object group in the target data field to obtain a first value and a second value; The first value and the second value are compared to obtain a size relationship between data objects in the target data object group.
9. A data processing device, characterized in that: include: A first determination module, configured to determine sorting rule information of a data object set, wherein the sorting rule information includes a first arrangement order of M data fields in the data object and a sorting method of each data field; A second determination module, configured to determine a target data field of the target data object group based on the first arrangement order and a value of a data field of the target data object group, wherein the target data object group is any two data objects in the data object set; The sorting module is used to sort the data objects in the data object set based on the value of the target data field and the sorting method of the target data field.
10. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data processing method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data processing method as claimed in any one of claims 1 to 8.
12. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps in the data processing method according to any one of claims 1 to 8.
Citation Information
Cited By
Database data processing method and device based on multi-rule dynamic sorting
CN120470157A
