MySQL-based sub-library and sub-table synchronization method, device, electronic device, and computer-readable storage medium

By parsing the synchronization instructions in the MySQL database, generating SQL instructions, merging the data and uploading it to HDFS, it solves the HDFS performance problem caused by too many small files in the MySQL database, achieves efficient synchronization and data storage of sub-databases and tables, and improves Hadoop. work efficiency.

CN113360470BActive Publication Date: 2024-10-11SHENZHEN ZHENAI JIEYUN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110571891.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-25
Publication Date
2024-10-11
Estimated Expiration
2041-05-25

AI Technical Summary

Technical Problem

In the MySQL database, the generation of massive small files has limited the scalability and performance of HDFS, and existing merging methods have efficiency and resource occupation problems before or after uploading. An efficient method for synchronizing databases and tables is needed. to solve this problem.

Method used

By obtaining synchronization instructions and configuration information, parsing placeholders, generating structured query language SQL instructions, initializing the thread pool, extracting and merging data, calling the HDFS interface to store data to the preset path, determining and updating partition information, and implementing data tables Synchronization and merging of sub-databases and sub-tables.

Benefits of technology

It simplifies the synchronization configuration of sub-databases and sub-tables, improves database synchronization efficiency, reduces the number of small files, improves the scalability and performance of HDFS, saves Yarn computing resources, and improves Hadoop work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113360470B_ABST
    Figure CN113360470B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, electronic device and computer-readable storage medium for synchronizing sub-libraries and sub-tables based on MySQL. The method comprises: obtaining synchronization instructions and configuration information; determining whether the synchronization instructions contain placeholders, and if so, parsing the synchronization instructions to extract the names of the libraries to be synchronized and the names of the tables to be synchronized to replace the placeholders, and obtaining multiple structured query language SQL instructions; initializing a thread pool, linking the target SQL database corresponding to the configuration information through the thread pool, and extracting multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; merging the multiple groups of table data to be synchronized to obtain at least one local synchronization file; calling a preset distributed file system HDFS interface to store the at least one local synchronization file to a preset path of a preset HDFS storage table. Implementing the embodiments of the present application is conducive to improving the working efficiency of the Hapood cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a MySQL-based sub-library and sub-table synchronization method, device, electronic device, and computer-readable storage medium. Background Art

[0002] With the advent of the big data era, data has shown explosive growth, and the problem of data storage has also arisen, thus promoting the research of a series of databases.

[0003] MySQL is a relational database management system. Relational databases increase data processing speed and flexibility by storing data in different tables. In actual applications, the massive database generated by MySQL will generate a large number of small files when uploading the distributed file system HDFS. Among them, HDFS (Hadoop Distributed File System) is the core subproject of the Hadoop project and the basis of data storage and management in distributed computing. A large number of small files seriously restrict the scalability and performance of HDFS, and thus restrict the work efficiency of Hadoop. Therefore, it is necessary to merge small files. At present, one processing method is to merge the data tables before uploading to HDFS. When merging data tables in MySQL, it is necessary to process them one by one according to the physical table. When merging two tables, reconfiguration is required, which makes subsequent maintenance difficult. Another processing method is to merge small files after uploading HDFS, but this processing method consumes a large amount of yarn computing resources in the Hadoop cluster, which restricts the work efficiency of Hadoop. Therefore, it is urgent to propose a MySQL-based sub-library and sub-table synchronization method. Summary of the invention

[0004] The embodiments of the present application provide a MySQL-based sub-library and sub-table synchronization method, device, electronic device, and computer-readable storage medium for synchronizing MySQL data tables and merging data tables before uploading them to HDFS.

[0005] In a first aspect, an embodiment of the present application provides a MySQL-based sub-library and sub-table synchronization method, including:

[0006] Get synchronization instructions and configuration information;

[0007] Determine whether the synchronization instruction contains a placeholder. If so, parse the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder to obtain multiple structured query language SQL instructions;

[0008] Initialize a thread pool, connect to a target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0009] Merging the multiple groups of table data to be synchronized to obtain at least one local synchronization file;

[0010] The preset distributed file system HDFS interface is called to store the at least one local synchronization file to a preset path of a preset HDFS storage table.

[0011] In one of the embodiments, the placeholder includes: a library placeholder and a table placeholder, and the parsing of the synchronization instruction to extract the library name to be synchronized and the table name to be synchronized to replace the placeholder includes: obtaining a library number interval from the synchronization instruction through a regular expression; obtaining a preset database prefix; cyclically extracting the library number as a database suffix within the library number interval, and generating the library name to be synchronized based on the database prefix and the database suffix; replacing the library placeholder of the synchronization instruction based on the library name to be synchronized to obtain the SQL instruction to be replaced; parsing the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced.

[0012] In one of the embodiments, the parsing of the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced includes: for each SQL instruction to be replaced, obtaining a table number interval from the SQL instruction to be replaced by using the regular expression; obtaining a preset data table prefix; cyclically extracting the table number as the data table suffix within the table number interval, and generating the table name to be synchronized based on the data table prefix and the data table suffix; replacing the table placeholder based on the table name to be synchronized to obtain the SQL instruction.

[0013] In one of the embodiments, after calling the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table, it also includes: determining whether the HDFS storage table is a partition table; if so, calling the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0014] In one of the embodiments, merging the multiple groups of table data to be synchronized to obtain at least one local synchronization file includes: writing the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool; generating a target file directory based on the multiple local files to be synchronized; traversing the target file directory, for any one of the multiple local files to be synchronized; determining whether the value of a file size counter of a preset linked list to be processed is less than a preset threshold; if the value is not less than the preset threshold, merging the files of the linked list to be processed as the local synchronization file, and initializing the linked list to be processed and the file size counter.

[0015] In one of the embodiments, it also includes: if the value is less than the preset threshold, obtaining the file size of any one of the synchronized local files; storing any one of the local files to be synchronized in the pending linked list, and updating the value based on the sum of the file size and the value.

[0016] In one of the embodiments, extracting the multiple groups of table data to be synchronized corresponding to the multiple SQL instructions further includes: generating an instruction linked list based on the multiple SQL instructions; using the instruction linked list as input of the thread pool to extract the multiple groups of table data to be synchronized, wherein the multiple groups of table data to be synchronized correspond to multiple threads of the thread pool.

[0017] In a second aspect, an embodiment of the present application provides a MySQL-based sub-library and sub-table synchronization device, including:

[0018] An acquisition unit, used for acquiring synchronization instructions and configuration information;

[0019] A replacement unit, used for determining whether the synchronization instruction contains a placeholder, and if so, parsing the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder, and obtaining a plurality of structured query language SQL instructions;

[0020] An extraction unit, used for initializing a thread pool, linking a target SQL database corresponding to the configuration information through the thread pool, and extracting multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0021] A merging unit, used for merging the plurality of sets of table data to be synchronized to obtain at least one local synchronization file;

[0022] A synchronization unit is used to call a preset HDFS interface to store the at least one local synchronization file in a preset path of a target storage table corresponding to the configuration information.

[0023] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program comprises instructions for executing some or all of the steps described in the method described in the first aspect of the embodiment of the present application.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, wherein the computer program is executed by a processor to implement part or all of the steps described in the method described in the first aspect of the embodiment of the present application.

[0025] It can be seen that in the embodiment of the present application, the electronic device obtains synchronization instructions and configuration information; determines whether the synchronization instruction contains a placeholder, and if so, parses the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and obtains multiple structured query language SQL instructions; initializes the thread pool, links the target SQL database corresponding to the configuration information through the thread pool, extracts multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; merges the multiple groups of table data to be synchronized to obtain at least one local synchronization file; calls the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table. In this way, multiple SQL instructions can be generated by replacing the placeholder in the synchronization instruction, so as to realize the extraction and merging of sub-libraries and sub-tables, simplify the synchronization configuration of sub-libraries and sub-tables, facilitate maintenance, and help improve the efficiency of database synchronization. At the same time, there is no need to maintain complex scripts, which is conducive to reducing operation and maintenance costs; at the same time, by merging local synchronization files and uploading them to HDFS, the number of small files is reduced, which is conducive to improving file query efficiency, improving the scalability and performance of HDFS, and saving Yarn computing resources, thereby helping to improve the work efficiency of Hadoop. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0027] Figure 1 This is an application environment architecture diagram of a MySQL-based sub-library and sub-table synchronization method provided in an embodiment of the present application;

[0028] Figure 2It is a flowchart of a MySQL-based sub-library and sub-table synchronization method provided in an embodiment of the present application;

[0029] Figure 3 It is a flowchart of another MySQL-based sub-library and sub-table synchronization method provided in an embodiment of the present application;

[0030] Figure 4 is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present application;

[0031] Figure 5 It is a structural diagram of a MySQL-based sub-library and sub-table synchronization device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present invention and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0034] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0035] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.

[0036] Electronic devices may include various handheld devices with wireless communication functions, vehicle-mounted devices, wearable devices (such as smart watches, smart bracelets, pedometers, etc.), computing devices or other processing devices connected to wireless modems, as well as various forms of user equipment (UE), mobile stations (MS), terminal devices, etc. For the convenience of description, the above-mentioned devices are collectively referred to as electronic devices.

[0037] See also Figure 1 , Figure 1 This is an application environment architecture diagram of a MySQL-based sub-library and sub-table synchronization method provided in an embodiment of the present application, wherein an electronic device 101 transmits data with a database 102 through a network, and the electronic device 101 receives synchronization instructions and configuration information, and determines whether the synchronization instruction contains a placeholder. If so, the synchronization instruction is parsed to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and a plurality of structured query language SQL instructions are obtained; the electronic device 101 initializes a thread pool, and through the thread pool, links to a target SQL database corresponding to the configuration information in the database 102, and extracts a plurality of groups of table data to be synchronized corresponding to the plurality of SQL instructions; through the thread pool, the plurality of groups of table data to be synchronized are merged to obtain at least one local synchronization file, and a preset distributed file system HDFS interface is called to store the at least one local synchronization file to a preset path of a preset HDFS storage table in a file server 103; it is determined whether the HDFS storage table is a partition table; if so, a Java database connection interface is called to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0038] The electronic device 101 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The file server 103 and the metadata database 104 may be implemented by an independent server or a server cluster consisting of multiple servers. Figure 2 , Figure 2 This is a flow chart of a MySQL-based sub-library and sub-table synchronization method provided in an embodiment of the present application. Figure 1 The terminal in is used as an example to illustrate, including the following steps:

[0039] Step 201: Acquire synchronization instructions and configuration information;

[0040] The configuration information includes but is not limited to: target SQL database link, target SQL database user name, target SQL database password, etc.

[0041] Wherein, the synchronization instruction is an executable SQL statement.

[0042] Step 202: determine whether the synchronization instruction contains a placeholder. If so, parse the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder, and obtain multiple structured query language SQL instructions.

[0043] Optionally, determine whether the synchronization instruction contains a placeholder, wherein the placeholder includes a sub-library placeholder and a sub-table placeholder. Determining whether the synchronization instruction contains a placeholder means determining whether the synchronization instruction contains a sub-library placeholder and / or a sub-table placeholder. If the synchronization instruction only contains a sub-library placeholder, the synchronization instruction is used to synchronize data tables with the same table number in different databases. If the synchronization instruction only contains a sub-table placeholder, the synchronization instruction is used to synchronize multiple data tables in the same database. If the synchronization instruction contains both the sub-library placeholder and the sub-table placeholder, the synchronization instruction is used to synchronize data tables with the same consecutive numbers in different databases. Optionally, the placeholder includes: a library placeholder and a table placeholder, and the parsing of the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder includes: obtaining a library number interval from the synchronization instruction through a regular expression; obtaining a preset database prefix; cyclically extracting the library number as a database suffix within the library number interval, and generating the library name to be synchronized based on the database prefix and the database suffix; replacing the library placeholder of the synchronization instruction based on the library name to be synchronized to obtain the SQL instruction to be replaced; parsing the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced.

[0044] Among them, the regular expression of the embodiment of the present application is a logical formula for operating on a string (including ordinary characters (for example, letters between a and z) and special characters (called "meta-characters")), that is, using some pre-defined specific characters and combinations of these specific characters to form a "regular string", and this "regular string" is used to express a filtering logic for the string.

[0045] Optionally, the library number interval is obtained from the synchronization instruction through a regular expression, that is, the library placeholder string in the synchronization instruction is filtered through a regular expression to extract the numbers contained in the library placeholder string, the first group of numbers extracted from the library placeholder is the starting number of the library number interval, the second group of numbers extracted from the library placeholder is the ending number of the library number interval, and the first group of numbers and the second group of numbers are distinguished by spaces in the library placeholder.

[0046] The database name consists of a database prefix and a database suffix. The database prefix is ​​the preset business library prefix. The business library prefix in SQL remains consistent, and the database suffix is ​​an integer.

[0047] Furthermore, the library numbers are cyclically extracted as database suffixes within the library number interval, including: starting from the starting number of the library number interval, through a for loop, the library numbers are sequentially obtained as database suffixes, and the database suffixes are concatenated with the database prefix to obtain a complete database name, that is, the name of the library to be synchronized.

[0048] The SQL instruction to be replaced includes a table placeholder.

[0049] In a specific implementation process, for example, the synchronization instruction is extracted as follows: select * from db_${0 9}.user_info_${0 999}, where the placeholder is ${}. In this synchronization instruction, the library placeholder is db_${0 9}, and the table placeholder is user_info_${0 999}. The library number interval (0 9) is extracted from the synchronization instruction through a regular expression, where the first digit of the library number interval, i.e., the starting number, is 0, and the second digit, i.e., the ending number, is 9. That is, in the library number interval, through a for loop, i.e., setting a variable x, x=0, under the condition that x is less than or equal to 9, setting x=x+1, and sequentially extracting each library number in the library number interval as a database suffix, assuming that the preset database prefix is ​​empty, i.e., the complete library name to be synchronized obtained by concatenation is the database number, and the library placeholder of the synchronization instruction is replaced based on the library name to be synchronized to obtain the SQL instruction to be replaced, i.e., 10 SQL instructions to be replaced are obtained, which are: select * from db_0.user_info_${0 999}, select * from db_1.user_info_${0 999}, …, select * from db_9.user_info_${0 999}, where the SQL instruction to be replaced contains the table placeholder.

[0050] Optionally, the parsing of the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced includes: for each SQL instruction to be replaced, obtaining a table number interval from the SQL instruction to be replaced by using the regular expression; obtaining a preset data table prefix; cyclically extracting the table number as the data table suffix within the table number interval, and generating the table name to be synchronized based on the data table prefix and the data table suffix; replacing the table placeholder based on the table name to be synchronized to obtain the SQL instruction.

[0051] Optionally, obtain the table number interval from the SQL instruction to be replaced through a regular expression, that is, filter the table placeholder string in the SQL instruction to be replaced through a regular expression, extract the numbers contained in the table placeholder string, the first group of numbers extracted from the table placeholder is the starting number of the table number interval, the second group of numbers extracted from the table placeholder is the ending number of the table number interval, and the first group of numbers and the second group of numbers are distinguished by spaces in the table placeholder.

[0052] Furthermore, the table numbers are cyclically extracted within the table number interval as data table suffixes, including: starting from the starting number of the table number interval, through a for loop, the table numbers are obtained in sequence as data table suffixes, and the data table suffixes are concatenated with the data table prefixes to obtain a complete data table name, that is, the name of the table to be synchronized.

[0053] Optionally, multiple names of tables to be synchronized may be determined based on the table placeholders, and the table placeholders in the SQL instruction to be replaced may be replaced in sequence based on the multiple names of the tables to be synchronized, so as to obtain the SQL instruction.

[0054] In the specific implementation process, for example, the synchronization instruction is extracted as: select * from db_${0 9}.user_info_${0 999}, and the library placeholder of the synchronization instruction is replaced based on the name of the library to be synchronized to obtain the SQL instruction to be replaced, that is, 10 SQL instructions to be replaced are obtained, which are: select * from db_0.user_info_${0 999}, select * from db_1.user_info_${0 999}, …, select * from db_9.user_info_${0 999}; then for each SQL instruction to be replaced, the table number interval (0 999), where the first digit of the table number interval, i.e., the starting number, is 0, and the second digit, i.e., the ending number, is 999. That is, in the table number interval, through a for loop, i.e., setting the variable x, x=0, under the condition that x is less than or equal to 999, setting x=x+1, each table number in the table number interval is sequentially extracted as the data table suffix. Assuming that the preset data table prefix is ​​empty, that is, the complete table name to be synchronized obtained by concatenation is the data table number. Based on the table name to be synchronized, the table placeholder of the SQL instruction to be replaced is replaced to obtain the SQL instruction, i.e., 10*1000 SQL instructions are obtained, which are: select * from db_0.user_info_0, select * from db_0.user_info_1, …, select * from db_9.user_info_999.

[0055] In this way, multiple executable SQL instructions can be generated by replacing the library placeholders and table placeholders in the synchronization instructions. Multiple executable SQL instructions can extract multiple table data in the sub-library and sub-table, thereby realizing the sub-library and sub-table synchronization configuration based on one instruction, solving the maintenance difficulty of synchronization scripts and synchronization configuration files, and improving the synchronization efficiency of sub-library and sub-table. Step 203, initialize the thread pool, link the target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0056] Optionally, extracting the multiple groups of table data to be synchronized corresponding to the multiple SQL instructions further includes: generating an instruction linked list based on the multiple SQL instructions; using the instruction linked list as input of the thread pool, and extracting the multiple groups of table data to be synchronized, wherein the multiple groups of table data to be synchronized correspond to multiple threads of the thread pool.

[0057] The multiple threads in the thread pool correspond one-to-one to the multiple SQL instructions, and any one of the threads executes and only executes one SQL instruction.

[0058] The corresponding SQL instruction is sent to the target SQL database through the thread to execute and obtain the table data to be synchronized corresponding to the SQL instruction.

[0059] Step 204: Merge the multiple groups of table data to be synchronized to obtain at least one local synchronization file;

[0060] Optionally, the merging of the multiple groups of table data to be synchronized to obtain at least one local synchronization file includes: writing the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool; generating a target file directory based on the multiple local files to be synchronized; traversing the target file directory, for any one of the multiple local files to be synchronized; determining whether the value of a file size counter of a preset linked list to be processed is less than a preset threshold; if the value is not less than the preset threshold, merging the files of the linked list to be processed as the local synchronization file, and initializing the linked list to be processed and the file size counter.

[0061] The multiple local files to be synchronized correspond to the multiple threads one by one.

[0062] Among them, any file to be synchronized uses the number of its corresponding thread as the file name to be synchronized.

[0063] Among them, generating a target file directory based on the multiple local files to be synchronized includes: extracting file links of the multiple local files to be synchronized, generating a target file directory based on the file links and file names, and linking to any local file to be synchronized based on the target file directory.

[0064] Among them, before traversing the target file directory, it is necessary to determine whether the threads in the thread pool are in a non-working state. If any thread is in a working state, the thread pool is in a working state. If every thread in the thread pool is in a non-working state, the thread pool is in a non-working state.

[0065] The file size counter is used to count the total file size of the files stored in the preset processing linked list.

[0066] The preset threshold may be 128MB, 256MB, 512MB, etc., which is not limited here.

[0067] Optionally, if the value is less than the preset threshold, obtain the file size of any one of the synchronized local files; store any one of the local files to be synchronized in the pending linked list, and update the value based on the sum of the file size and the value.

[0068] During the specific implementation process, assuming that the preset threshold is 256MB, when the first file to be synchronized is extracted, the file size of the first file to be synchronized is 100MB, and the value of the current file size counter is 200MB, the first file to be synchronized is stored in the pending linked list, and the value of the file size counter is updated to be the sum of the size of the first file to be synchronized and the current value, that is, 200+100=300MB; continue to traverse the target file directory, extract the second file to be synchronized, the file size of the second file to be synchronized is 30MB, at this time, the value of the file size counter is 300MB, which is greater than the preset threshold of 256MB, then extract the files to be synchronized in the current pending linked list for merging, and after obtaining the local synchronization file, initialize the file size counter, clear the pending linked list, and store the second file to be synchronized in the proxy processing linked list.

[0069] Step 205: Call a preset distributed file system HDFS interface to store the at least one local synchronization file in a preset path of a preset HDFS storage table.

[0070] Optionally, after calling a preset distributed file system HDFS interface to store the at least one local synchronization file in a preset path of a preset HDFS storage table, the method further includes: determining whether the HDFS storage table is a partition table;

[0071] Among them, a partition table divides the data of a table into multiple smaller and more manageable parts in a certain way, such as by month, but it is still a table logically.

[0072] If so, call the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0073] The metadata is data about other data, or structured data used to provide information about a resource. Metadata is data that describes objects such as information resources or data. Its purpose is to: identify resources; evaluate resources; track changes in resources during use; achieve simple and efficient management of large amounts of networked data; and achieve effective discovery, search, integrated organization of information resources and effective management of used resources.

[0074] Furthermore, Hive metadata is metadata stored in Hive tables. Hive is a data warehouse tool based on Hadoop that is used to extract, transform, and load data. It is a mechanism that can store, query, and analyze large-scale data stored in Hadoop. Hive can map structured data files to a database table and provide SQL query functions, which can convert SQL statements into MapReduce tasks for execution.

[0075] The partition information table includes but is not limited to: an SDS table, and the partition path field includes but is not limited to: a LOCATION field.

[0076] Among them, the Java Database Connectivity (JDBC) interface is an application program interface in the Java language that is used to regulate how client programs access the database, and provides methods such as querying and updating data in the database.

[0077] Among them, Hadoop Distributed File System (HDFS) refers to a distributed file system designed to run on commodity hardware.

[0078] In this way, small files are merged before the synchronized local files generated based on the MySQL data table are uploaded to the distributed file system, so as to avoid a large number of small files occupying too many resources in HDFS. At the same time, the merging of small files does not need to use the computing resources MapReduce of the offline data warehouse hive in HDFS, thus avoiding the occupation of yarn computing resources and helping to improve Hadoop work efficiency.

[0079] See also Figure 3 , Figure 3This is a flow chart of another method for synchronizing sub-libraries and sub-tables based on MySQL provided in an embodiment of the present application, which is applied to Figure 1 The electronic device shown is as shown in the figure:

[0080] Step 301: Acquire synchronization instructions and configuration information;

[0081] Step 302: determine whether the synchronization instruction contains a sub-library placeholder;

[0082] Step 303: If yes, parse the synchronization instruction to extract the name of the database to be synchronized, replace the sub-database placeholder based on the name of the database to be synchronized, obtain the SQL instruction to be replaced, and jump to step 304;

[0083] If the synchronization instruction does not contain a sub-library placeholder, directly jump to step 304;

[0084] Step 304: determine whether the synchronization instruction contains a table placeholder;

[0085] Step 305: If included, parse the information synchronization instruction to extract the name of the table to be synchronized, replace the sub-table placeholder based on the name of the table to be synchronized, and jump to step 306;

[0086] If not, jump directly to step 306;

[0087] Step 306: Generate one or more structured query language SQL instructions;

[0088] Step 307: Initialize a thread pool, connect to a target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0089] Step 308: Write the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool;

[0090] Step 309: Merge the multiple local files to be synchronized to obtain at least one local synchronization file;

[0091] Step 310: Call a preset distributed file system HDFS interface to store the at least one local synchronization file in a preset path of a preset HDFS storage table;

[0092] Step 311: Determine whether the HDFS storage table is a partition table;

[0093] Step 312: If yes, call the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0094] Thus, it can be seen that in the embodiment of the present application, the electronic device generates multiple executable SQL instructions based on one synchronization instruction by executing placeholder judgment and placeholder replacement on the synchronization instruction. At the same time, the synchronization of data tables across databases can be achieved through sub-library placeholders and sub-table placeholders, which solves the problem of complex script configuration required for cross-library data synchronization in the prior art. The target SQL database is linked through the configuration file, that is, when the target database is changed, the configuration can be changed by modifying the configuration file, which is easy to maintain; at the same time, by merging local synchronization files and uploading them to HDFS, the number of small files is reduced, which is beneficial to improving the scalability and performance of HDFS, while saving Yarn computing resources, and thus helping to improve the work efficiency of Hadoop.

[0095] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0096] See also Figure 4 , Figure 4 4 is a structural diagram of an electronic device 400 provided in an embodiment of the present application. As shown in the figure, the electronic device 400 includes: an application processor 410, a memory 420, a communication interface 430, and one or more programs 421, wherein the one or more programs 421 are stored in the above-mentioned memory 420 and are configured to be executed by the above-mentioned application processor 410, and the one or more programs 421 include instructions for performing the following steps:

[0097] Get synchronization instructions and configuration information;

[0098] Determine whether the synchronization instruction contains a placeholder. If so, parse the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder to obtain multiple structured query language SQL instructions;

[0099] Initialize a thread pool, connect to a target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0100] Merging the multiple groups of table data to be synchronized to obtain at least one local synchronization file;

[0101] The preset distributed file system HDFS interface is called to store the at least one local synchronization file to a preset path of a preset HDFS storage table.

[0102] It can be seen that in the embodiment of the present application, the electronic device obtains synchronization instructions and configuration information; determines whether the synchronization instruction contains a placeholder, and if so, parses the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and obtains multiple structured query language SQL instructions; initializes the thread pool, links the target SQL database corresponding to the configuration information through the thread pool, extracts multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; merges the multiple groups of table data to be synchronized to obtain at least one local synchronization file; calls the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table. In this way, multiple SQL instructions can be generated by replacing the placeholder in the synchronization instruction, so as to realize the extraction and merging of sub-libraries and sub-tables, simplify the synchronization configuration of sub-libraries and sub-tables, facilitate maintenance, and help improve the efficiency of database synchronization. At the same time, there is no need to maintain complex scripts, which is conducive to reducing operation and maintenance costs; at the same time, by merging local synchronization files and uploading them to HDFS, the number of small files is reduced, which is conducive to improving file query efficiency, improving the scalability and performance of HDFS, and saving Yarn computing resources, thereby helping to improve the work efficiency of Hadoop.

[0103] In a possible example, the placeholders include: a library placeholder and a table placeholder, the synchronization instruction is parsed to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and the one or more programs are used to execute the following steps: obtain a library number interval from the synchronization instruction through a regular expression; obtain a preset database prefix; cyclically extract the library number as a database suffix within the library number interval, and generate the library name to be synchronized based on the database prefix and the database suffix; replace the library placeholder of the synchronization instruction based on the library name to be synchronized to obtain the SQL instruction to be replaced; parse the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced.

[0104] In a possible example, the synchronization instruction is parsed to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced, and the one or more programs are used to execute the following steps: for each SQL instruction to be replaced, obtain the table number interval from the SQL instruction to be replaced by using the regular expression; obtain a preset data table prefix; cyclically extract the table number as the data table suffix within the table number interval, and generate the table name to be synchronized based on the data table prefix and the data table suffix; replace the table placeholder based on the table name to be synchronized to obtain the SQL instruction.

[0105] In a possible example, after calling the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table, the one or more programs are also used to execute the following steps: determine whether the HDFS storage table is a partition table; if so, call the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0106] In a possible example, the merging of the multiple groups of table data to be synchronized obtains at least one local synchronization file, and the one or more programs are used to execute the following steps: writing the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool; generating a target file directory based on the multiple local files to be synchronized; traversing the target file directory, for any one of the multiple local files to be synchronized; determining whether the value of a file size counter of a preset linked list to be processed is less than a preset threshold; if the value is not less than the preset threshold, merging the files of the linked list to be processed as the local synchronization file, and initializing the linked list to be processed and the file size counter.

[0107] In a possible example, the one or more programs are also used to execute the following steps: if the value is less than the preset threshold, obtain the file size of any one of the synchronized local files; store any one of the local files to be synchronized in the pending linked list, and update the value based on the sum of the file size and the value.

[0108] In a possible example, the multiple groups of table data to be synchronized corresponding to the multiple SQL instructions are extracted, and the one or more programs are also used to execute the following steps: generating an instruction linked list based on the multiple SQL instructions; using the instruction linked list as input to the thread pool, extracting the multiple groups of table data to be synchronized, wherein the multiple groups of table data to be synchronized correspond to multiple threads of the thread pool.

[0109] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0110] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into a control unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0111] See also Figure 5 , Figure 5 1 is a schematic diagram of the structure of a MySQL-based sub-library and sub-table synchronization device provided in an embodiment of the present application, including: an acquisition unit 501, a replacement unit 502, an extraction unit 503, a merging unit 504, and a synchronization unit 505, wherein:

[0112] An acquisition unit 501 is used to acquire synchronization instructions and configuration information;

[0113] The replacement unit 502 is used to determine whether the synchronization instruction contains a placeholder. If so, parse the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, so as to obtain multiple structured query language SQL instructions;

[0114] An extraction unit 503 is used to initialize a thread pool, connect to a target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions;

[0115] A merging unit 504 is used to merge the multiple groups of table data to be synchronized to obtain at least one local synchronization file;

[0116] The synchronization unit 505 is used to call a preset HDFS interface to store the at least one local synchronization file to a preset path of the target storage table corresponding to the configuration information.

[0117] It can be seen that in the embodiment of the present application, the electronic device obtains synchronization instructions and configuration information; determines whether the synchronization instruction contains a placeholder, and if so, parses the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and obtains multiple structured query language SQL instructions; initializes the thread pool, links the target SQL database corresponding to the configuration information through the thread pool, extracts multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; merges the multiple groups of table data to be synchronized to obtain at least one local synchronization file; calls the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table. In this way, multiple SQL instructions can be generated by replacing the placeholder in the synchronization instruction, so as to realize the extraction and merging of sub-libraries and sub-tables, simplify the synchronization configuration of sub-libraries and sub-tables, facilitate maintenance, and help improve the efficiency of database synchronization. At the same time, there is no need to maintain complex scripts, which is conducive to reducing operation and maintenance costs; at the same time, by merging local synchronization files and uploading them to HDFS, the number of small files is reduced, which is conducive to improving file query efficiency, improving the scalability and performance of HDFS, and saving Yarn computing resources, thereby helping to improve the work efficiency of Hadoop.

[0118] In a possible example, the placeholder includes: a library placeholder and a table placeholder, and the synchronization instruction is parsed to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholder, and the replacement unit 502 is specifically used to: obtain the library number interval from the synchronization instruction through a regular expression; obtain a preset database prefix; cyclically extract the library number as the database suffix within the library number interval, and generate the library name to be synchronized based on the database prefix and the database suffix; replace the library placeholder of the synchronization instruction based on the library name to be synchronized to obtain the SQL instruction to be replaced; parse the synchronization instruction to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced.

[0119] In a possible example, the synchronization instruction is parsed to extract the table name to be synchronized to replace the table placeholder of the SQL instruction to be replaced, and the replacement unit 502 is specifically used to: for each SQL instruction to be replaced, obtain a table number interval from the SQL instruction to be replaced by using the regular expression; obtain a preset data table prefix; cyclically extract the table number as the data table suffix within the table number interval, and generate the table name to be synchronized based on the data table prefix and the data table suffix; replace the table placeholder based on the table name to be synchronized to obtain the SQL instruction.

[0120] In a possible example, after calling the preset distributed file system HDFS interface to store the at least one local synchronization file to the preset path of the preset HDFS storage table, the synchronization unit 505 is specifically used to: determine whether the HDFS storage table is a partition table; if so, call the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

[0121] In a possible example, the merging of the multiple groups of table data to be synchronized obtains at least one local synchronization file, and the merging unit 504 is specifically used to: write the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool; generate a target file directory based on the multiple local files to be synchronized; traverse the target file directory, for any one of the multiple local files to be synchronized; determine whether the value of the file size counter of the preset linked list to be processed is less than a preset threshold; if the value is not less than the preset threshold, merge the files of the linked list to be processed as the local synchronization file, and initialize the linked list to be processed and the file size counter.

[0122] In a possible example, the merging unit 504 is also used to: if the value is less than the preset threshold, obtain the file size of any one of the synchronized local files; store any one of the local files to be synchronized in the pending linked list, and update the value based on the sum of the file size and the value.

[0123] In a possible example, the extraction unit 503 is further used to: generate an instruction linked list based on the multiple SQL instructions; and use the instruction linked list as input to the thread pool to extract the multiple groups of table data to be synchronized, wherein the multiple groups of table data to be synchronized correspond to multiple threads of the thread pool.

[0124] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method recorded in the above method embodiments, and the above computer includes an electronic device.

[0125] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.

[0126] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0127] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0128] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0129] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0130] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0131] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0132] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0133] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A MySQL-based sub-library and sub-table synchronization method, characterized in that: include: Get synchronization instructions and configuration information; Determine whether the synchronization instruction contains a placeholder. If so, parse the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder to obtain multiple structured query language SQL instructions; Initialize a thread pool, connect to a target SQL database corresponding to the configuration information through the thread pool, and extract multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; Merging the multiple groups of table data to be synchronized to obtain at least one local synchronization file; Calling a preset distributed file system HDFS interface to store the at least one local synchronization file to a preset path of a preset HDFS storage table; The placeholders include: library placeholders and table placeholders, and the parsing of the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholders includes: Obtaining a library number interval from the synchronization instruction by using a regular expression; Get the preset database prefix; Circularly extracting library numbers in the library number interval as database suffixes, and generating the name of the library to be synchronized based on the database prefix and the database suffix; Replace the library placeholder of the synchronization instruction based on the name of the library to be synchronized to obtain the SQL instruction to be replaced; Parse the synchronization instruction to extract the name of the table to be synchronized and replace the table placeholder of the SQL instruction to be replaced; The step of parsing the synchronization instruction to extract the name of the table to be synchronized and replace the table placeholder of the SQL instruction to be replaced includes: For each of the SQL instructions to be replaced, obtaining a table number interval from the SQL instruction to be replaced by using the regular expression; Get the preset data table prefix; Circularly extracting table numbers in the table number interval as data table suffixes, and generating the name of the table to be synchronized based on the data table prefix and the data table suffix; The table placeholder is replaced based on the name of the table to be synchronized to obtain the SQL instruction.

2. The method according to claim 1, characterized in that After calling the preset distributed file system HDFS interface to store the at least one local synchronization file in the preset path of the preset HDFS storage table, the method further includes: Determine whether the HDFS storage table is a partition table; If so, call the Java database connection interface to update the preset path to the partition path field of the partition information table of the Hive metadata database.

3. The method according to claim 1, characterized in that The merging of the multiple groups of table data to be synchronized to obtain at least one local synchronization file includes: Writing the multiple groups of table data to be synchronized into multiple local files to be synchronized through multiple threads of the thread pool; Generate a target file directory based on the multiple local files to be synchronized; Traverse the target file directory, targeting any local file to be synchronized among the multiple local files to be synchronized; Determine whether the value of the file size counter of the preset to-be-processed linked list is less than a preset threshold; If the value is not less than the preset threshold, the files in the to-be-processed linked list are merged as the local synchronization files, and the to-be-processed linked list and the file size counter are initialized.

4. The method according to claim 3, characterized in that Also includes: If the value is less than the preset threshold, obtaining the file size of any one of the local files to be synchronized; Any one of the to-be-synchronized local files is stored in the to-be-processed linked list, and the value is updated based on the sum of the file size and the value.

5. The method according to claim 1, characterized in that The extracting of the multiple groups of table data to be synchronized corresponding to the multiple SQL instructions also includes: Generate an instruction chain list based on the multiple SQL instructions; The instruction linked list is used as the input of the thread pool to extract the multiple groups of table data to be synchronized, wherein the multiple groups of table data to be synchronized correspond to the multiple threads of the thread pool.

6. A MySQL-based sub-library and sub-table synchronization device, characterized in that: include: An acquisition unit, used for acquiring synchronization instructions and configuration information; A replacement unit, used for determining whether the synchronization instruction contains a placeholder, and if so, parsing the synchronization instruction to extract the name of the to-be-synchronized library and the name of the to-be-synchronized table to replace the placeholder, and obtaining a plurality of structured query language SQL instructions; An extraction unit, used for initializing a thread pool, linking a target SQL database corresponding to the configuration information through the thread pool, and extracting multiple groups of table data to be synchronized corresponding to the multiple SQL instructions; A merging unit, used for merging the plurality of sets of table data to be synchronized to obtain at least one local synchronization file; A synchronization unit, configured to call a preset HDFS interface to store the at least one local synchronization file to a preset path of a target storage table corresponding to the configuration information; The placeholders include: library placeholders and table placeholders. In the aspect of parsing the synchronization instruction to extract the name of the library to be synchronized and the name of the table to be synchronized to replace the placeholders, the replacement unit is specifically used to: Obtaining a library number interval from the synchronization instruction by using a regular expression; Get the preset database prefix; Circularly extracting library numbers in the library number interval as database suffixes, and generating the name of the library to be synchronized based on the database prefix and the database suffix; Replace the library placeholder of the synchronization instruction based on the name of the library to be synchronized to obtain the SQL instruction to be replaced; Parse the synchronization instruction to extract the name of the table to be synchronized and replace the table placeholder of the SQL instruction to be replaced; Wherein, in the aspect of parsing the synchronization instruction to extract the name of the table to be synchronized and replace the table placeholder of the SQL instruction to be replaced, the replacement unit is specifically used to: For each of the SQL instructions to be replaced, obtaining a table number interval from the SQL instruction to be replaced by using the regular expression; Get the preset data table prefix; Circularly extracting table numbers in the table number interval as data table suffixes, and generating the name of the table to be synchronized based on the data table prefix and the data table suffix; The table placeholder is replaced based on the name of the table to be synchronized to obtain the SQL instruction.

7. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 5.