Method and device for generating unique identifier

文档序号:49490 发布日期:2021-09-28 浏览:13次 中文

阅读说明:本技术 唯一标识的生成方法和装置 (Method and device for generating unique identifier ) 是由 姚亦周 郭彦涛 叶宾 于 2020-03-27 设计创作,主要内容包括:本发明公开了一种唯一标识的生成方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:获取本机的机器码,并向注册中心注册机器码;将注册成功的机器码输入到标识生成算法中,以使标识生成算法根据机器码生成第一标识;获取数据库标识和数据表标识,并将数据库标识和数据表标识与第一标识进行拼接以得到唯一标识。该实施方式保证了分布式集群系统环境下生成的唯一标识的全局唯一性,且无需对机器进行单独配置,便于集群的水平扩展,同时,在数据分库分表保存的情况下,可以快速、准确地获取数据。(The invention discloses a method and a device for generating a unique identifier, and relates to the technical field of computers. One embodiment of the method comprises: acquiring a machine code of a local machine, and registering the machine code to a registration center; inputting the successfully registered machine code into an identification generation algorithm so that the identification generation algorithm generates a first identification according to the machine code; and acquiring a database identifier and a data table identifier, and splicing the database identifier and the data table identifier with the first identifier to obtain a unique identifier. The implementation mode ensures the global uniqueness of the unique identifier generated under the distributed cluster system environment, does not need to configure the machine independently, facilitates the horizontal extension of the cluster, and can acquire data quickly and accurately under the condition of sub-database and sub-table storage of the data.)

1. A method for generating a unique identifier, comprising:

acquiring a machine code of a local machine, and registering the machine code to a registration center;

inputting the successfully registered machine code into an identification generation algorithm, so that the identification generation algorithm generates a first identification according to the machine code;

and acquiring a database identifier and a data table identifier, and splicing the database identifier, the data table identifier and the first identifier to obtain a unique identifier.

2. The method of claim 1, wherein obtaining native machine code comprises:

acquiring a network address of a local machine, and calculating the code of the network address;

and performing modulus operation on the maximum number of machines supported by the identification generation algorithm by the codes of the network addresses to obtain the machine codes.

3. The method of claim 1, wherein inputting the successfully registered machine code into the identity generation algorithm comprises:

initializing the successfully registered machine code into the identification generation algorithm in the form of construction function transmission parameters.

4. The method of claim 1, wherein the logo generation algorithm is a modified snowflake algorithm.

5. The method of claim 4, wherein the identity generation algorithm consists of:

a 1-bit identifier, a 40-bit timestamp, a 6-bit machine code, and a 7-bit random sequence number.

6. The method of claim 4, wherein the identity generation algorithm consists of:

a 1-bit identifier, a 38-bit timestamp, a 7-bit machine code, and an 8-bit random sequence number.

7. The method of claim 1, wherein the method is implemented as a software development kit.

8. An apparatus for generating a unique identifier, comprising:

the machine code registration module is used for acquiring the machine code of the local machine and registering the machine code to a registration center;

the algorithm execution module is used for inputting the successfully registered machine code into an identifier generation algorithm so that the identifier generation algorithm generates a first identifier according to the machine code;

and the identifier splicing module is used for acquiring a database identifier and a data table identifier and splicing the database identifier, the data table identifier and the first identifier to obtain a unique identifier.

9. An electronic device that generates a unique identification, comprising:

one or more processors;

a storage device for storing one or more programs,

when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.

10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for generating a unique identifier.

Background

Most distributed business systems require a unique identifier (e.g., a globally unique identifier ID in an algorithm), such as: order ID, doctor ID, patient ID, etc. The snowflake algorithm is one of the generation modes of the global unique identifier commonly used at present.

In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:

1) in the traditional snowflake algorithm, machine codes need to be configured differently aiming at each machine in a micro-service cluster, if thousands of machines exist in the cluster, a configuration item is a huge project, the configuration is complicated, the global uniqueness of a generated unique identifier cannot be guaranteed, and meanwhile, the free horizontal expansion of the cluster is inconvenient;

2) data cannot be accurately acquired according to the global unique identification under the condition of database and table division;

3) in the cluster environment, the generation of the global unique identification ID by using the snowflake algorithm generally packages the algorithm into a micro-service, and a service system calls the micro-service to obtain the global ID through RPC. However, the method enables the business system to be coupled with the micro-service strongly and to be dependent strongly, and if the micro-service is unavailable, the whole business system is affected; secondly, the time consumption of the network has a great limit to the efficiency of ID generation.

Disclosure of Invention

In view of this, embodiments of the present invention provide a method and an apparatus for generating a unique identifier, which can ensure global uniqueness of the unique identifier generated in a distributed cluster system environment, and do not need to configure a machine separately, thereby facilitating horizontal extension of a cluster, and meanwhile, data can be obtained quickly and accurately in a case of database sub-table storage.

To achieve the above object, according to an aspect of an embodiment of the present invention, a method for generating a unique identifier is provided.

A method of generating a unique identifier, comprising: acquiring a machine code of a local machine, and registering the machine code to a registration center; inputting the successfully registered machine code into an identification generation algorithm, so that the identification generation algorithm generates a first identification according to the machine code; and acquiring a database identifier and a data table identifier, and splicing the database identifier, the data table identifier and the first identifier to obtain a unique identifier.

Optionally, obtaining the native machine code comprises: acquiring a network address of a local machine, and calculating the code of the network address; and performing modulus operation on the maximum number of machines supported by the identification generation algorithm by the codes of the network addresses to obtain the machine codes.

Optionally, inputting the successfully registered machine code into the identifier generation algorithm includes: initializing the successfully registered machine code into the identification generation algorithm in the form of construction function transmission parameters.

Optionally, the mark generation algorithm is a modified snowflake algorithm.

Optionally, the identifier generation algorithm is composed of: a 1-bit identifier, a 40-bit timestamp, a 6-bit machine code, and a 7-bit random sequence number.

Optionally, the identifier generation algorithm is composed of: a 1-bit identifier, a 38-bit timestamp, a 7-bit machine code, and an 8-bit random sequence number.

Optionally, the method is implemented as a software development kit.

According to another aspect of the embodiments of the present invention, there is provided a unique identifier generating apparatus.

An apparatus for generating a unique identifier, comprising: the machine code registration module is used for acquiring the machine code of the local machine and registering the machine code to a registration center; the algorithm execution module is used for inputting the successfully registered machine code into an identifier generation algorithm so that the identifier generation algorithm generates a first identifier according to the machine code; and the identifier splicing module is used for acquiring a database identifier and a data table identifier and splicing the database identifier, the data table identifier and the first identifier to obtain a unique identifier.

According to yet another aspect of an embodiment of the present invention, there is provided an electronic device for generating a unique identifier.

A unique identification generating electronic device, comprising: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for generating the unique identifier provided by the embodiment of the invention.

According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.

A computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the method of generating a unique identifier provided by an embodiment of the present invention.

One embodiment of the above invention has the following advantages or benefits: the method comprises the steps of acquiring a machine code of a local machine and registering the machine code with a registration center; inputting the successfully registered machine code into an identification generation algorithm so that the identification generation algorithm generates a first identification according to the machine code; the method comprises the steps of obtaining a database identifier and a data table identifier, splicing the database identifier and the data table identifier with a first identifier to obtain a unique identifier, ensuring global uniqueness of the unique identifier generated under the distributed cluster system environment, avoiding independent configuration of a machine, facilitating horizontal extension of a cluster, and meanwhile, rapidly and accurately obtaining data under the condition of sub-database sub-table storage. Application requirements of different service scenes can be met by improving the snowflake algorithm, and the method is flexible and convenient; the unique identifier generation method and device are packaged into a software development kit to be introduced into engineering, so that the method and device are non-invasive to service, can generate the unique identifier locally, and are high in generation efficiency and free of network time consumption.

Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.

Drawings

The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:

FIG. 1 is a schematic diagram of a prior snowflake algorithm;

fig. 2 is a schematic diagram of the main steps of a method for generating a unique identifier according to an embodiment of the present invention;

FIG. 3 is a schematic diagram of the structure of the improved snowflake algorithm of one embodiment of the present invention;

FIG. 4 is a schematic diagram of the structure of the improved snowflake algorithm according to another embodiment of the present invention;

FIG. 5 is a schematic diagram illustrating the stitching principle of the globally unique identifier according to an embodiment of the present invention;

FIG. 6 is a flowchart illustrating a process of generating a globally unique identifier according to an embodiment of the present invention;

FIG. 7 is a schematic diagram of the main blocks of a unique identifier generation apparatus according to an embodiment of the present invention;

FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;

fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.

Detailed Description

Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.

In the prior art, a snowflake algorithm is taken as an example, and is a commonly used generation algorithm of a global unique identification ID. Fig. 1 is a schematic diagram of a conventional snowflake algorithm. As shown in fig. 1, the existing snowflake algorithm mainly consists of the following parts:

(1) 1-bit identifier: always 0, since long data type (long integer) is signed in Java, the most significant bit is the sign bit, positive number is 0, negative number is 1, and id is generally a positive number, so the most significant bit is 0;

(2) 41-bit time stamp: the 41-bit timestamp is not a timestamp storing the current time, but a value obtained by storing a difference value (current timestamp — start timestamp) of timestamps, where the start timestamp, which is generally the time at which the id generator starts to use, is specified by a program;

(3) 10-bit machine code: 1024 nodes can be deployed, and if machine division equipment (IDC) is deployed, the 10 bits can be composed of 5 bits of equipment room ID +5 bits of machine ID;

(4) 12-bit sequence number: counting within milliseconds, a 12-bit counting sequence number supports generation of 4096 ID sequence numbers per millisecond (same machine, same timestamp) by each node.

In order to solve the problems existing in the prior art when a snowflake algorithm generates a global unique identifier, the invention provides a method and a device for generating the unique identifier, so that the generated unique identifier can meet the requirements of different use scenes; moreover, the global uniqueness of the unique identifier generated by each machine in the cluster is ensured by introducing the machine code of each machine in the cluster and inputting the machine code into the identifier generation algorithm; in addition, the database and data table information stored by the unique identifier is spliced into the unique identifier, so that the database and the table where the data is located can be accurately positioned under the environment of database division and table division; finally, the method and the device for generating the unique identifier are packaged into a software development kit jar package to be introduced into a project, so that the method and the device are non-invasive to the service, can generate the unique identifier locally, and are high in generation efficiency and free of network time consumption.

Fig. 2 is a schematic diagram of main steps of a method for generating a unique identifier according to an embodiment of the present invention, as shown in fig. 2, the method for generating a unique identifier according to an embodiment of the present invention mainly includes the following steps S201 to S203.

Step S201: acquiring a machine code of a local machine, and registering the machine code to a registration center;

step S202: inputting the successfully registered machine code into an identification generation algorithm so that the identification generation algorithm generates a first identification according to the machine code;

step S203: and acquiring a database identifier and a data table identifier, and splicing the database identifier and the data table identifier with the first identifier to obtain a unique identifier.

In an embodiment of the invention, the unique identifier is, for example, a globally unique identifier in an algorithm.

According to one embodiment of the invention, the step of obtaining native machine code may comprise:

acquiring a network address of a local machine, and calculating the code of the network address;

and modulus is carried out on the maximum number of machines supported by the identification generation algorithm by the coding of the network address to obtain a machine code.

In the embodiment of the present invention, a local IP address (network address) is obtained during program initialization, and a hash code of the IP address is calculated (other coding methods may be selected as needed). And then, performing modulus operation on the maximum number of machines included in the cluster supported in the identification generation algorithm by the Hash code of the IP address to obtain a machine code. Then, register the machine code to the registry, if the registration is not successful, then indicate that the machine code exists, then add 1 to the machine code and register again, and at the same time, set the overtime time to control the registration time. In the embodiment of the invention, the redis is used as a registration center, and the registered machine codes are not repeated through a single-thread realization principle of the redis.

And generating and registering the machine code of the current machine on the redis at the time of program initialization, and inputting the successfully registered machine code into the identification generation algorithm. In the identifier generation algorithm of the embodiment of the invention, the unique identifier is represented as a global unique identifier in a program algorithm. When the machine code successfully registered is input into the identifier generation algorithm, the specific method may be: and initializing the successfully registered machine codes into an identification generation algorithm in the form of constructing function transmission parameters. And then, the process of generating the global unique identifier by the identifier generation algorithm is unbound with the redis, so that the normal generation of the global unique identifier by the application is not influenced even if the redis host is hung up subsequently.

In an embodiment of the invention, the identity generation algorithm is for example a snowflake algorithm. In addition, the snowflake algorithm is improved, so that the length of the first identifier generated by the improved snowflake algorithm is controllable and is all digital, and the length requirements of different applications on the unique identifier can be met.

FIG. 3 is a schematic diagram of the composition structure of the improved snowflake algorithm according to an embodiment of the present invention. In one embodiment of the invention, the logo generation algorithm (modified snowflake algorithm) consists of the following parts: a 1-bit identifier, a 40-bit timestamp, a 6-bit machine code, and a 7-bit random sequence number.

The first identifier generated according to the modified snowflake algorithm of fig. 3 has the following regularity: the longest first mark is 16 bits, and is suitable for the application with the required length; can be continuously generated for 34.8 years; the maximum number of machines in the cluster supported by the algorithm is 64; 128 first identification numbers are generated per millisecond.

The service life is calculated as follows:

(240-1)/(1000 × 60 × 24 × 356) ═ 34.8 years.

Fig. 4 is a schematic diagram of the composition structure of the improved snowflake algorithm according to another embodiment of the present invention. In one embodiment of the invention, the logo generation algorithm (modified snowflake algorithm) consists of the following parts: a 1-bit identifier, a 38-bit timestamp, a 7-bit machine code, and an 8-bit random sequence number.

The first identifier generated according to the modified snowflake algorithm of fig. 4 has the following regularity: the longest of the first identification is 16 bits; can be continuously generated for 8.7 years; the maximum number of machines in the cluster supported by the algorithm is 128; 256 first identification numbers are generated per millisecond.

The composition structure of the improved snowflake algorithm given in the embodiments shown in fig. 3 and 4 is summarized in table 1 below.

TABLE 1

The first identifier generated by the improved snowflake algorithm shown in the embodiment shown in fig. 3 is shorter, and is suitable for scenes with requirements on the length of the unique identifier ID, so that a certain space can be saved; the improved snowflake algorithm provided in the embodiment shown in fig. 4 has high concurrency, and is suitable for scenes with a large number of machines in a cluster and a very frequent generation of unique identification IDs.

After the first identifier is generated through the identifier generation algorithm, the database identifier, the data table identifier and the first identifier can be spliced to obtain the unique identifier, so that the data can be accurately and quickly acquired according to the unique identifier under the condition of sub-database and sub-table storage. Meanwhile, the first identifier generated by the improved snowflake algorithm in the embodiment of the invention is 16 bits, and the unique identifier generated by the existing snowflake algorithm is 19-bit integer, so that a 1-bit database identifier and a 2-bit data table identifier can be spliced by the first identifier to generate a 19-bit global unique identifier, and the bits of the 19-bit global unique identifier are consistent with the bits of the existing unique identifier.

Fig. 5 is a schematic diagram illustrating a stitching principle of a globally unique identifier according to an embodiment of the present invention. As shown in FIG. 5, the first flag generated by the modified snowflake algorithm of the embodiment of the present invention is 16 bits: "XXXXXX XXXX XXXX", the database of splices is identified as "1", and the data table of splices is identified as "12".

In a specific application, if a user account provided by an external system is known and corresponds to a global unique identifier, when user data corresponding to the user account in other systems needs to be searched, the global unique identifier corresponding to the user account needs to be acquired first, and data search is performed according to the global unique identifier. At this time, a hash value can be obtained by performing hash operation on the user account, then a 1-bit database identifier is generated by modulo 10 of the hash value, and a 2-bit data table identifier is generated by modulo 100 of the hash value, so that the storage location of the user account is accurately acquired, and the corresponding globally unique identifier is quickly acquired.

Fig. 6 is a flowchart illustrating a process of generating a globally unique identifier according to an embodiment of the present invention. As shown in fig. 6, when a certain machine in the cluster for generating the global unique identifier is online, first, the IP address of the current machine is obtained; then, the machine code of the current machine is obtained by carrying out Hash coding on the IP address and carrying out modulus extraction on the maximum number of machines in the cluster supported by the identification generation algorithm; then, registering the machine code with a registration center, taking redis as the specific implementation of the registration center, and registering the machine code through a single thread; if the registration is successful, injecting the machine code which is successfully registered into an identifier generation algorithm (snowflake algorithm) to generate a first identifier, otherwise, increasing the machine code by 1 and then registering the machine code with the registration center again until the registration is successful; after the first identifier is generated, the first identifier is spliced with the database identifier and the data table identifier to generate a global unique identifier, and the global unique identifier is stored according to the database identifier and the data table identifier.

Fig. 7 is a schematic diagram of the main modules of a unique identifier generation apparatus according to an embodiment of the present invention. As shown in fig. 7, the apparatus 700 for generating a unique identifier according to an embodiment of the present invention mainly includes a machine code registration module 701, an algorithm execution module 702, and an identifier concatenation module 703.

A machine code registration module 701, configured to obtain a machine code of a local machine, and register the machine code with a registration center;

an algorithm executing module 702, configured to input the successfully registered machine code into an identifier generating algorithm, so that the identifier generating algorithm generates a first identifier according to the machine code;

the identifier splicing module 703 is configured to obtain a database identifier and a data table identifier, and splice the database identifier, the data table identifier, and the first identifier to obtain a unique identifier.

According to an embodiment of the present invention, the machine code registration module 701 may further be configured to:

acquiring a network address of a local machine, and calculating the code of the network address;

and performing modulus operation on the maximum number of machines supported by the identification generation algorithm by the codes of the network addresses to obtain the machine codes.

According to another embodiment of the present invention, the algorithm execution module 702 may further be configured to:

initializing the successfully registered machine code into the identification generation algorithm in the form of construction function transmission parameters.

According to an embodiment of the invention, the logo generation algorithm is a modified snowflake algorithm.

According to one embodiment of the invention, the identity generation algorithm consists of:

a 1-bit identifier, a 40-bit timestamp, a 6-bit machine code, and a 7-bit random sequence number.

According to another embodiment of the invention, the identity generation algorithm consists of:

a 1-bit identifier, a 38-bit timestamp, a 7-bit machine code, and an 8-bit random sequence number.

According to yet another embodiment of the invention, the apparatus is implemented as a software development kit.

According to the technical scheme of the embodiment of the invention, the machine code of the local machine is obtained, and the machine code is registered in the registration center; inputting the successfully registered machine code into an identification generation algorithm so that the identification generation algorithm generates a first identification according to the machine code; the method comprises the steps of obtaining a database identifier and a data table identifier, splicing the database identifier and the data table identifier with a first identifier to obtain a unique identifier, ensuring global uniqueness of the unique identifier generated under the distributed cluster system environment, avoiding independent configuration of a machine, facilitating horizontal extension of a cluster, and meanwhile, rapidly and accurately obtaining data under the condition of sub-database sub-table storage. Application requirements of different service scenes can be met by improving the snowflake algorithm, and the method is flexible and convenient; the unique identifier generation method and device are packaged into a software development kit to be introduced into engineering, so that the method and device are non-invasive to service, can generate the unique identifier locally, and are high in generation efficiency and free of network time consumption.

According to the embodiment of the invention, the following beneficial effects are mainly achieved:

(1) redis is used as a registration center, so that machines in the cluster can be guaranteed to take different machine codes, and further, the global uniqueness of the ID generated by the snowflake algorithm is guaranteed;

(2) the function robustness is strong, the generation process of the global unique identifier is decoupled from Redis, and even if a Redis machine is down, the generation of the global unique identifier by each service system can not be influenced;

(3) the snowflake algorithm ensures that the generated global unique identification is sequentially increased in size, ensures that the trend of the generated global unique identification is increased in size under the cluster environment, and has strong confidentiality on other user information and the like;

(4) the generated global unique identification is composed of numbers, can be used as a main key in a data warehouse environment, and is high in readability and query efficiency;

(5) the algorithm is packaged into a jar package of a software development kit for direct use, so that the method has no invasion to services, no network time consumption exists, and the efficiency of generating the global unique identifier is high;

(6) the service life of the generated global unique identifier is long;

(7) the access configuration is simple, the cluster horizontal extension does not need additional configuration, and the number of supported machines meets most applications;

(8) the identification generation algorithm is an improvement of the snowflake algorithm, and the two improvement schemes can be used as configuration items for system calling to meet different service requirements;

(9) under the condition of database division and table division, the position of the database table of the data to be inquired can be directly positioned according to the global unique identifier.

Fig. 8 shows an exemplary system architecture 800 to which the unique identifier generation method or the unique identifier generation apparatus of the embodiments of the present invention can be applied.

As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.

A user may use the terminal devices 801, 802, 803 to interact with a server 805 over a network 804 to receive or send messages or the like. The terminal devices 801, 802, 803 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).

The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.

The server 805 may be a server that provides various services, such as a back-office management server (for example only) that supports shopping-like websites browsed by users using the terminal devices 801, 802, 803. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.

It should be noted that the method for generating the unique identifier provided by the embodiment of the present invention is generally executed by the server 805, and accordingly, the generating device of the unique identifier is generally disposed in the server 805.

It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.

Referring now to FIG. 9, a block diagram of a computer system 900 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.

As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.

The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.

In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.

It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.

The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The described units or modules may also be provided in a processor, and may be described as: a processor includes a machine code registration module, an algorithm execution module, and an identity stitching module. Where the names of such units or modules do not in some cases constitute a limitation on the units or modules themselves, for example, a machine code registration module may also be described as a "module for acquiring native machine code and registering the machine code with a registry".

As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring a machine code of a local machine, and registering the machine code to a registration center; inputting the successfully registered machine code into an identification generation algorithm, so that the identification generation algorithm generates a first identification according to the machine code; and acquiring a database identifier and a data table identifier, and splicing the database identifier, the data table identifier and the first identifier to obtain a unique identifier.

According to the technical scheme of the embodiment of the invention, the machine code of the local machine is obtained, and the machine code is registered in the registration center; inputting the successfully registered machine code into an identification generation algorithm so that the identification generation algorithm generates a first identification according to the machine code; the method comprises the steps of obtaining a database identifier and a data table identifier, splicing the database identifier and the data table identifier with a first identifier to obtain a unique identifier, ensuring global uniqueness of the unique identifier generated under the distributed cluster system environment, avoiding independent configuration of a machine, facilitating horizontal extension of a cluster, and meanwhile, rapidly and accurately obtaining data under the condition of sub-database sub-table storage. Application requirements of different service scenes can be met by improving the snowflake algorithm, and the method is flexible and convenient; the unique identifier generation method and device are packaged into a software development kit to be introduced into engineering, so that the method and device are non-invasive to service, can generate the unique identifier locally, and are high in generation efficiency and free of network time consumption.

The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:标点符号标注方法、装置、计算机设备和存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!