Discrete data identifier generation method and device, equipment and storage medium

By dynamically adjusting the number of discrete bit vectors and using pseudo-random number allocation strategy, the binary balance tree has solved the problem of low identification allocation efficiency and high memory consumption under large-scale data, and efficient and flexible discrete data identification allocation is achieved.

CN119225963APending Publication Date: 2024-12-31JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411266227.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

When processing large amounts of discrete data in the prior art, the binary balance tree has problems of slow allocation and high memory consumption when used for identification allocation, especially when the number of identification reaches more than 100 million.

Method used

By determining the target discrete data and obtaining the number of discrete bit vectors it allocated and the number of assigned identification bits, if the number is less than the threshold, a new bit vector is added. If the threshold is exceeded, the allocation strategy will be dynamically adjusted based on the total number of bit vectors and the number of allocated bits relationship. , uses pseudo-random numbers to allocate identification to the data, and optimizes the identification allocation process.

Benefits of technology

It realizes efficient and flexible identification allocation of large amounts of discrete data, reduces the memory required for identification management, and improves allocation efficiency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119225963A_ABST
    Figure CN119225963A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a discrete data identifier generation method and device, equipment and a storage medium, and the method comprises the steps: determining target discrete data, and obtaining a first number of discrete bit vectors for distributing identifiers for the target discrete data, and a second number of distributed identifier bits in the discrete bit vectors; if the first number is smaller than or equal to a first preset threshold value, adding a new discrete bit vector, and allocating an identifier for the target discrete data according to the new discrete bit vector; and if the first number is greater than the first preset threshold value, calculating the total number of discrete bit vectors according to the first number, and allocating identifiers to the target discrete data according to the number relationship between the second number and the total number of discrete bit vectors. According to the embodiment of the invention, the unique identifier can be quickly allocated to a large amount of discrete data, memory consumption is reduced, and allocation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for generating discrete data identifiers. Background Art

[0002] In application areas with large amounts of discrete data and object management requirements, such as database indexes, file handles, socket handles, etc., there is a need to assign unique identifiers to discrete data.

[0003] In the prior art, the unique identifier allocation mechanism for discrete data generally uses a binary balanced tree to record the allocated identifiers. However, when the number of identifiers reaches more than 100 million, the existing allocation mechanism has the problems of slow allocation and high memory consumption.

[0004] Therefore, how to reduce the memory consumption of allocating unique identifiers for discrete data and thus improve allocation efficiency is a problem that needs to be solved at present. Summary of the invention

[0005] In view of the above problems, the present application proposes a discrete data identifier generation method, device, equipment and storage medium.

[0006] In a first aspect of the implementation of the present application, a method for generating a discrete data identifier is first provided, wherein the method comprises:

[0007] Determine target discrete data, and obtain a first number of discrete bit vectors assigned with identification for the target discrete data, and a second number of assigned identification bits in the discrete bit vectors;

[0008] If the first number is less than or equal to a first preset threshold, adding a new discrete bit vector, and assigning an identifier to the target discrete data according to the new discrete bit vector;

[0009] If the first number is greater than the first preset threshold, the total number of bits of the discrete bit vector is calculated according to the first number, and an identifier is allocated to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

[0010] Optionally, the adding of a newly created discrete bit vector and assigning an identifier to the target discrete data according to the newly created discrete bit vector includes:

[0011] Add new discrete bit vector;

[0012] Obtain the first digit corresponding to the first digit of the newly created discrete bit vector;

[0013] The first digit is used as the identifier of the target discrete data, and the first digit number corresponding to the first digit of the newly created discrete digit vector is set to a preset first digit number.

[0014] Optionally, calculating the total number of bits of the discrete bit vector according to the first number includes:

[0015] The total number of bits of the discrete bit vector is obtained by multiplying the first number by the number of bits of the unit discrete bit vector.

[0016] Optionally, allocating an identifier to the target discrete data according to a quantitative relationship between the second quantity and a total number of bits of the discrete bit vector includes:

[0017] Determine the available allocation times according to the second number and the total number of bits of the discrete bit vector;

[0018] According to the available allocation times, an identifier is allocated to the target discrete data by using a pseudo-random number method.

[0019] Optionally, determining the available allocation times according to the second number and the total number of bits of the discrete bit vector includes:

[0020] If the threshold of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is greater than or equal to the total number of bits of the discrete bit vector, determining the available number of allocation times to be a preset first number;

[0021] If the threshold of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is less than the total number of bits of the discrete bit vector, the available number of allocation times is determined to be the preset second number.

[0022] Optionally, allocating identifiers for the target discrete data using a pseudo-random number method according to the available allocation times includes:

[0023] Generate a first random number using a pseudo-random number, and use the first random number as a first index;

[0024] Obtain a first target bit corresponding to the first index in the discrete bit vector;

[0025] Obtain the number of first target bits and the first target bit number corresponding to the first target bit;

[0026] Adding the preset actual number of attempts to the preset count value;

[0027] If the available allocation number is the first number, comparing the first target number, the first number and a preset second number, and comparing the actual number of attempts with the first number;

[0028] If the first target bit number is equal to the first bit number and the actual number of attempts is greater than or equal to the first number, returning to the step of adding a new discrete bit vector;

[0029] If the first target bit number is equal to the first bit number and the actual number of attempts is less than the first number, returning to the step of generating the first random number using a pseudo-random number;

[0030] If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data;

[0031] If the available allocation number is the second number, comparing the first target bit number, the first bit number and a preset second bit number;

[0032] If the first target bit number is equal to the first bit number, returning to the step of generating the first random number by using a pseudo-random number;

[0033] If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data.

[0034] Optionally, the method further comprises:

[0035] Determine the discrete data to be released, and obtain a release identifier corresponding to the discrete data to be released;

[0036] Obtaining the number of bits of each bit of the discrete bit vector, and determining a second target number of bits equal to the release flag according to the number of bits of each bit of the discrete bit vector and the release flag;

[0037] Obtain a second target bit corresponding to the second target bit number, and set a second target bit number corresponding to the second target bit to the second bit number.

[0038] In a second aspect of the implementation of the present application, a discrete data identifier generating device is also provided, characterized in that the device comprises:

[0039] An acquisition module, configured to determine target discrete data, and acquire a first number of discrete bit vectors assigned with identifications for the target discrete data, and a second number of assigned identification bits in the discrete bit vectors;

[0040] A first processing module, configured to add a new discrete bit vector if the first number is less than or equal to a first preset threshold, and assign an identifier to the target discrete data according to the new discrete bit vector;

[0041] The second processing module is used to calculate the total number of bits of the discrete bit vector according to the first number if the first number is greater than the first preset threshold, and assign an identifier to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

[0042] Optionally, the first processing module includes:

[0043] Added a module for adding new discrete bit vectors;

[0044] A first digit module, used for obtaining the first digit corresponding to the first digit of the newly created discrete bit vector;

[0045] The first allocation module is used to use the first digit as the identifier of the target discrete data, and set the first digit number corresponding to the first digit of the newly created discrete digit vector to a preset first digit number.

[0046] Optionally, the second processing module includes:

[0047] The first calculation module is configured to multiply the first quantity by the number of bits of the unit discrete bit vector to obtain the total number of bits of the discrete bit vector.

[0048] Optionally, the second processing module further includes:

[0049] A second calculation module, configured to determine the available allocation times according to the second number and the total number of bits of the discrete bit vector;

[0050] The second allocation module is used to allocate identifiers to the target discrete data using a pseudo-random number method according to the available allocation times.

[0051] Optionally, the second calculation module includes:

[0052] A first calculation unit is configured to determine that the available allocation times is a preset first times if a threshold value of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is greater than or equal to the total number of bits of the discrete bit vector;

[0053] The second calculation unit is configured to determine that the available allocation times is a preset second times if a threshold of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is less than the total number of bits of the discrete bit vector.

[0054] Optionally, the second allocation module further includes:

[0055] An index obtaining unit, configured to generate a first random number using a pseudo-random number, and use the first random number as a first index;

[0056] A first acquisition unit, configured to acquire a first target bit corresponding to the first index in the discrete bit vector;

[0057] A second acquisition unit, used for acquiring a first target bit number and a first target bit number corresponding to the first target bit;

[0058] A counting unit, used for adding a preset actual number of attempts to a preset count value;

[0059] a first comparison unit, configured to compare the first target bit number, the first bit number, and a preset second bit number if the available allocation number is the first number, and to compare the actual number of attempts with the first number;

[0060] A first processing unit, configured to return to the step of adding a new discrete bit vector if the first target bit number is equal to the first bit number and the actual number of attempts is greater than or equal to the first number;

[0061] a second processing unit, configured to return to the step of generating a first random number by using a pseudo-random number if the first target bit number is equal to the first bit number and the actual number of attempts is less than the first number;

[0062] a third processing unit, configured to use the first target bit number as an identifier of target discrete data if the first target bit number is equal to a preset second bit number;

[0063] A second comparison unit, configured to compare the first target bit number, the first bit number, and a preset second bit number if the available allocation number is the second number;

[0064] a fourth processing unit, configured to return to the step of generating the first random number by using a pseudo-random number if the first target bit number is equal to the first bit number;

[0065] The fifth processing unit is configured to use the first target bit number as an identifier of target discrete data if the first target bit number is equal to a preset second bit number.

[0066] Optionally, the device further comprises:

[0067] A release identification module, used to determine the discrete data to be released, and obtain the release identification corresponding to the discrete data to be released;

[0068] A second target bit number acquisition module is used to acquire the number of bits of each bit of the discrete bit vector, and determine a second target bit number equal to the release flag according to the number of bits of each bit of the discrete bit vector and the release flag;

[0069] A release module is used to obtain a second target bit corresponding to the second target bit number, and set a second target bit number corresponding to the second target bit to the second bit number.

[0070] In the third aspect of the implementation of the present application, an electronic device is also provided, characterized in that it includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, the discrete data identifier generation method as described above is implemented.

[0071] In a fourth aspect of the implementation of the present application, a computer-readable storage medium is also provided, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the discrete data identifier generation method as described above is implemented.

[0072] The embodiments of the present application have the following advantages:

[0073] In an embodiment of the present application, target discrete data is determined, and a first number of discrete bit vectors that assign identifiers to the target discrete data, as well as a second number of assigned identifier bits in the discrete bit vector, are obtained; if the first number is less than or equal to a first preset threshold, a newly created discrete bit vector is added, and identifiers are assigned to the target discrete data according to the newly created discrete bit vector; if the first number is greater than the first preset threshold, the total number of bits of the discrete bit vector is calculated according to the first number, and identifiers are assigned to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector. The embodiment of the present application achieves efficient and flexible identifier allocation for a large amount of discrete data by dynamically adjusting the allocation strategy based on the number of discrete bit vectors, and greatly reduces the memory required for identifier management. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.

[0075] Figure 1 It is a flowchart of a method for generating a discrete data identifier provided by an embodiment of the present application;

[0076] Figure 2 It is a flowchart of a discrete data identifier generation method provided by an embodiment of the present application;

[0077] Figure 3 This is a flowchart of a discrete data identification release method provided by an embodiment of the present application;

[0078] Figure 4 It is a structural diagram of a discrete data identifier generation device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0079] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, each embodiment of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in each embodiment of the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not constitute any limitation, and the various embodiments can be combined with each other and referenced to each other without contradiction.

[0080] Discrete data can be data that can only take specific values, which are usually integers or elements in a finite set, with clear intervals between them and cannot take intermediate values ​​between two integers. Discrete data plays an important role in statistics and data analysis, and can reflect the counting or classification characteristics of things, such as the number of students, product categories, gender, etc. When dealing with discrete data, it is usually necessary to assign labels, statistical descriptions, and visualizations to better understand and analyze the data.

[0081] A database index is an optimization technique that can significantly increase the speed of data retrieval by creating auxiliary data structures on specific columns of a database table. Index data structures, such as hash tables, provide a way for the database engine to quickly locate and access rows of data, thereby reducing the need to scan the entire table when querying. Indexes are useful for columns that are frequently used for searching, sorting, or joining, but there is also a trade-off in their impact on the performance of insert, update, and delete operations.

[0082] A file handle is an abstract concept used in the operating system to identify and access files or input / output resources. It is a non-negative integer that serves as a medium for interaction between programs and the operating system, representing an open file or other types of resources such as pipes, sockets, or devices. When a program needs to read or write a file, it requests the operating system to perform the corresponding operation through a file handle. The management of file handles is crucial to the resource allocation and performance of the system because it determines the efficiency of file access and the flexibility of concurrent processing. In a multitasking environment, effective file handle management can ensure resource isolation and correct data access order between different processes.

[0083] Socket handles can be used to identify and operate network sockets. Sockets are the basic building blocks of network communication, allowing processes on different hosts to exchange data over the network. A socket handle is a non-negative integer that serves as an interface between an application and the operating system's network subsystem to identify an open network connection.

[0084] The ID of discrete data can be an identifier used to identify and distinguish discrete data. In data management and processing, it can ensure the uniqueness and traceability of data. The ID of discrete data is usually an integer or a string, and the specific form depends on the application scenario.

[0085] A binary balanced tree is a self-balancing binary search tree that can ensure that the height of the tree is kept to a minimum by adjusting the tree structure after each insertion or deletion operation. Common types of binary balanced trees include red-black trees, which maintain the balance of the tree and improve the efficiency of data operations through mechanisms such as rotation operations and color marking. Although there may be memory consumption and performance bottlenecks when processing large-scale data.

[0086] Discrete data identifier allocation generally uses a binary balanced tree to record the allocated identifiers. When processing a large number of discrete data identifier allocations, the traditional binary balanced tree will face the problems of slow allocation and high memory consumption when the number of identifiers reaches more than 100 million due to its structural characteristics. Therefore, the embodiment of the present application provides a discrete data identifier generation method to improve the efficiency of discrete data identifier allocation.

[0087] Reference Figure 1 , shows a flowchart of a method for generating a discrete data identifier provided by an embodiment of the present application, and the method may specifically include the following steps:

[0088] Step 101 : determine target discrete data, and obtain a first number of discrete bit vectors that allocate identifiers for the target discrete data, and a second number of allocated identifier bits in the discrete bit vectors.

[0089] It should be noted that the target discrete data may be discrete data to be assigned an identifier, and the discrete bit vector may be a data structure for efficiently representing and operating the discrete data identifier allocation state. An array may be composed of bits, each of which may represent a possible identifier, and may be used to manage unique identifiers of a large number of discrete data. The first number is the number of discrete bit vectors, and the second number is the number of bits in the discrete bit vector that have been assigned an identifier.

[0090] In an embodiment of the present application, discrete data that needs to be assigned an identifier can be determined, which may be new discrete data or discrete data that needs to be reallocated an identifier; the number of discrete bit vectors that assign identifiers to discrete data can be obtained, and the number of bits in the current discrete bit vector that have been assigned an identifier can be determined.

[0091] Step 102: If the first number is less than or equal to a first preset threshold, a new discrete bit vector is added, and an identifier is assigned to the target discrete data according to the new discrete bit vector.

[0092] It should be noted that the first preset threshold is 0, which may indicate that there is currently no discrete bit vector that can be assigned an identifier for discrete data.

[0093] In the embodiment of the present application, if there is currently no discrete bit vector that can assign an identifier to the discrete data, a new discrete bit vector can be created, and an identifier can be assigned to the discrete data according to the new discrete bit vector.

[0094] In an optional embodiment of the present application, step 102 includes the following sub-steps:

[0095] S21: Add a new discrete bit vector;

[0096] S22: Obtain the first digit corresponding to the first digit of the newly created discrete bit vector;

[0097] S23: taking the first digit as the identifier of the target discrete data, and setting the first digit number corresponding to the first digit of the newly created discrete digit vector to the preset first digit number.

[0098] It should be noted that the number of bits of a discrete bit vector may be the position corresponding to each bit in the discrete bit vector, for example, the number of bits corresponding to the 0th bit (the first bit) of the first discrete bit vector is 0, and the number of bits corresponding to the 2nd bit of the second discrete bit vector is 2. The bit number of a discrete bit vector may be the state corresponding to each bit of the discrete bit vector, indicating whether the identifier is unassigned (available) or allocated (unavailable), where 0 indicates that the identifier of the bit is not assigned, and 1 indicates that the identifier of the bit is assigned.

[0099] In the embodiment of the present application, a new discrete bit vector is created, and the initial bit number of the discrete bit vector is 0. At this time, the first bit of the discrete bit vector can be used as the identifier of the target discrete data. Finally, the first bit number of the discrete bit vector is changed to 1, indicating that the identifier of the first bit has been assigned to the target discrete data.

[0100] In the embodiment of the present application, by introducing a mechanism of creating a new discrete bit vector in the discrete data identification allocation process, it is ensured that a new bit vector can be dynamically created when there is no available discrete bit vector, thereby avoiding the problem of identification allocation failure. At the same time, by using the first digit of the newly created discrete bit vector as the identification of the target discrete data and updating the state of the bit vector in a timely manner, the discrete data identification allocation can be completed quickly and accurately.

[0101] Step 103: if the first number is greater than the first preset threshold, the total number of bits of the discrete bit vector is calculated according to the first number, and an identifier is assigned to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

[0102] It should be noted that the total number of bits of the discrete bit vectors may be the sum of the numbers of bits of all discrete bit vectors.

[0103] In an embodiment of the present application, if there are currently available discrete bit vectors, the total number of bits of the discrete bit vectors can be calculated by the number of current discrete bit vectors, and then an identifier is assigned to the target discrete data based on the relationship between the total number of bits of the discrete bit vectors and the number of already assigned identifier bits.

[0104] In an optional embodiment of the present application, step 103 includes the following sub-steps:

[0105] S31: multiplying the first quantity by the number of bits of the unit discrete bit vector to obtain the total number of bits of the discrete bit vector;

[0106] It should be noted that the number of bits of a unit discrete bit vector may be the total number of bits of each discrete bit vector. For example, the preset discrete bit vector may be a 16-bit unsigned integer variable. In this case, the number of bits of the unit discrete bit vector is 32768. This application does not make any specific limitation on this.

[0107] In the embodiment of the present application, the total number of bits of the discrete bit vectors may be obtained by multiplying the number of discrete bit vectors by the number of bits of a unit discrete bit vector.

[0108] In an optional embodiment of the present application, step 103 further includes the following sub-steps:

[0109] S32: Determine the available allocation times according to the second number and the total number of bits of the discrete bit vector;

[0110] S33: According to the available allocation times, use a pseudo-random number method to allocate identifiers to the target discrete data.

[0111] It should be noted that the available allocation times can be the number of times the identifier is allocated to the target discrete data. Pseudo-random numbers can be seemingly random numbers generated by an algorithm, which are close to real random numbers in terms of statistical properties. These number series can be used for random numbers in many applications, such as simulation, games, and identifier allocation. For example, the Mersenne Twister pseudo-random number algorithm that can be used in this application generates random numbers.

[0112] In an embodiment of the present application, the available number of allocations can be determined based on the quantitative relationship between the number of allocated identification bits in the discrete bit vector (the second number) and the total number of bits of the discrete bit vector (the first number), and then based on the obtained available number of allocations, an identifier is allocated to the target discrete data using a pseudo-random number method.

[0113] In an optional embodiment of the present application, step S32 further includes the following sub-steps:

[0114] S321: If the threshold of the number of allocated identification bits obtained by multiplying the second number by the preset multiple is greater than or equal to the total number of bits of the discrete bit vector, determining the available number of allocation times to be the preset first number;

[0115] S322: If the threshold of the number of allocated identification bits obtained by multiplying the second number by the preset multiple is less than the total number of bits of the discrete bit vector, determining the available number of allocation times to be the preset second number;

[0116] It should be noted that when the threshold of the number of allocated identification bits is greater than or equal to the total number of bits of the discrete bit vector, it means that the allocable identification bits of the current discrete bit vector are insufficient for unlimited random allocation. At this time, it means that the discrete bit vector does not have a position capacity margin. The number of available allocations at this time is the first number, which is generally 6 times. The preset multiple can be 1.5; when the threshold of the number of allocated identification bits is less than the total number of bits of the discrete bit vector, it means that the allocable identification bits of the current discrete bit vector are sufficient for unlimited random allocation. At this time, it means that the discrete bit vector has a position capacity margin. The number of allocable allocations at this time, that is, the second number, is infinite;.

[0117] In the embodiment of the present application, the second number is calculated and multiplied by a preset multiple to obtain a threshold value of the number of allocated identification bits;

[0118] When the threshold of the number of allocated identification bits is greater than or equal to the total number of bits in the discrete bit vector, the available number of allocations is the first number; when the threshold of the number of allocated identification bits is less than or equal to the total number of bits in the discrete bit vector, the available number of allocations is infinite.

[0119] In an embodiment of the present application, the total number of bits of the discrete bit vector is dynamically calculated, and the available allocation times are flexibly adjusted according to the relationship between the number of allocated identification bits and the total number of bits, thereby optimizing the allocation process of discrete data identifiers. At the same time, a capacity margin strategy is used to ensure the efficiency of discrete data identifier allocation in extreme cases.

[0120] In an optional embodiment of the present application, step S33 further includes the following sub-steps:

[0121] S331: Generate a first random number using a pseudo-random number, and use the first random number as a first index;

[0122] S332: Obtain a first target bit corresponding to the first index in the discrete bit vector;

[0123] S333: Obtaining the first target bit number and the first target bit number corresponding to the first target bit;

[0124] S334: adding a preset actual number of attempts to a preset count value;

[0125] S335: If the available allocation times are the first number, compare the first target number, the first number and the preset second number, and compare the actual number of attempts with the first number;

[0126] S336: If the first target bit number is equal to the first bit number and the actual number of attempts is greater than or equal to the first number, return to the step of adding a new discrete bit vector;

[0127] S337: If the first target number is equal to the first number and the actual number of attempts is less than the first number, return to the step of generating the first random number using a pseudo-random number;

[0128] S338: If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data;

[0129] S339: If the available allocation times is the second number, compare the first target number, the first number and the preset second number;

[0130] S3310: If the first target bit number is equal to the first bit number, return to the step of generating the first random number using a pseudo-random number;

[0131] S3311: If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data.

[0132] It should be noted that the first index can be used to find a target bit in the discrete bit vector, and the target bit is used to allocate a discrete data identifier. The preset count value is 1, and the value of the actual number of attempts is added by 1, indicating that an attempt to allocate a discrete data identifier is completed. The first bit number is 1, and the second bit number is 0.

[0133] In the embodiment of the present application, a random number is generated using a pseudo-random number method and used as the first index. The first target bit is determined according to the first index, that is, the value of the first index is equal to the number of bits of the first target bit. Then, the bit number and the number of bits of the first target bit are obtained, and an attempt to allocate a random number is completed.

[0134] When the available allocation times are the first number, it means that the actual number of attempts is the limited first number. At this time, it is necessary to compare the relationship between the first target number, the first number, and the preset second number, and compare the relationship between the actual number of attempts and the first number:

[0135] When the first target bit number is equal to 1 and the actual number of attempts is greater than or equal to the first number, it means that the first target bit has been assigned an identifier and the actual number of attempts has reached or exceeded the available number of allocations. At this time, it is necessary to return to the step of adding a new discrete bit vector;

[0136] When the first target bit number is equal to 1 and the actual number of attempts is less than the first number, it means that the first target bit has been assigned an identifier but the actual number of attempts does not exceed the available number of assignments, and at this time, the step of generating the first random number using a pseudo-random number can be returned;

[0137] When the first target bit number is equal to 0, it means that the first target bit has not been assigned an identifier. In this case, the number of bits of the first target bit can be used as an identifier of discrete data.

[0138] When the available allocation times are the first number, it means that the actual number of attempts is infinite. At this time, it is necessary to compare the relationship between the first target number, the first number, and the preset second number:

[0139] When the first target bit number is equal to 1, it means that the first target bit has been assigned an identifier, and the process can return to the step of generating the first random number using a pseudo-random number;

[0140] When the first target bit number is equal to 0, it means that the first target bit has not been assigned an identifier. In this case, the number of bits of the first target bit can be used as an identifier of discrete data.

[0141] It should be noted that the first target bit has been assigned an identifier and the actual number of attempts has reached or exceeded the available allocated number. At this time, it is necessary to return to the step of adding a new discrete bit vector and allocate the first bit of the new discrete bit vector for the discrete data. At this time, the first bit should be the total number of bits in the current discrete vector plus 1.

[0142] In an embodiment of the present application, a first index is generated by a pseudo-random number method to locate the target bit of a discrete bit vector, and an allocation strategy is intelligently selected based on the available number of allocations, the actual number of attempts, and the bit number of the target bit to ensure the uniqueness of the identifier allocation and improve the efficiency and reliability of discrete data identifier allocation.

[0143] In an optional embodiment of the present application, the following steps are further included after step 103:

[0144] Determine the discrete data to be released, and obtain a release identifier corresponding to the discrete data to be released;

[0145] Obtaining the number of bits of each bit of the discrete bit vector, and determining a second target number of bits equal to the release flag according to the number of bits of each bit of the discrete bit vector and the release flag;

[0146] A second target bit corresponding to the second target bit number is obtained, and a second target bit number corresponding to the second target bit is set as a second bit number.

[0147] It should be noted that the discrete data to be released is discrete data determined from the discrete data to which identifiers have been allocated.

[0148] In an embodiment of the present application, the discrete data to be released can be determined, and the release identifier of the discrete data can be obtained. Each bit of the discrete bit vector can be traversed, the number of digits of each bit can be obtained, and it can be compared with the release identifier. If there is a number of digits equal to the release identifier, the number of digits is determined to be the second target number of digits. The second target bit is located according to the second target number of digits, and the bit number of the bit is set to 0. At this time, it indicates that the identifier of the target bit has been released, and the identifier can be reassigned to the new discrete data.

[0149] In the embodiment of the present application, by releasing the identifiers of discrete data, efficient recovery and reallocation of discrete data identifiers are achieved.

[0150] In an embodiment of the present application, a discrete data identifier prediction and optimization mechanism based on historical allocation patterns can be used to analyze historical identifier allocation data, predict future identifier requirements, and dynamically adjust the state of discrete bit vectors to optimize the identifier allocation process.

[0151] Specifically, historical identification allocation data can be analyzed to identify patterns and trends in identification allocation, such as peak and trough periods of identification allocation. Based on historical allocation data, future identification needs can be predicted, and the bit numbers of discrete bit vectors can be dynamically adjusted according to the prediction results to ensure sufficient and efficient use of identification resources. In addition, based on the identification demand prediction results, discrete bit vectors can be expanded in advance during the peak period of identification allocation, or appropriately reduced during the trough period of identification allocation to optimize resource allocation.

[0152] In the embodiment of the present application, by introducing a discrete data identifier prediction and optimization mechanism based on historical allocation patterns, efficient allocation of discrete data identifiers is achieved, thereby improving the efficiency and reliability of discrete data identifier allocation.

[0153] In an embodiment of the present application, target discrete data is determined, and a first number of discrete bit vectors that assign identifiers to the target discrete data, as well as a second number of assigned identifier bits in the discrete bit vector, are obtained; if the first number is less than or equal to a first preset threshold, a newly created discrete bit vector is added, and identifiers are assigned to the target discrete data according to the newly created discrete bit vector; if the first number is greater than the first preset threshold, the total number of bits of the discrete bit vector is calculated according to the first number, and identifiers are assigned to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector. The embodiment of the present application achieves efficient and flexible identifier allocation for a large amount of discrete data by dynamically adjusting the allocation strategy based on the number of discrete bit vectors, and greatly reduces the memory required for identifier management.

[0154] Reference Figure 2 , shows a flowchart of a discrete data identifier generation method provided by an embodiment of the present application, which may specifically include the following contents:

[0155] In the embodiment of the present application, a request for assigning an identifier is received, and the target discrete data to which the identifier needs to be assigned is determined. The number of discrete bit vectors can be obtained, and it can be determined whether the number of discrete bit vectors is 0:

[0156] If the number of discrete bit vectors is equal to 0, a new discrete bit vector is created, and the bit number of the 0th bit of the newly created discrete bit vector can be set to 1, and the number of bits of the 0th bit is used as the identifier of the discrete data.

[0157] If the number of discrete bit vectors is not equal to 0, the relationship between the total number of bits in the discrete vector and the allocated identification bits can be determined:

[0158] When the number of allocated identification bits multiplied by 1.5 is greater than or equal to the total number of bits, the number of available allocations is 6;

[0159] When the number of allocated identification bits multiplied by 1.5 is less than the total number of bits, the number of available allocations is unlimited.

[0160] The actual number of attempts is set to 0, a first index value can be generated using a random number, and a first target bit number and a first target bit number in a discrete vector corresponding to the first index value can be determined.

[0161] At this time, add 1 to the actual number of attempts, and determine whether the first target number is 0 and the relationship between the actual number of attempts and the number of allocable times:

[0162] When the first target bit number is 1 and the actual number of attempts is less than the allocatable number, return to the step of generating the first index value using a random number;

[0163] When the first target bit number is 1 and the actual number of attempts is greater than or equal to the allocatable number, return to the step of creating a new discrete bit vector;

[0164] When the first target bit number is 0, the first target bit number is used as an identifier of discrete data.

[0165] Set the first target bit number to 1, then add 1 to the allocated identification bit, complete the allocation and return to receive the identification allocation request again.

[0166] Reference Figure 3 , shows a flowchart of a discrete data release generation method provided by an embodiment of the present application, which may specifically include the following contents:

[0167] A request for releasing an identifier is received, and the to-be-released discrete data whose identifier needs to be released is determined. The release identifier of the to-be-released discrete data can be obtained. Each bit of the discrete bit vector can be traversed to obtain the number of digits of each bit, and the number of digits can be compared with the release identifier. If there is a number of digits equal to the release identifier, the number of digits is determined to be the second target number of digits. A second target bit number corresponding to the second target bit number can be obtained, and the number of digits can be set to 0.

[0168] Finally, the allocated flag is reduced by 1, the release is completed and the return is made to receive the flag release request again.

[0169] Reference Figure 4 , shows a schematic diagram of the structure of a discrete data identifier generation device provided in an embodiment of the present application. The device includes:

[0170] The acquisition module 401 is used to determine the target discrete data, and acquire a first number of discrete bit vectors that assign identifiers to the target discrete data, and a second number of assigned identifier bits in the discrete bit vectors;

[0171] A first processing module 402 is configured to add a new discrete bit vector if the first number is less than or equal to a first preset threshold, and assign an identifier to the target discrete data according to the new discrete bit vector;

[0172] The second processing module 403 is used to calculate the total number of bits of the discrete bit vector according to the first number if the first number is greater than the first preset threshold, and assign an identifier to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

[0173] Optionally, the first processing module 402 includes:

[0174] Added a module for adding new discrete bit vectors;

[0175] A first digit module, used to obtain the first digit corresponding to the first digit of the newly created discrete bit vector;

[0176] The first allocation module is used to use the first digit as the identifier of the target discrete data, and set the first digit number corresponding to the first digit of the newly created discrete digit vector to the preset first digit number.

[0177] Optionally, the second processing module 403 includes:

[0178] The first calculation module is configured to multiply the first quantity by the number of bits of the unit discrete bit vector to obtain the total number of bits of the discrete bit vector.

[0179] Optionally, the second processing module 403 further includes:

[0180] A second calculation module, used to determine the available allocation times according to the second number and the total number of bits of the discrete bit vector;

[0181] The second allocation module is used to allocate identifiers to target discrete data using pseudo-random numbers according to the available allocation times.

[0182] Optionally, the second calculation module includes:

[0183] A first calculation unit is configured to determine that the available number of allocations is a preset first number if a threshold value of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is greater than or equal to the total number of bits of the discrete bit vector;

[0184] The second calculation unit is used to determine that the available allocation number is a preset second number if the threshold of the number of allocated identification bits obtained by multiplying the second number by the preset multiple is less than the total number of bits of the discrete bit vector.

[0185] Optionally, the second allocation module includes:

[0186] An index obtaining unit, configured to generate a first random number using a pseudo-random number, and use the first random number as a first index;

[0187] A first acquisition unit, used to acquire a first target bit corresponding to a first index in a discrete bit vector;

[0188] A second acquisition unit, used to acquire a first target bit number and a first target bit number corresponding to the first target bit;

[0189] A counting unit, used for adding a preset actual number of attempts to a preset count value;

[0190] A first comparison unit is used for comparing the first target number, the first number and the preset second number if the available allocation number is the first number, and comparing the actual number of attempts with the first number;

[0191] A first processing unit, configured to return to the step of adding a new discrete bit vector if the first target bit number is equal to the first bit number and the actual number of attempts is greater than or equal to the first number;

[0192] A second processing unit, configured to return to the step of generating the first random number by using a pseudo-random number if the first target bit number is equal to the first bit number and the actual number of attempts is less than the first number;

[0193] A third processing unit is used for using the first target bit number as an identifier of the target discrete data if the first target bit number is equal to the preset second bit number;

[0194] A second comparison unit is used for comparing the first target bit number, the first bit number and the preset second bit number if the available allocation number is the second number;

[0195] a fourth processing unit, configured to return to the step of generating the first random number by using a pseudo-random number if the first target bit number is equal to the first bit number;

[0196] The fifth processing unit is used to use the first target bit number as the identifier of the target discrete data if the first target bit number is equal to the preset second bit number.

[0197] Optionally, the discrete data identifier generating device further includes:

[0198] A release identification module, used to determine the discrete data to be released and obtain the release identification corresponding to the discrete data to be released;

[0199] A second target bit number acquisition module is used to acquire the number of bits of each bit of the discrete bit vector, and determine a second target bit number equal to the release flag according to the number of bits of each bit of the discrete bit vector and the release flag;

[0200] The release module is used to obtain a second target bit corresponding to the second target bit number, and set the second target bit number corresponding to the second target bit to the second bit number.

[0201] As for the device 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.

[0202] An embodiment of the present application further provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the discrete data identifier generation method as described above is implemented.

[0203] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the discrete data identifier generation method as described above is implemented.

[0204] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0205] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0206] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0207] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0208] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0209] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0210] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0211] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal 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, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.

[0212] The discrete data identifier generation method and device provided above are introduced in detail. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for generating a discrete data identifier, characterized in that: The method comprises: Determine target discrete data, and obtain a first number of discrete bit vectors assigned with identification for the target discrete data, and a second number of assigned identification bits in the discrete bit vectors; If the first number is less than or equal to a first preset threshold, adding a new discrete bit vector, and assigning an identifier to the target discrete data according to the new discrete bit vector; If the first number is greater than the first preset threshold, the total number of bits of the discrete bit vector is calculated according to the first number, and an identifier is allocated to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

2. The method according to claim 1, characterized in that The adding of a newly created discrete bit vector and assigning an identifier to the target discrete data according to the newly created discrete bit vector includes: Add new discrete bit vector; Obtain the first digit corresponding to the first digit of the newly created discrete bit vector; The first digit is used as the identifier of the target discrete data, and the first digit number corresponding to the first digit of the newly created discrete digit vector is set to a preset first digit number.

3. The method according to claim 1, characterized in that The calculating the total number of bits of the discrete bit vector according to the first number includes: The total number of bits of the discrete bit vector is obtained by multiplying the first number by the number of bits of the unit discrete bit vector.

4. The method according to claim 2, characterized in that: The assigning an identifier to the target discrete data according to the quantitative relationship between the second quantity and the total number of bits of the discrete bit vector comprises: Determine the available allocation times according to the second number and the total number of bits of the discrete bit vector; According to the available allocation times, an identifier is allocated to the target discrete data by using a pseudo-random number method.

5. The method according to claim 4, characterized in that The determining of the available allocation times according to the second number and the total number of bits of the discrete bit vector comprises: If the threshold of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is greater than or equal to the total number of bits of the discrete bit vector, determining the available number of allocation times to be a preset first number; If the threshold of the number of allocated identification bits obtained by multiplying the second number by a preset multiple is less than the total number of bits of the discrete bit vector, the available number of allocation times is determined to be the preset second number.

6. The method according to claim 5, characterized in that The step of assigning an identifier to the target discrete data by using a pseudo-random number according to the available number of assignments includes: Generate a first random number using a pseudo-random number, and use the first random number as a first index; Obtain a first target bit corresponding to the first index in the discrete bit vector; Obtain the number of first target bits and the first target bit number corresponding to the first target bit; Adding the preset actual number of attempts to the preset count value; If the available allocation number is the first number, comparing the first target number, the first number and a preset second number, and comparing the actual number of attempts with the first number; If the first target bit number is equal to the first bit number and the actual number of attempts is greater than or equal to the first number, returning to the step of adding a new discrete bit vector; If the first target bit number is equal to the first bit number and the actual number of attempts is less than the first number, returning to the step of generating the first random number using a pseudo-random number; If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data; If the available allocation number is the second number, comparing the first target bit number, the first bit number and a preset second bit number; If the first target bit number is equal to the first bit number, returning to the step of generating the first random number by using a pseudo-random number; If the first target bit number is equal to the preset second bit number, the first target bit number is used as the identifier of the target discrete data.

7. The method according to claim 6, characterized in that The method further comprises: Determine the discrete data to be released, and obtain a release identifier corresponding to the discrete data to be released; Obtaining the number of bits of each bit of the discrete bit vector, and determining a second target number of bits equal to the release flag according to the number of bits of each bit of the discrete bit vector and the release flag; Obtain a second target bit corresponding to the second target bit number, and set a second target bit number corresponding to the second target bit to the second bit number.

8. A discrete data identifier generating device, characterized in that: The device comprises: An acquisition module, configured to determine target discrete data, and acquire a first number of discrete bit vectors assigned with identifications for the target discrete data, and a second number of assigned identification bits in the discrete bit vectors; A first processing module, configured to add a new discrete bit vector if the first number is less than or equal to a first preset threshold, and assign an identifier to the target discrete data according to the new discrete bit vector; The second processing module is used to calculate the total number of bits of the discrete bit vector according to the first number if the first number is greater than the first preset threshold, and assign an identifier to the target discrete data according to the quantitative relationship between the second number and the total number of bits of the discrete bit vector.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, configured to implement the discrete data identifier generation method as described in any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the discrete data identifier generation method according to any one of claims 1 to 7 is implemented.