CN113342819A - Card number generation method, device, equipment and storage medium - Google Patents

Card number generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN113342819A
CN113342819A CN202110718474.XA CN202110718474A CN113342819A CN 113342819 A CN113342819 A CN 113342819A CN 202110718474 A CN202110718474 A CN 202110718474A CN 113342819 A CN113342819 A CN 113342819A
Authority
CN
China
Prior art keywords
card
segment
bitmap
numbers
available
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110718474.XA
Other languages
Chinese (zh)
Inventor
王威
姜黎明
王大飞
江旻
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202110718474.XA priority Critical patent/CN113342819A/en
Publication of CN113342819A publication Critical patent/CN113342819A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2237Vectors, bitmaps or matrices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The application provides a card number generation method, a card number generation device and a computer readable storage medium, wherein the method comprises the following steps: acquiring a card selection request; wherein the card selection request carries a card product number; acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with a card product number; the in-segment compression bitmap comprises character marks and an ordered character string constructed by numbers, wherein the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state; acquiring a serial number of an available card number in an available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark; the card number is generated based on the card product number, the available card segment, and the serial number.

Description

Card number generation method, device, equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of data processing of financial technology (Fintech), and relates to but is not limited to a card number generation method, a card number generation device, card number generation equipment and a computer-readable storage medium.
Background
With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), however, the financial technology also puts higher demands on the technology due to the requirements of security and real-time performance of the financial industry.
In the field of financial science and technology, card numbers are generated in full quantity and stored in a local database in the related technology, and automatic allocation is carried out on the basis of the card numbers stored in the local database when a user opens a card. It is obvious that the card number in the related art must be generated in advance, and it is highly desirable to provide a method for generating the card number in real time.
Disclosure of Invention
Embodiments of the present application provide a card number generation method, a card number generation apparatus, a card number generation device, and a computer-readable storage medium, so as to solve the problem that card numbers must be generated in advance in the related art, and provide a method for generating card numbers in real time, thereby avoiding excessive occupation of storage space by generating all card numbers in advance, and improving the usability of a database.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides a card number generation method, which comprises the following steps:
acquiring a card selection request; wherein the card selection request carries a card product number;
acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with the card product number; the in-segment compressed bitmap comprises an ordered character string constructed by character identifications and numbers, wherein the character identifications are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character identifications are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state;
acquiring a serial number of an available card number in the available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark;
generating a card number based on the card product number, the available card segment, and the serial number.
A card number generation apparatus comprising:
the acquisition module is used for acquiring a card selection request; wherein the card selection request carries a card product number;
the acquisition module is used for acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with the card product number; the in-segment compressed bitmap comprises an ordered character string constructed by character identifications and numbers, wherein the character identifications are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character identifications are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state;
the acquisition module is used for acquiring the serial number of the available card number in the available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark;
and the processing module is used for generating a card number based on the card product number, the available card segment and the serial number.
An embodiment of the present application provides an apparatus, including:
a memory for storing executable instructions; a processor, when executing executable instructions stored in the memory, implements the method described above.
Embodiments of the present application provide a computer-readable storage medium storing executable instructions for causing a processor to implement the above-mentioned method when executed.
The embodiment of the application has the following beneficial effects:
obtaining a card selection request; wherein the card selection request carries a card product number; acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with a card product number; aiming at a high-performance processing scene of card selection, the total number of card numbers is expanded by using an in-segment compressed bitmap, the in-segment compressed bitmap comprises character marks and ordered character strings constructed by numbers, the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in an allocated state, and the numbers are used for indicating the number of the card numbers in a continuous state; then, based on the first identifier in the segment compressed bitmap and the first number associated with the first identifier, the serial number of the available card number in the available card segment is quickly acquired; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark; generating a card number in real time based on the card product number, the available card segment and the serial number; therefore, the problem that the card number must be generated in advance in the related technology is solved, the method for generating the card number in real time is provided, excessive occupation of the storage space caused by generation of all the card numbers in advance is avoided, and the service performance of the database is improved.
Drawings
Fig. 1 is an alternative architecture diagram of a server provided in the embodiment of the present application;
fig. 2 is a schematic flow chart of an alternative card number generation method provided by the embodiment of the application;
FIG. 3 is a schematic diagram of an implementation of a bitmap compression algorithm provided by an embodiment of the present application;
fig. 4 is a schematic flow chart of an alternative card number generation method provided by the embodiment of the application;
fig. 5 is a schematic flow chart of an alternative card number generation method provided by the embodiment of the application;
fig. 6 is a schematic flow chart of an alternative card number generation method provided by the embodiment of the application;
fig. 7 is an alternative flow chart of the card number generation method provided by the embodiment of the application;
fig. 8 is a schematic view of a scene flow for updating a compressed bitmap in a later stage according to an embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the embodiments of the present application belong. The terminology used in the embodiments of the present application is for the purpose of describing the embodiments of the present application only and is not intended to be limiting of the present application.
An exemplary application of the card number generation device provided in the embodiment of the present application is described below, and the card number generation device provided in the embodiment of the present application may be implemented as any terminal having an on-screen display function, such as a notebook computer, a tablet computer, a desktop computer, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, and a portable game device), an intelligent robot, and may also be implemented as a server. Next, an exemplary application when the card number generation device is implemented as a server will be explained.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a server 100 provided in an embodiment of the present application, where the server 100 shown in fig. 1 includes: at least one processor 110, at least one network interface 120, a user interface 130, and memory 150. The various components in server 100 are coupled together by a bus system 140. It is understood that the bus system 140 is used to enable connected communication between these components. The bus system 140 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 140 in fig. 1.
The Processor 110 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The user interface 130 includes one or more output devices 131, including one or more speakers and/or one or more visual display screens, that enable the presentation of media content. The user interface 130 also includes one or more input devices 132 including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
The memory 150 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 150 optionally includes one or more storage devices physically located remotely from processor 110. The memory 150 includes volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 150 described in embodiments herein is intended to comprise any suitable type of memory. In some embodiments, memory 150 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplified below.
An operating system 151 including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
a network communication module 152 for communicating to other computing devices via one or more (wired or wireless) network interfaces 120, exemplary network interfaces 120 including: bluetooth, wireless-compatibility authentication (Wi-Fi), and Universal Serial Bus (USB), etc.;
an input processing module 153 for detecting one or more user inputs or interactions from one of the one or more input devices 132 and translating the detected inputs or interactions.
In some embodiments, the apparatus provided by the embodiments of the present application may be implemented in software, and fig. 1 shows a card number generating apparatus 154 stored in the memory 150, where the card number generating apparatus 154 may be a card number generating apparatus in the server 100, and may be software in the form of programs and plug-ins, and the like, and includes the following software modules: an acquiring module 1541, a processing module 1542, these modules being logical and thus arbitrarily combined or further split according to the implemented functions. The functions of the respective modules will be explained below.
In other embodiments, the apparatus provided in this embodiment may be implemented in hardware, and for example, the apparatus provided in this embodiment may be a processor in the form of a hardware decoding processor, which is programmed to execute the card number generation method provided in this embodiment, for example, the processor in the form of the hardware decoding processor may be one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field-Programmable Gate arrays (FPGAs), or other electronic components.
The card number generation method provided by the embodiment of the present application will be described below with reference to an exemplary application and implementation of the server 100 provided by the embodiment of the present application. Referring to fig. 2, fig. 2 is a schematic flow chart of an alternative card number generation method provided in the embodiment of the present application, which will be described in conjunction with the steps shown in fig. 2,
step S201, a card selection request is obtained.
Wherein the card selection request carries a card product number.
In the embodiment of the application, when the user inputs the card selection request, the server acquires the card selection request, and the card selection request carries the card product number. The card product number is used to indicate the type of card product that is requested to open the card.
In an implementation scenario, after receiving an external card selection request, i.e., a card opening request, the server finds all card segments allocated to the product according to the card product number carried by the card selection request. In the embodiment of the application, 1 ten thousand is used as one segment for splitting the card segment, one segment is a record, the number of the distributed card numbers of one product is not less than 1 ten thousand by analyzing the business layer, meanwhile, for a large product (in the tens of millions/hundred million level), the card segment can be split to a great extent according to the split card number of 1 ten thousand, concurrency is increased, the problem of hot spots recorded by the card segment is avoided, so that a large amount of preemption failures are caused, the pressure measurement performance of updating a single record hot spot can be embodied as the number of Transactions processed Per Second (TPS) is 200, and the TPS requirements of Transactions of different products are met.
Step S202, an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with the card product number is obtained.
The in-segment compression bitmap comprises character marks and an ordered character string constructed by numbers, wherein the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state. The character mark comprises a first mark and a second mark, the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is not distributed, and the second mark is used for indicating that the card number of the serial number corresponding to the position of the second mark is distributed.
Here, the first identifier, such as character identifier N, is used to represent that the card number is not allocated and is available, and the second identifier, such as character identifier Y, is used to represent that the card number is allocated and is occupied; the value of the continuous state is represented by a number, and the continuous state comprises a continuously allocated state or a continuously unallocated state, for example, the number of the card from 0 to 9 is not occupied, and is represented by N10.
In the embodiment of the application, when the card product number is obtained, a card segment allocation table associated with the card product number may be further obtained, where at least an available card segment and an intra-segment compression bitmap corresponding to the available card segment are recorded in the card segment allocation table. The compressed bitmap in the segment corresponding to the available card segment is used for inquiring the serial number of the unused card number.
The card number includes the following parts: the card issuing Bank Identification Number (BIN) + card segment + serial Number +1 digit check bit. If the mode of card number production in advance is adopted, a large number of card numbers can be generated, storage resources are wasted, and in order to improve the requirement of the total number of the card numbers and simultaneously realize the rapid positioning of the state of a certain bit in the bitmap, a bitmap compression algorithm is adopted.
When a new segment is recorded and initialized, the number of available cards is a preset number, for example 10000, which can be represented as N10000, when a card-opening transaction is acquired, a query is carried out from a certain position, such as the left-most side, of a compressed bitmap to find a first N value, then a next N/Y value is found from the position of the N value, if the tail part of the compressed bitmap is queried, the total length of the bitmap is used as an end position, and the value from the N value to the next N/Y value represents a continuous unused card number segment.
Step S203, based on the first identifier in the segment compressed bitmap and the first number associated with the first identifier, the serial number of the available card number in the available card segment is obtained.
In the embodiment of the application, the serial number part in the card number has a sequence, and the serial number of the sequence is obtained because of the sequence, so that the corresponding card number can be constructed according to the serial number. In this embodiment, in step S203, when the serial number of the available card number in the available card segment is obtained based on the intra-segment compressed bitmap, the serial number of the available card number in the available card segment may be obtained based on the intra-segment compressed bitmap and a random number corresponding to the available card segment.
For example, referring to fig. 3, assuming that 3862 is the random number between 1 and 10000, and the card number with 3862 is occupied, the intra-segment compression bitmap corresponding to the available card segment may be updated to N3861Y1N6238, that is, the card numbers of the previous consecutive card segments 1 to 3861 are all unoccupied, the card number with 3862 is occupied, the card number with 3862 and 10000 is unoccupied, when a next request comes, the search is started from the leftmost side, the value after the first N is 3861, the number between 1 and 3861 is randomly selected, such as 732, and the intra-segment compression bitmap is split, and the updated intra-segment compression bitmap is as follows: N731Y1N3129Y1N6138, and so on, when a new card number is occupied, the strategy can be used to update the in-segment compression bitmap, and update the available card number and the used card number, when all the card numbers are used up, the update is in an exhausted state, so that the card selection operation is not performed on the segment any more.
The card number generation method provided by the application adopts a compressed bitmap, because the compressed bitmap uses characters to identify the state of N/Y memory card numbers and uses numbers to store corresponding numbers, when in query, the unused card number can be found by searching the first N character from front to back by using a specific query index, on the time complexity, one unused card number in a card segment is Y9999N1, the performance is O (1), on the storage, the worst compression can generate the following data form N1Y1 … … N1Y1, the data form of the card number available at intervals has the card storage byte number of 20000 for ten thousand continuous card segments, aiming at the scene, the first continuous unused card segment is selected from front to back in each query in the application and a random value is made, thus the compression performance can be better ensured, and after a plurality of tests, the byte number of the card storage byte number of one ten thousand continuous card segments is about 1000, no matter 20000 bytes or 1000 bytes are in the TEXT type storage space range of the distributed database, and as can be seen, the card number generation and card selection scheme is optimized.
In step S204, a card number is generated based on the card product number, the available card segment and the serial number.
In the embodiment of the application, under the condition that the card product number, the available card segment and the serial number are obtained, the card product number, the available card segment and the serial number can be spliced according to a card splicing mode to generate the card number.
The card number generation method provided by the application acquires a card selection request; wherein the card selection request carries a card product number; acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with a card product number; aiming at a high-performance processing scene of card selection, the total number of card numbers is expanded by using an in-segment compressed bitmap, the in-segment compressed bitmap comprises character marks and ordered character strings constructed by numbers, the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in an allocated state, and the numbers are used for indicating the number of the card numbers in a continuous state; then, based on the first identifier in the segment compressed bitmap and the first number associated with the first identifier, the serial number of the available card number in the available card segment is quickly acquired; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark; generating a card number in real time based on the card product number, the available card segment and the serial number; therefore, the problem that the card number must be generated in advance in the related technology is solved, the method for generating the card number in real time is provided, excessive occupation of the storage space caused by generation of all the card numbers in advance is avoided, and the service performance of the database is improved.
Referring to fig. 4, fig. 4 is a schematic flow chart of an alternative card number generation method provided in the embodiment of the present application, which will be described in conjunction with the steps shown in fig. 4,
step S301, a card selection request is obtained.
Wherein the card selection request carries a card product number.
Step S302, based on the card product number and the card segment identification information, a query index is created.
The card segment identification information is used for indicating whether the card number in the segment is distributed completely.
In this embodiment, the card segment allocation table further includes card segment identification information for indicating whether the card number in the segment is already allocated.
After receiving an external card selection request, according to the card product number carried by the card selection request, inquiring the card number section which is distributed to the card product and is not used up, and in order to increase the randomness, inquiring by using random of a database, wherein the inquiring Structured Query Language (SQL) is as follows:
SELECT*FROM TM_CARD_SEG WHERE RUN_OUT=’N’AND PRODUCT_CD=’100070’ORDER BY RAND()LIMIT 1;
step S303, inquiring in the distributed database by the inquiry index to obtain the available card segment.
In the embodiment of the present application, the SQL language is used for querying, a CARD segment record can be randomly obtained, a joint index of the CARD segment identification information (RUN _ OUT) and the CARD PRODUCT number (PRODUCT _ CD) is created in the TM _ CARD _ SEG table, and the database index can be used to quickly locate the available CARD segment under the CARD PRODUCT.
In other embodiments of the present application, when the step S303 queries the distributed database with the query index to obtain the available card segment, the following steps may be further performed: locking the available card sections; wherein the locked available card section is in a locked state. Here, the available card segment records can be locked by a pessimistic lock using a distributed database, and the data inconsistency generated by concurrency is prevented, so that the correctness of the update time sequence of the compressed bitmap in the available card segment is ensured in a high-concurrency scene.
Step S304, an intra-segment compression bitmap corresponding to the available card segment in the card segment distribution table associated with the card product number is obtained.
In the embodiment of the application, the intra-segment compressed bitmap comprises an ordered character string constructed by character identifications and numbers, wherein the character identifications are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character identifications are in the allocated state or not, the numbers are used for indicating the number of the card numbers in the continuous state, and the continuous state comprises the continuous allocated state or the continuous unallocated state.
In step S305, a serial number of the available card number in the available card segment is obtained based on the first identifier in the intra-segment compressed bitmap and the first number associated with the first identifier.
In the embodiment of the application, the intra-segment compressed bitmap comprises ordered character strings, and in the process of acquiring the serial numbers of the available card numbers in the available card segments based on the intra-segment compressed bitmap, the serial numbers of the available card numbers in any available card segment can be acquired by using the first numbers related to N and N in the intra-segment compressed bitmap; or according to the ordered traversal mode and the traversal sequence, the serial numbers of the available card numbers in the available card segments can be obtained. It should be noted that, compared to the mode of acquiring the serial numbers of the available card numbers in the available card segments out of order, the mode of acquiring the serial numbers of the available card numbers in the available card segments in the ordered traversal mode can avoid generating the following card number data form N1Y1 … … N1Y1 available at intervals as much as possible.
In other embodiments of the present application, in step S305, based on the first identifier in the intra-segment compressed bitmap and the first number associated with the first identifier, the serial number of the available card number in the available card segment is obtained, which may be implemented by the steps shown in fig. 5:
and S3051, determining a first identifier according to a front-to-back traversal sequence corresponding to the ordered character strings.
The first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark.
Step S3052, determining a first random number based on the first number associated with the first identifier.
Wherein the first random number is greater than or equal to 1 and less than or equal to the first number;
here, random selection is made from 1 to the first number, and the first random number is used to improve the randomness of the card number selection.
And S3053, determining the number of sequence numbers before the bitmap corresponding to the first random number in the compressed bitmap in the segment, and calculating the sum of the number of the sequence numbers plus 1 to obtain the sequence number.
For example, referring to fig. 8, taking the intra-segment compression bitmap Y3 … N60 … Y1 … N1 as an example, for limiting the description to follow, the front and rear portions of the intra-segment compression bitmap Y3 … N60 … Y1 … N1 are shown in more detail in fig. 8, that is, the intra-segment compression bitmap Y3N3Y5N2 … … N5N 1. Here, according to the traversal sequence from front to back corresponding to the ordered character strings, the first N in the intra-segment compression bitmap Y3N3Y5N2 … … N5N1 is determined, so that an unused card number can be found, meanwhile, the value after N is judged, then, Random is performed by taking the value after N as the maximum value, and a Random number between 1 and 3 is found, as shown in fig. 8, Random has a Random number between 1 and 3, and the Random number in fig. 8 is 1. Further, the number of sequence numbers before the bitmap corresponding to 1 in the compressed bitmap in the segment is determined to be 3, and the sum of 3 plus 1 is calculated to obtain a sequence number of 4.
In other embodiments of the present application, after determining the first random number based on the first number associated with the first identifier in step S3052, the compressed bitmap in the segment may also be updated, and the steps shown in fig. 6 may be implemented:
and Step1, performing fission processing on a part of bitmaps in the compressed bitmaps in the segments based on the first random number to obtain the bitmaps after fission.
In the embodiment of the application, the selected first random numbers are different, and the updated compressed bitmaps in the segments are different.
Here, the intra-segment compressed bitmap includes an ordered string corresponding to a partial bitmap and an ordered string corresponding to the remaining bitmap.
The partial bitmap comprises a bitmap corresponding to a first identifier and a first number; the fission bitmap at least comprises a bitmap corresponding to the first identifier and the second number, and a bitmap corresponding to the second identifier and the third number; the second mark is used for indicating that the card number of the serial number corresponding to the position of the second mark is in the allocated state, and the character mark comprises the second mark; the second number is smaller than the first number.
In the embodiment of the application, Step1 performs fission processing on a part of bitmaps in the compressed bitmaps in the segment based on the first random number to obtain a fission bitmap, and may be implemented by the following steps:
first, a first position occupied by a first random number in the partial bitmap NX1 is determined.
Wherein N is the first identifier, and X1 is the first number associated with the first identifier.
And secondly, splitting a first position in the partial bitmap NX1 into a newly added second identifier Y to obtain a split bitmap which is Y1NX1-1, NX1-1Y1 or NX2Y1NX 3.
Wherein, X2 and X3 are natural numbers, and the sum of X2, X3 and X1 is X1.
Here, still taking the intra-segment compression bitmap Y3N3Y5N2 … … N5N1 in fig. 8 as an example, the partial bitmap NX1 is determined to be N3, and the fission at this time exists in the following three cases:
first, if the random number is 1 in fig. 8, it indicates that the first bit needs to be occupied and changed to Y, then N3 is changed to Y1N2, and then the nearest N/Y value is found forward and backward, respectively, as shown in fig. 8, the next N/Y is Y5, the bitmap after fission is Y1N2, the last N/Y value in Y1N2 is N, unlike Y, and cannot be merged, and the previous N/Y value is Y3, which is consistent with the previous map of the bitmap after fission Y1N2, and can be merged, and Y3 and Y1 are merged to become Y4, thus generating a new bitmap Y4N2Y5N2 … … N5N 1.
Secondly, if the random number is 2, it means that the second bit needs to be occupied, and it is changed to Y, then N3 is changed to N1Y1N1, and then the nearest N/Y value is found forward and backward respectively, the next N/Y is Y5, and the bitmap after fission generation is N1Y1N1, where the last N/Y value is N, unlike Y, and cannot be merged, and the previous N/Y value is N1, unlike the previous bitmap of the bitmap N1Y1N1 after fission generation, cannot be merged, and thus a new bitmap Y3N1Y1N1Y5N2 … … N5N1 is generated.
Thirdly, if the random number is 3, it means that the last bit needs to be occupied and changed into Y, then N3 is changed into N2Y1, and then the nearest value of N/Y is found forward and backward respectively, the next N/Y is Y5, the bitmap after fission is N2Y1, the last N/Y value in N2Y1 is Y, merging can be performed, the previous N/Y value is Y3, unlike the first map of the bitmap after fission N2Y1, merging cannot be performed, and thus a new bitmap Y3N2Y6N2 … … N5N1 is generated.
And Step2, merging the rest bitmaps in the compressed bitmaps in the segments and adjacent bitmaps with second identifications in the fission bitmaps to obtain updated compressed bitmaps in the segments.
Wherein the remaining bitmap and the partial bitmap constitute an in-segment compressed bitmap.
In step S306, a card number is generated based on the card product number, the available card segment and the serial number.
In other embodiments of the present application, the step S306 generates the card number based on the card product number, the available card segment, and the serial number, and may be implemented by the following steps: splicing the card product number, the available card segment and the serial number according to the card number splicing mode to generate a card number and a check digit of the card number; the check digit is used for indicating whether the card number meets the card number generating condition. Illustratively, the check digit is used to indicate whether the card number meets the correct card number generation criteria.
In the embodiment of the application, after a server acquires a random card selection request, according to the card product number carried by the card selection request, a corresponding card segment which is not used up is found, an available segment is selected from the card segment, a bitmap is compressed in the segment, the number of a card number in an N state is found, a sequence diagram is updated to be occupied, the number of the available card and the number of the used card are updated, the total number of the former N and Y states is summarized, so that the number where the card number is located is judged, a check digit is generated after splicing according to the number and the known information of the BIN and the card segment of the card, the card number is truly generated into a card number table, and the card number is returned to a calling party, so that the card number is generated efficiently in real time.
It should be noted that, for the descriptions of the same steps and the same contents in this embodiment as those in other embodiments, reference may be made to the descriptions in other embodiments, which are not described herein again.
In an implementation scenario, referring to fig. 7, fig. 7 is an alternative flow chart of the card number generation method provided in the embodiment of the present application, the process of generating the card number will be described in detail with reference to the steps shown in fig. 7,
step S401, a card selection request is obtained.
Wherein the card selection request carries a card product number.
Step S402, inquiring the available card segment in the card segment distribution table according to the card product number.
Illustratively, referring to fig. 8, the card BIN corresponding to the card product number is 623633, and the card segment corresponding to the card product number includes 90000000, 90000001 and 90000002, and at this time, the available card segment in the card segment allocation table is queried according to the card product number to be two available card segments 90000000 and 90000002, assuming that the finally selected available card segment is 90000002.
In step S403, the selected available card segment is locked using a pessimistic lock.
Here, the pessimistic lock of the database is used to lock the card segment 90000002 record, so as to prevent the data inconsistency generated concurrently and ensure the correctness of the update timing sequence of the compressed bitmap in the segment in a high-concurrency scene.
Step S404, obtaining the card segment compression bitmap of the available card segment.
Here, the card segment compression bitmap of the get card segment 90000002 is Y3 … N60 … Y1 … N1.
Step S405, processing the card segment compressed bitmap according to a bitmap random acquisition algorithm, and finding out the serial number of the available card number in the available card segment.
Further, an intra-segment compressed bitmap Y3 … N60 … Y1 … N1 of the card segment 90000002 is analyzed, a serial number corresponding to an unused card number is obtained and updated to be used, and a search and update algorithm of the intra-segment compressed bitmap is as follows:
wherein N indicates unused, Y indicates used, because the intra-segment compressed bitmap is an ordered string, the first N is found by traversing the characters in the ordered string, searching from front to back, finding the unused card number, meanwhile, judging the value after N, then performing Random with the value after N as the maximum value, finding a Random number between values after 1-N (the value is equal to 3 in FIG. 8), splitting according to the value, as shown in FIG. 8, Random is a Random number between 1-3, as shown in FIG. 8, the Random number is 1, it indicates that the first bit needs to be occupied, changing it into Y, then N3 becomes Y1N2, then finding the nearest value of N/Y forward and backward respectively, as shown in FIG. 8, the next N/Y is Y5, and the bitmap after fission is Y1N2, wherein the last N/Y value is N, unlike Y, merging cannot be performed, the previous N/Y has a value of Y3, which is consistent with the previous map of the bitmap Y1N2 after fission, merging can be performed, Y3 is merged with Y1, which becomes Y4, so that a new bitmap is generated, and the position of the sequence number in the whole bitmap is calculated, and it can be deduced from the original sequence number merging before N3 that there are 3 sequence numbers before N3 and the random value is 1, so that it can be obtained that the sequence number is 4 in the bitmap of the card segment.
In step S406, a card number is generated based on the card product number, the available card segment and the serial number.
Here, the last parity digit, e.g. 3, is generated according to the card BIN and the card segment in the card segment table, which represents the card number generated under the correct card number generation condition, and the card number at this position is obtained as 6236339000000200043, as shown in fig. 8.
In step S407, the generated card number is inserted into the card number table.
Furthermore, after the CARD number is produced, the CARD number is newly added into a CARD number table, the CARD number table is named according to the BIN and the CARD segment of the CARD, the number of the memory CARD of each CARD table is not more than 1000 ten thousand according to the storage requirement of a distributed database (Data Base, DB), so that each CARD table stores ten million CARD numbers, the affiliated CARD number table can be obtained as TM _ CARD _ B623633_ P90000 according to the CARD numbers, the CARD numbers are stored into the CARD number table, and the unique constraint of the database can be used for ensuring that the CARD numbers cannot be regenerated due to the fact that the CARD numbers are used as main keys in each CARD number table, so that the CARD numbers can be found to be used when the CARD insertion fails and the CARD selection needs to be carried out again.
Step S408, the updated intra-segment compressed bitmap is filled into the distribution table, and the number of the used card numbers is increased.
Here, the updated in-segment compressed bitmap is filled into the allocation table, and the number of used cards of the card segment is increased by 1.
According to the content, the card number generation method provided by the application removes the problem that the card segment is actually unavailable due to the inconsistency of the cache database caused by the use of the cache structure, but the cache is available, and meanwhile, for the whole storage, the card segment and the card segment compression bitmap are used for card selection, the newly added card segment does not need to be initialized first, the storage capacity overhead is greatly reduced, the card number is stored only after the card is actually opened, and the storage is ensured to grow along with the increase of the service.
Continuing with the exemplary structure in which the card number generating device 154 provided by the embodiments of the present application is implemented as a software module, in some embodiments, as shown in fig. 1, the software module stored in the card number generating device 154 of the memory 150 may be a card number generating device in the server 100, including:
an obtaining module 1541, configured to obtain a card selection request; wherein the card selection request carries a card product number;
an obtaining module 1541, configured to obtain an intra-segment compression bitmap corresponding to an available card segment in a card segment allocation table associated with a card product number; the in-segment compression bitmap comprises character marks and an ordered character string constructed by numbers, wherein the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state;
an obtaining module 1541, configured to obtain a serial number of an available card number in an available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark;
the processing module 1542 is configured to generate a card number based on the card product number, the available card segment, and the serial number.
In some embodiments of the present application, the processing module 1542 is configured to create a query index based on the card product number and the card segment identification information; the card segment identification information is used for indicating whether the card number in the segment is distributed completely;
the obtaining module 1541 is configured to query the distributed database with the query index to obtain an available card segment.
In some embodiments of the present application, the processing module 1542 is configured to perform a locking operation on an available card segment; wherein the locked available card section is in a locked state.
In some embodiments of the present application, the intra-segment compressed bitmap includes an ordered character string constructed by a character identifier and a number, the character identifier is used to indicate whether the card number corresponding to the serial number at the position of the character identifier is in an allocated state, the number is used to indicate the number of the card numbers in a continuous state, and the continuous state includes a continuous allocated state or a continuous unallocated state.
In some embodiments of the present application, the processing module 1542 is configured to determine a first identifier according to a traversal order from front to back corresponding to the ordered character string; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark; determining a first random number based on a first number associated with the first identifier; and determining the number of sequence numbers before the bitmap corresponding to the first random number in the compressed bitmap in the segment, and calculating the sum of the number of the sequence numbers plus 1 to obtain the sequence numbers.
In some embodiments of the present application, the processing module 1542 is configured to perform fission processing on a part of bitmaps in the intra-segment compressed bitmap based on the first random number, to obtain a fission bitmap; the partial bitmap comprises a bitmap corresponding to a first identifier and a first number; the fission bitmap at least comprises a bitmap corresponding to the first identifier and the second number, and a bitmap corresponding to the second identifier and the third number; the second mark is used for indicating that the card number of the serial number corresponding to the position of the second mark is in the allocated state, and the character mark comprises the second mark; merging the rest bitmaps in the compressed bitmaps in the segments and adjacent bitmaps with second identifications in the split bitmaps to obtain updated compressed bitmaps in the segments; wherein the remaining bitmap and the partial bitmap constitute an in-segment compressed bitmap.
In some embodiments of the present application, the processing module 1542 is configured to determine a first position occupied by a first random number in the partial bitmap NX 1; wherein, N is a first identifier, and X1 is a first number associated with the first identifier; splitting a first position in the partial bitmap NX1 into a newly added second identifier Y to obtain a split bitmap Y1NX1-1, NX1-1Y1 or NX2Y1NX 3; wherein, X2 and X3 are natural numbers, and the sum of X2, X3 and X1 is X1.
In some embodiments of the present application, the processing module 1542 is configured to splice the card product number, the available card segment, and the serial number according to a card number splicing manner, so as to generate a card number and a check digit of the card number; the check digit is used for indicating whether the card number meets the card number generating condition.
The card number generation device provided by the application acquires a card selection request; wherein the card selection request carries a card product number; acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with a card product number; aiming at a high-performance processing scene of card selection, the total number of card numbers is expanded by using an in-segment compressed bitmap, the in-segment compressed bitmap comprises character marks and ordered character strings constructed by numbers, the character marks are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character marks are in an allocated state, and the numbers are used for indicating the number of the card numbers in a continuous state; then, based on the first identifier in the segment compressed bitmap and the first number associated with the first identifier, the serial number of the available card number in the available card segment is quickly acquired; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark; generating a card number in real time based on the card product number, the available card segment and the serial number; therefore, the problem that the card number must be generated in advance in the related technology is solved, the method for generating the card number in real time is provided, excessive occupation of the storage space caused by generation of all the card numbers in advance is avoided, and the service performance of the database is improved.
It should be noted that the description of the apparatus in the embodiment of the present application is similar to the description of the method embodiment, and has similar beneficial effects to the method embodiment, and therefore, the description is not repeated. For technical details not disclosed in the embodiments of the apparatus, reference is made to the description of the embodiments of the method of the present application for understanding.
Embodiments of the present application provide a storage medium having stored therein executable instructions, which when executed by a processor, will cause the processor to perform the methods provided by embodiments of the present application, for example, the methods as illustrated in fig. 2 and 4.
In some embodiments, the storage medium may be a computer-readable storage medium, such as a Ferroelectric Random Access Memory (FRAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), a charged Erasable Programmable Read Only Memory (EEPROM), a flash Memory, a magnetic surface Memory, an optical disc, or a Compact disc Read Only Memory (CD-ROM), among other memories; or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (hypertext Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code). By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (10)

1. A card number generation method, comprising:
acquiring a card selection request; wherein the card selection request carries a card product number;
acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with the card product number; the in-segment compressed bitmap comprises an ordered character string constructed by character identifications and numbers, wherein the character identifications are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character identifications are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state;
acquiring a serial number of an available card number in the available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark;
generating a card number based on the card product number, the available card segment, and the serial number.
2. The method of claim 1, wherein after obtaining the card selection request, the method further comprises:
creating a query index based on the card product number and the card segment identification information; the card segment identification information is used for indicating whether the card number in the segment is distributed completely;
and querying the distributed database by using the query index to obtain the available card segment.
3. The method of claim 2, wherein when the query is performed in the distributed database with the query index to obtain the available card segment, the method further comprises:
locking the available card segment; wherein the available card section after locking is in a locked state.
4. The method of claim 1, wherein obtaining the serial number of the available card number in the available card segment based on the first identifier in the intra-segment compressed bitmap and the first number associated with the first identifier comprises:
determining a first identifier according to a traversal sequence from front to back corresponding to the ordered character string;
determining a first random number based on a first number associated with a first one of the first identifiers; wherein the first random number is greater than or equal to 1 and less than or equal to the first number;
and determining the number of sequence numbers before the bitmap corresponding to the first random number in the intra-segment compressed bitmap, and calculating the sum of the number of the sequence numbers plus 1 to obtain the sequence numbers.
5. The method of claim 4, wherein after determining the first random number based on the first number associated with the first identifier, the method further comprises:
performing fission treatment on a part of bitmaps in the compressed bitmaps in the segments based on the first random number to obtain fissured bitmaps; wherein the partial bitmap comprises a bitmap corresponding to the first identifier and the first number; the fission bitmap at least comprises a bitmap corresponding to the first identifier and the second number, and a bitmap corresponding to the second identifier and the third number; the second mark is used for indicating that the card number of the serial number corresponding to the position of the second mark is in the allocated state, and the character mark comprises the second mark;
merging the rest bitmaps in the compressed bitmaps in the segments and the adjacent bitmaps with the second identifications in the fissile bitmaps to obtain updated compressed bitmaps in the segments; wherein the remaining bitmap and the partial bitmap constitute the intra-segment compressed bitmap.
6. The method of claim 5, wherein the fissioning of the partial bitmaps in the intra-segment compressed bitmap based on the first random number to obtain a fissioning bitmap, comprises:
determining a first position occupied by the first random number in the partial bitmap NX 1; wherein N is the first identifier, and X1 is a first number associated with the first identifier;
splitting the first location in the partial bitmap NX1 into the newly added second identity Y, resulting in a split bitmap Y1NX1-1, NX1-1Y1, or NX2Y1NX 3; wherein, the X2 and the X3 are natural numbers, and the sum of the X2, the X3 and the X351 is the X1.
7. The method of any one of claims 1 to 6, wherein generating a card number based on the card product number, the available card segment, and the serial number comprises:
splicing the card product number, the available card segment and the serial number according to a card number splicing mode to generate the card number and a check digit of the card number; the check digit is used for indicating whether the card number meets the card number generation condition.
8. A card number generation apparatus, comprising:
the acquisition module is used for acquiring a card selection request; wherein the card selection request carries a card product number;
the acquisition module is used for acquiring an intra-segment compression bitmap corresponding to an available card segment in a card segment distribution table associated with the card product number; the in-segment compressed bitmap comprises an ordered character string constructed by character identifications and numbers, wherein the character identifications are used for indicating whether the card numbers of the serial numbers corresponding to the positions of the character identifications are in the allocated state, and the numbers are used for indicating the number of the card numbers in the continuous state;
the acquisition module is used for acquiring the serial number of the available card number in the available card segment based on a first identifier in the intra-segment compressed bitmap and a first number associated with the first identifier; the first mark is used for indicating that the card number of the serial number corresponding to the position of the first mark is in an unallocated state, and the character mark comprises the first mark;
and the processing module is used for generating a card number based on the card product number, the available card segment and the serial number.
9. A card number generation apparatus, comprising:
a memory for storing executable instructions; a processor for implementing the method of any one of claims 1 to 7 when executing executable instructions stored in the memory.
10. A computer-readable storage medium having stored thereon executable instructions for causing a processor, when executed, to implement the method of any one of claims 1 to 7.
CN202110718474.XA 2021-06-28 2021-06-28 Card number generation method, device, equipment and storage medium Pending CN113342819A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110718474.XA CN113342819A (en) 2021-06-28 2021-06-28 Card number generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110718474.XA CN113342819A (en) 2021-06-28 2021-06-28 Card number generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113342819A true CN113342819A (en) 2021-09-03

Family

ID=77479073

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110718474.XA Pending CN113342819A (en) 2021-06-28 2021-06-28 Card number generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113342819A (en)

Similar Documents

Publication Publication Date Title
CN108287669B (en) Date storage method, device and storage medium
US6675180B2 (en) Data updating apparatus that performs quick restoration processing
US20180307428A1 (en) Data storage method, electronic device, and computer non-volatile storage medium
CN109086388B (en) Block chain data storage method, device, equipment and medium
CN111506269B (en) Disk storage space allocation method, device, equipment and storage medium
CN112765271A (en) Block chain transaction index storage method and device, computer equipment and medium
CN104731896A (en) Data processing method and system
CN109582231B (en) Data storage method and device, electronic equipment and storage medium
CN109460406B (en) Data processing method and device
US20220129428A1 (en) Database key compression
CN113157689A (en) Data indexing method and device and electronic equipment
CN104573112A (en) Page query method and data processing node for OLTP cluster database
CN116662019B (en) Request distribution method and device, storage medium and electronic device
CN117235069A (en) Index creation method, data query method, device, equipment and storage medium
KR20120082176A (en) Data processing method of database management system and system thereof
CN115543224B (en) ZNS SSD-based file system control method, device and equipment
CN113342819A (en) Card number generation method, device, equipment and storage medium
CN114217741A (en) Storage method of storage device and storage device
CN111399759B (en) Method for reading data and writing data and object file system
KR20220099745A (en) A spatial decomposition-based tree indexing and query processing methods and apparatus for geospatial blockchain data retrieval
CN114297196A (en) Metadata storage method and device, electronic equipment and storage medium
KR100662389B1 (en) Method for managing storage information, and apparatus for the same
CN112084141A (en) Full-text retrieval system capacity expansion method, device, equipment and medium
KR101106568B1 (en) File sorting System for mobile device and Method thereof
CN109760044A (en) A kind of data processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination