A multi-source data synchronous acquisition system and method
Through the multi-source data synchronous collection system, the methods of cache space allocation, data source connection, update time determination and timeliness window association are used to solve the problems of data accuracy, completeness and timeliness in big data collection and achieve efficient data collection. Collection and storage.
Patent Information
- Application Number
- CN202410157181.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-04
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-02-04
AI Technical Summary
It is difficult for existing big data collection technology to effectively ensure the accuracy, completeness and timeliness of data, especially when the Internet is flooded with a large amount of invalid data, resulting in a large amount of invalid data being stored in the database, occupying storage space and bringing data Difficulties in handling.
A multi-source data synchronous collection system and method is proposed, including a cache space allocation module, a data source connection module, an update time determination module, a timeliness window association module and a data comparison verification module. By pre-allocating cache space, connecting target data sources, determining Update time, associate aging window, and compare and verify data to ensure data accuracy and completeness.
It effectively ensures the accuracy, completeness and timeliness of the collected data, avoids the storage of invalid data, and improves the efficiency of data processing and storage utilization.
Smart Images

Figure CN117971847B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data technology, and in particular to a multi-source data synchronous acquisition system and method. Background Art
[0002] Big data technology is a general term for technologies used to collect, store, manage, analyze, display and visualize large-scale and complex data. It is widely used in cloud storage, distributed computing, data mining, machine learning and data visualization. The development of big data technology enables people to make full use of massive data in various fields to gain deeper insights and decision support. Big data collection technology is one of the main means of obtaining data in the field of big data technology. Efficient data collection is an important basis for ensuring the accuracy, integrity and timeliness of data. As we all know, the Internet is full of a large amount of invalid data, including false data, erroneous data and incomplete data. Indiscriminate collection of data from various data sources on the Internet will store a large amount of invalid data in the database, which will occupy a large amount of storage space and bring great difficulties to subsequent data processing and analysis. Summary of the invention
[0003] Based on the above problems, the present invention proposes a multi-source data synchronous acquisition system and method, which can effectively ensure the accuracy, completeness and timeliness of the collected data.
[0004] In view of this, a first aspect of the present invention proposes a multi-source data synchronous acquisition system, comprising:
[0005] A cache space allocation module, used for pre-allocating cache space for caching target data;
[0006] A data source connection module, used to connect to a plurality of pre-configured target data sources for collecting the target data;
[0007] An update time determination module, used to determine the update time of the target data in each of the target data sources;
[0008] A cache data writing module, used for collecting the target data from the target data source and writing it into the cache space;
[0009] A timeliness window association module, used to associate the target data collected from each target data source with the corresponding timeliness window according to the target data update time;
[0010] A data comparison and verification module is used to perform comparison and verification on the target data in each time window to determine the accuracy and completeness of the target data;
[0011] The data persistence module is used to persist the collected target data to the database according to the comparison and verification results.
[0012] A second aspect of the present invention provides a multi-source data synchronous acquisition method, comprising:
[0013] Pre-allocate cache space for caching target data;
[0014] Connecting to a plurality of target data sources pre-configured for collecting the target data;
[0015] Determine the target data update time in each of the target data sources;
[0016] Collecting the target data from the target data source and writing it into the cache space;
[0017] Associating the target data collected from each target data source to the corresponding time window according to the target data update time;
[0018] Performing comparative verification on the target data in each time window to determine the accuracy and completeness of the target data;
[0019] The collected target data is persisted to the database based on the comparison and verification results.
[0020] Preferably, the step of pre-allocating cache space for caching target data specifically includes:
[0021] Acquire a pre-configured structure corresponding to the target data, wherein the structure includes static attributes and dynamic attributes of the target data;
[0022] Constructing a first structure instance of the target data based on the structure;
[0023] configuring static properties of the target data in the first structure instance;
[0024] Calculate the maximum occupied space S_Struct of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute max ;
[0025] Get the number n of target data sources corresponding to the target data source ;
[0026] Calculate the cache space size S_Cache=n required to collect the target data source ×S_Struct max ;
[0027] A cache space whose size is equal to the cache space size S_Cache is allocated for collecting the target data.
[0028] Preferably, the step of calculating the maximum occupied space of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute specifically comprises:
[0029] Get the occupied space S_Static of the static attribute configured in the target data i , where i is 0 to n static Integer between -1, n static is the number of static attributes in the first structure instance;
[0030] Get the maximum occupied space of each dynamic attribute S_Dynamic that is pre-configured j , where j is 0 to n dynamic Integer between -1, n dynamic is the number of dynamic attributes in the first structure instance;
[0031] Calculate the maximum space occupied by the first structure instance:
[0032]
[0033] Preferably, before the step of associating the target data collected from each target data source with the corresponding timeliness window according to the target data update time, the method further includes:
[0034] Get the preset target data validity period T valid ;
[0035] Calculate the average change period T of the target data based on the historical data of the target data vari ; Set the target data valid time T valid Split into n window time windows, so that n window At the same time:
[0036]
[0037] Preferably, the average change period T of the target data is calculated based on the historical data of the target data. vari The steps specifically include:
[0038] Configuration for calculating the average change period T of the target data vari A reference property of the structure, wherein the reference property is one of the dynamic properties of the structure;
[0039] Obtain the data corresponding to the reference attribute in the historical target data of each target data source to construct a reference attribute time series Where n is the number of historical collections corresponding to the historical target data of the target data source, t1, t2, ..., t n Collect time series for target data of corresponding data source;
[0040] Generate the first time difference sequence Δt of the historical data time series 11 , Δt 12 ,…,Δt1 n-1 , the first time difference sequence Δt 11 , Δt 12 ,…,Δt1 n-1 Each time difference in is the difference between adjacent acquisition times in the target data acquisition time series;
[0041] Obtain a preset reference attribute error threshold d0;
[0042] Construct a second time difference sequence Δt21, Δt22, ..., Δt2 based on the reference attribute error threshold d0 m ;
[0043] Calculate the mean of the second time difference series:
[0044]
[0045] According to the average value T of the second time difference series of each target data source average Determine the average change period T vari .
[0046] Preferably, a second time difference sequence Δt21, Δt22, ... Δt2 is constructed based on the reference attribute error threshold d0. m The steps specifically include:
[0047] Configure a first temporary counting variable k and a second temporary counting variable l and initialize them to k=1 and l=1;
[0048] Traverse the reference attribute time series To do this:
[0049] Calculate the difference as well as
[0050] When Δd k ≥d0, let Δt2 l =Δt1 k , and let the values of the first temporary counting variable k and the second temporary counting variable l be accumulated by 1 respectively;
[0051] When Δd k <d0 and Δd k+1 ≥d0, let Δt2l =Δt1 k +Δt1 k+1 , and let the value of the first temporary count variable k be accumulated by 2, and the value of the second temporary count variable l be accumulated by 1;
[0052] The above steps are executed repeatedly until k>n.
[0053] Preferably, the step of performing comparative verification on the target data in each time window specifically includes:
[0054] Get the pre-configured clustering lower limit n min ;
[0055] Determine the number of target data sources in each aging window according to the target data update time of each target data source;
[0056] When the number of target data sources in any aging window is less than or equal to n min When , the target data of the corresponding target data source is discarded;
[0057] When the number of target data sources in any time window is greater than n min When the target data in the same time window is compared and verified.
[0058] Preferably, the step of performing comparative verification on target data within the same time window specifically includes:
[0059] Get the second structure corresponding to the target data in each aging window to perform the following steps:
[0060] Get the dynamic properties of each second structure;
[0061] Constructing a dynamic attribute vector of each second structure based on the dynamic attribute;
[0062] The density clustering algorithm is used to cluster the dynamic attribute vectors in the time window;
[0063] Determine the main cluster with the largest number of dynamic attribute vectors in the time window;
[0064] The target data corresponding to the dynamic attribute vectors contained in clusters other than the main cluster are discarded.
[0065] Preferably, the step of persisting the collected target data to the database according to the comparison and verification results specifically includes:
[0066] Calculating the centroid of the main cluster, where the centroid is the geometric center of each dynamic attribute vector in the main cluster;
[0067] determining a dynamic attribute vector having a minimum distance from the center of mass;
[0068] The target data corresponding to the dynamic attribute vector having the smallest distance from the central vector is persisted in the database.
[0069] The present invention proposes a multi-source data synchronous acquisition system and method, which pre-allocates a cache space for caching target data, connects multiple pre-configured target data sources for collecting the target data, determines the target data update time in each of the target data sources, collects the target data from the target data source and writes it into the cache space, associates the target data collected from each target data source with a corresponding time window according to the target data update time, performs comparative verification on the target data in each time window to determine the accuracy and completeness of the target data, and persists the collected target data to a database according to the comparative verification result, thereby effectively ensuring the accuracy, completeness and timeliness of the collected data. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 is a schematic diagram of a multi-source data synchronization acquisition system provided by an embodiment of the present invention;
[0071] Figure 2 The present invention provides a flowchart of a method for synchronously collecting multi-source data. DETAILED DESCRIPTION
[0072] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0073] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0074] In the description of the present invention, the term "multiple" refers to two or more. Unless otherwise clearly defined, the orientation or positional relationship indicated by the terms "upper", "lower", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation of the present invention. The terms "connection", "installation", "fixation", etc. should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. In addition, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first", "second", etc. can explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, the meaning of "multiple" is two or more.
[0075] In the description of this specification, the description of the terms "one embodiment", "some implementations", "specific embodiments", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0076] A multi-source data synchronous acquisition system and method provided according to some embodiments of the present invention will be described below with reference to the accompanying drawings.
[0077] like Figure 1 As shown, the first aspect of the present invention proposes a multi-source data synchronous acquisition system, comprising:
[0078] A cache space allocation module, used for pre-allocating cache space for caching target data;
[0079] A data source connection module, used to connect to a plurality of pre-configured target data sources for collecting the target data;
[0080] An update time determination module, used to determine the update time of the target data in each of the target data sources;
[0081] A cache data writing module, used for collecting the target data from the target data source and writing it into the cache space;
[0082] A timeliness window association module, used to associate the target data collected from each target data source with the corresponding timeliness window according to the target data update time;
[0083] A data comparison and verification module is used to perform comparison and verification on the target data in each time window to determine the accuracy and completeness of the target data;
[0084] The data persistence module is used to persist the collected target data to the database according to the comparison and verification results.
[0085] In the technical solution of the present invention, the target data is data with strong timeliness, such as weather data, commodity price data, and real-time traffic data. The target data source is a server that publicly provides the target data to the Internet or specific Internet users through a WEB (World Wide Web) page or an API (Application Programming Interface). Regardless of the type of data source, it usually contains the update time of the target data in the target data provided. In the technical solution of some embodiments of the present invention, the multi-source data synchronization acquisition system also includes:
[0086] An expired data judgment module, used to judge whether the target data in each target data source is expired data according to the update time of the target data;
[0087] The target data source marking module is used to mark the corresponding target data source in the cache data writing module to skip the current collection of the corresponding target data source when the target data in any target data source is expired data.
[0088] The expired data judgment module specifically includes:
[0089] An effective duration acquisition module is used to acquire a preset effective duration of target data, wherein the effective duration of target data corresponds to the target data, that is, a different effective duration of target data can be configured for each different target data;
[0090] A difference calculation module, used to calculate the difference between the current time and the target data update time;
[0091] The expired data is specifically used to determine that the target data is expired data when the difference is greater than the valid time length of the target data.
[0092] It should be known that in data visualization, usually only the latest target data collected last is displayed, but the change state of the target data is presented in combination with historical data within a period of time. Therefore, the effective duration of the target data can be configured as the duration corresponding to the historical data required for data visualization. Since data with strong timeliness have the characteristics of high frequency of change and short effective time, the target data may have changed significantly within the effective duration of the target data. In order to ensure the accuracy of the multi-source data comparison and verification results, it is necessary to perform comparison and verification on the target data with similar target data update time within the effective duration of the target data. In the technical solution of the present invention, the time period corresponding to the effective duration of the target data is configured as several continuous time periods as the time window to perform comparison and verification on the target data in each time window, and the time window is a number of continuous time periods obtained by dividing the time period corresponding to the effective duration of the target data according to pre-configured rules. That is, multiple time windows are connected end to end, and together constitute the time period corresponding to the effective duration of the target data. By adopting the technical solution of the present invention, when the number of target data sources corresponding to the same target data is relatively large, comparative verification can be performed directly according to the corresponding relationship between the target data update time and the time window, without performing a large amount of calculations to determine the adjacent relationship of the update time between the target data of different target data sources.
[0093] Preferably, the cache space allocation module specifically includes:
[0094] A structure acquisition module, used to acquire a pre-configured structure corresponding to the target data, wherein the structure includes static attributes and dynamic attributes of the target data;
[0095] A first structure instance construction module, used for constructing a first structure instance of the target data based on the structure;
[0096] A static attribute configuration module, used for configuring the static attributes of the target data in the first structure instance;
[0097] A maximum occupied space calculation module is used to calculate the maximum occupied space S_Struct of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute. max ;
[0098] The target data source quantity acquisition module is used to obtain the number n of target data sources corresponding to the target data. source ;
[0099] Cache space size calculation module, used to calculate the cache space size S_Cache=n required for collecting the target data source ×S_Struct max;
[0100] The cache space allocation module is specifically used to allocate a cache space whose size is equal to the cache space size S_Cache for collecting the target data.
[0101] Specifically, the static attribute of the target data is an attribute used to identify the target data, which does not change over time. The dynamic attribute of the target data is an attribute with timeliness that changes over time. In the technical solution of the present invention, different types of target data are distinguished by the static attributes of the target data. The same type of target data is associated with multiple target data sources. The present invention ensures the accuracy, completeness and timeliness of the target data by performing synchronous acquisition on multiple target data sources of the same type of target data. Taking weather data as the target data as an example, its structure is composed of the following attributes: {region: {country, province, city, county / district}, weather: {weather overview, temperature, humidity, wind speed}}. Of course, in the actual implementation process, the region in the weather forecast data may be represented by the grid number corresponding to the longitude and latitude coordinates, or it may be directly represented by the region name or other number. At the same time, for the convenience of representation, only some weather attributes are shown in the above structure. In the implementation process, it may also include attributes such as wind direction, rainfall, visibility, air pressure, etc., which will not be repeated here. It should be known that the above structure is only an example and does not limit the scope of protection of the present invention.
[0102] In the technical solution of the above-mentioned implementation, the cache space allocation module is specifically used to determine the first cache space address and the second cache space address in the cache space, so that the cache space size between the first cache space address and the second cache space address is equal to the cache space size S_Cache, and the first cache space address and the second cache space address are associated with the first structure instance for storage. Using the technical solution of this implementation, since the dynamic attributes of the first structure instance usually do not completely occupy the corresponding maximum occupied space, the maximum occupied space S_Struct of the first structure instance max It already contains a large enough redundant space, so it has strong fault tolerance and there is no need to allocate additional redundant space to prevent data overflow errors.
[0103] Preferably, the cache data writing module specifically includes:
[0104] A formatted data judgment module is used to judge whether the target data collected from each data source is formatted data, wherein the formatted data includes JSON (JavaScript Object Notation) format or XML (Extensible Markup Language) format, etc.;
[0105] A content identification module, used for performing content identification on the target data of any data source when the target data collected from the data source is unformatted data;
[0106] A corresponding relationship determination module, used to determine the corresponding relationship between the content in the target data and the attributes of the structure according to the content recognition result;
[0107] A standardization processing module, used for performing standardization processing on the content in the target data, wherein the standardization processing includes one or more of data type standardization processing, data unit standardization processing, value range standardization processing, and data format standardization processing, wherein the data type standardization processing specifically formats the data into one of character type, integer type, and floating point type, the data unit standardization processing specifically converts the data into a preset standard unit, such as converting a temperature value in Fahrenheit into a temperature value in Celsius, the value range standardization processing specifically maps the data to a preset standard range, such as mapping a relative humidity range of 0%-100% to a standard range of 0-1, and the data format standardization processing includes processing of character length, number of decimal places, etc.;
[0108] The second structure instance construction module is used to construct a second structure instance for storing target data of the data source.
[0109] In the technical solution of the above-mentioned implementation, the second structure instance construction module is also used to construct a second structure instance for storing the target data of the data source according to the correspondence between the pre-configured formatted data fields and the properties of the structure when the target data collected from any data source is formatted data. The data source of the target data is provided in the form of an API interface, and the target data provided by it is usually formatted data. According to the formatted data field description in the API interface document, the correspondence between the formatted data fields of the target data provided by it and the properties of the structure can be configured.
[0110] Preferably, the maximum occupied space calculation module specifically includes:
[0111] The static attribute occupied space acquisition module is used to obtain the occupied space S_Statici of the static attribute configured in the target data, where i is 0 to nstatic Integer between -1, n static is the number of static attributes in the first structure instance;
[0112] Dynamic attribute occupied space acquisition module, used to obtain the maximum occupied space S_Dynamic of each pre-configured dynamic attribute j , where j is 0 to n dynamic Integer between -1, n dynamic is the number of dynamic attributes in the first structure instance;
[0113] The maximum occupied space calculation module is specifically used to calculate the maximum occupied space of the first structure instance:
[0114]
[0115] Specifically, the space occupied by the static attribute is the actual space occupied by the configured attribute value. For example, when the attribute value of the static attribute "country" is "China", taking GBK (Chinese Internal Code Specification, Chinese character internal code extension specification) encoding as an example, the two Chinese characters "China" occupy a total of four bytes of storage space. The dynamic attribute is the maximum occupied space of each pre-configured dynamic attribute. For example, the dynamic attribute "temperature" will not be greater than 100 degrees Celsius at most, and will not be less than minus 100 degrees Celsius at least, so it can be stored using a signed character type (signedchar) that only occupies 1 byte. The value range of the signed character type is from -128 to 127, where the first two digits are the integer digits of the temperature, and the last digit is the decimal digit of the temperature.
[0116] Preferably, the multi-source data synchronous acquisition system further includes:
[0117] The effective time acquisition module is used to obtain the preset effective time T of the target data. valid ;
[0118] The average change period calculation module is used to calculate the average change period T of the target data based on the historical data of the target data. vari ;
[0119] The time window segmentation module is used to divide the effective time of the target data into valid Split into n window time windows, so that n window At the same time:
[0120]
[0121] Using the technical solution of the above embodiment, the average change period T of the target data is calculated based on the historical data of the target data. vari , and then according to the average change period T of the target data vari To determine the effective time T of the target data valid The number of time windows divided out from n window , which can avoid the problem of low accuracy of comparative verification results due to too large a time window, and also avoid the problem of too small a time window causing the target data to be too dispersed and unable to effectively perform comparative verification.
[0122] Preferably, the average change period calculation module specifically includes:
[0123] Reference attribute configuration module, used to configure the average change period T for calculating the target data vari A reference property of the structure, wherein the reference property is one of the dynamic properties of the structure;
[0124] A reference attribute time series construction module is used to obtain data corresponding to the reference attribute in the historical target data of each target data source to construct a reference attribute time series Where n is the number of historical collections corresponding to the historical target data of the target data source, t1, t2, ..., t n Collect time series for target data of corresponding data source;
[0125] The first time difference sequence generating module is used to generate the first time difference sequence Δt11, Δt12, ..., Δt1 of the historical data time series n-1 , the first time difference sequence Δt11, Δt12, ..., Δt1 n-1 Each time difference in is the difference between adjacent acquisition times in the target data acquisition time series;
[0126] An error threshold acquisition module is used to obtain a preset reference attribute error threshold d0;
[0127] A second time difference sequence construction module is used to construct a second time difference sequence Δt21, Δt22, ..., Δt2 based on the reference attribute error threshold d0 m ;
[0128] The average value calculation module is used to calculate the average value of the second time difference series:
[0129]
[0130] The average change period calculation module is specifically used to calculate the average value T of the second time difference series of each target data source. average Determine the average change period Tvari .
[0131] Usually, the target data in each target data source are updated in batches, that is, in each target data source, when it updates the data, it usually synchronizes and updates the data corresponding to each dynamic attribute in the structure. Therefore, from the perspective of the target data update time, the update cycle of each dynamic attribute is consistent, but the numerical change cycle of the dynamic attribute itself may be less than the update cycle, or it may be greater than the update cycle. In order to accurately reflect the timeliness of the target data, in the reference attribute configuration module, the dynamic attribute with a smaller change cycle should be selected as the reference attribute. In the technical scheme of the above-mentioned implementation method, in order to make the expression more concise, the historical collection times n of different target data sources are not specifically distinguished, and in actual applications, the historical collection times of different data sources may be the same or different. In the first time difference sequence generation module, Δt11=t2-t1, Δt12=t3-t2, and so on.
[0132] In the average change period calculation module, the average change period T vari It can be the average value T of the second time difference series of all target data sources average The value obtained by averaging again can also be the median or minimum value.
[0133] Preferably, the second time difference sequence construction module specifically includes:
[0134] A temporary counting variable configuration module, used to configure a first temporary counting variable k and a second temporary counting variable l and initialize them to k=1 and l=1;
[0135] A traversal module for traversing the reference attribute time series
[0136] Difference calculation module, used to calculate the difference as well as
[0137] Assignment module, used when Δd k ≥d0, let Δt2 l =Δt1 k , and let the values of the first temporary counting variable k and the second temporary counting variable l be accumulated by 1 respectively;
[0138] The assignment module is also used for when Δd k <d0 and Δd k+1 ≥d0, let Δt2 l =Δt1 k +Δt1 k+1, and let the value of the first temporary count variable k be accumulated by 2, and the value of the second temporary count variable l be accumulated by 1;
[0139] The loop module is used for cyclically calling the difference calculation module and the assignment module until k>n.
[0140] In the technical solution of the above embodiment, adding 1 to the values of the first temporary count variable k and the second temporary count variable l is specifically setting k=k+1, l=l+1. Similarly, adding 2 to the value of the first temporary count variable k is specifically setting k=k+2, and so on.
[0141] In the technical solution of the above embodiment, when Δd k <d0,Δd k+1 <d0 and Δd k+2 ≥d0, let Δt2 l =Δt1 k +Δt1 k+1 +Δt1 k+2 , and let the value of the first temporary count variable k be accumulated by 3, and the value of the second temporary count variable l be accumulated by 1, and so on. That is, in each loop string, set a count variable x such that:
[0142] When Δd k <d0,Δd k+1 <d0,…Δd k+x-1 <d0, and Δd k+x ≥d0, and let the value of the first temporary counting variable k be accumulated by x+1, and the value of the second temporary counting variable l be accumulated by 1, wherein x should satisfy k+x≤n.
[0143] Preferably, the data comparison and verification module specifically includes:
[0144] Cluster lower limit acquisition module, used to obtain the pre-configured cluster lower limit n min ;
[0145] A target data source quantity determination module, used to determine the number of target data sources in each time window according to the target data update time of each target data source;
[0146] The target data discarding module is used when the number of target data sources in any time window is less than or equal to n min When , the target data of the corresponding target data source is discarded;
[0147] The data comparison and verification module is specifically used to check if the number of target data sources in any time window is greater than n. min When the target data in the same time window is compared and verified.
[0148] In the technical solution of the above implementation, when the number of target data sources in any time window is less than or equal to n min When the number of target data sources in any time window is greater than n, the accuracy and completeness of the data collected from the target data source cannot be verified by data from a similar period. Therefore, the reliability of the data in the corresponding target data source is questionable and the data in the target data source is not saved. min When the target data in the same time window are compared with each other to verify their data accuracy and completeness, the target data that needs to be persisted in the database is determined.
[0149] Preferably, the data comparison and verification module also includes:
[0150] A second structure acquisition module, used to acquire a second structure corresponding to the target data in each aging window;
[0151] A dynamic property acquisition module, used to acquire the dynamic properties of each second structure;
[0152] A dynamic attribute vector construction module, used for constructing a dynamic attribute vector of each second structure based on the dynamic attribute;
[0153] A clustering module is used to cluster the dynamic attribute vectors in the time window using a density clustering algorithm;
[0154] A main cluster determination module, used to determine the main cluster with the largest number of dynamic attribute vectors in the time window;
[0155] The target data discarding module is used to discard the target data corresponding to the dynamic attribute vectors contained in clusters other than the main cluster.
[0156] Specifically, in the dynamic attribute vector construction module, after quantizing and normalizing the non-numerical dynamic attributes, each attribute value of the dynamic attribute is mapped to a vector space whose dimension value is equal to the attribute number of the dynamic attribute to obtain the dynamic attribute vector.
[0157] Preferably, in the clustering module, a density clustering algorithm such as DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is used to cluster the dynamic attribute vectors. In the density clustering algorithm, the Euclidean distance or cosine similarity between the dynamic attribute vectors is calculated by a distance function such as the Euclidean distance function or the cosine similarity function, and the distance between each dynamic attribute vector is measured by the Euclidean distance or cosine similarity between the dynamic attribute vectors.
[0158] In the technical solution of the above implementation, the dynamic attribute vectors are clustered by configuring the distance function and the clustering radius and then executing the density clustering algorithm, and finally forming several clusters containing one or more dynamic attribute vectors, wherein the cluster containing the most dynamic attribute vectors is the main cluster.
[0159] In the technical solutions of some embodiments of the present invention, the data comparison and verification module further includes:
[0160] A static property acquisition module, used to acquire the static properties of each second structure;
[0161] A static attribute comparison module, used for comparing the static attribute of the second structure with the static attribute of the first structure;
[0162] The target data elimination module is used to eliminate the target data corresponding to the second structure whose static attributes are inconsistent with the static attributes of the first structure.
[0163] Preferably, the data persistence module specifically includes:
[0164] A centroid calculation module, used to calculate the centroid of the main cluster, where the centroid is the geometric center of each dynamic attribute vector in the main cluster;
[0165] A dynamic attribute vector determination module, used to determine the dynamic attribute vector with the smallest distance from the mass center;
[0166] The data persistence module is specifically used to persist the target data corresponding to the dynamic attribute vector with the smallest distance from the central vector to the database.
[0167] In the technical solution of the above implementation, the centroid of the main cluster is also represented by a vector in the corresponding vector space, and the distance between the centroid and each dynamic attribute vector can be calculated by a Euclidean distance function or a cosine similarity function.
[0168] The integrity of the target data includes attribute integrity and attribute content integrity. The attribute integrity refers to whether the target content contains the content corresponding to all the attributes in the structure. When it lacks any attribute corresponding content in the structure, it is considered to have no attribute integrity, such as the lack of temperature data or humidity data in the weather data. The attribute integrity of the target data can be judged in the second structure instance construction module. The attribute content integrity represents the integrity of the content corresponding to the attribute value of the static attribute or dynamic attribute of the structure. It can be the case that the numerical data lacks the unit symbol, or the character data content is incomplete. For example, in the collected weather data, it is impossible to determine whether it is Fahrenheit or Celsius due to the lack of unit symbols, or the text description of the weather overview only contains "cloudy to overcast", and due to the lack of text, it is impossible to determine whether it is "cloudy to overcast" or "cloudy to sunny". For target data with a small amount of missing attribute content, it will be classified as a non-main cluster and discarded in the data comparison and verification module.
[0169] like Figure 2 As shown, the second aspect of the present invention proposes a multi-source data synchronous acquisition method, comprising:
[0170] Pre-allocate cache space for caching target data;
[0171] Connecting to a plurality of target data sources pre-configured for collecting the target data;
[0172] Determine the target data update time in each of the target data sources;
[0173] Collecting the target data from the target data source and writing it into the cache space;
[0174] Associating the target data collected from each target data source to the corresponding time window according to the target data update time;
[0175] Performing comparative verification on the target data in each time window to determine the accuracy and completeness of the target data;
[0176] The collected target data is persisted to the database based on the comparison and verification results.
[0177] In the technical solution of the present invention, the target data is data with strong timeliness, such as weather data, commodity price data, and real-time traffic data. The target data source is a server that publicly provides the target data to the Internet or specific Internet users through a WEB (World Wide Web) page or an API (Application Programming Interface). Regardless of the type of data source, it usually contains the update time of the target data in the target data provided. In the technical solution of some embodiments of the present invention, after the step of determining the update time of the target data in each of the target data sources, it also includes:
[0178] Determining whether the target data in each target data source is expired data according to the target data update time;
[0179] When the target data in any target data source is expired data, in the step of collecting the target data from the target data source and writing it into the cache space, the corresponding target data source is marked to skip the current collection of the corresponding target data source.
[0180] The step of judging whether the target data in each target data source is expired data according to the target data update time specifically includes:
[0181] Obtaining a preset target data validity period, wherein the target data validity period corresponds to the target data, that is, a different target data validity period can be configured for each different target data;
[0182] Calculate the difference between the current time and the target data update time;
[0183] When the difference is greater than the valid time of the target data, it is determined that the target data is expired data.
[0184] It should be known that in data visualization, usually only the latest target data collected last is displayed, but the change state of the target data is presented in combination with historical data within a period of time. Therefore, the effective duration of the target data can be configured as the duration corresponding to the historical data required for data visualization. Since data with strong timeliness have the characteristics of high frequency of change and short effective time, the target data may have changed significantly within the effective duration of the target data. In order to ensure the accuracy of the multi-source data comparison and verification results, it is necessary to perform comparison and verification on the target data with similar target data update time within the effective duration of the target data. In the technical solution of the present invention, the time period corresponding to the effective duration of the target data is configured as several continuous time periods as the time window to perform comparison and verification on the target data in each time window, and the time window is a number of continuous time periods obtained by dividing the time period corresponding to the effective duration of the target data according to pre-configured rules. That is, multiple time windows are connected end to end, and together constitute the time period corresponding to the effective duration of the target data. By adopting the technical solution of the present invention, when the number of target data sources corresponding to the same target data is relatively large, comparative verification can be performed directly according to the corresponding relationship between the target data update time and the time window, without performing a large amount of calculations to determine the adjacent relationship of the update time between the target data of different target data sources.
[0185] Preferably, the step of pre-allocating cache space for caching target data specifically includes:
[0186] Acquire a pre-configured structure corresponding to the target data, wherein the structure includes static attributes and dynamic attributes of the target data;
[0187] Constructing a first structure instance of the target data based on the structure;
[0188] configuring static properties of the target data in the first structure instance;
[0189] Calculate the maximum occupied space S_Struct of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute max ;
[0190] Get the number n of target data sources corresponding to the target data source ;
[0191] Calculate the cache space size S_Cache=n required to collect the target data source ×S_Struct max ;
[0192] A cache space whose size is equal to the cache space size S_Cache is allocated for collecting the target data.
[0193] Specifically, the static attribute of the target data is an attribute used to identify the target data, which does not change over time. The dynamic attribute of the target data is an attribute with timeliness that changes over time. In the technical solution of the present invention, different types of target data are distinguished by the static attributes of the target data. The same type of target data is associated with multiple target data sources. The present invention ensures the accuracy, completeness and timeliness of the target data by performing synchronous acquisition on multiple target data sources of the same type of target data. Taking weather data as the target data as an example, its structure is composed of the following attributes: {region: {country, province, city, county / district}, weather: {weather overview, temperature, humidity, wind speed}}. Of course, in the actual implementation process, the region in the weather forecast data may be represented by the grid number corresponding to the longitude and latitude coordinates, or it may be directly represented by the region name or other number. At the same time, for the convenience of representation, only some weather attributes are shown in the above structure. In the implementation process, it may also include attributes such as wind direction, rainfall, visibility, air pressure, etc., which will not be repeated here. It should be known that the above structure is only an example and does not limit the scope of protection of the present invention.
[0194] In the technical solution of the above-mentioned implementation, the step of allocating a cache space of a size equal to the cache space size S_Cache for collecting the target data is specifically to determine a first cache space address and a second cache space address in the cache space, so that the cache space size between the first cache space address and the second cache space address is equal to the cache space size S_Cache, and the first cache space address and the second cache space address are associated with the first structure instance for storage. Using the technical solution of this implementation, since the dynamic attributes of the first structure instance usually do not completely occupy the corresponding maximum occupied space, the maximum occupied space S_Struct of the first structure instance max It already contains a large enough redundant space, so it has strong fault tolerance and there is no need to allocate additional redundant space to prevent data overflow errors.
[0195] The step of collecting the target data from the target data source and writing it into the cache space specifically includes:
[0196] Determine whether the target data collected from each data source is formatted data, wherein the formatted data includes JSON (JavaScript Object Notation) format or XML (Extensible Markup Language) format, etc.;
[0197] When the target data collected from any data source is unformatted data, performing content recognition on the target data of the data source;
[0198] Determine the correspondence between the content in the target data and the attributes of the structure according to the content recognition result;
[0199] Performing standardization processing on the content in the target data, the standardization processing includes one or more of data type standardization processing, data unit standardization processing, value range standardization processing, and data format standardization processing, wherein the data type standardization processing specifically formats the data into one of character type, integer type, and floating point type, the data unit standardization processing specifically converts the data into a preset standard unit, such as converting a temperature value in Fahrenheit unit into a temperature value in Celsius unit, the value range standardization processing specifically maps the data to a preset standard range, such as mapping a relative humidity range of 0%-100% to a standard range of 0-1, and the data format standardization processing includes processing of character length, number of decimal places, etc.;
[0200] Construct a second structure instance for storing the target data of the data source.
[0201] In the technical solution of the above implementation mode, after the step of determining whether the target data collected from each data source is formatted data, the method further includes:
[0202] When the target data collected from any data source is formatted data, a second structure instance for storing the target data of the data source is constructed according to the correspondence between the pre-configured formatted data fields and the properties of the structure. The data source that provides the target data in the form of an API interface usually provides formatted data. According to the formatted data field description in the API interface document, the correspondence between the formatted data fields of the target data provided by the data source and the properties of the structure can be configured.
[0203] Preferably, the step of calculating the maximum occupied space of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute specifically comprises:
[0204] Get the occupied space S_Static of the static attribute configured in the target data i , where i is 0 to n static Integer between -1, n static is the number of static attributes in the first structure instance;
[0205] Get the maximum occupied space of each dynamic attribute S_Dynamic that is pre-configured j, where j is 0 to n dynamic Integer between -1, n dynamic is the number of dynamic attributes in the first structure instance;
[0206] Calculate the maximum space occupied by the first structure instance:
[0207]
[0208] Specifically, the space occupied by the static attribute is the actual space occupied by the configured attribute value. For example, when the attribute value of the static attribute "country" is "China", taking GBK (Chinese Internal Code Specification, Chinese character internal code extension specification) encoding as an example, the two Chinese characters "China" occupy a total of four bytes of storage space. The dynamic attribute is the maximum occupied space of each pre-configured dynamic attribute. For example, the dynamic attribute "temperature" will not be greater than 100 degrees Celsius at most, and will not be less than minus 100 degrees Celsius at least, so it can be stored using a signed character type (signedchar) that only occupies 1 byte. The value range of the signed character type is from -128 to 127, where the first two digits are the integer digits of the temperature, and the last digit is the decimal digit of the temperature.
[0209] Preferably, before the step of associating the target data collected from each target data source with the corresponding timeliness window according to the target data update time, the method further includes:
[0210] Get the preset target data validity period T valid ;
[0211] Calculate the average change period T of the target data based on the historical data of the target data vari ; Set the target data valid time T valid Split into n window time windows, so that n window At the same time:
[0212]
[0213] Using the technical solution of the above embodiment, the average change period T of the target data is calculated based on the historical data of the target data. vari , and then according to the average change period T of the target data vari To determine the effective time T of the target data valid The number of time windows divided out from n window , which can avoid the problem of low accuracy of comparative verification results due to too large a time window, and also avoid the problem of too small a time window causing the target data to be too dispersed and unable to effectively perform comparative verification.
[0214] Preferably, the average change period T of the target data is calculated based on the historical data of the target data. vari The steps specifically include:
[0215] Configuration for calculating the average change period T of the target data vari A reference property of the structure, wherein the reference property is one of the dynamic properties of the structure;
[0216] Obtain the data corresponding to the reference attribute in the historical target data of each target data source to construct a reference attribute time series Where n is the number of historical collections corresponding to the historical target data of the target data source, t1, t2, ..., t n Collect time series for target data of corresponding data source;
[0217] Generate the first time difference sequence Δt11, Δt12, ..., Δt1 of the historical data time series n-1 , the first time difference sequence Δt11, Δt12, ..., Δt1 n-1 Each time difference in is the difference between adjacent acquisition times in the target data acquisition time series;
[0218] Obtain a preset reference attribute error threshold d0;
[0219] Construct a second time difference sequence Δt21, Δt22, ..., Δt2 based on the reference attribute error threshold d0 m ;
[0220] Calculate the mean of the second time difference series:
[0221]
[0222] According to the average value T of the second time difference series of each target data source average Determine the average change period T vari .
[0223] Usually, the target data in this target data source are updated in batches, that is, in each target data source, when it updates the data, it usually synchronizes the data corresponding to each dynamic attribute in the structure. Therefore, from the perspective of target data update time, the update cycle of each dynamic attribute is consistent, but the value change cycle of the dynamic attribute itself may be less than or greater than the update cycle. In order to accurately reflect the timeliness of the target data, the average change cycle of the target data is calculated in the configuration.
[0224] T variIn the step of determining the dynamic attribute of the historical data, the dynamic attribute with a smaller change period should be selected as the reference attribute. In the technical solution of the above implementation, in order to make the expression more concise, the number of historical collection times n of different target data sources is not specifically distinguished, and in actual applications, the number of historical collection times of different data sources may be the same or different. In generating the first time difference sequence of the historical data time series
[0225] Δt11, Δt12, …, Δt1 n-1 In the steps, Δt11=t2-t1, Δt12=t3-t2, and so on.
[0226] According to the average value T of the second time difference series of each target data source average Determine the average change period T vari In the step, the average change period T vari It can be the average value T of the second time difference series of all target data sources average The value obtained by averaging again can also be the median or minimum value.
[0227] Preferably, a second time difference sequence Δt21, Δt22, ... Δt2 is constructed based on the reference attribute error threshold d0. m The steps specifically include:
[0228] Configure a first temporary counting variable k and a second temporary counting variable l and initialize them to k=1 and l=1;
[0229] Traverse the reference attribute time series To do this:
[0230] Calculate the difference as well as
[0231] When Δd k ≥d0, let Δt2 l =Δt1 k , and let the values of the first temporary count variable k and the second temporary count variable l be accumulated respectively 1 ;
[0232] When Δd k <d0 and Δd k+1 ≥d0, let Δt2 l =Δt1 k +Δt1 k+1 , and let the value of the first temporary count variable k be accumulated by 2, and the value of the second temporary count variable l be accumulated by 1;
[0233] The above steps are executed repeatedly until k>n.
[0234] In the technical solution of the above embodiment, adding 1 to the values of the first temporary count variable k and the second temporary count variable l is specifically setting k=k+1, l=l+1. Similarly, adding 2 to the value of the first temporary count variable k is specifically setting k=k+2, and so on.
[0235] In the technical solution of the above embodiment, when Δd k <d0,Δd k+1 <d0 and Δd k+2 ≥d0, let Δt2 l =ΔΔt1 k +Δt1 k+1 +Δt1 k+2 , and let the value of the first temporary count variable k be accumulated by 3, and the value of the second temporary count variable l be accumulated by 1, and so on. That is, in each loop string, set a count variable x such that:
[0236] When Δd k <d0,Δd k+1 <d0, ... Δd k+x-1 <d0, and Δd k+x ≥d0, and let the value of the first temporary counting variable k be accumulated by x+1, and the value of the second temporary counting variable l be accumulated by 1, wherein x should satisfy k+x≤n.
[0237] Preferably, the step of performing comparative verification on the target data in each time window specifically includes:
[0238] Get the pre-configured clustering lower limit n min ;
[0239] Determine the number of target data sources in each aging window according to the target data update time of each target data source;
[0240] When the number of target data sources in any aging window is less than or equal to n min When , the target data of the corresponding target data source is discarded;
[0241] When the number of target data sources in any time window is greater than n min When the target data in the same time window is compared and verified.
[0242] In the technical solution of the above implementation, when the number of target data sources in any time window is less than or equal to n min When the number of target data sources in any time window is greater than n, the accuracy and completeness of the data collected from the target data source cannot be verified by data from a similar period. Therefore, the reliability of the data in the corresponding target data source is questionable and the data in the target data source is not saved.min When the target data in the same time window are compared with each other to verify their data accuracy and completeness, the target data that needs to be persisted in the database is determined.
[0243] Preferably, the step of performing comparative verification on target data within the same time window specifically includes:
[0244] Get the second structure corresponding to the target data in each aging window to perform the following steps:
[0245] Get the dynamic properties of each second structure;
[0246] Constructing a dynamic attribute vector of each second structure based on the dynamic attribute;
[0247] The density clustering algorithm is used to cluster the dynamic attribute vectors in the time window;
[0248] Determine the main cluster with the largest number of dynamic attribute vectors in the time window;
[0249] The target data corresponding to the dynamic attribute vectors contained in clusters other than the main cluster are discarded.
[0250] Specifically, in the step of constructing the dynamic attribute vector of each second structure based on the dynamic attribute, after quantizing and normalizing the non-numerical dynamic attributes, each attribute value of the dynamic attribute is mapped to a vector space with a dimension value equal to the number of attributes of the dynamic attribute to obtain the dynamic attribute vector.
[0251] Preferably, in the step of clustering the dynamic attribute vectors in the time window, a density clustering algorithm such as DBSCAN (Density Based Spatiai Clustering of Applications with Noise) is used to cluster the dynamic attribute vectors. In the density clustering algorithm, the Euclidean distance or cosine similarity between the dynamic attribute vectors is calculated by a distance function such as the Euclidean distance function or the cosine similarity function, and the distance between each dynamic attribute vector is measured by the Euclidean distance or cosine similarity between the dynamic attribute vectors.
[0252] In the technical solution of the above implementation, the dynamic attribute vectors are clustered by configuring the distance function and the clustering radius and then executing the density clustering algorithm, and finally forming several clusters containing one or more dynamic attribute vectors, wherein the cluster containing the most dynamic attribute vectors is the main cluster.
[0253] In the technical solutions of some embodiments of the present invention, before the step of obtaining the dynamic properties of each second structure, the step further includes:
[0254] Get the static properties of each second structure;
[0255] comparing the static properties of the second structure with the static properties of the first structure;
[0256] Target data corresponding to a second structure whose static attributes are inconsistent with those of the first structure are eliminated.
[0257] Preferably, the step of persisting the collected target data to the database according to the comparison and verification results specifically includes:
[0258] Calculating the centroid of the main cluster, where the centroid is the geometric center of each dynamic attribute vector in the main cluster;
[0259] determining a dynamic attribute vector having a minimum distance from the center of mass;
[0260] The target data corresponding to the dynamic attribute vector having the smallest distance from the central vector is persisted in the database.
[0261] In the technical solution of the above implementation, the centroid of the main cluster is also represented by a vector in the corresponding vector space, and the distance between the centroid and each dynamic attribute vector can be calculated by a Euclidean distance function or a cosine similarity function.
[0262] The integrity of the target data includes attribute integrity and attribute content integrity. The attribute integrity refers to whether the target content contains the content corresponding to all the attributes in the structure. When any attribute corresponding content in the structure is missing, it is considered to have no attribute integrity, such as the lack of temperature data or humidity data in the weather data. The attribute integrity of the target data can be judged in the step of constructing a second structure instance for storing the target data of each target data source. The attribute content integrity represents the integrity of the content corresponding to the attribute value of the static attribute or dynamic attribute of the structure, which can be the case that the numerical data lacks a unit symbol, or the character data content is incomplete, such as the weather data collected, due to the lack of a unit symbol, it cannot be determined whether it is Fahrenheit or Celsius, or the text description of the weather overview only contains "cloudy to overcast", due to the lack of text, it cannot be determined whether it is "cloudy to overcast" or "cloudy to sunny", etc. For target data with a small amount of missing attribute content, it will be classified into a non-primary cluster and discarded in the step of performing comparison and verification on the target data in each time window.
[0263] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0264] According to the embodiments of the present invention as described above, these embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made based on the above description. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can make good use of the present invention and the modified use based on the present invention. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A multi-source data synchronous acquisition system, characterized in that: include: A cache space allocation module, used for pre-allocating cache space for caching target data; A data source connection module, used to connect to a plurality of pre-configured target data sources for collecting the target data; An update time determination module, used to determine the update time of the target data in each of the target data sources; A cache data writing module, used for collecting the target data from the target data source and writing it into the cache space; A timeliness window association module, used to associate the target data collected from each target data source with the corresponding timeliness window according to the target data update time; A data comparison and verification module is used to perform comparison and verification on the target data in each time window to determine the accuracy and completeness of the target data; The data persistence module is used to persist the collected target data to the database according to the comparison and verification results; The cache space allocation module specifically includes: A structure acquisition module, used to acquire a pre-configured structure corresponding to the target data, wherein the structure includes static attributes and dynamic attributes of the target data; A first structure instance construction module, used for constructing a first structure instance of the target data based on the structure; A static attribute configuration module, used for configuring the static attributes of the target data in the first structure instance; A maximum occupied space calculation module is used to calculate the maximum occupied space S_Struct of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute. max ; The target data source quantity acquisition module is used to obtain the number n of target data sources corresponding to the target data. source ; Cache space size calculation module, used to calculate the cache space size S_Cache=n required for collecting the target data source ×S_Struct max ; The cache space allocation module is specifically used to allocate a cache space with a size equal to the cache space size S_Cache for collecting the target data; The maximum occupied space calculation module specifically includes: The static attribute occupied space acquisition module is used to obtain the occupied space S_Static of the static attribute configured in the target data. i , where i is 0 to n static Integer between -1, n static is the number of static attributes in the first structure instance; Dynamic attribute occupied space acquisition module, used to obtain the maximum occupied space S_Dynamic of each pre-configured dynamic attribute j , where j is 0 to n dynamic Integer between -1, n dynamic is the number of dynamic attributes in the first structure instance; The maximum occupied space calculation module is specifically used to calculate the maximum occupied space of the first structure instance: The multi-source data synchronous acquisition system also includes: The effective duration acquisition module is used to obtain the preset effective duration T of the target data. valid ; The average change period calculation module is used to calculate the average change period T of the target data based on the historical data of the target data. vari ; The time window segmentation module is used to divide the effective time of the target data into valid Split into n window time windows, so that n window At the same time: The average change period calculation module specifically includes: Reference attribute configuration module, used to configure the average change period T for calculating the target data vari A reference property of the structure, wherein the reference property is one of the dynamic properties of the structure; A reference attribute time series construction module is used to obtain data corresponding to the reference attribute in the historical target data of each target data source to construct a reference attribute time series Where n is the number of historical collections corresponding to the historical target data of the target data source, t1, t2, ..., t n Collect time series for target data of corresponding data source; The first time difference sequence generating module is used to generate the first time difference sequence Δt11, Δt12, ..., Δt1 of the historical data time series n-1 , the first time difference sequence Δt11, Δt12, ..., Δt1 n-1 Each time difference in is the difference between adjacent acquisition times in the target data acquisition time series; An error threshold acquisition module is used to obtain a preset reference attribute error threshold d0; A second time difference sequence construction module is used to construct a second time difference sequence Δt21, Δt22, ..., Δt2 based on the reference attribute error threshold d0 m ; The average value calculation module is used to calculate the average value of the second time difference series: The average change period calculation module is specifically used to calculate the average value T of the second time difference series of each target data source. average Determine the average change period T vari ; The second time difference sequence construction module specifically includes: A temporary counting variable configuration module, used to configure a first temporary counting variable k and a second temporary counting variable l and initialize them to k=1 and l=1; A traversal module for traversing the reference attribute time series Difference calculation module, used to calculate the difference as well as Assignment module, used when Δd k ≥d0, let Δt2 l =Δt1 k , and let the values of the first temporary counting variable k and the second temporary counting variable l be accumulated by 1 respectively; The assignment module is also used for when Δd k <d0 and Δd k+1 ≥d0, let Δt2 l =Δt1 k +Δt1 k+1 , and let the value of the first temporary count variable k be accumulated by 2, and the value of the second temporary count variable l be accumulated by 1; A loop module, used for looping and calling the difference calculation module and the assignment module until k>n; The data comparison and verification module specifically includes: Cluster lower limit acquisition module, used to obtain the pre-configured cluster lower limit n min ; A target data source quantity determination module, used to determine the number of target data sources in each time window according to the target data update time of each target data source; The target data discarding module is used when the number of target data sources in any time window is less than or equal to n min When , the target data of the corresponding target data source is discarded; The data comparison and verification module is specifically used to check if the number of target data sources in any time window is greater than n. min When , comparative verification is performed on the target data within the same time window; The data comparison and verification module also includes: A second structure acquisition module, used to acquire a second structure corresponding to the target data in each aging window; A dynamic property acquisition module, used to acquire the dynamic properties of each second structure; A dynamic attribute vector construction module, used for constructing a dynamic attribute vector of each second structure based on the dynamic attribute; A clustering module is used to cluster the dynamic attribute vectors in the time window using a density clustering algorithm; A main cluster determination module, used to determine the main cluster with the largest number of dynamic attribute vectors in the time window; The target data discarding module is used to discard the target data corresponding to the dynamic attribute vectors contained in clusters other than the main cluster.
2. A method for synchronously collecting multi-source data, characterized in that: include: Pre-allocate cache space for caching target data; Connecting to a plurality of target data sources pre-configured for collecting the target data; Determine the target data update time in each of the target data sources; Collecting the target data from the target data source and writing it into the cache space; Associating the target data collected from each target data source to the corresponding time window according to the target data update time; Performing comparative verification on the target data in each time window to determine the accuracy and completeness of the target data; According to the comparison and verification results, the collected target data is persisted to the database; The steps of pre-allocating cache space for caching target data specifically include: Acquire a pre-configured structure corresponding to the target data, wherein the structure includes static attributes and dynamic attributes of the target data; Constructing a first structure instance of the target data based on the structure; configuring static properties of the target data in the first structure instance; Calculate the maximum occupied space S_Struct of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute max ; Get the number n of target data sources corresponding to the target data source ; Calculate the cache space size S_Cache=n required to collect the target data source ×S_Struct max ; Allocating a cache space of a size equal to the cache space size S_Cache for collecting the target data; The step of calculating the maximum occupied space of the first structure instance according to the occupied space of the static attribute and the maximum occupied space of the dynamic attribute specifically comprises: Get the occupied space S_Static of the static attribute configured in the target data i , where i is 0 to n static Integer between -1, n static is the number of static attributes in the first structure instance; Get the maximum occupied space of each dynamic attribute S_Dynamic that is pre-configured j , where j is 0 to n dynamic Integer between -1, n dynamic is the number of dynamic attributes in the first structure instance; Calculate the maximum space occupied by the first structure instance: Before the step of associating the target data collected from each target data source with the corresponding timeliness window according to the target data update time, the method further includes: Get the preset target data validity period T valid ; Calculate the average change period T of the target data based on the historical data of the target data vari ; The target data effective time T valid Split into n window time windows, so that n window At the same time: Calculate the average change period T of the target data based on the historical data of the target data vari The steps specifically include: Configuration for calculating the average change period T of the target data vari A reference property of the structure, wherein the reference property is one of the dynamic properties of the structure; Obtain the data corresponding to the reference attribute in the historical target data of each target data source to construct a reference attribute time series Where n is the number of historical collections corresponding to the historical target data of the target data source, t1, t2, ..., t n Collect time series for target data of corresponding data source; Generate a first time difference sequence Δt11, Δt12, ..., Δt1 of the historical data time series n-1 , the first time difference sequence Δt11, Δt12, ..., Δt1 n-1 Each time difference in is the difference between adjacent acquisition times in the target data acquisition time series; Obtain a preset reference attribute error threshold d0; Construct a second time difference sequence Δt21, Δt22, ..., Δt2 based on the reference attribute error threshold d0 m ; Calculate the mean of the second time difference series: According to the average value T of the second time difference series of each target data source average Determine the average change period T vari ; Construct a second time difference sequence Δt21, Δt22, ... Δt2 based on the reference attribute error threshold d0 m The steps specifically include: Configure a first temporary counting variable k and a second temporary counting variable l and initialize them to k=1 and l=1; Traverse the reference attribute time series To do this: Calculate the difference as well as When Δd k ≥d0, let Δt2 l =Δt1 k , and let the values of the first temporary counting variable k and the second temporary counting variable l be accumulated by 1 respectively; When Δd k <d0 and Δd k+1 ≥d0, let Δt2 l =Δt1 k +Δt1 k+1 , and let the value of the first temporary count variable k be accumulated by 2, and the value of the second temporary count variable l be accumulated by 1; Repeat the above steps until k>n; The steps for performing comparative verification on the target data in each time window specifically include: Get the pre-configured clustering lower limit n min ; Determine the number of target data sources in each aging window according to the target data update time of each target data source; When the number of target data sources in any aging window is less than or equal to n min When , the target data of the corresponding target data source is discarded; When the number of target data sources in any time window is greater than n min When , comparative verification is performed on the target data within the same time window; The steps for performing comparative verification on target data within the same time window specifically include: Get the second structure corresponding to the target data in each aging window to perform the following steps: Get the dynamic properties of each second structure; Constructing a dynamic attribute vector of each second structure based on the dynamic attribute; The density clustering algorithm is used to cluster the dynamic attribute vectors in the time window; Determine the main cluster with the largest number of dynamic attribute vectors in the time window; The target data corresponding to the dynamic attribute vectors contained in clusters other than the main cluster are discarded.
3. The multi-source data synchronous acquisition method according to claim 2, characterized in that: The steps of persisting the collected target data to the database according to the comparison and verification results specifically include: Calculating the centroid of the main cluster, where the centroid is the geometric center of each dynamic attribute vector in the main cluster; determining a dynamic attribute vector having a minimum distance from the center of mass; The target data corresponding to the dynamic attribute vector having the smallest distance from the central vector is persisted in the database.
Citation Information
Patent Citations
Target identification method and system based on multi-source spatiotemporal data combination
CN108573039A
Big data analysis method and system for multi-source aggregation structure
CN111400569A
Multi-source data acquisition method and device, electronic equipment and storage medium
CN112506910A
Real-time data acquisition method and device, electronic equipment and storage medium
CN114036160A
Multi-source atmospheric environment data fusion method and apparatus, terminal, and storage medium
WO2023206983A1
