CN110866002A - Method and device for processing sub-table data - Google Patents

Method and device for processing sub-table data Download PDF

Info

Publication number
CN110866002A
CN110866002A CN201810979311.5A CN201810979311A CN110866002A CN 110866002 A CN110866002 A CN 110866002A CN 201810979311 A CN201810979311 A CN 201810979311A CN 110866002 A CN110866002 A CN 110866002A
Authority
CN
China
Prior art keywords
data
sub
processed
data table
determining
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
CN201810979311.5A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810979311.5A priority Critical patent/CN110866002A/en
Publication of CN110866002A publication Critical patent/CN110866002A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a method and a device for processing sub-table data, and relates to the technical field of computers. One embodiment of the method comprises: acquiring data to be processed and a dynamic structured query language instruction; judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key; and processing the data to be processed according to the instruction of the dynamic structured query language in the data table. According to the implementation mode, the technical means of directly and correctly positioning the data tables according to the main key is adopted, all data tables needing to be operated do not need to be circulated, the problem of circulation redundancy caused by complexity of database composition is effectively avoided, the efficiency of processing sub-table data is improved, the pressure of processing data in the database is reduced, and the performance of the database is improved.

Description

Method and device for processing sub-table data
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for processing sub-table data.
Background
The table division may refer to storing data originally stored in one table into a plurality of data tables in blocks, and the table division data may refer to data stored in each data table after table division. For processing of sub-table data, in the prior art, because a data table storing to-be-processed data cannot be directly located, only data records corresponding to all tables can be globally inquired, that is, all processing operations such as inquiry, modification, deletion and the like need to be circulated to all data tables, processing results in all data tables are obtained, and then all processing results are aggregated.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: the prior art has low performance and efficiency in the mode of processing the sub-table data.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for processing table-divided data, which can solve the problem that the ability and efficiency of processing table-divided data are not high due to the fact that all data tables need to be cycled to obtain processing results in each data table, and thus all processing results are aggregated.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of processing tabular data, including: acquiring data to be processed and a dynamic structured query language instruction; judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key; and processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
Optionally, the primary key is generated in the following manner: acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the sub-table field; acquiring an MAC address of a server, and determining a hash code value of the MAC address; dividing the hash code value of the MAC address by the remainder of the total number of the data table to serve as a serial number; and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number.
Optionally, the primary key sequentially includes: a sign bit, a 41-bit timestamp, an 8-bit sequence number, a 6-bit database number, and an 8-bit data table number.
Optionally, the method further comprises: if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not; if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number; and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables.
Optionally, judging whether the data to be processed carries a primary key; if yes, determining a data table corresponding to the data to be processed according to the data table number in the primary key, and further comprising: if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then: determining a data table corresponding to the data to be processed according to the data table number in the primary key; if the instruction of the dynamic structured query language is an instruction for adding data, then: the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an apparatus for processing tabular data, including: an acquisition module to: acquiring data to be processed and a dynamic structured query language instruction; a determine data table module to: judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key; an execution instruction module to: and processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
Optionally, the apparatus further comprises a primary key generation module configured to: acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the sub-table field; acquiring an MAC address of a server, and determining a hash code value of the MAC address; dividing the hash code value of the MAC address by the remainder of the total number of the data table to serve as a serial number; and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number.
Optionally, the primary key generation module is further configured to: the generated primary key sequentially comprises a sign bit, a 41-bit time stamp, an 8-bit serial number, a 6-bit database number and an 8-bit data table number.
Optionally, the determine data table module is further configured to: if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not; if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number; and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables.
Optionally, the determine data table module is further configured to: if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then: determining a data table corresponding to the data to be processed according to the data table number in the primary key; if the instruction of the dynamic structured query language is an instruction for adding data, then: the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an electronic apparatus including: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for processing the sub-table data according to the embodiment of the invention.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a computer readable medium on which a computer program is stored, the program implementing the method of sub-table data processing as proposed by an embodiment of the present invention when executed by a processor.
One embodiment of the above invention has the following advantages or benefits: because the technical means of directly and correctly positioning the data table according to the primary key and executing the instruction of the dynamic structured query language in the data table is adopted, all the data tables needing to be operated do not need to be circulated, the problem of circulation complexity caused by the complexity of the database composition is effectively avoided, the efficiency of processing the sub-table data is improved, the pressure of processing the data in the database is reduced, and the performance of the database is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a basic flow of a method of sub-table data processing according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a primary key generation strategy according to an embodiment of the invention;
FIG. 3 is a schematic illustration of a preferred flow of a method of sub-table data processing according to an embodiment of the invention;
FIG. 4 is a schematic diagram of basic modules of an apparatus for sub-table data processing according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a basic flow of a method of sub-table data processing according to an embodiment of the present invention. As shown in fig. 1, an embodiment of the present invention provides a method for processing tabular data, including:
step S101, acquiring data to be processed and an instruction of a dynamic Structured Query Language (SQL);
s102, judging whether the data to be processed carries a main key or not; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key;
and S103, processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
The data table number may be a serial number of the data table or may be a data table ID. The primary key may refer to a record that represents the uniqueness of a data in the database. The embodiment of the invention adopts the technical means of directly and correctly positioning the data table according to the primary key and executing the instruction of the dynamic structured query language in the data table without circulating all the data tables needing to be operated, thereby effectively avoiding the problem of circulation complexity caused by the complexity of the database, improving the efficiency of processing the data in the sub-tables, further reducing the access pressure of the database and improving the performance of the database.
In the embodiment of the invention, the main key is generated in the following way: acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to serve as the data table number corresponding to the sub-table field; acquiring a media access control address (namely an MAC address) of a server, and determining a hash code value of the media access control address; dividing the hash code value of the media access control address by the remainder of the total number of the data tables according to the hash code value of the media access control address and the total number of the data tables to be used as a serial number; and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number. The primary key needs to be added to the data newly added to the data table after it is generated. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the database and the data table, and the beneficial effect of utilizing the main key to locate the database and the data table in the process of processing the sub-table data is realized. Snowflow is an algorithm that generates a globally unique ID (i.e., primary key) under a distributed cluster. In the embodiment of the invention, the globally unique ID in the distributed cluster can be generated by a zooker similar to a distributed application program coordination service of a third party.
In the embodiment of the present invention, the main key sequentially includes: a sign bit, a 41-bit timestamp, an 8-bit sequence number, a 6-bit database number, and an 8-bit data table number. FIG. 2 is a schematic diagram of a primary key generation strategy according to an embodiment of the invention; as shown in fig. 2, the first bit is a sign bit, and has no business significance; the following 41 bits represent the time stamp, and in milliseconds, 41 bits can represent the value of 2^41-1 milliseconds, and the conversion into a unit year is 69 years; the next 8-bit sequence number is used to distinguish the same data generated in the same millisecond, and in the cluster environment, when the timestamps taken by a plurality of instances are the same, the 8-bit value needs to be generated according to the mac address of the instance for distinguishing; the next 6-bit database number represents the serial number of the generated database, and 63 databases are supported in total; the last 8-bit data table number represents the sequence number of the generated data table, supporting a total of 128 database tables. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the database and the data table, and the beneficial effect of utilizing the main key to locate the database and the data table in the process of processing the sub-table data is realized.
In the embodiment of the present invention, determining the data table corresponding to the data to be processed according to the data table number in the primary key includes: determining the last 8 bits in the main key as a data table number according to the main key; and positioning the data table corresponding to the data to be processed according to the number of the data table. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the data table, and the beneficial effect of positioning the data table by using the main key in the process of processing the sub-table data is realized.
In the embodiment of the present invention, the method further includes: if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not; if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number; and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables. The table division field is a basis for storing data in one table into a plurality of data tables in blocks, and determines the result of table division. For example, the user information is stored into two data tables according to "gender", and in the table dividing process, the "gender" is a table dividing field. According to the embodiment of the invention, under the condition of no main key, a technical means of positioning the data table according to the sub-table fields is adopted, all data tables needing to be operated do not need to be circulated, the problem of circulation complexity caused by the complexity of the database structure is effectively avoided, the efficiency of processing sub-table data is improved, the access pressure of the database is further reduced, and the performance of the database is improved.
In the embodiment of the invention, whether the data to be processed carries a main key is judged; if yes, determining a data table corresponding to the data to be processed according to the data table number in the primary key, and further comprising: if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then: determining a data table corresponding to the data to be processed according to the data table number in the primary key; if the instruction of the dynamic structured query language is an instruction for adding data, then: the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number. For new data to be added into the data table, as the new data does not carry a primary key, the data table needs to be positioned according to the sub-table field (namely, the data table into which the new data is to be added is determined); after the primary key is generated according to the sub-table field, the primary key is added into the new data, so that the data table can be directly positioned by using the primary key when the new data is modified, deleted, inquired and the like, the efficiency of processing sub-table data is improved, and the pressure of processing data in a database is further reduced.
An embodiment for implementing new data addition is further provided, which comprises the following steps:
generating a dynamic SQL statement (or instruction) with a newly added function according to the SQL rule of the mybatis framework; parameters expressing a database table in the dynamic SQL statement are dynamic parameters;
calculating a hash code (hashCode) value according to the sub-table field, and dividing the hash code value by the total number of the data table to obtain a data table number;
generating a unique main key according to the timestamp, the serial number, the database sequence and the data table sequence, wherein the serial number is obtained by calculating a hashCode value of a Media Access Control (MAC) address and dividing the hashCode value by the total number of the data table for remainder;
specifically, an invoke method in the proxy class MapperProxy may be adopted, the generated primary key is used to initialize the primary key of the entity class object (i.e. the generated primary key is added to new data), a parameter of the data table is obtained according to the data table determined by the data table number, and the parameter in the dynamic SQL statement are dynamically replaced; and after dynamic replacement, directly adding and saving the new data into the data table to complete data addition.
Wherein, the time stamp represents a long integer binary code of the current time, and can be understood as the current time, the sequence number is an 8-bit binary code generated by the MAC address processing of the physical machine (server), and the database table sequence is an 8-bit 2 binary code generated according to the routing rule. The dynamic SQL statement supports dynamic replacement of database tables needing to be added or queried, such as statements: table A in "select from Table A" is dynamically generated according to routing rules. The hash code (hashCode) value is a numerical value of int type calculated by the toolkit JDK according to the address or character string or number of the object. Mybatis is a middleware that supports persistent layer operations and dynamic replacement of data.
Further, the embodiment of implementing other data processing functions except the added function is as follows:
generating a dynamic SQL statement (or instruction) with a newly added function according to an SQL rule of the mybatis framework, wherein a parameter which represents a database table in the dynamic SQL statement is a dynamic parameter;
whether a main key exists can be judged by adopting a Mapperproxy invoke method, if so, the corresponding data table is directly positioned according to the main key, the parameters of the corresponding data table are dynamically replaced, and then the dynamic SQL statement is executed. If the main key does not exist, judging whether the value of the sub-table field exists, if so, obtaining the number of the data table according to the sub-table field, thereby positioning the corresponding data table, dynamically replacing the parameter of the corresponding data table, and then executing the dynamic SQL statement. If not, the corresponding data table (i.e. all data tables of the current data structure are circulated, the data meeting the conditions is inquired, and the data table where the data is located is the corresponding data table) needs to be recurrently executed, and the dynamic SQL statement is executed.
FIG. 3 is a schematic illustration of a preferred flow of a method of sub-table data processing according to an embodiment of the invention; as shown in fig. 3, the specific modification, deletion, and query processes may be as follows:
modifying the flow: and judging whether the modified condition has a primary key, if so, directly obtaining the last 8 bits of the id and directly positioning to the data table. If the primary key does not exist, judging whether the sublist field exists to calculate the hash value and calculate the data table, modifying the data and returning. If none exists, all tables need to be circulated for data modification operation.
And (4) deleting the flow: and judging whether the modified condition has a primary key, if so, directly obtaining the last 8 bits of the id and directly defining the last 8 bits to the data table. And if the primary key does not exist, judging whether the sublist field exists to calculate the hash value and calculate the data table, deleting the data and returning. If none exists, all tables need to be circulated for data deletion operation.
And (3) query flow: and judging whether the modified condition has a primary key, if so, directly obtaining the last 8 bits of the id and directly defining the last 8 bits to the data table. And if the primary key does not exist, judging whether the sublist field exists to calculate the hash value and calculate the data table, inquiring the data and returning. If none exists, all tables need to be circulated for data query operation.
An embodiment of the present invention provides a device 400 for processing table-divided data, including: an obtaining module 401 configured to: acquiring data to be processed and a dynamic structured query language instruction; a determine data table module 402 for: judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key; an execution instruction module 403, configured to: and processing the data to be processed according to the instruction of the dynamic structured query language in the data table. The embodiment of the invention adopts the technical means of directly and correctly positioning the data table according to the primary key and executing the instruction of the dynamic structured query language in the data table without circulating all the data tables needing to be operated, thereby effectively avoiding the problem of circulation complexity caused by the complexity of the database, improving the efficiency of processing the data in the sub-tables, further reducing the access pressure of the database and improving the performance of the database.
In an embodiment of the present invention, the apparatus further includes a primary key generation module, configured to: acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to serve as the data table number corresponding to the sub-table field; acquiring a media access control address of a server, and determining a hash code value of the media access control address; dividing the hash code value of the media access control address by the remainder of the total number of the data tables according to the hash code value of the media access control address and the total number of the data tables to be used as a serial number; and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the database and the data table, and the beneficial effect of utilizing the main key to locate the database and the data table in the process of processing the sub-table data is realized.
In this embodiment of the present invention, the primary key generation module is further configured to: the generated primary key sequentially comprises a sign bit, a 41-bit time stamp, an 8-bit serial number, a 6-bit database number and an 8-bit data table number. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the database and the data table, and the beneficial effect of utilizing the main key to locate the database and the data table in the process of processing the sub-table data is realized.
In this embodiment of the present invention, the data table determining module is further configured to: determining the last 8 bits in the main key as a data table number according to the main key; and positioning the data table corresponding to the data to be processed according to the number of the data table. The embodiment of the invention optimizes the generation mode of the main key on the basis of a snowFlake algorithm (snowFlake), so that the main key can store the information of the data table, and the beneficial effect of positioning the data table by using the main key in the process of processing the sub-table data is realized.
In this embodiment of the present invention, the data table determining module is further configured to: if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not; if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number; and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables. According to the embodiment of the invention, under the condition of no main key, a technical means of positioning the data table according to the sub-table fields is adopted, all data tables needing to be operated do not need to be circulated, the problem of circulation complexity caused by the complexity of the database structure is effectively avoided, the efficiency of processing sub-table data is improved, the access pressure of the database is further reduced, and the performance of the database is improved.
In this embodiment of the present invention, the data table determining module is further configured to: if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then: determining a data table corresponding to the data to be processed according to the data table number in the primary key; if the instruction of the dynamic structured query language is an instruction for adding data, then: the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables according to the hash code value of the sub-table field and the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number. For new data to be added into the data table, as the new data does not carry a primary key, the data table needs to be positioned according to the sub-table field (namely, the data table into which the new data is to be added is determined); after the primary key is generated according to the sub-table field, the primary key is added into the new data, so that the data table can be directly positioned by using the primary key when the new data is modified, deleted, inquired and the like, the efficiency of processing sub-table data is improved, and the pressure of processing data in a database is further reduced.
Fig. 5 shows an exemplary system architecture 500 of a method of sub-table data processing or an apparatus of sub-table data processing to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 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 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 501, 502, 503. The background management server can analyze and process the received data such as the product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that the method for processing the sub-table data provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the apparatus for processing the sub-table data is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The invention also provides an electronic device and a computer readable medium according to the embodiment of the invention.
The electronic device of the embodiment of the invention comprises: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for processing the sub-table data according to the embodiment of the invention.
The computer readable medium of the embodiment of the present invention has a computer program stored thereon, and the program, when executed by a processor, implements the method of sub-table data processing as set forth in the embodiment of the present invention.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprising: the device comprises an acquisition module, a data table determining module and an instruction executing module. The names of these modules do not in some cases constitute a limitation of the module itself, and for example, the obtaining module may also be described as a "module for obtaining data to be processed and instructions of a dynamic structured query language".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: s101, acquiring data to be processed and a dynamic structured query language instruction; s102, judging whether the data to be processed carries a main key or not; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key; and S103, processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
According to the embodiment of the invention, the technical means of directly and correctly positioning the data table according to the primary key and executing the instruction of the dynamic structured query language in the data table is adopted, and all the data tables needing to be operated do not need to be circulated, so that the problem of circulation complexity caused by the complexity of the database structure is effectively avoided, the efficiency of processing sub-table data is improved, the data processing pressure in the database is reduced, and the performance of the database is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method of tabulated data processing, comprising:
acquiring data to be processed and a dynamic structured query language instruction;
judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the data table number in the primary key;
and processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
2. The method of claim 1, wherein the primary key is generated by:
acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the sub-table field;
acquiring an MAC address of a server, and determining a hash code value of the MAC address; dividing the hash code value of the MAC address by the remainder of the total number of the data table to serve as a serial number;
and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number.
3. The method of claim 1, wherein the primary key comprises, in order: a sign bit, a 41-bit timestamp, an 8-bit sequence number, a 6-bit database number, and an 8-bit data table number.
4. The method of claim 1, further comprising:
if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not;
if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number;
and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables.
5. The method according to claim 1, wherein, judging whether the data to be processed carries a primary key; if yes, determining a data table corresponding to the data to be processed according to the data table number in the primary key, and further comprising:
if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then:
determining a data table corresponding to the data to be processed according to the data table number in the primary key;
if the instruction of the dynamic structured query language is an instruction for adding data, then:
the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number.
6. An apparatus for processing tabular data, comprising:
an acquisition module to: acquiring data to be processed and a dynamic structured query language instruction;
a determine data table module to: judging whether the data to be processed carries a main key; if so, determining a data table corresponding to the data to be processed according to the main key;
an execution instruction module to: and processing the data to be processed according to the instruction of the dynamic structured query language in the data table.
7. The apparatus of claim 6, further comprising a primary key generation module to:
acquiring a sub-table field, and determining a hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the sub-table field;
acquiring an MAC address of a server, and determining a hash code value of the MAC address; dividing the hash code value of the MAC address by the remainder of the total number of the data table to serve as a serial number;
and generating a primary key according to the timestamp of the current time, the serial number, the database number and the data table number.
8. The apparatus of claim 6, wherein the primary key generation module is further configured to: the generated primary key sequentially comprises a sign bit, a 41-bit time stamp, an 8-bit serial number, a 6-bit database number and an 8-bit data table number.
9. The apparatus of claim 6, wherein the determine data table module is further configured to:
if the data to be processed does not carry the primary key, judging whether a sub-table field exists or not;
if the sub-table field exists, determining the hash code value of the sub-table field; dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to serve as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number;
and if the sub-table fields do not exist, circularly searching the data tables corresponding to the data to be processed in all the data tables.
10. The apparatus of claim 6, wherein the determine data table module is further configured to:
if the instruction of the dynamic structured query language is an instruction for modifying data or deleting data or querying data, and the data to be processed carries a main key, then:
determining a data table corresponding to the data to be processed according to the data table number in the primary key;
if the instruction of the dynamic structured query language is an instruction for adding data, then:
the data to be processed does not carry a primary key; acquiring a sub-table field, and determining a hash code value of the sub-table field; and dividing the hash code value of the sub-table field by the remainder of the total number of the data tables to be used as the data table number corresponding to the data to be processed, and determining the data table corresponding to the data to be processed according to the data table number.
11. 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-5.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201810979311.5A 2018-08-27 2018-08-27 Method and device for processing sub-table data Pending CN110866002A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810979311.5A CN110866002A (en) 2018-08-27 2018-08-27 Method and device for processing sub-table data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810979311.5A CN110866002A (en) 2018-08-27 2018-08-27 Method and device for processing sub-table data

Publications (1)

Publication Number Publication Date
CN110866002A true CN110866002A (en) 2020-03-06

Family

ID=69651137

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810979311.5A Pending CN110866002A (en) 2018-08-27 2018-08-27 Method and device for processing sub-table data

Country Status (1)

Country Link
CN (1) CN110866002A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704245A (en) * 2020-05-22 2021-11-26 北京沃东天骏信息技术有限公司 Database main key generation method, sub-table positioning method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001025962A1 (en) * 1999-10-05 2001-04-12 S.C. Medicarom Group S.R.L. Database organization for increasing performance by splitting tables
CN105005624A (en) * 2015-07-31 2015-10-28 天脉聚源(北京)传媒科技有限公司 Method and device for generating index document ID
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding
CN107633016A (en) * 2017-08-23 2018-01-26 阿里巴巴集团控股有限公司 Data processing method and device and electronic equipment
CN107818115A (en) * 2016-09-14 2018-03-20 苏宁云商集团股份有限公司 A kind of method and device of processing data table

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001025962A1 (en) * 1999-10-05 2001-04-12 S.C. Medicarom Group S.R.L. Database organization for increasing performance by splitting tables
CN105005624A (en) * 2015-07-31 2015-10-28 天脉聚源(北京)传媒科技有限公司 Method and device for generating index document ID
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding
CN107818115A (en) * 2016-09-14 2018-03-20 苏宁云商集团股份有限公司 A kind of method and device of processing data table
CN107633016A (en) * 2017-08-23 2018-01-26 阿里巴巴集团控股有限公司 Data processing method and device and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704245A (en) * 2020-05-22 2021-11-26 北京沃东天骏信息技术有限公司 Database main key generation method, sub-table positioning method and device

Similar Documents

Publication Publication Date Title
CN110019350B (en) Data query method and device based on configuration information
CN107704202B (en) Method and device for quickly reading and writing data
CN111190888A (en) Method and device for managing graph database cluster
CN110689268B (en) Method and device for extracting indexes
CN110471848B (en) Method and device for dynamically returning message
CN110795315A (en) Method and device for monitoring service
CN107844488B (en) Data query method and device
CN113761565B (en) Data desensitization method and device
CN111858621B (en) Method, apparatus, device and computer readable medium for monitoring business process
CN111949648B (en) Memory data caching system and data indexing method
CN110866002A (en) Method and device for processing sub-table data
CN113704245A (en) Database main key generation method, sub-table positioning method and device
CN109947736B (en) Method and system for real-time computing
CN110705271A (en) System and method for providing natural language processing service
CN109144991B (en) Method and device for dynamic sub-metering, electronic equipment and computer-storable medium
CN110866001A (en) Method and device for determining order to be processed
CN113495891B (en) Data processing method and device
CN112783914B (en) Method and device for optimizing sentences
CN111858586B (en) Data processing method and device
US20180046656A1 (en) Constructing filterable hierarchy based on multidimensional key
US10114864B1 (en) List element query support and processing
CN113704242A (en) Data processing method and device
CN107665241B (en) Real-time data multi-dimensional duplicate removal method and device
CN113220981A (en) Method and device for optimizing cache
CN113535768A (en) Production monitoring 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