A method and device for comparing differences in full data in the medical field
The medical data is stored in shards through the MurmurHash3 algorithm and sharding technology, and is combined with consistent hashing and information summary values for differential comparison, which solves the problem of low efficiency in massive data collection and comparison, and achieves efficient data processing and analyze.
Patent Information
- Application Number
- CN202410835353.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-26
AI Technical Summary
When faced with massive amounts of data, existing medical data collection technology has low efficiency in comparison and can easily lead to full program resources, complex CPU calculations, and cannot effectively handle the memory and CPU surge problems of tens of millions of data.
The MurmurHash3 algorithm is used to hash the unique keys of the data feature attributes, and the differences are compared after shard storage. The shard numbers are used to disperse the data into multiple CSV files, and secondary sharding and timing are performed when necessary. Range sharding, combined with consistent hashing algorithm and message digest value for difference detection.
It effectively avoids memory and CPU occupancy during data loading, improves the comparison efficiency of massive data, supports large data collection and analysis applications, and reduces program load and computational complexity.
Smart Images

Figure CN118394849B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of medical data processing, and in particular relates to a method and device for comparing differences in full amount of data in the medical field. Background Art
[0002] The existing medical institutions’ intranet deployed and applied HIS (Hospital Information System), PASS (Prescription Automatic Screening System) and other systems use Oracle, SQL Server, MySQL and other databases to store the generated medical data.
[0003] With the development of data fusion, data application, artificial intelligence and other directions, we are facing the demand for data collection, analysis, and application in medical institutions in different provinces and cities. Since medical institutions use intranet deployment systems, the external network cannot be accessed. In this way, the collection of medical data in the medical structure faces restrictions on the network, data security, non-leakage, and the collection process cannot affect the daily use of the system. This makes data collection face various challenges. In the existing data collection technology, the full amount of medical data snapshot in the main database is backed up to the backup database, and the full amount of data is read from the backup database through the standard interface of the JDBC (Jave Database Connectivity, API) program to access the database to export to the CSV file format and save it. Then the CSV file is transmitted to the dedicated network server of the Health and Health Bureau through the special network channel opened by the medical institution.
[0004] Since the HIS and PASS systems of many regional medical institutions are deployed on internal LANs, full data collection can only be done in the form of backup files, which are then transmitted to the dedicated network server of the Health Bureau. The above full data collection actions are repeated many times. It becomes very important to find out the changes (addition, deletion, modification) of the full data collected multiple times.
[0005] The commonly used solution is to store the current full data and the previous day's full data separately in two CSV files, read the two CSV files into two arrays, and then compare them. The comparison methods include: (1) calculating the difference based on DiffUtils.diff(). In practical applications, it may be necessary to consider the specific content and format of the CSV file to customize the comparison; (2) manually looping through the two arrays and manually comparing each element in the data. This method is simple but inefficient and suitable for situations with small amounts of data. When encountering massive amounts of data, this comparison method is directly abandoned; (3) using the streaming API call method in Java 8, namely List.stream().filter(i->list.contains(i)).collect(Collectors.toList()), which corresponds to: creating a stream from the List collection (a new feature introduced in JavaDevelopment kit 8), then using the filter filter to obtain those elements that also exist in another collection List, and finally putting the filtered elements into the new collection List.
[0006] The above commonly used solutions have great drawbacks, including: when a data table contains tens of millions of data and is exported as a single CSV file, loading the CSV file with tens of millions of data during comparison will easily cause the memory of the program service resources to be full, and the cyclic comparison will produce a time complexity of (o)N, and the crazy calculation of the CPU will cause the CPU to continue to soar. Summary of the invention
[0007] In view of the above, the purpose of the present invention is to provide a method and device for comparing the differences of the full amount of data in the medical field, and then perform difference comparison on the full amount of data after segmentation storage to avoid the program's memory and CPU being filled up when loading data.
[0008] To achieve the above-mentioned purpose of the invention, an embodiment provides a method for comparing differences in full data in the medical field, comprising the following steps:
[0009] Obtain the system properties in the public agreed specifications during the development of the medical data system, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system properties;
[0010] Obtain the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database by accessing the application program interface of the database based on the connection information of the backup database;
[0011] The shard value is calculated based on the total number of records and the modulus base. The MurmurHash3 algorithm is used to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number.
[0012] Locate similar data in the backup database by shard number, and extract similar data belonging to the same shard number into a CSV file, obtaining multiple CSV files at the same time;
[0013] Compare the differences between CSV files at different times corresponding to the same shard number.
[0014] Preferably, the method further comprises: when the data volume difference between the multiple CSV files obtained at the same time exceeds a set threshold, selecting the CSV file with a larger data volume for secondary division, including:
[0015] Extract another total number of records from a CSV file with a large amount of data, perform a hash calculation on the other total number of records based on the MurmurHash3 algorithm, and then take the hash value modulo the custom secondary sharding value to determine the secondary sharding number. Use the secondary sharding number to locate similar data in the backup database, and extract similar data belonging to the same secondary sharding number into a CSV file. In this way, a CSV file with a large amount of data can be divided into multiple CSV files for the second time.
[0016] Preferably, the method further comprises: performing Murmurhash3 calculation again on the hash value obtained for the first time to obtain a hash value calculated for the second time, and performing modulo calculation of the hash value calculated for the second time and the shard value to determine the shard number.
[0017] Preferably, the method further comprises: using a consistent hashing algorithm to sequentially map the hash value corresponding to each shard to the node corresponding to the hash ring; when adding or reducing a shard, determining two related shards corresponding to the added or reduced shard from the hash ring, re-moving the data corresponding to the two related shards, recalculating the corresponding hash value based on the moved data, and adjusting the shard number;
[0018] The two related shards corresponding to the added shards are the two shards adjacent to the added shards. At this time, the data corresponding to the two related shards that are relocated are the data of the two adjacent shards.
[0019] The two related shards corresponding to the reduction of shards refer to the two shards adjacent to the reduced shards. At this time, the data corresponding to the two re-moved related shards are the data of the reduced shards and the data of the two adjacent shards.
[0020] Preferably, the method also includes: adopting a time range sharding algorithm, taking a time field in a unique key representing a data feature attribute as a sharding field, setting a time sharding lower boundary value and a time sharding upper boundary value, and customizing and assembling an SQL query statement based on the set sharding value, time sharding lower boundary value, and time sharding upper boundary value, acquiring data by executing the SQL query statement and writing it into a CSV file corresponding to the sharding number.
[0021] Preferably, based on the system attributes, in addition to reading the connection information of the backup database and the modulus base of the CSV file from the backup database corresponding to the medical data system, the user name, password, database class type, and CSV file storage path are also read.
[0022] Preferably, when the medical data system is developed using the Spring framework, the system properties in the public convention specification during the development of the medical data system are obtained, including:
[0023] Start the Java application and load the public convention specification spring.properties file from the main function method entry. Based on the PropertiesConfiguration object, read the system properties from the spring.properties file and store them in the Map data structure object. The system properties are stored in KV key-value pairs.
[0024] The application program interface for accessing the database adopts the JDBC API interface added in the main function method body, and obtains the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database by executing SQL statements based on the connection information of the backup database.
[0025] Preferably, performing a difference comparison on CSV files at different times corresponding to the same shard number includes:
[0026] For two CSV files with the same shard number but at different times, first read the file content summary, convert the string corresponding to the file content summary into a representation mode, and then calculate the information summary value of the string. When the information summary values corresponding to the two CSV files are equal, it is considered that there is no difference between the two CSV files.
[0027] Preferably, performing a difference comparison on CSV files at different times corresponding to the same shard number also includes:
[0028] When the information summary values corresponding to the two CSV files are not equal, it is considered that there are differences between the two CSV files, and data comparison is performed, including: reading specific data from the two CSV files and storing them in two arrays respectively, and performing data difference comparison based on the two arrays to obtain difference results.
[0029] To achieve the above-mentioned purpose of the invention, an embodiment of the present invention further provides a device for comparing differences in full amount of data in the medical field, comprising:
[0030] The first acquisition module is used to obtain the system attributes in the public agreed specifications when the medical data system is developed, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system attributes;
[0031] A second acquisition module is used to obtain the total number of records of the full amount of data and a unique key representing a characteristic attribute of the data from the backup database by accessing the application program interface of the database and based on the connection information of the backup database;
[0032] The shard number determination module is used to calculate the shard value based on the total number of records and the modulus base, and the MurmurHash3 algorithm is used to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number;
[0033] The shard acquisition module is used to locate similar data in the backup database by shard number, and extract similar data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time;
[0034] The difference comparison module is used to compare the differences of CSV files at different times corresponding to the same shard number.
[0035] To achieve the above-mentioned purpose of the invention, an embodiment of the present invention also provides a computing device, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement the above-mentioned method for comparing differences in the full amount of data in the medical field.
[0036] To achieve the above-mentioned purpose of the invention, an embodiment of the present invention further provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned method for comparing the difference of the full amount of data in the medical field is implemented.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] The present invention is based on a string of unique keys representing data feature attributes, and adopts the MurmurHash3 algorithm and a modulus calculation based on the shard value to determine the shard number. The full data in the backup database is sharded based on the shard number, and the full data of the large data table can be stored in multiple CSV files after sharding, so that the memory and CPU of the file loader will not be directly full, which will cause the program process to freeze. The present invention can support applications in the fields of full data collection, data change difference comparison, data analysis, and the like. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0040] Figure 1 is a flow chart of a method for comparing differences in all amounts of data in the medical field provided by an embodiment;
[0041] Figure 2 It is a data sharding extraction flow chart for a medical data system developed with a spring framework provided in an embodiment;
[0042] Figure 3 is a difference comparison flow chart provided in the embodiment;
[0043] Figure 4 is a schematic diagram of the structure of a device for comparing differences in the entire amount of data in the medical field provided by an embodiment;
[0044] Figure 5 It is a schematic diagram of the structure of a computing device provided in an embodiment. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.
[0046] like Figure 1 As shown, the difference comparison method of the full amount of data in the medical field provided in the embodiment includes the following steps:
[0047] S1, obtain the system properties in the public agreed specifications when the medical data system is developed, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system properties.
[0048] The medical data system refers to the system used by medical institutions, including HIS, PASS, etc. It can be developed through the spring framework in Java applications, etc., and public conventions and specifications will be followed during development. The public conventions and specifications constrain system properties. The system properties include user name, password, database type, storage path of the CSV file that extracts data from the database, connection information of the system's corresponding backup database, etc.
[0049] When extracting full medical data from these medical data systems, since the system is deployed based on the intranet, it is also necessary to first back up the full medical data snapshot in the system's main database to the backup database, and then read the full data from the backup database to export it to a CSV file and save it.
[0050] In the embodiment, when the medical data system is developed using the spring framework, the system properties in the public convention specification when the medical data system is developed are obtained, such as Figure 2 As shown, it includes: starting the Java application to load the public convention specification spring.properties file from the main function method entrance, reading the system properties stored in the KV key-value pair from the spring.properties file based on the PropertiesConfiguration object, and storing the read KV field value (that is, the specific system property) in the Map data structure object. Among them, the PropertiesConfiguration object is a class in the Apache Configuration library that is specifically used to process the corresponding configuration information loaded by the properties file.
[0051] After obtaining the system properties, the specific system property values are read based on the system properties. Specifically, the connection information of the backup database corresponding to the medical data system and the modulus base mod of the CSV file are read through the KV field value in the Map data structure object. The username username, password password, database class type, and CSV file storage path, etc. can also be read.
[0052] S2, by accessing the application program interface of the database and based on the connection information of the backup database, obtain the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database.
[0053] In the backup database, the full amount of medical data is generally stored in the form of a table, which contains data characteristic attributes, such as name, age, diagnosis code, recording time, update time, medicine, follow-up status, etc. These data characteristic attributes are generally listed in the first row or column of the table, and each row and column is a data record.
[0054] Based on the storage characteristics of the above-mentioned full medical data, the total number of records totalNums of the full data and the unique key tiger_unique_key representing the characteristic attribute of the data are obtained from the backup database by accessing the application program interface of the database and based on the connection information of the backup database.
[0055] Specifically, Figure 2As shown, the JDBC API interface added to the main function method is used to obtain the total number of records of the full data and the unique key representing the data feature attribute from the backup database by executing SQL statements based on the connection information of the backup database. When obtaining the total number of records, execute the SQL statement select count (*) from table, which means selecting records from the data table and counting them. When obtaining the unique key of the data feature attribute, execute the SQL statement select (*)from table, which means obtaining the unique key of the data feature attribute from the data table, where the * indicates the selected content. An exemplary data table is shown in Table 1:
[0056] Table 1
[0057]
[0058] In Table 1, add_dt indicates the adding time, Upt_dt indicates the updating time, his_code indicates the code, and his_name indicates the name. According to Table 1, the unique key Key corresponding to tiger_unique_key is an irregular string, and how to horizontally segment the string is the key to the shard storage of the present invention.
[0059] S3, calculates the shard value based on the total number of records and the modulus base, and uses the MurmurHash3 algorithm to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number.
[0060] After obtaining the total number of records totalNums and the modulus base mod, the shard value n is calculated based on totalNums and mod. The formula is: totalNums%mod =n, where the symbol % is the rounding operator. In this way, the shard value n of the table can be obtained.
[0061] Since the unique key Key corresponding to tiger_unique_key is an irregular string, it is very critical to select a suitable hash function to process the unique key Key string of the entire table. The MD5 algorithm or the SHA-256 algorithm can provide sufficient distribution characteristics, but directly using these two algorithms to output will be complicated, so a certain part of the hash value is selected. Considering simplicity and practicality, the present invention chooses to use non-encrypted, high-performance Hash algorithms such as MurmurHash3 to perform efficient hash scenario calculations of strings, and the specific hash value hash_value = mmh3.hash(id_string), where id_string represents a string and mmh3.hash() represents the MurmurHash3 algorithm.
[0062] After calculating the hash value hash_value, you need to map it to the number of shards through modulo operation to obtain different shard numbers. Specifically, call the determine_shard function to calculate the shard number num_n=determine_shard(hash_value, n), where n represents the shard value. Assuming that the shard value n needs to be equal to 100, use modulo 100 to operate.
[0063] S4, locate the same type of data in the backup database by the shard number, and extract the same type of data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time.
[0064] After obtaining the shard number num_n, locate the same type of data in the backup database according to the shard number num_n, and extract the same type of data belonging to the same shard number num_n into a CSV file named table_date_num_n.csv. In this way, n CSV files are obtained at the same time. The file names of these n CSV files are different only in the num_n position. It should be noted that in order to ensure the uniformity of the file name, the num_n position will retain the same number of digits, for example, 5 digits, so that the num_n position can be 00001 for the first CSV file and 00011 for the 11th CSV file.
[0065] It should also be noted that n CSV files can be obtained in the same batch at different times. In this case, the date in the file name is different compared to the historical time, such as table_20100506_00001.csv and table_20100507_00001.csv representing the first CSV file.
[0066] During the research process, we found that the following problems may still occur: (1) During the shard extraction process, although the high-quality hash function of MurmurHash3 can disperse data well, the possibility of hash conflicts still needs to be considered; (2) When more shards are needed in the future, it may be necessary to recalculate the hash value to adapt to the new number of shards, which is a complex and costly operation; (3) Since the unique key is a complex string with a unique ID rather than a continuous string, the use of auto-incremental sharding will become more complicated; (4) In the sharding results obtained by sharding based on the Murmuhash3 algorithm, it is possible that the data will be distributed to a certain shard number, resulting in too much data in this table, that is, the difference in the amount of data between multiple CSV files obtained at the same time may exceed the set threshold, which may cause the program's memory and CPU to be fully utilized.
[0067] To solve the hash conflict problem of serial number (1), a low-conflict, high-quality Murmurhash3 hash function is used to effectively reduce the probability of conflict. If the probability of hash conflict increases, the unique field string will be hashed twice, that is, the hash value obtained for the first time will be subjected to Murmurhash3 calculation again to obtain the hash value calculated for the second time, and the hash value calculated for the second time will be modulo the shard value to determine the shard number.
[0068] In order to solve the problem of adding more slices to recalculate the hash value, which will cause complexity and high cost, a consistent hashing algorithm is used. The consistent hashing algorithm is a hash ring that can store 0 to 2. 32 -1, each calculated hash value is mapped to different nodes of the hash ring in sequence, for example, hava_value_1 is mapped to a certain position P of the hash ring, and then the first node corresponding to the shard number A is found clockwise from this position P, and the data is written to the CSV file of the shard number A. This is the process of consistent hash addressing. If a shard is suddenly added or reduced, the two related shards corresponding to the added shard or very few shards are determined from the hash ring. For example, when a shard needs to be added between node 1 and node 2, the shards corresponding to nodes 1 and 2 are the two related shards corresponding to the added shard. When the shard corresponding to node 3 needs to be reduced, the shards corresponding to nodes 2 and 4 are the two related shards corresponding to the reduced shard. At this time, the data corresponding to the two related shards is the shard data corresponding to nodes 2-4. At this time, the data corresponding to the two related shards needs to be moved again. Moving part of the data will not incur a large amount of data recalculation overhead. The corresponding hash value is recalculated based on the moved data and the corresponding shard number is adjusted.
[0069] To solve the problem of calculating the complexity of sharding based on a complex string unique ID in sequence number (3), a time range sharding algorithm can be used. Plan a time field such as add_dt or upt_dt in Table 1 as a sharding field, such as using a range based on the time field add_dt to perform sharding. The details are as follows: first plan the number of shards n, and set n time shard lower bound values lower_time and n time shard upper bound values upper_time, and then customize the assembly of SQL query statements, such as Select * from Table A 1 WHERE time shard field add_dt beteen time shard lower bound value low_time and time shard upper bound value upper_time; finally, access the database interface through the JDBC API to execute the corresponding SQL query statement to obtain the corresponding data and write it into the CSV file of the corresponding shard number.
[0070] In order to solve the problem of large data volume differences among multiple CSV files in sequence number (4), a multi-level hash strategy is used to perform a hash sharding on the data, and then hash again within each shard to further disperse the data and reduce the pressure on a single shard. Specifically, a CSV file with a large amount of data is selected for secondary partitioning, including: extracting another total record number totalNums' in the CSV file with a large amount of data, and performing a hash calculation based on the MurmurHash3 algorithm on the other total record number totalNums', taking the hash calculation result modulo the custom secondary sharding value to determine the secondary sharding number, locating the same type of data in the backup database through the secondary sharding number, and extracting the same type of data belonging to the same secondary sharding number into one CSV file, thereby realizing the secondary partitioning of a CSV file with a large amount of data into multiple CSV files.
[0071] S5, performing a difference comparison on the CSV files at different times corresponding to the same shard number.
[0072] In the embodiment, two CSV files corresponding to the same shard number at different times are compared for differences, for example, the CSV file table_20240530_00001.csv and the CSV file table_2024_0531_00001.csv are compared for differences. Figure 3 As shown, first read the file content summary, and convert the string corresponding to the file content summary into a representation mode, and then calculate the information summary value (such as Md5 value) of the string. When the information summary values corresponding to the two CSV files are equal, it is considered that there is no difference between the two CSV files. When the information summary values corresponding to the two CSV files are not equal, it is considered that there is a difference between the two CSV files, and perform data comparison, including: respectively reading the specific data in the two CSV files and storing them in two arrays, and performing data difference comparison based on the two arrays to obtain the difference result.
[0073] In the embodiment, the data difference comparison can be performed based on two arrays (a, b), and DiffUtils.diff(a, b) can be used to compare the data in the two arrays (a, b) to compare the differences between the two arrays, and to obtain the newly added, deleted, and updated data between the corresponding arrays. Among them, DiffUtils.diff(a, b) belongs to the tool method under the Java standard library.
[0074] Specifically, first, create a MessageDigest instance object, and use the md5 algorithm to create a FileInputStream file stream object according to the file storage path to read the content of the CSV file, define a buffer to store the read file blocks, and then define the number of bytes to record each time, loop through the read CSV file content and store it in the buffer until the file reading is completed, and close the corresponding file stream;
[0075] Then, calculate the summary of the read file content, get the corresponding byte array, convert the byte array into a hexadecimal string representation, and then use the string formatting method format method to convert each byte into a two-digit decimal number and fill it into the string buffer object Stringbuffer object accordingly;
[0076] Next, the string buffer object is calculated by Md5 to obtain the corresponding Md5 value, and the Md5 values of the two CSV files are judged to be the same. If they are the same, it is considered that the slice data of the same type is successfully compared at one time after the above MurmurHash3 algorithm and modulus operation, which greatly improves the efficiency of large data volume comparison, instead of the traditional one-to-one comparison of each row of records, resulting in a time complexity of O(n), and greatly reduces the program load and computing power.
[0077] If they are not the same, the contents of the CSV file are read through the FileInputStream file stream object and stored in the corresponding array List. The third-party library is introduced to use the DiffUtils.diff(a,b) method under the java-diff-utils package to calculate the difference to confirm the corresponding difference data and return the corresponding difference object Patch. The difference object Patch can be used to obtain the corresponding data rows that have been added, deleted, or modified.
[0078] like Figure 4As shown, the embodiment also provides a difference comparison device 40 for full data in the medical field, including a first acquisition module 41, a second acquisition module 42, a shard number determination module 43, a shard acquisition module 44, and a difference comparison module 45, wherein the first acquisition module 41 is used to obtain the system attributes in the public agreed specifications when the medical data system is developed, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system attributes; the second acquisition module 42 is used to obtain the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database by accessing the application program interface of the database and based on the connection information of the backup database; the shard number determination module 43 is used to calculate the shard value based on the total number of records and the modulus base, and use the MurmurHash3 algorithm to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number; the shard acquisition module 44 is used to locate the same type of data in the backup database through the shard number, and extract the same type of data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time; the difference comparison module 45 is used to perform difference comparison on CSV files corresponding to the same shard number at different times.
[0079] It should be noted that the device for comparing the difference of the full amount of data in the medical field provided in the above-mentioned embodiment should be illustrated by the division of the above-mentioned functional modules when performing the comparison of the difference of the full amount of data in the medical field. The above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the device for comparing the difference of the full amount of data in the medical field provided in the above-mentioned embodiment and the embodiment of the method for comparing the difference of the full amount of data in the medical field belong to the same concept. The specific implementation process is detailed in the embodiment of the method for comparing the difference of the full amount of data in the medical field, which will not be repeated here.
[0080] Based on the same inventive concept, an embodiment further provides a computing device, including a memory and one or more processors, wherein executable code is stored in the memory, and when the one or more processors execute the executable code, the method for comparing the difference of the full amount of data in the medical field is implemented, specifically including the following steps:
[0081] S1, obtaining the system attributes in the public agreed specifications during the development of the medical data system, and reading the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system attributes;
[0082] S2, by accessing the application program interface of the database and obtaining the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database based on the connection information of the backup database;
[0083] S3, calculates the shard value based on the total number of records and the modulus base, uses the MurmurHash3 algorithm to take the hash value of the unique key string and then takes the modulus with the shard value to determine the shard number;
[0084] S4, locate the same type of data in the backup database by shard number, and extract the same type of data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time;
[0085] S5, performing a difference comparison on the CSV files at different times corresponding to the same shard number.
[0086] like Figure 5 As shown, the computing device provided in the embodiment, at the hardware level, in addition to the processor and memory, also includes the hardware required for other services such as internal bus, network interface, memory, etc. The memory is a non-volatile memory, and the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the difference comparison method of the full amount of data in the medical field described in S1-S5 above. Of course, in addition to the software implementation, the present invention does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0087] Based on the same inventive concept, an embodiment further provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned method for comparing the difference of the full amount of data in the medical field is implemented, which specifically includes the following steps:
[0088] S1, obtaining the system attributes in the public agreed specifications during the development of the medical data system, and reading the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system attributes;
[0089] S2, by accessing the application program interface of the database and obtaining the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database based on the connection information of the backup database;
[0090] S3, calculates the shard value based on the total number of records and the modulus base, uses the MurmurHash3 algorithm to take the hash value of the unique key string and then takes the modulus with the shard value to determine the shard number;
[0091] S4, locate the same type of data in the backup database by shard number, and extract the same type of data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time;
[0092] S5, performing a difference comparison on the CSV files at different times corresponding to the same shard number.
[0093] In embodiments, computer-readable media include permanent and non-permanent, removable and non-removable media that may be implemented by any method or technology for information storage.
[0094] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for comparing differences in all data in the medical field, characterized in that: The following steps are involved: Obtain the system properties in the public agreed specifications during the development of the medical data system, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system properties; Obtain the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database by accessing the application program interface of the database and based on the connection information of the backup database; The shard value is calculated based on the total number of records and the modulus base. The MurmurHash3 algorithm is used to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number. Locate similar data in the backup database by shard number, and extract similar data belonging to the same shard number into a CSV file, obtaining multiple CSV files at the same time; Compare the differences between CSV files at different times corresponding to the same shard number, including: For two CSV files with different time periods corresponding to the same shard number, first read the file content summary, convert the string corresponding to the file content summary into a representation mode, and calculate the information summary value of the string. When the information summary values corresponding to the two CSV files are equal, it is considered that there is no difference between the two CSV files. When the information summary values corresponding to the two CSV files are not equal, it is considered that there are differences between the two CSV files, and data comparison is performed, including: reading specific data from the two CSV files and storing them in two arrays respectively, and performing data difference comparison based on the two arrays to obtain difference results.
2. The method for comparing differences in all data in the medical field according to claim 1, characterized in that: Also includes: When the data volume difference between multiple CSV files obtained at the same time exceeds the set threshold, the CSV file with the larger data volume is selected for secondary division, including: Extract another total number of records from a CSV file with a large amount of data, perform a hash calculation on the other total number of records based on the MurmurHash3 algorithm, and then take the hash value modulo the custom secondary sharding value to determine the secondary sharding number. Use the secondary sharding number to locate similar data in the backup database, and extract similar data belonging to the same secondary sharding number into a CSV file. In this way, a CSV file with a large amount of data can be divided into multiple CSV files for the second time.
3. The method for comparing differences in all data in the medical field according to claim 1, characterized in that: Also includes: The hash value obtained for the first time is calculated again by Murmurhash3 to obtain the hash value calculated for the second time, and the hash value calculated for the second time is modulo the shard value to determine the shard number.
4. The method for comparing differences in full data in the medical field according to claim 1, characterized in that: The method further includes: using a consistent hashing algorithm to sequentially map the hash value corresponding to each shard to the node corresponding to the hash ring; when adding or reducing a shard, determining two related shards corresponding to the added or reduced shard from the hash ring, re-moving the data corresponding to the two related shards, recalculating the corresponding hash value based on the moved data, and adjusting the shard number; The two related shards corresponding to the added shards are the two shards adjacent to the added shards. At this time, the data corresponding to the two related shards that are relocated are the data of the two adjacent shards. The two related shards corresponding to the reduction of shards refer to the two shards adjacent to the reduced shards. At this time, the data corresponding to the two re-moved related shards are the data of the reduced shards and the data of the two adjacent shards.
5. The method for comparing differences in full data in the medical field according to claim 1, characterized in that: Also includes: The time range sharding algorithm is adopted. A time field in the unique key representing the data feature attribute is used as the sharding field. The lower boundary value and the upper boundary value of the time sharding are set. The SQL query statement is assembled based on the set sharding value, the lower boundary value and the upper boundary value. The data is obtained by executing the SQL query statement and written into the CSV file corresponding to the sharding number.
6. The method for comparing differences in all data in the medical field according to claim 1, characterized in that: When the medical data system is developed using the Spring framework, obtain the system properties in the public conventions during the development of the medical data system, including: Start the Java application and load the public convention specification spring.properties file from the main function method entry. Based on the PropertiesConfiguration object, read the system properties from the spring.properties file and store them in the Map data structure object. The system properties are stored in KV key-value pairs. The application program interface for accessing the database adopts the JDBC API interface added in the main function method body, and obtains the total number of records of the full data and the unique key representing the characteristic attribute of the data from the backup database by executing SQL statements based on the connection information of the backup database.
7. A device for comparing differences in all data in the medical field, characterized in that: include: The first acquisition module is used to obtain the system attributes in the public agreed specifications when the medical data system is developed, and read the connection information of the backup database corresponding to the medical data system and the modulus base of the CSV file based on the system attributes; A second acquisition module is used to obtain the total number of records of the full amount of data and a unique key representing a characteristic attribute of the data from the backup database by accessing the application program interface of the database and based on the connection information of the backup database; The shard number determination module is used to calculate the shard value based on the total number of records and the modulus base, and the MurmurHash3 algorithm is used to take the hash value of the unique key string and then take the modulus with the shard value to determine the shard number; The shard acquisition module is used to locate similar data in the backup database by shard number, and extract similar data belonging to the same shard number into a CSV file, and obtain multiple CSV files at the same time; The difference comparison module is used to compare the differences of CSV files at different times corresponding to the same shard number, including: For two CSV files with different time periods corresponding to the same shard number, first read the file content summary, convert the string corresponding to the file content summary into a representation mode, and calculate the information summary value of the string. When the information summary values corresponding to the two CSV files are equal, it is considered that there is no difference between the two CSV files. When the information summary values corresponding to the two CSV files are not equal, it is considered that there are differences between the two CSV files, and data comparison is performed, including: reading specific data from the two CSV files and storing them in two arrays respectively, and performing data difference comparison based on the two arrays to obtain difference results.
8. A computing device comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the one or more processors execute the executable code, they are used to implement the method for comparing differences in full data in the medical field as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the method for comparing the difference of the full amount of data in the medical field described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Audio-video image-text recognition system
CN110674337A
Method and device for full data comparison based on database, equipment and storage medium
CN111177119A
Data exchange method and system based on full fragmentation and incremental log analysis
CN111339103A
Dynamic data difference comparison method and system
CN111949728A
File data feature extraction method and device and computing equipment
CN112015699A
