CN111125112A - Data processing method and device, electronic equipment and computer readable storage medium - Google Patents

Data processing method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN111125112A
CN111125112A CN201911357496.7A CN201911357496A CN111125112A CN 111125112 A CN111125112 A CN 111125112A CN 201911357496 A CN201911357496 A CN 201911357496A CN 111125112 A CN111125112 A CN 111125112A
Authority
CN
China
Prior art keywords
target
primary key
range
server
value
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
CN201911357496.7A
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.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings 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 JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN201911357496.7A priority Critical patent/CN111125112A/en
Publication of CN111125112A publication Critical patent/CN111125112A/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/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/2453Query optimisation
    • 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/2471Distributed queries

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure provides a data processing method, an apparatus, an electronic device and a computer-readable storage medium, the method comprising: the target server sends an acquisition request of a main key range of a target service to a target database; the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service; the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length; and the target server responds to a primary key generation request of a target object and determines a target primary key value in the first target range. The technical scheme provided by the embodiment of the disclosure can relieve the pressure of the database request when the primary key of the target service is generated, improve the generation speed of the primary key and relieve the blocking condition of the user request.

Description

Data processing method and device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a data processing method and apparatus, an electronic device, and a computer-readable storage medium.
Background
In a distributed system, we usually split some traffic with large data volume. For example, a user table or an order table may not receive all data because of a huge amount of data, and thus, the user table or the order table needs to be sorted and sorted. But once the sub-base and the sub-table are involved, the generation problem of the unique primary key in the distributed system can be extended.
However, in the process of implementing the present invention, the inventor finds that in the process of generating the main key, the user is often blocked due to the problem of high frequency transmission, so that the user experience is not good.
Therefore, a data processing method that can increase the generation speed of the primary key and reduce user congestion is very important for database technology.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The embodiment of the disclosure provides a data processing method and device, an electronic device and a computer readable storage medium, which can improve the speed of generating a primary key of a target service and alleviate the user blocking condition in the primary key generation process.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
The embodiment of the disclosure provides a data processing method, which includes: the target server sends an acquisition request of a main key range of a target service to a target database; the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service; the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length; and the target server responds to a primary key generation request of a target object and determines a target primary key value in the first target range.
In some embodiments, the data processing method further comprises: and if the utilization rate of the value in the first target range in the target server exceeds a first preset threshold value, the target server sends an acquisition request of the primary key range of the target service to the target database so as to acquire a second target range of the primary key of the target service.
In some embodiments, the determining, by the target server, a target primary key value within the first target scope in response to a primary key generation request of a target object includes: and if the utilization rate of the value of the first target range in the target server exceeds a second preset threshold value, determining the target primary key value in the second target range.
In some embodiments, the target server comprises a first target server and a second target server; wherein, the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service, including: if the first target server and the second target server simultaneously send the acquisition request of the primary key range of the target service to the target database; the target database sends the first maximum value of the main key of the target service and the main key step length to the first target server according to a database transaction technology and a row lock technology, so that the first target server determines a third target range of the main key and updates the first maximum value of the main key according to the main key step length; and the target database sends the updated first maximum value of the primary key and the primary key step length to the second target server so that the second target server can determine a fourth target range of the primary key.
In some embodiments, the determining, by the target server, a target primary key value within the first target scope in response to a primary key generation request of a target object includes: determining target primary keys within the first target range in increasing order.
In some embodiments, the target object comprises a first target object and a second target object; wherein the target server determines a target primary key value within the first target range in response to a primary key generation request of a target object, further comprising: if the first target object and the second target object simultaneously initiate a primary key generation request to the target server; the target server determines a first target primary key value of the first target object in the first target range according to a row lock technology, and deletes the first target primary key value from the first target range; and the server determines a second target primary key value of the second target object according to the first target range in which the first target primary key value is deleted.
In some embodiments, the target database is located in a database server; the method for sending the acquisition request of the primary key range of the target service to the target database by the target server comprises the following steps: and the target server initiates an acquisition request of the primary key range to a target database in the database server through a primary key range generation interface.
An embodiment of the present disclosure provides a data processing apparatus, including: the device comprises a request sending module, a primary key most value sending module, a first target range determining module and a target primary key value determining module.
The request sending module can be configured to send an acquisition request of a primary key range of a target service to a target database by a target server; the primary key most value sending module may be configured to send, by the target database, the first most value of the primary key of the target service and the primary key step length to the target server, and update the first most value of the primary key according to the primary key step length, so as to respond to a next primary key range acquisition request of the target service; the first target range determining module may be configured to determine, by the target server, a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length; the target primary key value determination module may be configured to determine a target primary key value within the first target range by the target server in response to a primary key generation request of a target object.
An embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the data processing method of any one of the above.
The disclosed embodiments provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements a data processing method as described in any one of the above.
According to the data processing method and device, the electronic device and the computer readable storage medium provided by some embodiments of the disclosure, the target server obtains the primary key range from the target database in advance, so that the target object can directly obtain the primary key value from the target server. On one hand, the requests of the target objects are dispersed to different target servers, so that the pressure of a target database is reduced, and the speed of acquiring the primary key by the target objects is improved; on the other hand, the target server may store the first target range in a local memory, and compared with the method of remotely acquiring the primary key value from the target database through a network, the method for acquiring the primary key value from the local memory of the target server by the target object greatly improves the acquisition speed and indirectly reduces the user blocking.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. The drawings described below are merely some embodiments of the present disclosure, and other drawings may be derived from those drawings by those of ordinary skill in the art without inventive effort.
Fig. 1 shows a schematic diagram of an exemplary system architecture of a data processing method or a data processing apparatus to which the embodiments of the present disclosure can be applied.
Fig. 2 is a schematic diagram illustrating a computer system applied to a data processing apparatus according to an exemplary embodiment.
FIG. 3 is a flow chart illustrating a method of data processing according to an exemplary embodiment.
Fig. 4 is a flowchart of step S4 in fig. 3 in an exemplary embodiment.
FIG. 5 is a flow chart illustrating another method of data processing according to an exemplary embodiment.
FIG. 6 is a schematic diagram illustrating a data processing system in accordance with an exemplary embodiment.
Fig. 7 is a flowchart illustrating yet another data processing method according to an example embodiment.
FIG. 8 is a schematic diagram illustrating another data processing system in accordance with an illustrative embodiment.
FIG. 9 is a flow chart illustrating yet another method of data processing according to an exemplary embodiment.
Fig. 10 is a block diagram illustrating a data processing care apparatus according to an exemplary embodiment.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The same reference numerals denote the same or similar parts in the drawings, and thus, a repetitive description thereof will be omitted.
The described features, structures, or characteristics of the disclosure may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The drawings are merely schematic illustrations of the present disclosure, in which the same reference numerals denote the same or similar parts, and thus, a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and steps, nor do they necessarily have to be performed in the order described. For example, some steps may be decomposed, and some steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
In this specification, the terms "a", "an", "the", "said" and "at least one" are used to indicate the presence of one or more elements/components/etc.; the terms "comprising," "including," and "having" are intended to be inclusive and mean that there may be additional elements/components/etc. other than the listed elements/components/etc.; the terms "first," "second," and "third," etc. are used merely as labels, and are not limiting on the number of their objects.
The following detailed description of exemplary embodiments of the disclosure refers to the accompanying drawings.
Fig. 1 shows a schematic diagram of an exemplary system architecture of a data processing method or a data processing apparatus to which the embodiments of the present disclosure can be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, wearable devices, virtual reality devices, smart homes, and the like.
The server 105 may be a server that provides various services, such as a background management server that provides support for devices operated by users using the terminal apparatuses 101, 102, 103. The background management server can analyze and process the received data such as the request and feed back the processing result to the terminal equipment.
Server 105 may, for example, send a primary key range acquisition request for the target service to the target database; server 105 may, for example, send the first maximum value and the primary key step length of the primary key of the target service to the target server through the target database, and update the first maximum value of the primary key according to the primary key step length, so as to respond to the next acquisition request of the primary key range of the target service; server 105 may, for example, determine a first target range for the primary key of the target service based on the first maximum value of the primary key and the primary key step size; server 105 may, for example, determine a target primary key value within the first target scope in response to a primary key generation request of a target object.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is only illustrative, and the server 105 may be a physical server or may be composed of a plurality of servers, and there may be any number of terminal devices, networks and servers according to actual needs.
Referring now to FIG. 2, a block diagram of a computer system 200 suitable for implementing a terminal device of the embodiments of the present application is shown. The terminal device shown in fig. 2 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 2, the computer system 200 includes a Central Processing Unit (CPU)201 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)202 or a program loaded from a storage section 208 into a Random Access Memory (RAM) 203. In the RAM 203, various programs and data necessary for the operation of the system 200 are also stored. The CPU 201, ROM 202, and RAM 203 are connected to each other via a bus 204. An input/output (I/O) interface 205 is also connected to bus 204.
The following components are connected to the I/O interface 205: an input portion 206 including a keyboard, a mouse, and the like; an output section 207 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 208 including a hard disk and the like; and a communication section 209 including a network interface card such as a LAN card, a modem, or the like. The communication section 209 performs communication processing via a network such as the internet. A drive 210 is also connected to the I/O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is mounted on the drive 210 as necessary, so that a computer program read out therefrom is installed into the storage section 208 as necessary.
In particular, according to an embodiment 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 storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 209 and/or installed from the removable medium 211. The above-described functions defined in the system of the present application are executed when the computer program is executed by the Central Processing Unit (CPU) 201.
It should be noted that the computer readable storage medium shown in the present application 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 application, 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 this application, 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 storage 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 storage 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 application. 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 modules and/or units described in the embodiments of the present application may be implemented by software or hardware. The described modules and/or units may also be provided in a processor, and may be described as: a processor includes a transmitting unit, an obtaining unit, a determining unit, and a first processing unit. Wherein the names of such modules and/or units do not in some way constitute a limitation on the modules and/or units themselves.
As another aspect, the present application also provides a computer-readable storage medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable storage medium carries one or more programs which, when executed by a device, cause the device to perform functions including: the target server sends an acquisition request of a main key range of a target service to a target database; the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service; the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length; and the target server responds to a primary key generation request of a target object and determines a target primary key value in the first target range.
In the e-commerce field, it may happen that multiple users purchase the same item at the same time. The background needs to record the purchasing behaviors of the users, and assigns a uniquely identifiable primary key to each user purchasing record for identification.
In the related art, the value of the primary key, which is generally uniquely identifiable, may be used to uniquely identify a record in a table in a database.
However, before assigning a primary key to a user purchase record in the background, the background needs to initiate a primary key generation request to a primary key generation service to obtain the corresponding primary key. It is obvious that if there is a case where a plurality of users purchase the same commodity at the same time, the server backgrounds of the plurality of users will initiate a plurality of requests to the primary key generation service at the same time. However, obtaining the primary key by directly initiating a primary key generation request to the primary key generation server is generally slow, which may cause user congestion and degrade user experience for the following reasons:
1. when the background initiates a request to the primary key generation service, information needs to be transmitted through the network, which results in a slow primary key acquisition speed.
2. The primary key generation server may receive multiple requests at the same time, and in order to avoid generating repeated primary keys, the primary key generation server usually needs to complete the processing of each request through a line lock technology, but this method usually results in a slow primary key acquisition speed.
To improve the primary key acquisition speed, the present disclosure provides the following data processing method.
FIG. 3 is a flow chart illustrating a method of data processing according to an exemplary embodiment. The method provided by the embodiment of the present disclosure may be processed by any electronic device with computing processing capability, for example, the server 105 and/or the terminal devices 102 and 103 in the embodiment of fig. 1 described above, and in the following embodiment, the server 105 is taken as an execution subject for example, but the present disclosure is not limited thereto.
Referring to fig. 3, a data processing method provided by an embodiment of the present disclosure may include the following steps.
In step S1, the target server transmits an acquisition request of the primary key range of the target service to the target database.
In some embodiments, the primary key range of the target service may refer to a range of values that can be taken when the target database is configured with a primary key for a target object requesting to obtain the primary key of the target service. For example, if the primary key range of the target service obtained by the target server is [1,1000], when the target object requests the target server to obtain the primary key related to the target service, the target server may determine the primary key of the target object within the primary key range of [1,1000 ].
In some embodiments, the target server may refer to a server that specifies user services, such as a server for primary key generation traffic, each target server may serve multiple users.
In some embodiments, the target server may include a plurality of servers, for example, the target server may include a first target server, a second target server, a third server, and the like, and the number of the target servers is not limited by the present disclosure.
In some embodiments, the target database may be located in a database server, and the database server may be a different server from the target server or the same server, which is not limited by this disclosure.
In step S2, the target database sends the first maximum value and the primary key step size of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step size, so as to respond to the next acquisition request of the primary key range of the target service.
In some embodiments, the first maximum value of the primary key may refer to a maximum value of the primary key stored in the target database, may also refer to a minimum value of the primary key, and the like, which is not limited by the present disclosure.
In some embodiments, the target database may determine, according to the target service, a first maximum value of a primary key of the target service and a primary key step length corresponding to the target service. The initial first maximum value of the primary key of the target service (since the first maximum value of the primary key may be continuously updated, the initial first maximum value may refer to the initial first maximum value of the primary key) and the primary key step length may be set according to the target service, which is not limited in this disclosure. For example, the initial first maximum of the primary key of the target service may be specified to be 0, and the primary key step size may be 1000.
In some embodiments, after the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, the target database may update the first maximum value of the primary key of the target service according to the primary key step length. For example, the first maximum value of the primary key after updating can be obtained by adding the first maximum value of the primary key before updating to the primary key step size.
For example, assuming that the first maximum value is the maximum value of the target service, the size of the first maximum value is 0, and the step size of the primary key is 1000, when the target database issues the first maximum value 0 of the primary key of the target service and the corresponding primary key step size 1000 to the target server, the target database adds the key step size to the first maximum value to obtain an updated first maximum value of the primary key; for another example, assuming that the first maximum value is the minimum value of the target service, the size of the first maximum value is 10000, and the step size of the primary key is 1000, when the target database issues the first maximum value 10000 of the primary key of the target service and the corresponding step size 1000 of the primary key to the target server, the target database subtracts the step size of the key on the basis of the first maximum value to obtain the updated first maximum value of the primary key.
In step S3, the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step size.
In some embodiments, the target server may determine a first target range of the target traffic according to the first maximum of the primary key and the primary key step size. For example, the left end point of the first target range may be determined according to the first maximum value of the primary key, and the right end point of the first target range may be determined according to the first maximum value of the primary key and the primary key step size, and assuming that the first maximum value of the primary key is the maximum value, the size of the maximum value is 1000, and the step size is 1000, then the first target range may be [1001,2000 ]; for another example, the right end point of the first target range may be determined according to the first maximum value of the primary key, and the left end point of the first target range may be determined according to the first maximum value of the primary key and the step size of the primary key, and assuming that the first maximum value of the primary key is the minimum value, the minimum value is 10000, and the step size is 1000, the first target range may be [9000, 10000-1 ].
In step S4, the target server determines a target primary key value within the first target range in response to a primary key generation request of a target object.
In some embodiments, the target object may initiate a primary key generation request to the target server, and the target server may determine a target primary key value within a first target range of a primary key of the target service to send to the target object.
In some embodiments, the target primary key values may be determined within the first target range in increasing order. Assuming that the first target range is [1,1000], the target primary key value obtained by the first target object from the target server may be 1, the primary key value obtained by the second target object from the target server may be 2, and so on.
In some embodiments, a getaddressincrement (a no-wait concurrency algorithm) method in atominLong (a function that performs an atomic operation on long shaping data) may be employed to determine the target primary key value within the first target range.
In this embodiment, the target database may issue different primary key ranges to each target server according to the primary key of the target service and the primary key step length, and a certain size relationship exists between the primary key ranges, for example, a left end point of the primary key range issued at a later time is greater than all values in the primary key range issued at a previous time, or a right power-off of the primary key range issued at a later time is less than all values in the primary key range issued at a previous time. It will be appreciated that the target database may generate different primary key ranges from different primary key first maxima and primary key step sizes. Assuming that the initial primary key value is a1 and the primary key step is b1, when a first target server initiates a primary key range acquisition request to the target database, the target database may return [ a1+1, b1], and when a second target server initiates a primary key range acquisition request to the target database, the target database may return [ a1+ b1+1, b1 ].
According to the technical scheme provided by the embodiment, the uniqueness of the generated main key can be ensured through the main key range without intersection, the generated main key is ensured to be in trend increasing or trend decreasing through ensuring that the endpoint value of the issued main key range is all larger or all smaller than the value in the main key range issued at the last moment, and in addition, the query efficiency of the query according to the main key is higher due to the fact that the main key generated according to the method is shorter.
The trend increment may refer to an increasing trend in the generation of primary keys, e.g., primary keys generated over time are between [0,1000] and primary keys generated over time are between [1001,2000 ].
In the data processing method provided by this embodiment, the target server obtains the primary key range from the target database in advance, so that the target object can directly obtain the primary key value from the target server. On one hand, the requests of the target objects are dispersed to different target servers, so that the pressure of a target database is reduced, and the speed of acquiring the primary key by the target objects is improved; on the other hand, the target server may store the first target range in a local memory, and compared with the method of remotely acquiring the primary key value from the target database through a network, the method for acquiring the primary key value from the local memory of the target server by the target object greatly improves the acquisition speed and indirectly reduces the user blocking.
Fig. 4 is a flowchart of step S4 in fig. 3 in an exemplary embodiment. Referring to fig. 4, the above-mentioned step S4 may include the following steps.
In step S41, if the usage rate of the value in the first target range in the target server exceeds a first preset threshold, the target server sends an acquisition request of the primary key range of the target service to the target database.
In some embodiments, if the usage rate of the values in the first target range in the target server exceeds a first preset threshold, for example, the values in the first target range in the target server have been used by 10%, the target server may initiate a desire to request a new primary key range in advance to the target database.
In step S42, a second target range of the primary key of the target service is acquired.
In some embodiments, when the usage of values within a first target range within the target server exceeds a first preset threshold, the target server may request the second target range from the target database.
In some embodiments, the targeted primary key value may be retrieved directly from within the second target range after exhaustion of values within the first target range.
It can be understood that if a new primary key range is obtained from the target database after the values in the first target range are exhausted, a blocking situation is likely to occur, and the user experience is reduced.
In the technical scheme provided by this embodiment, when the value in the first target range is not used up, a new second target range is obtained in advance, so that the target primary key value can be obtained from the second target range immediately after the value in the first target range is used up, and the problem of user congestion is reduced.
FIG. 5 is a flow chart illustrating another method of data processing according to an exemplary embodiment. Referring to fig. 5, the above-described data processing method may include the following steps.
In step S1, the target server transmits an acquisition request of the primary key range of the target service to the target database.
In step S2, the target database sends the first maximum value and the primary key step size of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step size, so as to respond to the next acquisition request of the primary key range of the target service.
In step S3, the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step size.
In step S421, the target server responds to the primary key generation request of the target object, and determines whether the usage rate of the value in the first target range in the target server exceeds a second preset threshold, and if the usage rate of the value in the first target range in the target server exceeds the second preset threshold, determines the target primary key value in the second target range.
As shown in fig. 6, when the target object initiates a primary key generation request to the target server 601, the target server 601 may determine that the usage rate of the value in the first target range in the local first cache 6011 currently in use exceeds a first preset threshold (e.g., ten percent); if the usage rate of the value in the first target range exceeds a first preset threshold, the target server 601 will initiate a primary key range acquisition request to the target database 603 through the primary key range generation interface 602; the target database 603 may return a second target range to the target server 601; the target server will store the second target range in a second cache 6012 in the local.
In some embodiments, when the target object initiates a primary key generation request to the target server 601, the target server 601 may determine whether the usage rate of the value in the first target range in the local first cache 6011 currently in use exceeds the second preset threshold (e.g., one hundred percent); if the usage rate of the value in the first target range exceeds the second preset threshold, the target server 601 may directly obtain the target primary key value from the second target range in the second cache 6012.
The technical scheme provided by the embodiment can avoid the user blocking situation caused by acquiring a new primary key range from the target database after the value in the first target range is exhausted.
Fig. 7 is a flowchart illustrating yet another data processing method according to an example embodiment.
In some embodiments, the target server includes a first target server and a second target server.
Referring to fig. 7, the above-described data processing method may include the following steps.
In step S701, if the first target server and the second target server simultaneously send an acquisition request of the primary key range of the target service to the target database.
In some embodiments, the target database may orchestrate a plurality of target servers to send primary key ranges to the target servers. For example, the plurality of servers may include a first target server 801, a second target server 802, a third target server 803, and the like as shown in fig. 8, and the number of target servers is not limited by the present disclosure.
In some embodiments, the first target server 801, the second target server 802, the third target server 803, and the like may simultaneously initiate a primary key range acquisition request to the target database.
In step S702, the target database sends the first maximum value of the primary key of the target service and the primary key step length to the first target server according to a database transaction technique and a row lock technique, so that the first target server determines a third target range of the primary key and updates the first maximum value of the primary key according to the primary key step length.
The lock is a very important concept in data network transmission, and brings about a situation of data inconsistency when a plurality of users operate a database, so that the lock mainly guarantees the integrity and consistency of database data under the condition of multiple users. The row lock is to lock one or more rows of records during data update, so that other users cannot operate on the locked one or more rows of records.
A transaction is a logical unit of program execution consisting of operations that access and update data in the system. The transaction includes atomicity of the transaction, and hospital atomicity of the transaction means that the transaction must be an operation sequence unit of a hospital. The operations contained in the transaction allow two states to occur, namely, all execution is successful or all execution is failed, on average during one execution.
In some embodiments, a database transaction technique may refer to performing operations on data in units of transactions in a database.
In some embodiments, to avoid issuing the same primary key range to different target servers, the target database may send the first maximum value of the primary key of the target service and the primary key step length to the first target server according to a database service and a row lock technology, so that the first target server determines the third target range of the primary key, and updates the first maximum value of the primary key according to the primary key step length.
In step S703, the target database sends the updated first maximum value of the primary key and the primary key step size to the second target server, so that the second target server determines a fourth target range of the primary key.
In some embodiments, after the operation of issuing the primary key range to the first target server 801 by the target database is completed, the target database will issue the primary key range to the second target server 802 and the third target server, respectively.
It can be understood that the ranges of the primary keys issued each time by the target database are different, and as time increases, the values in the range of the primary keys issued at the current time are all larger than the range of the primary keys issued at the previous time, so that the trend of the finally generated primary keys is ensured to increase.
FIG. 9 is a flow chart illustrating yet another method of data processing according to an exemplary embodiment.
In some embodiments, the target object includes a first target object and a second target object. Referring to fig. 9, the above-described data processing method may include the following steps.
In step S901, if the first target object and the second target object initiate a primary key generation request to the target server at the same time.
In step S902, the target server determines a first target primary key value of the first target object in the first target range according to a row lock technology, and deletes the first target primary key value from the first target range.
In some embodiments, if there are multiple target objects sending requests to the target server at the same time, in order to avoid sending the same primary key value to different target objects, the target server may determine, according to a row lock technology, a first target primary key value of the first target object in the first target range, and delete the first target primary key value from the first target range.
In step S903, the server determines a second target primary key value of the second target object according to the first target range from which the first target primary key value is deleted.
The technical scheme provided by the embodiment avoids the issue of the same primary key value to different target objects, and ensures that the finally generated primary key value is uniquely identifiable.
Fig. 10 is a block diagram illustrating a data processing care apparatus according to an exemplary embodiment. Referring to fig. 10, a data processing apparatus 1000 provided in an embodiment of the present disclosure may include: a request sending module 1001, a primary key most value sending module 1002, a first target range determining module 1003 and a target primary key value determining module 1004.
The request sending module 1001 may be configured to send, by the target server, an acquisition request of the primary key range of the target service to the target database. The primary key maximum value sending module 1002 may be configured to send, by the target database, the first maximum value and the primary key step length of the primary key of the target service to the target server, and update the first maximum value of the primary key according to the primary key step length, so as to respond to a next request for obtaining the primary key range of the target service. The first target range determining module 1003 may be configured to determine, by the target server, a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step size. The target primary key value determination module 1004 may be configured to determine a target primary key value within the first target range by the target server in response to a primary key generation request of a target object.
In some embodiments, the data processing apparatus 1000 may further include a second target range determination module.
The second target range determining module may be configured to send, by the target server, an acquisition request of a primary key range of a target service to the target database to acquire a second target range of a primary key of the target service if a usage rate of a value in a first target range in the target server exceeds a first preset threshold.
In some embodiments, the target primary key value determination module 1004 may be further configured to determine the target primary key value within the second target range if the usage rate of the first target range of values within the target server exceeds a second preset threshold.
In some embodiments, the target server includes a first target server and a second target server. In some embodiments, the primary key most value sending module 1002 may include: the device comprises a request acquisition unit, a target range first determination unit and a target range second determination unit.
The request obtaining unit may be configured to send, to the target database, a request for obtaining the primary key range of the target service if the first target server and the second target server simultaneously send a request for obtaining the primary key range of the target service to the target database. The target range first determining unit may be configured to send, by the target database, the first maximum value of the primary key of the target service and the primary key step length to the first target server according to a database transaction technology and a row lock technology, so that the first target server determines a third target range of the primary key, and updates the first maximum value of the primary key according to the primary key step length. The target range second determining unit may be configured to send, by the target database, the updated first maximum value of the primary key and the primary key step to the second target server, so that the second target server determines a fourth target range of the primary key.
In some embodiments, the target primary key value determination module 1004 may be further configured to determine the target primary keys within the first target range in an increasing order.
In some embodiments, the target object includes a first target object and a second target object.
In some embodiments, the target primary key value determination module 1004 further includes: the device comprises a request simultaneous initiation unit, a first target primary key value determination unit and a second target primary key value determination unit.
The request simultaneous initiation unit may be configured to initiate a primary key generation request to the target server if the first target object and the second target object simultaneously initiate requests. The first target primary key value determining unit may be configured to determine, by the target server, a first target primary key value of the first target object in the first target range according to a row lock technique, and delete the first target primary key value from the first target range. The second target primary key value determining unit may be configured to determine, by the server, a second target primary key value of the second target object according to the first target range from which the first target primary key value is deleted.
In some embodiments, the target database is located in a database server.
In some embodiments, the request sending module 1001 may further be configured to initiate, for the target server, an acquisition request of the primary key range to a target database in the database server through a primary key range generation interface.
Since each functional module of the data processing apparatus 1000 according to the exemplary embodiment of the present disclosure corresponds to the step of the exemplary embodiment of the data processing method, it is not described herein again.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution of the embodiment of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computing device (which may be a personal computer, a server, a mobile terminal, or a smart device, etc.) to execute the method according to the embodiment of the present disclosure, such as one or more of the steps shown in fig. 3.
Furthermore, the above-described figures are merely schematic illustrations of processes included in methods according to exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the disclosure is not limited to the details of construction, the arrangements of the drawings, or the manner of implementation that have been set forth herein, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A data processing method, comprising:
the target server sends an acquisition request of a main key range of a target service to a target database;
the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service;
the target server determines a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length;
and the target server responds to a primary key generation request of a target object and determines a target primary key value in the first target range.
2. The method of claim 1, further comprising:
and if the utilization rate of the value in the first target range in the target server exceeds a first preset threshold value, the target server sends an acquisition request of the primary key range of the target service to the target database so as to acquire a second target range of the primary key of the target service.
3. The method of claim 2, wherein the target server determines a target primary key value within the first target scope in response to a primary key generation request of a target object, comprising:
and if the utilization rate of the value of the first target range in the target server exceeds a second preset threshold value, determining the target primary key value in the second target range.
4. The method of claim 1, wherein the target server comprises a first target server and a second target server; wherein, the target database sends the first maximum value and the primary key step length of the primary key of the target service to the target server, and updates the first maximum value of the primary key according to the primary key step length so as to respond to the next acquisition request of the primary key range of the target service, including:
if the first target server and the second target server simultaneously send the acquisition request of the primary key range of the target service to the target database;
the target database sends the first maximum value of the main key of the target service and the main key step length to the first target server according to a database transaction technology and a row lock technology, so that the first target server determines a third target range of the main key and updates the first maximum value of the main key according to the main key step length;
and the target database sends the updated first maximum value of the primary key and the primary key step length to the second target server so that the second target server can determine a fourth target range of the primary key.
5. The method of claim 1, wherein the target server determines a target primary key value within the first target scope in response to a primary key generation request of a target object, comprising:
determining target primary keys within the first target range in increasing order.
6. The method of claim 1, wherein the target object comprises a first target object and a second target object; wherein the target server determines a target primary key value within the first target range in response to a primary key generation request of a target object, further comprising:
if the first target object and the second target object simultaneously initiate a primary key generation request to the target server;
the target server determines a first target primary key value of the first target object in the first target range according to a row lock technology, and deletes the first target primary key value from the first target range;
and the server determines a second target primary key value of the second target object according to the first target range in which the first target primary key value is deleted.
7. The method of claim 1, wherein the target database is located in a database server; the method for sending the acquisition request of the primary key range of the target service to the target database by the target server comprises the following steps:
and the target server initiates an acquisition request of the primary key range to a target database in the database server through a primary key range generation interface.
8. A data processing apparatus, comprising:
the request sending module is configured to send an acquisition request of a main key range of a target service to a target database by a target server;
a primary key maximum value sending module configured to send, by the target database, a first maximum value and a primary key step length of a primary key of the target service to the target server, and update the first maximum value of the primary key according to the primary key step length, so as to respond to a next primary key range acquisition request of the target service;
a first target range determining module configured to determine, by the target server, a first target range of the primary key of the target service according to the first maximum value of the primary key and the primary key step length;
and the target primary key value determining module is configured to determine a target primary key value in the first target range by the target server in response to a primary key generation request of a target object.
9. An electronic device, 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 storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201911357496.7A 2019-12-25 2019-12-25 Data processing method and device, electronic equipment and computer readable storage medium Pending CN111125112A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911357496.7A CN111125112A (en) 2019-12-25 2019-12-25 Data processing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911357496.7A CN111125112A (en) 2019-12-25 2019-12-25 Data processing method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111125112A true CN111125112A (en) 2020-05-08

Family

ID=70502270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911357496.7A Pending CN111125112A (en) 2019-12-25 2019-12-25 Data processing method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111125112A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999525A (en) * 2011-09-16 2013-03-27 深圳市金蝶中间件有限公司 Data-table processing method and system
CN106610865A (en) * 2015-10-21 2017-05-03 阿里巴巴集团控股有限公司 Data locking and unlocking method and apparatus
CN106919640A (en) * 2016-11-16 2017-07-04 阿里巴巴集团控股有限公司 A kind of method and device for business processing
CN107133285A (en) * 2017-04-18 2017-09-05 北京北信源软件股份有限公司 A kind of distributed major key generation method and device
CN107464359A (en) * 2017-08-03 2017-12-12 苏州燃气集团有限责任公司 The processing method and system of a kind of prepayment information
CN108804451A (en) * 2017-04-28 2018-11-13 北京京东尚科信息技术有限公司 Generate method, apparatus, electronic equipment and the readable storage medium storing program for executing of major key

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999525A (en) * 2011-09-16 2013-03-27 深圳市金蝶中间件有限公司 Data-table processing method and system
CN106610865A (en) * 2015-10-21 2017-05-03 阿里巴巴集团控股有限公司 Data locking and unlocking method and apparatus
CN106919640A (en) * 2016-11-16 2017-07-04 阿里巴巴集团控股有限公司 A kind of method and device for business processing
CN107133285A (en) * 2017-04-18 2017-09-05 北京北信源软件股份有限公司 A kind of distributed major key generation method and device
CN108804451A (en) * 2017-04-28 2018-11-13 北京京东尚科信息技术有限公司 Generate method, apparatus, electronic equipment and the readable storage medium storing program for executing of major key
CN107464359A (en) * 2017-08-03 2017-12-12 苏州燃气集团有限责任公司 The processing method and system of a kind of prepayment information

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium
CN114844947B (en) * 2022-04-29 2024-03-26 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium

Similar Documents

Publication Publication Date Title
CN108846753B (en) Method and apparatus for processing data
CN109388626B (en) Method and apparatus for assigning numbers to services
CN110706093A (en) Accounting processing method and device
CN108011949B (en) Method and apparatus for acquiring data
CN110909022A (en) Data query method and device
CN111324615A (en) Data processing method, device, medium and electronic equipment
CN112948498A (en) Method and device for generating global identification of distributed system
CN111881329A (en) Account balance management method and system
CN111159211A (en) Order information generation method, device and system, computer equipment and storage medium
CN112925859A (en) Data storage method and device
CN111062572A (en) Task allocation method and device
CN114661523A (en) Data backup method, device, program product, medium and electronic equipment
CN110928594A (en) Service development method and platform
CN111125112A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN112884181A (en) Quota information processing method and device
CN113190517A (en) Data integration method and device, electronic equipment and computer readable medium
CN113778565A (en) Interface data processing method and device
CN111949648B (en) Memory data caching system and data indexing method
CN113641706A (en) Data query method and device
CN112948138A (en) Method and device for processing message
CN111949678A (en) Method and device for processing non-accumulation indexes across time windows
CN113722007A (en) Configuration method, device and system of VPN branch equipment
CN109087097B (en) Method and device for updating same identifier of chain code
CN113127561B (en) Method and device for generating service single number, electronic equipment and storage medium
CN113760928A (en) Cache data updating system and method

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.