Business object deserialization index alignment method, computer equipment and storage medium

By configuring the attribute field index assignment business classes and deformation strategies in the business system, and using hash arrays to achieve automatic index alignment of business attribute fields and system attribute fields, it solves the alignment difficulties caused by developers' writing habits, and improves development flexibility and maintenance convenience.

CN120234329AActive Publication Date: 2025-07-01SHENZHOU LINGYUN (BEIJING) TECH CO LTD

Patent Information

Application Number
CN202510707614.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-07-01
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

During the development of business programs, due to the writing habits of different developers, the expression and sorting of business CSV attribute fields are inconsistent with the system CSV attribute fields, resulting in difficulty in alignment. Traditional methods have problems such as insufficient flexibility and low execution efficiency.

Method used

A business object deserialization index alignment method is proposed. By configuring the attribute field index assignment business class in the business system, deforming the system attribute field using a preset deformation strategy, and using a hash array to realize automatic index alignment of the business attribute field and the system attribute field.

Benefits of technology

It improves the flexibility of code development and the convenience of system maintenance, realizes automatic alignment of business attribute fields and system attribute fields, adapts to different development styles, and automatically updates the hash array after the system restarts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234329A_ABST
    Figure CN120234329A_ABST
Patent Text Reader

Abstract

The invention provides a business object deserialization index alignment method, computer equipment and a storage medium. The method comprises the following steps: configuring an attribute field index assignment business class in a business system; performing deformation processing on the system attribute field by adopting a preset deformation strategy, and expanding the deformed system attribute field into system configuration; initializing a system attribute field by using an attribute field index assignment service class to obtain a hash array used for indexing the system field; in response to the acquired service data, deserializing the service data to determine a service attribute field corresponding to the service data; and calling the attribute field index assignment service class to carry out Hash calculation on the service attribute field, and matching an index in a Hash array based on a Hash calculation result to determine a system attribute field corresponding to the service attribute field. According to the method, the system attribute field and the service attribute field are automatically aligned in a Hash index mode, and the alignment compatibility is improved through deformation processing of the system attribute field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method for aligning deserialization indexes of business objects, a computer device, and a storage medium. Background Art

[0002] During the development of business programs, in order to shorten the development cycle, the business system architecture and specific business functions are developed by different developers in a division-of-labor manner. However, different developers may have their own coding habits, resulting in differences in the expression and sorting of business CSV (Comma-Separated Values) attribute fields and those of the system CSV attribute fields built into the business system. Therefore, it is necessary to align (i.e., determine the corresponding relationship) the business CSV attribute fields with the system CSV attribute fields later. There are two traditional ways to align csv fields, and their specific methods and disadvantages are as follows: 1. Hard coding based on the fixed input order of csv attribute fields; this method not only hinders the flexibility of code writing, but also requires corresponding modification of each business function code every time the order of system csv attribute fields is modified, which is not conducive to later maintenance and upgrade work.

[0003] 2. Based on the reflection method, map the input fields to the attributes in the business class, and call the reflection method of the base class to set the values of the object; although this method is more flexible, one mapping plus one reflection operation results in lower execution efficiency. Summary of the Invention

[0004] In order to improve the flexibility of code development and facilitate the later system maintenance, in the first aspect of the present invention, a method for aligning deserialization indexes of business objects is proposed. The method includes: configuring a business class for assigning attribute field indexes in the business system; performing deformation processing on the system attribute fields by using a preset deformation strategy and expanding the deformed system attribute fields into the system configuration; initializing the system attribute fields by using the business class for assigning attribute field indexes to obtain a hash array for indexing system fields; in response to obtaining business data, deserializing the business data to determine the business attribute fields corresponding to the business data; calling the business class for assigning attribute field indexes to perform hash calculation on the business attribute fields, and matching indexes in the hash array based on the hash calculation result to determine the system attribute fields corresponding to the business attribute fields.

[0005] In one or more embodiments, the method further includes: before initializing the system attribute fields by using the attribute field index assignment service class to obtain a hash array for indexing system fields, performing a transformation process on the system attribute fields by using a preset transformation strategy and extending the transformed system attribute fields into the system configuration.

[0006] In one or more embodiments, performing a transformation process on the system attribute fields by using a preset transformation strategy includes: respectively converting each of the system attribute fields into all lowercase, all uppercase, with the first word's first letter in uppercase, with the second word's first letter in uppercase, with the first and second words' first letters in uppercase, and adding a specified character between the first and second words.

[0007] In one or more embodiments, initializing the system attribute fields by using the attribute field index assignment service class to obtain a hash array for indexing system fields includes: sorting the system attribute fields and assigning serial numbers; calling a preset weak hash algorithm to calculate the weak hash value of the system attribute fields; constructing a hash array with the weak hash value as the index key and the serial number as the index value.

[0008] In one or more embodiments, calling the attribute field index assignment service class to perform a hash calculation on the service attribute fields and matching an index in the hash array based on the hash calculation result includes: calling the preset weak hash algorithm to calculate the weak hash value of the service attribute fields; performing an index key match for the weak hash value in the hash array; in response to matching the same index key, indexing the system attribute fields at the corresponding sorted position based on the corresponding key value.

[0009] In one or more embodiments, the service object deserialization index alignment method of the present invention further includes: in response to the weak hash value of the service attribute fields calculated by using the preset weak hash algorithm being 0, ending the index matching operation and outputting an error prompt.

[0010] In one or more embodiments, the service object deserialization index alignment method of the present invention further includes: in response to the non - existence of system attribute fields at the corresponding sorted position based on the key value index, ending the index matching operation and prompting to restart the service system.

[0011] In one or more embodiments, calling the attribute field index assignment service class to perform a hash calculation on the service attribute fields and matching an index in the hash array based on the hash calculation result includes: in response to deserializing the service data to obtain a plurality of service attribute fields; using multi - thread concurrent execution to call the attribute field index assignment service class to perform a hash calculation on the service attribute fields and matching an index in the hash array based on the hash calculation result.

[0012] In one or more embodiments, the business object deserialization index alignment method of the present invention further includes: determining a system attribute field aligned with the business attribute field in response to the existence of a hash value in the hash array that matches the hash calculation result.

[0013] In a second aspect of the present invention, a computer device is provided, including: at least one processor; and a memory storing an executable computer program, where the computer program, when executed by the at least one processor, is used to implement the steps of the business object deserialization index alignment method described in any of the above method embodiments.

[0014] In a third aspect of the present invention, a readable storage medium is provided, including: an executable computer program, where the computer program, when executed by an executor, is used to implement the steps of the business object deserialization index alignment method described in any of the above method embodiments.

[0015] The beneficial effects of the present invention include: by developing an attribute field index assignment service class in the business system to achieve automatic index alignment of business attribute fields and system attribute fields, the present invention enables users to not need to pay attention to the order of input business attribute fields when developing business functions, thus greatly improving the flexibility of coding. Before initializing the system attribute fields using the attribute field index assignment service class, the system attribute fields are deformed and the deformed system attribute fields are extended to the system configuration, thereby greatly improving the compatibility of the alignment between the system attribute fields and the business attribute fields to adapt to different development styles. After each system restart, the system attribute fields are automatically scanned through an initialization operation to generate an updated hash array, combined with the automatic index alignment function, thus greatly improving the convenience of subsequent system maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other embodiments based on these drawings without creative efforts.

[0017] Figure 1 It is a flowchart of a working process of a business object deserialization index alignment method according to an embodiment of the present invention; Figure 2 It is a schematic structural diagram of a computer device according to an embodiment of the present invention; Figure 3 It is a schematic structural diagram of a readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0018] To make the objectives, technical solutions and advantages of the present invention more clear and understandable, the following further elaborates on embodiments of the present invention in detail with reference to specific embodiments and the accompanying drawings.

[0019] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two entities or parameters with the same name but different identities. It can be seen that "first" and "second" are only for the convenience of expression and should not be construed as a limitation on the embodiments of the present invention. This will not be elaborated one by one in the subsequent embodiments.

[0020] In order to improve the flexibility of code development and facilitate subsequent system maintenance, the present invention proposes a method for aligning business object deserialization indexes, as Figure 1 shown. In one embodiment, the method of the present invention includes: Step S1, configuring an attribute field index assignment service class in the business system; Step S2, performing a transformation process on the system attribute fields using a preset transformation strategy and expanding the transformed system attribute fields into the system configuration; Step S3, initializing the system attribute fields using the attribute field index assignment service class to obtain a hash array for indexing system fields; Step S4, in response to obtaining business data, deserializing the business data to determine the business attribute fields corresponding to the business data; Step S5, calling the attribute field index assignment service class to perform a hash calculation on the business attribute fields and matching indexes in the hash array based on the hash calculation result to determine the system attribute fields corresponding to the business attribute fields.

[0021] In this embodiment, an attribute field index assignment service class is developed in the business system to achieve automatic index alignment between business attribute fields and system attribute fields, enabling users not to pay attention to the order of input business attribute fields when developing business functions, thus greatly improving the flexibility of coding. Before initializing the system attribute fields using the attribute field index assignment service class, a transformation process is performed on the system attribute fields and the transformed system attribute fields are expanded into the system configuration, thereby greatly improving the compatibility of the alignment between system attribute fields and business attribute fields to adapt to different development styles. After each system restart, the system attribute fields are automatically scanned through an initialization operation to generate an updated hash array, combined with the automatic index alignment function, thus greatly improving the convenience of subsequent system maintenance.

[0022] In one embodiment, performing a transformation process on the system attribute fields using a preset transformation strategy includes: converting business attribute fields to all lowercase, all uppercase, the first word with the first letter capitalized, the second word with the first letter capitalized, the first and second words with the first letters capitalized, and adding a specified character between the first and second words.

[0023] Specifically, each application system has its own business scope, and there will be a maximum set of business fields involved accordingly. For example, for network performance analysis, about 500 fields cover all business data. If these 500 data are further divided into all possible forms of camel case, snake case, all uppercase, and all lowercase according to the writing form, about 2000 fields can cover all possible fields. For example, for the timestamp field, the four forms of camel case, snake case, all uppercase, and all lowercase are as follows: timeStamp, time_stamp, TIMESTAMP, timestamp. In this embodiment, in order to improve the success rate of indexing, the business attribute fields, such as business CSV (Comma Separate Values) fields, will be automatically expanded through a preset transformation strategy, and then a hash array for index alignment will be initialized and generated based on the expanded business CSV fields. Among them, the specified symbols in this embodiment include not only the "-" in snake case but also the "&", "*", etc. in some user-defined forms, provided that the specified symbol cannot be a specific command symbol and cannot affect the correct expression of the command.

[0024] In an alternative embodiment, the transformation strategy is triggered and started each time the system restarts, scans the business attribute fields in each business function code, determines whether there are extended fields, and if there are no extended fields, expands them and solidifies the expanded transformed business attribute fields into the business function code.

[0025] In an alternative embodiment, the transformation strategy is triggered and started each time the system restarts, scans the business attribute fields in each business function code, determines whether there are extended fields, and if there are no extended fields, expands them and temporarily stores the expanded transformed business attribute fields in the system memory, and clears the transformed business attribute fields when the system shuts down.

[0026] In an embodiment, the specific operations of initializing the system attribute fields by using the attribute field indexing assignment service class in step S1 of the present invention to obtain a hash array for indexing system fields include: sorting the system attribute fields and assigning serial numbers; calling a preset weak hash algorithm to calculate the weak hash values of the system attribute fields; and constructing a hash array with the weak hash values as index keys and the serial numbers as index values.

[0027] Specifically, taking timeStamp as an example for the process of constructing a hash array, assume that the weak hash value of timeStamp is 10000, and the sequence number of timeStamp in the system attribute field is 3. Then the assignment instruction for constructing the hash array is expressed as: weakHashCodeArray

[10000] =3. Here, weakHashCode represents the hash function (specifically, the weak hash function) called when generating the array Array. Array

[10000] represents the array element 10000, and Array

[10000] =3 means assigning 3 to Array

[10000] , that is, establishing the connection between the weak hash value 10000 and the third field in the system attribute field. After calculating the hash values of multiple business attribute fields in a business function and establishing the index relationship in the above manner, an array Array[10000, ……, 11111] is formed. Each element represents the hash value of a business attribute field, and the index relationship will be hidden. Among them, the user can customize the hash range of the weak hash function, so as to control its hashing to a reasonable range according to the number of system attribute fields involved in the business function.

[0028] In an alternative embodiment, the system attribute fields are first classified, and multiple fields with the same reference are grouped into one category, and then sorted. For example: after putting the fields that all refer to the time stamp together, such as timeStamp, time_stamp, TIMESTAMP, timestamp, and then sorting them as timeStamp1, time_stamp2, TIMESTAMP3, timestamp4. The advantage of this embodiment is that when enabling multi-threading, it can match and index multiple deformation methods of a field at one time, so as to quickly complete the rapid retrieval of a certain type of attribute.

[0029] In an alternative embodiment, the system attribute fields are first classified, and fields with the same expression form are grouped into one category, and then sorted. For example: timestamp, protocoltype, timeStamp, protocolType, and then sorting them as timestamp1, protocoltype2, timeStamp3, protocolType4. The advantage of this embodiment is that when enabling multi-threading, it can quickly match and index multiple attributes at one time.

[0030] In one embodiment, the specific steps of the calling attribute field index assignment service class in step S3 to perform hash calculation on the service attribute fields and match the index in the hash array include: calling a preset weak hash algorithm to calculate the weak hash value of the service attribute fields; performing index key matching of the weak hash value in the hash array; and in response to matching the same index key, indexing the system attribute fields at the corresponding sorting position based on the corresponding key value.

[0031] In one embodiment, the method of the present invention further includes: in response to the weak hash value of the service attribute fields calculated by using the preset weak hash algorithm being 0, ending the index matching operation and outputting an error prompt. Among them, the weak hash value of 0 may indicate that the length of the input service attribute fields exceeds the range, and the developer needs to re-check the maximum length of the service fields.

[0032] In one embodiment, the method of the present invention further includes: in response to the non-existence of system attribute fields at the corresponding sorting position indexed based on the key value, ending the index matching operation and outputting an error prompt. If the system attribute fields are deleted during the later system maintenance but the system is not restarted, there may be a problem that there are no attribute fields at the corresponding position. At this time, it is necessary to prompt to restart the service system.

[0033] In one embodiment, calling the attribute field index assignment service class to perform hash calculation on the service attribute fields and match the index in the hash array includes: in response to deserializing service data to obtain multiple service attribute fields; using multithreading to concurrently execute calling the attribute field index assignment service class to perform hash calculation on the service attribute fields and match the index in the hash array; and in response to the existence of a hash value in the hash array that matches the above hash calculation result, determining the system attribute fields aligned with the above service attribute fields. Since the present invention adopts an index alignment mechanism, multithreading can be used for concurrent processing, thereby further improving the attribute field alignment speed.

[0034] By the above method, the present invention abstracts the hash array of each service function for index alignment, can be applied to most application scenarios, and at the same time maintains the alignment efficiency at the same level as that of fixed-order hard coding.

[0035] In the second aspect of the present invention, a computer device is proposed, as Figure 2 shown, including: at least one processor 100; and a memory 200, where an executable computer program is stored in the memory 200, and when the computer program is executed by the at least one processor 100, it is used to implement the steps in any of the above service object deserialization index alignment method examples.

[0036] In the third aspect of the present invention, a readable storage medium 300 is proposed, asFigure 3 As shown, it includes: an executable computer program 301, which is used to implement the steps in any of the above method examples of business object deserialization index alignment when executed by an executor.

[0037] The above are the exemplary embodiments disclosed by the present invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments disclosed by the present invention as defined by the claims. The functions, steps, and / or actions of the method claims according to the disclosed embodiments here do not need to be executed in any specific order.

[0038] The serial numbers of the disclosed embodiments of the present invention above are only for description and do not represent the superiority or inferiority of the embodiments.

[0039] Those of ordinary skill in the art should understand that: the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the embodiments disclosed by the present invention (including the claims) is limited to these examples; under the idea of the embodiments of the present invention, the technical features between the above embodiments or different embodiments can also be combined, and there are many other variations in different aspects of the embodiments of the present invention as above, which are not provided in detail for the sake of brevity. Therefore, any omission, modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present invention shall be included in the protection scope of the embodiments of the present invention.

Claims

1. A method for aligning deserialization indexes of business objects, characterized in that The method includes: Configuring an attribute field index assignment service class in the business system; Performing transformation processing on the system attribute fields using a preset transformation strategy and expanding the transformed system attribute fields into the system configuration; Initializing the system attribute fields using the attribute field index assignment service class to obtain a hash array for indexing system fields; In response to obtaining business data, deserializing the business data to determine the business attribute fields corresponding to the business data; Invoking the attribute field index assignment service class to perform hash calculation on the business attribute fields, and matching indexes in the hash array based on the hash calculation result to determine the system attribute fields corresponding to the business attribute fields.

2. The method for deserializing and indexing alignment of business objects according to claim 1, characterized in that Performing transformation processing on the system attribute fields using a preset transformation strategy, including: Converting each of the system attribute fields into all lowercase, all uppercase, the first word with the first letter capitalized, the second word with the first letter capitalized, the first and second words with the first letters capitalized, and adding a specified character between the first and second words.

3. The method for aligning the deserialization index of a business object according to claim 1 or 2, characterized in that, Initializing the system attribute fields using the attribute field index assignment service class to obtain a hash array for indexing system fields, including: Sorting the system attribute fields and assigning serial numbers; Invoking a preset weak hash algorithm to calculate the weak hash values of the system attribute fields; Constructing a hash array with the weak hash values as index keys and the serial numbers as index values.

4. The method for aligning the deserialization index of a business object according to claim 3, characterized in that, Invoking the attribute field index assignment service class to perform hash calculation on the business attribute fields, and matching indexes in the hash array based on the hash calculation result, including: Invoking the preset weak hash algorithm to calculate the weak hash values of the business attribute fields; Performing index key matching for the weak hash values in the hash array; In response to matching the same index key, indexing the system attribute fields at the corresponding sorting position based on the corresponding key value.

5. The method for aligning the deserialization index of a service object according to claim 4, wherein The method further includes: In response to the weak hash value of the business attribute fields calculated using the preset weak hash algorithm being 0, ending the index matching operation and outputting an error prompt.

6. The method for aligning the deserialization index of a business object according to claim 4, wherein The method further includes: In response to the non-existence of system attribute fields at the corresponding sorting position based on key value indexing, ending the index matching operation and prompting to restart the business system.

7. The method for aligning the deserialization index of a service object according to claim 1, wherein Invoking the attribute field index assignment service class to perform hash calculation on the business attribute fields, and matching indexes in the hash array based on the hash calculation result, including: In response to deserializing the business data to obtain multiple business attribute fields; Using multi-threaded concurrent execution to invoke the attribute field index assignment service class to perform hash calculation on the business attribute fields, and matching indexes in the hash array based on the hash calculation result.

8. The method for aligning the deserialization index of a business object according to claim 7, characterized in that, The method further includes: In response to the existence of hash values matching the hash calculation result in the hash array, determining the system attribute fields aligned with the business attribute fields.

9. A computer device, characterized in that, Including: At least one processor; And A memory storing an executable computer program which, when executed by the at least one processor, is used to implement the steps of the business object deserialization index alignment method according to any one of claims 1-8 above.

10. A readable storage medium, characterized in that, Comprising: An executable computer program which, when executed by an executor, is used to implement the steps of the business object deserialization index alignment method according to any one of claims 1-8 above.

Citation Information

Patent Citations

  • A Hash table processing method and device

    CN106033420A

  • Chain log storage structure, hash index structure and data operation method thereof, server and medium

    CN107515901A

  • Index creation and data query method, device and equipment

    CN110825737A

  • A method and system for generating call ticket

    CN111224831A

  • Serialization method and deserialization method of data object and first electronic equipment

    CN115129759A

Cited By

  • Data processing method and device, electronic equipment and storage medium

    CN121387828A