A sequence generation method, device and electronic device

By using two sequence management tables in a distributed database, and prioritizing the use of unused sequence numbers to bind new data, the problem of self-increasing sequence generation difficulty and sequence holes in a distributed database is solved, and data insertion performance is improved.

CN114490688BActive Publication Date: 2024-12-06ZHEJIANG DAHUA TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210088818.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-25
Publication Date
2024-12-06
Estimated Expiration
2042-01-25

AI Technical Summary

Technical Problem

In distributed databases, the difficulty of generating self-increasing sequences increases, resulting in frequent interaction between computing nodes and service centers, reducing the performance of data insertion and possible sequence holes.

Method used

By maintaining two sequence management tables in the computing node, the newly added data is preferred using unused sequence numbers to reduce the number of interactions with the service center and prevent the occurrence of sequence holes.

Benefits of technology

It effectively reduces the number of interactions between the computing node and the service center, avoids the occurrence of sequence holes, and improves the performance of data insertion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490688B_ABST
    Figure CN114490688B_ABST
Patent Text Reader

Abstract

The present application discloses a sequence generation method, device and electronic device, the method comprising: when acquiring N newly added data, determining whether there is a first sequence number set in an unused state in a first sequence management table; if so, binding the N newly added data to the first sequence number set; if not, binding the N newly added data to the second sequence number in an unused state in a second sequence management table. Through the above method, the unused sequence numbers in the computing nodes are preferentially used to bind the newly added data, thereby making full use of the preset number of sequence numbers allocated by the service center, thereby preventing sequence holes while reducing the number of interactions with the service center.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a sequence generation method, device and electronic device. Background Art

[0002] In a database system, it is usually necessary to globally uniquely identify a large amount of data with an ID, and at the same time ensure that each time a piece of data is added, the value of the ID of the newly added data will also be "+1". At this time, by finding the largest ID number, the total amount of data in the database can be known. The above process is to generate an auto-increment sequence, and the ID number is the sequence number. In a distributed database scenario, since multiple nodes are involved and each node has a corresponding database, it is more difficult to generate an auto-increment sequence.

[0003] like Figure 1 As shown in Figure 1, it is a schematic diagram of a distributed database application scenario. Figure 1 In the system, the coordination node is connected to multiple computing nodes. The coordination node is used to assign data and tasks to each computing node, summarize the computing results of the computing nodes, and finally return the results to the user end; the computing nodes are used for data storage and the execution of computing tasks.

[0004] When a computing node inserts data, it needs to send a request to the service center to obtain the latest serial number. At this time, the service center receives the requests sent by each computing node in order to ensure that the serial numbers obtained by each computing node are strictly monotonically increasing. For example, the order in which the service center obtains requests is computing node 1, computing node 2, computing node 3, and computing node 4, and the latest serial number is "0001", then the latest serial numbers obtained by computing node 1, computing node 2, computing node 3, and computing node 4 are "0002", "0003", "0004", and "0005" respectively. In the above process, each computing node needs to interact with the service center when inserting data, resulting in reduced performance of inserting new data.

[0005] In order to solve the above problem and avoid frequent interactions between computing nodes and service centers, the prior art, when creating a self-incrementing sequence, specifies how many serial numbers are assigned to computing nodes at a time by presetting parameters, and stores the assigned serial numbers in the memory corresponding to the computing nodes, which can reduce the number of interactions between computing nodes and service centers and enable computing nodes to obtain serial numbers faster. In the above process, since the number of serial numbers assigned to computing nodes by the service center each time is fixed, there may be a situation where the assigned serial numbers have no corresponding data, resulting in a sequence hole.

[0006] For example, after the server assigns serial numbers to computing nodes according to preset parameters, if the data insertion cancellation operation is added, the assigned serial numbers will have no corresponding values, resulting in a sequence hole. For another example, if the computing node inserts 15 data at a time, and the service center assigns 20 serial numbers, then there will be 5 serial numbers without corresponding data among the 20 serial numbers assigned by the service center, and these 5 serial numbers will not be used when data is inserted next time. In this case, there will also be a sequence hole. Summary of the invention

[0007] The present application provides a sequence generation method, device and electronic device. When new data is inserted, the unused serial numbers in the computing nodes are preferentially used to bind the new data. By making full use of the preset number of serial numbers allocated by the service center, the number of interactions with the service center can be reduced while preventing the occurrence of sequence holes.

[0008] In a first aspect, the present application provides a sequence generation method, the method comprising:

[0009] When acquiring N newly added data, determining whether there is a first sequence number set in an unused state in the first sequence management table, wherein the first sequence management table includes at least one sequence number set and a usage state corresponding to the sequence number set, and N is an integer greater than or equal to 1;

[0010] If so, binding the N newly added data to the first sequence number in the first sequence number set;

[0011] If not, the N newly added data are bound to the unused second sequence number in the second sequence management table, wherein the second sequence management table contains at least one sequence number and the usage status corresponding to the sequence number.

[0012] Through the above method, when new data is inserted, the unused serial numbers in the computing nodes are preferentially used to bind the new data. By fully utilizing the preset number of serial numbers allocated to the service center, it is possible to prevent sequence holes while reducing the number of interactions with the service center.

[0013] In a possible design, binding the N newly added data with the first sequence number in the first sequence number set includes:

[0014] When the value of N is greater than a first value corresponding to the first serial number, determining whether a sum of the first value and a second value corresponding to the second serial number is greater than or equal to N;

[0015] If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the use status corresponding to the first sequence number set and the use status corresponding to the second sequence number are adjusted to used;

[0016] If not, request the service center to obtain the second serial number set.

[0017] Through the above method, when the number of unused serial numbers in the computing nodes is greater than or equal to the number of new data, the unused serial numbers in the computing nodes are used preferentially, thereby preventing sequence holes while reducing the number of interactions with the service center.

[0018] In a possible design, binding the N newly added data with the first sequence number in the first sequence number set includes:

[0019] When the value of N is less than the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0020] The use status corresponding to the first sequence number set is adjusted to used, and the first sequence numbers in the first sequence number set that are not bound to the newly added data are inserted into the second sequence management table.

[0021] Through the above method, when the number of serial numbers in the first serial number set that is unused in the first sequence management table is greater than the number of newly added data, the serial numbers in the first serial number set are preferentially bound to the newly added data, and the redundant serial numbers are managed for easy use next time, thereby preventing sequence holes while reducing the number of interactions with the service center.

[0022] In a possible design, binding the N newly added data with the first sequence number in the first sequence number set includes:

[0023] When the value of N is equal to the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0024] The usage status corresponding to the first sequence number set is adjusted to used.

[0025] By the above method, when the number of sequence numbers in the unused sequence number set in the first sequence management table is greater than the number of newly added data, the sequence numbers in the priority sequence number set are bound to the newly added data, thereby preventing sequence holes while reducing the number of interactions with the service center.

[0026] In a possible design, binding the N newly added data with the unused second sequence numbers in the second sequence management table includes:

[0027] Determine whether the value of N is less than or equal to a second value corresponding to the second serial number;

[0028] If yes, the N newly added data are bound to the second sequence number, and the usage status corresponding to the second sequence number bound to the newly added data is adjusted to used;

[0029] If not, request the service center to obtain the second serial number set.

[0030] Through the above method, when there is no unused serial number set in the first sequence management table, the unused serial numbers in the second sequence management table are bound to the newly added data, thereby preventing sequence holes while reducing the number of interactions with the service center.

[0031] In a second aspect, the present application provides a sequence generation device, the device comprising:

[0032] a judgment module, configured to judge whether there is a first sequence number set in an unused state in the first sequence management table when acquiring N newly added data, wherein the first sequence management table includes at least one sequence number set and a usage state corresponding to the sequence number set, and N is an integer greater than or equal to 1;

[0033] A first binding module, configured to bind the N newly added data to a first sequence number in the first sequence number set if the first sequence number set exists;

[0034] The second binding module is used to bind the N newly added data to the unused second serial number in the second sequence management table if the first serial number set does not exist, wherein the second sequence management table contains at least one serial number and the usage status corresponding to the serial number.

[0035] In a possible design, the first binding module is specifically used to:

[0036] When the value of N is greater than a first value corresponding to the first serial number, determining whether a sum of the first value and a second value corresponding to the second serial number is greater than or equal to N;

[0037] If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the use status corresponding to the first sequence number set and the use status corresponding to the second sequence number are adjusted to used;

[0038] If not, request the service center to obtain the second serial number set.

[0039] In a possible design, the first binding module is further used for:

[0040] When the value of N is less than the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0041] The use status corresponding to the first sequence number set is adjusted to used, and the first sequence numbers in the first sequence number set that are not bound to the newly added data are inserted into the second sequence management table.

[0042] In a possible design, the first binding module is further used for:

[0043] When the value of N is equal to the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0044] The usage status corresponding to the first sequence number set is adjusted to used.

[0045] In a possible design, the second binding module is specifically used to:

[0046] Determine whether the value of N is less than or equal to a second value corresponding to the second serial number;

[0047] If yes, the N newly added data are bound to the second sequence number, and the usage status corresponding to the second sequence number bound to the newly added data is adjusted to used;

[0048] If not, request the service center to obtain the second serial number set.

[0049] In a third aspect, the present application provides an electronic device, including:

[0050] Memory, used to store computer programs;

[0051] The processor is used to implement the above sequence generation method steps when executing the computer program stored in the memory.

[0052] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned sequence generation method steps are implemented.

[0053] Based on the above sequence generation method, when inserting new data, priority is given to obtaining the unused first sequence set from the first sequence management table, and using the first sequence number in the first sequence number set to bind the new data, and then considering using the unused second sequence number in the second sequence management table to bind the new data. This method can make full use of the preset number of sequence numbers allocated by the service center, thereby preventing the occurrence of sequence holes while reducing the number of interactions with the service center. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A schematic diagram of a distributed database application scenario provided for this application;

[0055] Figure 2 A schematic diagram of an improved distributed database application scenario provided for this application;

[0056] Figure 3 A flowchart of a sequence generation method provided in this application;

[0057] Figure 4 A schematic diagram of the structure of a sequence generation device provided in this application;

[0058] Figure 5 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operating methods in the method embodiments can also be applied to device embodiments or system embodiments. It should be noted that in the description of the present application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A is connected to B, which can represent: A is directly connected to B and A is connected to B through C. In addition, in the description of the present application, words such as "first" and "second" are only used to distinguish the purpose of description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.

[0060] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0061] In a distributed database, in order to avoid frequent interactions between computing nodes and service centers, the prior art, when creating an auto-increment sequence, specifies how many sequence numbers are assigned to computing nodes at a time by presetting parameters, and stores the assigned sequence numbers in the memory corresponding to the computing nodes, which can reduce the number of interactions between computing nodes and service centers and enable computing nodes to obtain sequence numbers faster. However, since the number of sequence numbers assigned to computing nodes by the service center is fixed each time, there may be a situation where the assigned sequence numbers have no corresponding data, resulting in sequence holes.

[0062] For example, after the server assigns serial numbers to computing nodes according to preset parameters, if the data insertion cancellation operation is added, the assigned serial numbers will have no corresponding values, resulting in a sequence hole. For another example, if the computing node inserts 15 data at a time, and the service center assigns 20 serial numbers, then there will be 5 serial numbers without corresponding data among the 20 serial numbers assigned by the service center, and these 5 serial numbers will not be used when data is inserted next time. In this case, there will also be a sequence hole.

[0063] In order to solve the above problems, the present invention improves the prior art. Figure 2 As shown, a new sequence management table is added in each computing node, wherein each sequence management table includes a first sequence management table and a second sequence management table, the first sequence management table is used to manage the first sequence set issued by the service center, and the second sequence management table is used to manage a single sequence number in the first sequence set that is in an unused state.

[0064] Based on the above improvements, when inserting new data, priority is given to obtaining the unused first sequence set from the first sequence management table, and using the first sequence number in the first sequence number set to bind the new data, and then considering using the unused second sequence number in the second sequence management table to bind the new data. This method can make full use of the preset number of sequence numbers allocated by the service center, and prevent sequence holes from occurring while reducing the number of interactions with the service center. Among them, the method and device described in the embodiments of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can refer to each other, and the repeated parts will not be repeated.

[0065] like Figure 3 As shown, it is a flowchart of a sequence generation method provided by the present application, which specifically includes the following steps:

[0066] S31, when acquiring N newly added data, determining whether there is an unused first sequence number set in the first sequence management table;

[0067] In the embodiment of the present application, the first sequence management table is mainly used to manage the use status of the serial number set allocated by the management service center according to preset parameters. For example, the service center allocates two serial number sets, one of which contains serial numbers "0001, 0002, 0003, 0004" and the other contains serial numbers "0005, 0006, 0007, 0008". In the two serial number sets, if only serial number 0001 has bound data, that is, the serial number is used, then the serial number set where serial number 0001 is located is considered to be in a used state, while the other serial number set is in an unused state. In possible scenarios, when serial number 0005 is bound to a certain data, the use status of the serial number set where 0005 is located should be adjusted to used.

[0068] As can be seen from the above, the first sequence management table includes at least one sequence number set and the usage status corresponding to the sequence number set.

[0069] When N new data are acquired, in order to reduce the number of interactions with the service center and avoid sequence holes, the embodiment of the present application considers using the first sequence number in the first sequence number set in an unused state in the first management list to bind with the N new data, and fully utilizes the sequence number allocated by the service center, wherein N is an integer greater than or equal to 1. Therefore, it is first necessary to determine whether there is an unused first sequence number set in the first management list.

[0070] If there is an unused first sequence number set in the first sequence number set, step S12 is executed; if there is no unused first sequence number set in the first sequence number set, step S13 is executed.

[0071] S32, binding the N newly added data to the first sequence number in the first sequence number set;

[0072] In the embodiment of the present application, when binding N newly added data with the first sequence number in the first sequence number set, first consider whether the N newly added data can all be bound to the first sequence number, and adopt different binding strategies according to different situations. Specifically:

[0073] Compare the value of N with the first value corresponding to the first sequence number. When the value of N is greater than the first value, it indicates that at least one of the N new data cannot be bound to the first sequence number. In this case, consider obtaining the unused second sequence number from the second sequence management table.

[0074] In the above process, the second sequence management table is used to manage single serial numbers in the serial number set in the first sequence management table that are in an unused state. For example, when the first serial number contained in the first serial number set is a serial number set and the serial numbers contained in the serial number set are "0001, 0002, 0003, 0004" respectively, in a possible scenario, serial number 0001 is bound to the newly added data. At this time, in addition to adjusting the first serial number set to a used state, the remaining serial numbers 0002 to 0004 need to be inserted into the second sequence management table for unified management to facilitate next use.

[0075] As can be seen from the above, the second sequence management table contains at least one sequence number and the usage status corresponding to the sequence number. When considering using the second sequence number in the second sequence management table, first determine whether the sum of the first value and the second value corresponding to the second sequence number is greater than or equal to N;

[0076] If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the usage status corresponding to the first sequence number set and the usage status corresponding to the second sequence number are adjusted to used. In the binding process, since the first sequence number and the second sequence number are both allocated by the service center, each sequence number is unique, and when the sequence numbers in multiple computing nodes are merged together, all sequence numbers are monotonically increasing.

[0077] If not, it indicates that the number of unused serial numbers stored in the computing node is insufficient, and it is necessary to request the service center to obtain the second serial number set. After receiving the request, the service center allocates the second serial number set according to the serial number values ​​in all computing nodes and the preset parameters. For example, if there are currently three computing nodes, the serial number set that has been allocated to computing node 1 includes serial numbers 0001 to 0005, the serial number set that has been allocated to computing node 2 includes serial numbers 0006 to 0010, and the serial number set that has been allocated to computing node 3 includes serial numbers 0011 to 0015. At this time, if computing node 2 requests the service center to allocate the second serial number set, the serial number set allocated to computing node 2 by the service center includes serial numbers 0016 to 0020.

[0078] In a possible application scenario, the value of N is smaller than the first value, which indicates that when the first sequence number in the first sequence set is bound to N new data, each new data has a corresponding first sequence number. Therefore, it is only necessary to bind the N new data to the first sequence number, and adjust the usage status corresponding to the first sequence number set after the bound data to used.

[0079] During the binding process, since there are redundant first sequence numbers in the first sequence number set that are not bound to the newly added data, this part of the first sequence numbers without bound data is inserted into the second sequence management table for easy use when new data is inserted next time to prevent sequence holes.

[0080] There is another possible application scenario, where the value of N is equal to the first value. In this case, it is only necessary to bind the N newly added data to the first serial number respectively, and adjust the usage status corresponding to the first serial number set to used.

[0081] By using the above method, when there is an unused first sequence list in the first management list, the serial number in the first sequence list is preferentially used to bind with the newly added data, thereby preventing sequence holes while reducing the number of interactions with the service center.

[0082] S33, binding the N newly added data to the unused second sequence numbers in the second sequence management table;

[0083] In the embodiment of the present application, if there is no unused first management list in the first sequence management table, in order to reduce the number of interactions between the computing node and the service center and avoid data and voids, consider binding N data to the unused second sequence number in the second sequence management table. The specific binding method includes:

[0084] Determine whether the value of N is less than or equal to the second value corresponding to the second serial number;

[0085] If yes, bind the N newly added data to the second sequence number, and adjust the usage status corresponding to the second sequence number bound to the newly added data to used;

[0086] If not, request the service center to obtain the second serial number set.

[0087] For example, the newly inserted data are A and B, and the number of unused second sequence numbers in the second sequence management table is 3, and these 3 second sequence numbers are 0001, 0002, and 0003. Because the number of newly added data is less than the number of second sequence numbers, data A and B can be directly bound to sequence numbers 0001 and 0002, and the use status of sequence numbers 0001 and 0002 is adjusted to used, and sequence number 3 is still in an unused state.

[0088] In one possible design, in order to avoid excessive accumulation of data in the first sequence management table and the second sequence management table, the two sequence management tables may be processed periodically to clear out the used serial numbers and serial number sets to avoid excessive data in the sequence management tables.

[0089] Based on the sequence generation method provided by the present application, when inserting new data, priority is given to obtaining an unused first sequence set from the first sequence management table, and using the first sequence number in the first sequence number set to bind the new data, and then considering using the unused second sequence number in the second sequence management table to bind the new data. This method can make full use of the preset number of sequence numbers allocated by the service center, thereby preventing the occurrence of sequence holes while reducing the number of interactions with the service center.

[0090] Based on the same inventive concept, the present application also provides a sequence generation device, such as Figure 4 FIG. 1 is a schematic diagram of a sequence generation device in the present application, the device comprising:

[0091] A judgment module 41 is used to judge whether there is a first sequence number set in an unused state in the first sequence management table when acquiring N newly added data, wherein the first sequence management table contains at least one sequence number set and a use state corresponding to the sequence number set, and N is an integer greater than or equal to 1;

[0092] A first binding module 42, configured to bind the N newly added data to a first sequence number in the first sequence number set if the first sequence number set exists;

[0093] The second binding module 43 is used to bind the N newly added data to the unused second serial number in the second sequence management table if the first serial number set does not exist, wherein the second sequence management table contains at least one serial number and the usage status corresponding to the serial number.

[0094] In a possible design, the first binding module 42 is specifically configured to:

[0095] When the value of N is greater than a first value corresponding to the first serial number, determining whether a sum of the first value and a second value corresponding to the second serial number is greater than or equal to N;

[0096] If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the use status corresponding to the first sequence number set and the use status corresponding to the second sequence number are adjusted to used;

[0097] If not, request the service center to obtain the second serial number set.

[0098] In a possible design, the first binding module 42 is further configured to:

[0099] When the value of N is less than the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0100] The use status corresponding to the first sequence number set is adjusted to used, and the first sequence numbers in the first sequence number set that are not bound to the newly added data are inserted into the second sequence management table.

[0101] In a possible design, the first binding module 42 is further configured to:

[0102] When the value of N is equal to the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number;

[0103] The usage status corresponding to the first sequence number set is adjusted to used.

[0104] In a possible design, the second binding module 43 is specifically configured to:

[0105] Determine whether the value of N is less than or equal to a second value corresponding to the second serial number;

[0106] If yes, the N newly added data are bound to the second sequence number, and the usage status corresponding to the second sequence number bound to the newly added data is adjusted to used;

[0107] If not, request the service center to obtain the second serial number set.

[0108] Based on the sequence generation device provided by the present application, when new data is inserted, priority is given to obtaining an unused first sequence set from the first sequence management table, and using the first sequence number in the first sequence number set to bind the new data, and then considering using the unused second sequence number in the second sequence management table to bind the new data. This method can make full use of the preset number of sequence numbers allocated by the service center, thereby preventing the occurrence of sequence holes while reducing the number of interactions with the service center.

[0109] Based on the same inventive concept, an electronic device is also provided in an embodiment of the present application, and the electronic device can realize the function of the aforementioned sequence generating device, referring to Figure 5 , the electronic device comprises:

[0110] At least one processor 51, and a memory 52 connected to the at least one processor 51. The specific connection medium between the processor 51 and the memory 52 is not limited in the embodiment of the present application. Figure 5 In the example, the processor 51 and the memory 52 are connected via a bus 50. The bus 50 is Figure 5The connection between other components is shown by bold lines, and the connection between other components is only for schematic illustration and is not intended to be limiting. The bus 50 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 51 can also be called a controller, and there is no limitation on the name.

[0111] In the embodiment of the present application, the memory 52 stores instructions that can be executed by at least one processor 51. The at least one processor 51 can execute the sequence generation method discussed above by executing the instructions stored in the memory 52. ​​The processor 51 can implement Figure 4 The functions of each module in the device shown.

[0112] Among them, the processor 51 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 52 and calling data stored in the memory 52, the various functions of the device and processing data, the device can be monitored as a whole.

[0113] In a possible design, the processor 51 may include one or more processing units, and the processor 51 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 51. In some embodiments, the processor 51 and the memory 52 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.

[0114] The processor 51 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the sequence generation method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or the hardware and software modules in the processor can be combined and executed.

[0115] The memory 52 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 52 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 52 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 52 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0116] By programming the processor 51, the code corresponding to the sequence generation method described in the above embodiment can be fixed into the chip, so that the chip can execute the sequence generation method when it is running. Figure 3 The steps of the sequence generation method in the embodiment shown are as follows: How to design and program the processor 51 is a technique well known to those skilled in the art and will not be described in detail here.

[0117] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the sequence generation method discussed above.

[0118] In some possible implementations, various aspects of the sequence generation method provided in the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on an apparatus, the program code is used to enable the control device to execute the steps of the sequence generation method according to various exemplary embodiments of the present application described above in this specification.

[0119] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, 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 present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0120] The present application is described with reference to the flowcharts and / or block diagrams of the methods, 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 device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing 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.

[0121] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising 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.

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

[0123] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A sequence generation method, characterized in that: The method comprises: When acquiring N newly added data, determining whether there is a first sequence number set in an unused state in the first sequence management table, wherein the first sequence management table includes at least one sequence number set and a usage state corresponding to the sequence number set, and N is an integer greater than or equal to 1; If so, binding the N newly added data to the first sequence number in the first sequence number set; If not present, the N newly added data will be bound to the second serial number in the second sequence management table that is in an unused state, wherein the second sequence management table contains at least one serial number and the usage status corresponding to the serial number, and the second sequence management table is used to manage a single serial number that is in an unused state in the serial number set in the first sequence management table.

2. The method according to claim 1, characterized in that The binding the N newly added data with the first sequence number in the first sequence number set includes: When the value of N is greater than a first value corresponding to the first serial number, determining whether a sum of the first value and a second value corresponding to the second serial number is greater than or equal to N; If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the use status corresponding to the first sequence number set and the use status corresponding to the second sequence number are adjusted to used; If not, request the service center to obtain the second serial number set.

3. The method according to claim 1, characterized in that The binding the N newly added data with the first sequence number in the first sequence number set includes: When the value of N is less than the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number; The use status corresponding to the first sequence number set is adjusted to used, and the first sequence numbers in the first sequence number set that are not bound to the newly added data are inserted into the second sequence management table.

4. The method according to claim 1, characterized in that The binding the N newly added data with the first sequence number in the first sequence number set includes: When the value of N is equal to the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number; The usage status corresponding to the first sequence number set is adjusted to used.

5. The method according to claim 1, characterized in that The step of binding the N newly added data to the unused second sequence numbers in the second sequence management table includes: Determine whether the value of N is less than or equal to a second value corresponding to the second serial number; If yes, the N newly added data are bound to the second sequence number, and the usage status corresponding to the second sequence number bound to the newly added data is adjusted to used; If not, request the service center to obtain the second serial number set.

6. A sequence generation device, characterized in that: The device comprises: a judgment module, configured to judge whether there is a first sequence number set in an unused state in the first sequence management table when acquiring N newly added data, wherein the first sequence management table includes at least one sequence number set and a usage state corresponding to the sequence number set, and N is an integer greater than or equal to 1; A first binding module, configured to bind the N newly added data to a first sequence number in the first sequence number set if the first sequence number set exists; The second binding module is used to bind the N newly added data to the second serial number in the second sequence management table that is in an unused state if the first serial number set does not exist, wherein the second sequence management table contains at least one serial number and the usage status corresponding to the serial number, and the second sequence management table is used to manage a single serial number that is in an unused state in the serial number set in the first sequence management table.

7. The device according to claim 6, characterized in that The first binding module is specifically used for: When the value of N is greater than a first value corresponding to the first serial number, determining whether a sum of the first value and a second value corresponding to the second serial number is greater than or equal to N; If yes, the N newly added data are bound to the first sequence number and the second sequence number, and the use status corresponding to the first sequence number set and the use status corresponding to the second sequence number are adjusted to used; If not, request the service center to obtain the second serial number set.

8. The device according to claim 6, characterized in that The first binding module is also used for: When the value of N is less than the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number; The use status corresponding to the first sequence number set is adjusted to used, and the first sequence numbers in the first sequence number set that are not bound to the newly added data are inserted into the second sequence management table.

9. The device according to claim 6, characterized in that The first binding module is also used for: When the value of N is equal to the first value corresponding to the first sequence number, binding the N newly added data to the first sequence number; The usage status corresponding to the first sequence number set is adjusted to used.

10. The device according to claim 6, characterized in that The second binding module is specifically used for: Determine whether the value of N is less than or equal to a second value corresponding to the second serial number; If yes, the N newly added data are bound to the second sequence number, and the usage status corresponding to the second sequence number bound to the newly added data is adjusted to used; If not, request the service center to obtain the second serial number set.

11. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method steps of any one of claims 1 to 5 when executing the computer program stored in the memory.

12. 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 method steps of any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Data storage method and device for distributed database and computer equipment

    CN112347076A

  • Method for generating primary key and distributed system

    CN113190554A

  • System and method for generating an account number automatically

    WO2012137217A1