Data processing method and device, processing equipment, computer storage medium and program product
By combining fixed patterns and adaptive arithmetic coding, and using neural network models to predict local character probability distributions, the problem of low prediction efficiency of symbol probability distributions in the existing technology is solved, and the efficiency and accuracy of compression coding in data collection scenarios are improved.
Patent Information
- Application Number
- CN202411039618.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-22
AI Technical Summary
In the data processing of the existing technology, the prediction efficiency or accuracy of the symbol probability distribution is low, which affects the compression and coding efficiency. Especially in industrial large-scale data collection scenarios, there is a lack of effective means to predict the updated symbol probability distribution.
By obtaining the first N characters in the data stream, the target interval is determined based on the initial character probability distribution, and subsequent characters are traversed, and the target character probability distribution is updated based on the local character probability distribution, using a method that combines fixed mode arithmetic coding and adaptive arithmetic coding. , predict and encode symbol probabilities, using neural network models to predict local character probability distributions to improve accuracy.
It improves the prediction accuracy and compression coding efficiency of symbol probability distribution, avoids the problem of low prediction efficiency of symbol probability distribution, is suitable for large-scale data collection scenarios, and improves concurrency, compression and business reliability.
Smart Images

Figure CN118826752A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method and apparatus, a processing device, a computer storage medium, and a program product. Background Art
[0002] Arithmetic coding is an entropy coding technique that compresses data streams given a probability estimate for each symbol. In the coding process, the prediction of the probability distribution of characters is crucial. Existing technologies either use a single fixed-mode arithmetic coding or a single adaptive arithmetic coding. For a single fixed-mode arithmetic coding, it is necessary to traverse the entire symbol stream and calculate the global probability of each symbol to determine the character probability distribution, which is inefficient. For a single adaptive arithmetic coding, the probability of a symbol occurring changes continuously with the symbol input, but there is a lack of an effective means to predict the updated symbol probability distribution. Therefore, an effective data processing method is urgently needed to solve this problem. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present invention provide a data processing method and apparatus, a processing device, a computer storage medium and a program product.
[0004] In a first aspect, the data processing method provided in the embodiments of the present application includes:
[0005] Obtain a data stream, wherein the data stream includes L characters, where L is a positive integer;
[0006] The first N characters of the L characters are intercepted as target objects, and a target interval corresponding to the target object is determined in an initial interval according to an initial character probability distribution;
[0007] Traversing each character after the target object in the L characters, performing the following process: determining a local character probability distribution according to the N characters before the character, determining a target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, and determining an interval corresponding to the character in a first interval according to the target character probability distribution, the first interval being the target interval or an interval determined by the process before the current process;
[0008] After determining the interval corresponding to the last character of the L characters, a value is selected from the interval corresponding to the last character as the encoding information of the L characters.
[0009] In a second aspect, the data processing method provided in the embodiment of the present application includes:
[0010] Receive L characters of coded information, where the coded information is represented by a numerical value, where L is a positive integer;
[0011] Determine a target interval to which the value belongs in an initial interval according to an initial character probability distribution, and determine first N characters among the L characters according to the target interval;
[0012] For each character to be determined after the first N characters among the L characters, the following process is performed: determining a local character probability distribution according to the N characters before the character to be determined, determining a target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determining the interval to which the numerical value belongs in a first interval according to the target character probability distribution, and determining the character to be determined according to the interval to which the numerical value belongs, wherein the first interval is the target interval or the interval determined by the process before the current process;
[0013] After the last character to be determined among the L characters is determined, the data stream is restored according to all the determined characters.
[0014] In a third aspect, the data processing device provided in the embodiment of the present application includes:
[0015] An acquisition unit, used for acquiring a data stream, wherein the data stream includes L characters, where L is a positive integer;
[0016] The encoding unit is used to intercept the first N characters of the L characters as target objects, determine the target interval corresponding to the target object in the initial interval according to the initial character probability distribution; traverse each character after the target object in the L characters to perform the following process: determine the local character probability distribution according to the N characters before the character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval corresponding to the character in the first interval according to the target character probability distribution, and the first interval is the target interval or the interval determined by the process before the current process; after determining the interval corresponding to the last character of the L characters, select a value from the interval corresponding to the last character as the encoding information of the L characters.
[0017] In a fourth aspect, the data processing device provided by the embodiment of the present application includes:
[0018] A receiving unit, used for receiving encoding information of L characters, wherein the encoding information is represented by a numerical value, and L is a positive integer;
[0019] A decoding unit is used to determine the target interval to which the numerical value belongs in the initial interval according to the initial character probability distribution, and determine the first N characters of the L characters according to the target interval; for each to-be-determined character after the first N characters of the L characters, perform the following process: determine the local character probability distribution according to the N characters before the to-be-determined character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval to which the numerical value belongs in the first interval according to the target character probability distribution, and determine the to-be-determined character according to the interval to which the numerical value belongs, the first interval being the target interval or the interval determined by the process before the current process; after determining the last to-be-determined character of the L characters, restore the data stream according to all the determined characters.
[0020] In a fifth aspect, the processing device provided in an embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of the above-mentioned data processing methods.
[0021] In a sixth aspect, the computer-readable storage medium provided in an embodiment of the present application is used to store a computer program, and the computer program enables a computer to execute any one of the above-mentioned data processing methods.
[0022] In a seventh aspect, the computer program product provided in an embodiment of the present application includes computer program instructions, which enable a computer to execute any one of the above-mentioned data processing methods.
[0023] In the technical solution of the embodiment of the present application, a data stream is obtained, where L is a positive integer; the first N characters of the L characters are intercepted as target objects, and a target interval corresponding to the target object is determined in the initial interval according to the initial character probability distribution; each character after the target object in the L characters is traversed to perform the following process: a local character probability distribution is determined according to the N characters before the character, a target character probability distribution is determined according to the local character probability distribution determined by the current process and the process before the current process, and an interval corresponding to the character is determined in a first interval according to the target character probability distribution, the first interval being the target interval or the interval determined by the process before the current process; after determining the interval corresponding to the last character of the L characters, a value is selected from the interval corresponding to the last character as the encoding information of the L characters; in this way, by predicting the probability distribution of the character to be encoded, and then predicting the probability range corresponding to the character to be encoded, and encoding the character to be encoded according to the obtained probability range, a more accurate predicted symbol probability is obtained, and the compression coding efficiency is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 1 ;
[0025] Figure 2 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 2 ;
[0026] Figure 3 It is a structural diagram of a neural network model provided in an embodiment of the present application;
[0027] Figure 4 A training diagram of a neural network model provided in an embodiment of the present application;
[0028] Figure 5 Schematic diagram of the data processing method provided in the embodiment of the present application Figure 3 ;
[0029] Figure 6 A schematic diagram of the architecture of the data processing method provided in the embodiment of the present application;
[0030] Figure 7 Storage diagram of the data processing method provided in the embodiment of the present application Figure 1 ;
[0031] Figure 8 Storage diagram of the data processing method provided in the embodiment of the present application Figure 2 ;
[0032] Fig. 9 The structure of the data processing device provided in the embodiment of the present application is shown in FIG. Figure 1 ;
[0033] Fig.10 The structure of the data processing device provided in the embodiment of the present application is shown in FIG. Figure 2 ;
[0034] Fig.11 It is a schematic structural diagram of a processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.
[0037] With the development of the big data era, data collection is the most frequent and high-value scenario in the entire industrial Internet project, and it is also an important link for enterprises to carry out information transformation as stipulated by the Ministry of Industry and Information Technology. Data storage is the top priority in data collection. In current industry projects, time series databases are all delivered using open source databases, which have security issues and performance bottlenecks. In addition, some medium and large enterprises do not recommend the use of open source databases, and put forward clear requirements for commercial domestic databases. For example, based on equipment data collection and real-time monitoring, it is necessary to provide equipment intelligent operation and maintenance capabilities; in the process of operation and maintenance services, it is necessary to accumulate industry knowledge and empower all operation and maintenance personnel to provide operation and maintenance efficiency and quality. At present, domestic policies advocate the localization of software. After the construction of time series databases and intelligent interactive systems is completed, it is necessary to solve the problems of medium and large enterprises' demand for domestic databases, enterprise knowledge sharing, and operation and maintenance efficiency improvement. Therefore, data collection and storage are important links. By compressing and encoding the collected data and storing the compressed and encoded data, the efficiency of equipment data storage, reading, and writing can be improved.
[0038] Arithmetic coding is an entropy coding technique that compresses data streams given a probability estimate for each symbol. Arithmetic coding maintains a probability range in the interval [0, 1], and each symbol stream uniquely determines a probability range. This range directly depends on the conditional probability distribution of the next character and can be calculated as the sequence of characters is input. Finally, the range is encoded into a bit stream to form compressed data. The decoding process performs the inverse operation of encoding given a probability estimate. Due to the different symbol probability estimation methods, arithmetic coding is divided into fixed mode arithmetic coding and adaptive arithmetic coding. In the fixed mode, the probability of the source symbol needs to be statistically calculated in advance, and the symbol probability remains unchanged during the encoding process, while adaptive arithmetic coding dynamically modifies the probability of the source symbol according to the frequency of the symbol during encoding. The fixed mode requires traversing the entire symbol stream and counting the global probability of each symbol. Arithmetic coding complies with the probability matching principle, that is, symbols with a higher probability of occurrence are compressed into shorter codewords, and symbols with a lower probability of occurrence take longer codewords. It is possible that a symbol has a lower global probability in the entire symbol stream, but is concentrated at a certain position in the symbol stream. In this case, adaptive coding is used. Since the probability of symbol occurrence changes with the symbol input, the more the same symbol is input, the greater the probability of the symbol being updated. In this case, the compressed codeword of the symbol is significantly smaller than the fixed pattern coding.
[0039] In the encoding process, the prediction of character probability distribution is crucial. Existing technologies either use a single fixed-mode arithmetic coding or a single adaptive arithmetic coding. For a single fixed-mode arithmetic coding, it is necessary to traverse the entire symbol stream and calculate the global probability of each symbol to determine the character probability distribution, which is inefficient. For a single adaptive arithmetic coding, the probability of a symbol changing with the symbol input, but there is a lack of an effective means to predict the updated symbol probability distribution.
[0040] In summary, on the one hand, the current scheme has the problem of low efficiency or low accuracy in predicting the probability distribution of symbols, which affects the compression coding efficiency. On the other hand, for industrial large-scale data collection scenarios, it is necessary to improve concurrency, compression, and business reliability, and solve the security risks of products using open source databases. To this end, the following technical solution is proposed in this application.
[0041] It should be noted that the terms "first", "second", etc. in this document are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present disclosure, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0042] To facilitate understanding of the technical solutions of the embodiments of the present application, the technical solutions of the present application are described in detail below through specific embodiments. The above related technologies can be combined arbitrarily with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application. The embodiments of the present application include at least part of the following contents.
[0043] Figure 1 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 1 ,like Figure 1 As shown, the data processing method includes:
[0044] Step 101: Obtain a data stream, where the data stream includes L characters, where L is a positive integer.
[0045] In the embodiment of the present application, the encoder obtains a data stream, and each data in the data stream may be ordered data with a timestamp. The data stream may be a character sequence including multiple characters. For example, the data stream is a character sequence C including L characters. L ={C 1 , C 2 , …, C L}. Among them, C 1 , C 2 ,……,C L For each character.
[0046] It should be noted that the data processing method provided in the embodiment of the present application can be applicable to scenarios requiring large-scale data collection and storage, such as factories, which contain a large number of industrial equipment. These industrial equipment can be used to monitor the situation in the factory, directly participate in the production of products, and so on. At this time, the data stream can refer to the data generated by each industrial equipment and the data collected. Since the data collected in the large-scale data collection scenario is relatively large. If all of this data is stored, a large amount of storage resources are required. In order to save some storage resources, the obtained data stream needs to be compressed and encoded before storage.
[0047] In the actual application process, the acquisition (i.e., collection) of data streams may include at least one of the following methods: software direct communication collection, gateway collection, and collection through a data collection terminal. Among them, the software direct communication collection uses the communication protocol and communication network port of the system to which the data processing method is applied, without adding any hardware, to directly communicate with the data collection server on site to obtain the collected data stream; the gateway collection can be for a system that does not have an Ethernet communication interface or does not support Ethernet communication, and can use the gateway to connect to the field equipment or the data collection server on site to obtain the collected data stream. Here, the gateway can convert different protocols into standard protocols to realize the collection of field equipment data, and transmit the collected data to the system to which the data processing method is applied through the gateway; the collection through a data collection terminal can refer to a field device that has no network port\serial port and only has an IO interface. The field device can be connected to the IO interface of the data collection terminal to collect data, and the collected data can be transmitted to the system to which the data processing method is applied through the data collection device. Among them, the data acquisition terminal can be such as the explosion-proof acquisition terminal (AX-F60 (EX)), which is mainly used in explosion-proof and power-supply environments. It is a general packet radio service (GPRS) terminal device specially designed to meet the requirements of customers and the market. It enables users to really put the device online in real time, making it convenient for users to view data and observe the situation on site. Specifically, the type of data acquisition terminal is related to its working scenario, and its types will not be listed one by one here.
[0048] Step 102: intercept the first N characters of the L characters as target objects, and determine the target interval corresponding to the target object in the initial interval according to the initial character probability distribution.
[0049] In the embodiment of the present application, the data stream is a character sequence containing L characters, and the first N characters of the L characters are intercepted as the target object, that is, the data stream C L ={C1 , C 2 , …, C L The first C in} 1 , C 2 , ..., C N , a total of N characters are used as the target object. For example, N is equal to 5, and the first N characters are: ADBCD, then the target object is ADBCD.
[0050] In the embodiment of the present application, the initial character probability distribution includes the probabilities corresponding to different types of characters in K types of characters, where K is a positive integer. Specifically, the initial character probability distribution refers to taking the first N characters as the target object, and the target object includes K different characters, and the probability corresponding to each different character is the initial character probability. Here, the initial character probability can be the probability of K types of characters appearing in the data stream. For example, if the target object is CADACDB, then K is 4, that is, each character of different types is A, B, C, and D, then the K types of characters can be assigned probabilities in advance, for example, the assigned initial character probability distribution is 0.1, 0.4, 0.2, and 0.3. For another example, if the target object is ADBCD, then each character of different types is A, B, C, and D, respectively, then the initial character probabilities can be assigned as 0.2, 0.2, 0.2, and 0.4 according to the probability of the characters appearing in the data stream.
[0051] In some embodiments, determining a target interval corresponding to a target object in an initial interval according to an initial character probability distribution includes: traversing each character in the target object to perform the following process: dividing the second interval into K first sub-intervals according to the initial character probability distribution, the probability that different first sub-intervals in the K first sub-intervals correspond to different types of characters, K being a positive integer; determining the first sub-interval corresponding to the character in the K first sub-intervals, the second interval being the initial interval or an interval determined by a process before the current process; and determining the first sub-interval corresponding to the last character in the target object as the target interval.
[0052] Here, "determining the interval corresponding to a character" can be understood as encoding the character. Therefore, determining the target interval corresponding to the target object in the initial interval according to the initial character probability distribution can be understood as encoding the N characters in the target object. Specifically, read in the N target objects, namely C 1 , C 2 , ..., C N . Start with the first character C in the target object 1To start encoding, first determine that the second interval is the initial interval, the range is [0, 1), and then divide the initial interval [0, 1) into K first sub-intervals according to the initial character probability distribution. Each first sub-interval represents a character, a total of K types. In this way, the K first sub-intervals can be understood as the probability intervals corresponding to the K types of characters. After the second interval is divided into K first sub-intervals according to the initial character probability distribution, the encoding starts from the initial interval [0, 1), and the low 0 =0, high 0 =1, read C in order 1 Character, find C 1 The first subinterval of is [L, H), and according to formula (1) 1 The first sub-interval of the character to be encoded is updated to [L, H), and the updated first sub-interval is used as the second interval of the next character to be encoded, that is, the updated first sub-interval is used as the second interval of the character to be encoded. 2 The second encoding interval begins. Until the encoding reaches C N , the first subinterval [low N , high N ) is determined as the target interval. Any decimal within this encoding interval is converted into the corresponding binary to obtain the final encoding result of the first N characters.
[0053] low N =low N-1 +(high N-1 -low N-1 )*L N , high N =low N-1 +(high N-1 -low N-1 )*H N (1)
[0054] Exemplarily, taking the target object ADBCD as an example, according to the probability of the characters appearing in the data stream, the initial character probabilities are assigned as P(A)=0.2, P(B)=0.2, P(C)=0.2, P(D)=0.4. Then, according to the initial character probability distribution, [0, 1) is divided into 4 first sub-intervals, and different first sub-intervals in the 4 first sub-intervals correspond to the probabilities of different types of characters, namely A: [0, 0.2); B: [0.2, 0.4); C: [0.4, 0.6); D: [0.6, 1]. After the second interval is divided into 4 first sub-intervals according to the initial character probability distribution, the first sub-intervals where the 5 characters are located are found in order and updated according to formula (1). The specific encoding process is as follows:
[0055] After the second interval is divided into four first subintervals according to the probability distribution of the initial character, the first character is first located from the initial interval: A: [0, 0.2); B: [0.2, 0.4); C: [0.4, 0.6); D: [0.6, 1]. The first character is A, and the first subinterval corresponding to A is [0, 0.2). Then A: [0, 0.2) is divided based on the above steps: A: [0, 0.04), B: [0.04, 0.08), C: [0.08, 0.12), D: [0.12, 0.2). The second character is D, and the first subinterval corresponding to D is [0.12, 0.2). Then D: [0.12, 0.2) is further divided into: A: [0.12, 0.136), B: [0.136, 0.152), C: [0.152, 0.168), D: [0.168, 0.2). The third character is B, and the first subinterval corresponding to B is [0.136, 0.152). Then B: [0.136, 0.152) is further divided into: A: [0.136, 0.392), B: [0.1392, 0.1424), C: [0.1424, 0.1456), D: [0.1456, 0.152). The fourth character is C, and the first subinterval corresponding to C is [0.1424, 0.1456). Then C:[0.1424, 0.1456) is further divided into: A:[0.1424, 0.14304), B:[0.14304, 0.14368), C:[0.14368, 0.14432), D:[0.14432, 0.1456). The last character, i.e. the fifth character, is D, so D:[0.14432, 0.1456) is determined as the target interval.
[0056] The specific process of dividing the interval is as follows:
[0057] The first character read in sequence is A, and the encoding starts from the initial interval [0, 1), and sets low 1 =0, high 1 =1, find the first subinterval where A is located is [0, 0.2), then L 1 =0,H 1 = 0.2, and update according to formula (1), and the updated first sub-interval is [0, 0.2). [0, 0.2) is used as the second interval for encoding the second character D, and the low 2 =0, high 2 =0.2, find the first subinterval where D is located is [0.6, 1), then L 2 =0.6, H 2=1, update according to formula (1), and obtain the updated first sub-interval as [0.12, 0.2). [0.12, 0.2) is used as the second interval for encoding the third character B, and the low 3 =0.12, high 3 =0.2, find the first subinterval where B is located is [0.2, 0.4), then L 3 =0.2, H 3 =0.4, and update according to formula (1), and the updated first sub-interval is [0.136, 0.152). [0.136, 0.152) is used as the second interval for encoding the fourth character C, and the low 4 =0.136, high 4 =0.152, find the first subinterval where B is located is [0.2, 0.4), then L 4 =0.2, H 4 =0.4, and update according to formula (1), and the updated first sub-interval is [0.1424, 0.1456). [0.1424, 0.1456) is used as the second interval for encoding the fifth character D, and the low 5 =0.1424, high 5 =0.1456, find the first subinterval where D is located is [0.6, 1), then L 5 =0.6, H 4 =1, and update according to formula (1), and the updated first sub-interval is obtained as [0.14432, 0.1456). Finally, [0.14432, 0.1456) is determined as the target interval.
[0058] Step 103, traverse each character after the target object in the L characters and perform the following process: determine the local character probability distribution based on the N characters before the character, determine the target character probability distribution based on the local character probability distribution determined by the current process and the process before the current process, and determine the interval corresponding to the character in the first interval based on the target character probability distribution, where the first interval is the target interval or the interval determined by the process before the current process.
[0059] In the embodiment of the present application, for each character after N characters of the target object in the data stream, that is, C N+1 , C N+2 , ..., C L Based on the target interval, the interval corresponding to each character is determined in turn according to the continuously updated character probability distribution, and the last character C is determined. L After finding the corresponding interval, a value can be selected from the last interval as the encoding information corresponding to the L characters.
[0060] Here, in the compression strategy for each character after traversing the target object among the L characters, for the N+1th character, it is first necessary to determine the local character probability distribution based on the N characters before the character. Specifically, these N characters can be input into the RNN probability predictor model that has loaded the trained network model weights, and the probability distribution of each different type of characters, that is, the local character probability distribution, is obtained according to the RNN probability predictor model. Afterwards, according to the local character probability distribution and the N+1th character value, the original character probability distribution and cumulative frequency are updated to obtain the local character probability distribution of the N+1th character value, that is, the target character probability distribution. Finally, based on the obtained target character probability distribution, a new probability range for each character is obtained, that is, the interval corresponding to the character is determined in the first interval. Repeat this process and finally lock the character C. L The probability range of (the last character) is used, and the encoded data stream is obtained according to a decimal in the probability range.
[0061] In some embodiments, in the above-mentioned step 103, the target character probability distribution is determined based on the local character probability distribution determined by the current process and the process before the current process, including: taking a weighted average of the first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process to obtain the target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0062] Here, each time the interval corresponding to a character is determined, the local character probability distribution is predicted based on the previous N characters, and the currently predicted local character probability distribution and the previously predicted local character probability distribution are combined to obtain a more global target character probability distribution. That is, the first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process can be weighted averaged to obtain the target character probability distribution.
[0063] Specifically, the first local character probability distribution is the local probability distribution corresponding to each different type of character in the N characters before the target character predicted by the constructed neural network model in the current process, and the second local character probability distribution is the local probability distribution corresponding to each different type of character in the N characters before the previous target character predicted by the constructed neural network model in the process before the current process. For example, the target character is C N+2 , then the first local character probability distribution is the C before the target character is predicted according to the constructed neural network model in the current process 2 , C 3 , …, C N+1, the local probability distribution corresponding to each type of character in N characters, the second local character probability distribution is the process before the current process, according to the constructed neural network model to predict the previous C N+1 Before C 1 , C 2 , ..., C N , the local probability distribution corresponding to each different type of character in the N characters. Therefore, the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0064] In some embodiments, in the above step 103, the interval corresponding to the character is determined in the first interval according to the target character probability distribution, including: dividing the first interval into K second sub-intervals according to the target character probability distribution, different second sub-intervals in the K second sub-intervals correspond to the probability of different types of characters, K is a positive integer; and determining the second sub-interval corresponding to the character in the K second sub-intervals.
[0065] Here, each time the interval corresponding to a character is determined, the local character probability distribution is predicted based on the first N characters, and the more global target character probability distribution is obtained by combining the currently predicted local character probability distribution and the previously predicted local character probability distribution. The target local character probability distribution is used to divide the interval determined last time, and then the interval corresponding to the next character is determined based on the division result. It should be noted that "determining the interval corresponding to a character" can be understood as "encoding the character". Therefore, determining the interval corresponding to the character in the first interval based on the target character probability distribution can be understood as encoding the N+1th character. The specific encoding process is as follows:
[0066] Here, in the compression strategy for each character after the target object in the traversal of L characters, the first N characters C are read in order. 1 , C 2 , ..., C N , and input these N characters into the RNN probability predictor model that has loaded the trained network model weights to obtain the probability distribution of K different types of characters, that is, the local character probability distribution. Then, according to the local character probability distribution and the N+1th character value, the original character probability distribution and cumulative frequency are updated to obtain C N+1 The target character probability distribution is obtained. The first interval is divided into K second sub-intervals according to the target character probability distribution, wherein the first interval here is the target interval finally determined in the above step 102. In this way, the probabilities of different second sub-intervals in the K second sub-intervals corresponding to different types of characters are obtained, that is, the K second sub-intervals can be understood as the probability intervals corresponding to K types of characters. Finally, in the K second sub-intervals, according to C N+1 Character value determination C N+1The corresponding second subinterval, and C N+1 The corresponding second subinterval is taken as the pair C N+2 Start encoding the first interval. Repeat this process and finally lock on character C L (the last character) of the first interval, that is, in the K second sub-intervals according to C L Character value determination C L The corresponding second sub-interval.
[0067] Step 104: After determining the interval corresponding to the last character of the L characters, select a value from the interval corresponding to the last character as the encoding information of the L characters.
[0068] As mentioned above, the last locked character C L (last character) corresponding to the interval, and according to C L A decimal in the corresponding interval is converted into the corresponding binary number, which is the final encoding result of L characters.
[0069] From the above, it can be seen that a data processing method provided by an embodiment of the present application obtains a data stream, where the data stream includes L characters, where L is a positive integer; the first N characters of the L characters are intercepted as target objects, and a target interval corresponding to the target object is determined in the initial interval according to the initial character probability distribution; each character after the target object in the L characters is traversed to perform the following process: a local character probability distribution is determined according to the N characters before the character, a target character probability distribution is determined according to the local character probability distribution determined by the current process and the process before the current process, and an interval corresponding to the character is determined in a first interval according to the target character probability distribution, where the first interval is the target interval or the interval determined by the process before the current process; after determining the interval corresponding to the last character of the L characters, a value is selected from the interval corresponding to the last character as the L. Character encoding information; in this way, by adopting fixed-mode arithmetic coding for the first N characters and adaptive arithmetic coding for each character after N characters, on the one hand, since the number of N characters is relatively small compared to all characters, the fixed-mode arithmetic coding part of the present application can avoid the problem of low efficiency in symbol probability distribution prediction; on the other hand, since in the adaptive arithmetic coding part of the present application, the local character probability distribution is predicted each time based on the N characters before the current character, the final target character probability distribution is determined by combining the local character probability distributions predicted multiple times before, and the current character is encoded using the target character probability distribution. Since the target character probability distribution is obtained based on the weighted average of multiple local character probability distributions, the target character probability distribution is closer to the global probability distribution, which improves the accuracy of the character probability distribution and is beneficial to improving the compression coding efficiency.
[0070] In some embodiments, determining the local character probability distribution based on the N characters preceding the character includes: inputting the N characters preceding the character into a neural network model, and predicting the local character probability distribution of the N characters through the neural network model.
[0071] Among them, Figure 2 As shown, Figure 2 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 2 The neural network model 20 may include: an embedding layer (Embedding) 201, a recurrent neural network (RNN) layer 202, a flattening layer (Flatten) 203 and a fully connected layer (FC) 204, wherein;
[0072] The embedding layer is used to determine the relationship between the N characters before the input character.
[0073] The RNN layer includes a first recurrent unit GRU layer and a second GRU layer, wherein the first GRU layer and the second GRU layer each include N GRUs; each GRU in the first GRU layer is used to receive one of the first N characters, and its output end is connected to the input end of a corresponding GRU in the second GRU layer; the RNN layer is used to process the first N characters processed by the embedding layer to form N output vectors.
[0074] The flattening layer is used to concatenate N output vectors to form a target vector.
[0075] The fully connected layer is used to process the target vector to form the local character probability distribution corresponding to each different type of character in the first N characters.
[0076] It should be noted that the neural network model can be called an RNN probability predictor model, which uses a two-layer multi-input and multi-output gated recurrent unit (GRU) as the RNN model to prevent problems such as gradient diffusion and weakened dependence on distant characters in the character sequence. The structure of the neural network model is as follows Figure 3 shown.
[0077] like Figure 3 As shown, Figure 3It is a structural diagram of the neural network model provided in the embodiment of the present application. In the input layer of the neural network model, an Embedding layer, that is, an embedding layer 201, is added. The Embedding layer has two functions: dimensionality reduction and dimensionality increase, wherein the principle of dimensionality reduction is matrix multiplication, specifically, the sparse matrix represented by the character sequence to be processed is transformed into a dense matrix through some linear changes (converted by a fully connected layer in CNN, also known as a table lookup operation). This dense matrix uses M features to characterize all the characters in the character sequence to be processed, wherein M is less than the number of characters in the character sequence to be processed, and in this dense matrix, the appearance represents the one-to-one correspondence between the dense matrix and a single character, but in fact, it also contains a large number of intrinsic relationships between characters, words and words, and even sentences. Among them, the character sequence is represented as a vector input into the neural network model, an optional way, using a binary unique hot encoding method to represent each character in the character sequence to be processed as a vector with a corresponding index position of 1 and all other positions of 0, and then the character sequence to be processed is represented as a sparse matrix. In an embodiment of the present application, the Embedding layer maps the input characters to scores on M dimensions according to the single-layer neural network and the position of the characters in the dictionary, so that the independent input string vectors become intrinsically connected relationship vectors, which can be used to discover the deep relationship between the input string vectors. These relationships are constantly updated during the back propagation process of the network model training, so that after the number of epochs increases, the relationship becomes relatively mature and can correctly express the relationship between the various input strings. The trained vectors can better adapt to data compression tasks. That is, determine the relationship between the characters in the first N characters of the input.
[0078] Among them, the RNN layer includes a first GRU layer and a second GRU layer, wherein the first GRU layer and the second GRU layer each contain N GRUs; each GRU in the first GRU layer is used to receive one of the first N characters, and its output end is connected to the input end of a corresponding GRU in the second GRU layer; the RNN layer is used to process the first N characters processed by the embedding layer to form N output vectors. That is, the RNN layer includes two layers of GRU layers, and the number of GRUs in each layer is the length of the input character sequence. For example, if the first N characters are the input character sequence, then the number of GRUs in each layer is N. At time t, in the first GRU layer, each GRU generates an output to form a (1, M)-dimensional vector, where M is the output dimension of the GRU. In the second GRU layer, each GRU generates an output to form a (1, N, M)-dimensional vector. That is, the neural network model is used to process the first N characters processed by the embedding layer to form N (1, M)-dimensional vectors, that is, (1, N, M)-dimensional vectors. After that, the (1, N, M)-dimensional vectors are concatenated through the Flatten layer to form a (1, N×M)-dimensional vector, that is, the target vector. After that, the target vector is processed using two activation functions, namely, the rectified linear unit (RELU) and the softmax, to form a fully connected layer FC to obtain the local probability distribution corresponding to the different types of characters in the first N characters. The number of neurons in the fully connected layer FC is the number K of different types of characters in the first N characters, where K is less than or equal to N. This method can be used to output the C N+1 The local character probability distribution of the N characters before the character is used to prepare for the subsequent determination of the target character probability distribution.
[0079] Among them, GRU, as an extended RNN network unit structure with gated recurrent units, uses update gates and reset gates. The purpose is to solve the gradient diffusion problem in standard RNN while retaining long-term sequence information. The update gate linearly transforms the current input character information and the output information of the previous GRU unit, and transforms the output to between 0 and 1 through the Sigmoid activation function, which helps the model determine the amount of information that needs to be continued to be transmitted between the memory information of the previous step and the current input character information. Similarly, the reset gate linearly transforms the current input character information and the output information of the previous GRU unit, and adds them, and sends them to the Sigmoid function to determine the information that needs to be retained and forgotten. When calculating the current memory content, the reset gate is used to determine the elements to be retained and forgotten in the output of the previous GRU unit in the form of gated control. Finally, the update gate is used to add the information retained in the final memory of the output of the previous GRU unit and the information retained in the final memory of the current memory content, which is the final output content of the current GRU unit.
[0080] In practical applications, the training of the RNN probability predictor model can be as follows:
[0081] The purpose of the RNN probability predictor model is to predict the probability of a character sequence C given a character list S. L ={C 1 , C 2 , …, C L}, based on the first N observed characters, estimate the N+1th character C r The conditional probability distribution of Therefore, the present application first reads the character stream from the training data file, reorganizes it into a one-dimensional character vector, and transforms the one-dimensional vector C into a character vector by the step length method. L Decompose into (R, N+1)-dimensional overlapping segment matrices, such as Figure 4 As shown, Figure 4 A training diagram of a neural network model provided in an embodiment of the present application.
[0082] The data of the first N columns in the (R, N+1)-dimensional overlapping segmentation matrix are intercepted as training samples, that is, the number of training samples is R, and the dimension of each training sample is N. In the actual training process, the training samples are shuffled and divided into multiple batches, which is conducive to the convergence of the network model. The expected output of the network model is the vector {C N+1 , C N+2 , …, C L}A binary sequence of 0 and 1 generated by binary one hot encoding (One Hot Encoder). Vector {CN+1 , C N+2 , …, C L The number of states (i.e., the number of character types) in the vector {C is the number of bits in the binary sequence of the one-hot encoding, and the corresponding positions of the binary sequence are 1, and the other positions are 0. N+1 , C N+2 , …, C L} traverses almost the entire input data stream, and the number of character types is the number of characters in the character table S. In this way, each bit of the binary sequence corresponds to the output of the neuron in the top fully connected layer of the neural network model. For example, for the training sample {C 1 , C 2 , …, C N}The expected output character is character C N+1 The unique hot encoding of 1000…0, that is, C N+1 The corresponding neuron output is 1, which can be regarded as a conditional probability. At this time, the outputs of other neurons are 0. N+2 If with C N+1 If they are the same, the one-hot encoding is the same. If they are different, the one-hot encoding is 0100…0, and the same applies to other characters.
[0083] After the training is completed, the weight parameters of the neural network model are saved. Then, during the compression process, the saved weight parameters are loaded into the neural network model, the neural network model is used to predict the local character probability distribution of N characters, and the probability distribution of the target character is determined based on the currently determined local character probability distribution.
[0084] From the above, it can be seen that the data processing method provided by the embodiment of the present application performs lossless processing of data based on deep learning algorithm technology, which can reduce the scale and volume of data from the root. Based on the predicted lossless compression principle, a recurrent neural network model is constructed as a conditional probability predictor of sequence data. After a large number of sample training, the weights of the neural network model are saved. During the compression process, the saved neural network model weights are loaded, the probability distribution of characters in the data stream is calculated, and the adaptive arithmetic encoder updates the probability interval of the character according to the distribution and the current character to be encoded and encodes the output.
[0085] Figure 5 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 3 ,like Figure 5 As shown, the data processing method includes:
[0086] Step 501: Receive encoding information of L characters, where the encoding information is represented by a numerical value, and L is a positive integer.
[0087] In the implementation mode of the present application, the decompression process is symmetrical with the compression process and is the inverse process of compression. The decoder receives the encoded information of L characters, which can be represented by a binary value and converted into a corresponding decimal value. The encoded information of L characters is the character sequence C containing L characters converted by the encoder. L ={C 1 , C 2 , …, C L}The data stream is obtained after the encoding and compression process as described above.
[0088] Step 502: Determine a target interval to which the value belongs in the initial interval according to the initial character probability distribution, and determine the first N characters among the L characters according to the target interval.
[0089] In an embodiment of the present application, the initial character probability distribution includes the probabilities corresponding to different types of characters among K types of characters, where K is a positive integer. Specifically, the initial character probability distribution refers to taking the first N characters as the target object, where the target object includes K different characters, and the probability corresponding to each different character is the initial character probability. Here, the initial character probability can be the probability of K types of characters appearing in the data stream. Among them, the target interval is known by the encoding end, and the specific determination process is as described above.
[0090] In some embodiments, a target interval to which a numerical value belongs is determined in an initial interval according to an initial character probability distribution, and the first N characters among L characters are determined according to the target interval, including: executing the following process N times: dividing the second interval into K first sub-intervals according to the initial character probability distribution, different first sub-intervals among the K first sub-intervals correspond to probabilities of different types of characters, and K is a positive integer; determining the first sub-interval to which the numerical value belongs among the K first sub-intervals, and determining one of the N characters according to the first sub-interval to which the numerical value belongs; the second interval is the initial interval or an interval determined by a process before the current process; and the N characters determined by the N processes are taken as the first N characters among the L characters.
[0091] Here, the target interval to which the value belongs is determined, and the corresponding character is determined according to the target interval. This process can be understood as decoding the value. The specific decoding process is as follows:
[0092] For example, the binary code received by the decoding end is 11100001101100. After adding the decimal point, it is restored to 0.0011100001101100, and the corresponding decimal code is 0.14444. According to the probability of the character appearing in the data stream, the initial character probability is assigned as P(A)=0.2, P(B)=0.2, P(C)=0.2, P(D)=0.4. Then, according to the initial character probability distribution, [0, 1) is divided into 4 first sub-intervals, and different first sub-intervals in the 4 first sub-intervals correspond to the probabilities of different types of characters, that is, A: [0, 0.2); B: [0.2, 0.4); C: [0.4, 0.6); D: [0.6, 1]. After the second interval is divided into four first subintervals according to the initial character probability distribution, the first character is located from the initial interval: A: [0, 0.2); B: [0.2, 0.4); C: [0.4, 0.6); D: [0.6, 1]. 0.1444 is in interval A, so the first character is A. Then A: [0, 0.2) is divided into: A: [0, 0.04), B: [0.04, 0.08), C: [0.08, 0.12), D: [0.12, 0.2). 0.14444 is in interval D, so the second character is D. Then, D:[0.12, 0.2) is further divided into: A:[0.12, 0.136), B:[0.136, 0.152), C:[0.152, 0.168), D:[0.168, 0.2). 0.14444 is in the B interval, so the third character is B. Then, B:[0.136, 0.152) is further divided into: A:[0.136, 0.392), B:[0.1392, 0.1424), C:[0.1424, 0.1456), D:[0.1456, 0.152). 0.14444 is in the C interval, so the fourth character is C. Then C:[0.1424, 0.1456) is further divided into: A:[0.1424, 0.14304), B:[0.14304, 0.14368), C:[0.14368, 0.14432), D:[0.14432, 0.1456). 0.14444 is in the D interval, so the fifth character is D. By analogy, the entire character can be decoded from 0.14444 to get ADBCD.
[0093] Step 503, for each character to be determined after the first N characters among the L characters, perform the following process: determine the local character probability distribution based on the N characters before the character to be determined, determine the target character probability distribution based on the local character probability distribution determined by the current process and the process before the current process, determine the interval to which the numerical value belongs in the first interval based on the target character probability distribution, and determine the character to be determined based on the interval to which the numerical value belongs, the first interval being the target interval or the interval determined by the process before the current process.
[0094] In the embodiment of the present application, for each character after N characters of the target object in the data stream, that is, C N+1 , C N+2 , ..., C L , predict the local character probability distribution based on the first N characters, and calculate the target character probability distribution by combining the local character probability distributions predicted multiple times before; divide the current interval into K sub-intervals according to the target character probability distribution, and different sub-intervals in the K sub-intervals correspond to the probabilities of different types of characters; determine the sub-interval in which the value falls among the K sub-intervals, use the character corresponding to the sub-interval as the decoded character, and use the sub-interval as the current interval of the next character to be decoded; repeat the above process multiple times until all characters are decoded.
[0095] Here, the decoder first uses the decoded first N characters, and then uses the RNN probability predictor to obtain the local character probability distribution and decode the subsequent characters. Here, the decoder also needs to update the local character probability distribution each time to obtain a new character probability interval, and decode the character corresponding to the probability interval according to the probability interval in which the real number represented by the compressed data stream falls. During the decompression process, the RNN probability predictor also uses the trained network model weights to produce the same probability estimates as the compression process.
[0096] In some embodiments, a target character probability distribution is determined based on local character probability distributions determined by a current process and a process before the current process, including: taking a weighted average of a first local character probability distribution determined by the current process and a second local character probability distribution determined by a process before the current process to obtain a target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0097] Here, according to the probability interval into which the real number represented by the compressed data stream falls, the character corresponding to the probability interval is decoded. Similarly, the decoding process needs to predict the local character probability distribution based on the first N characters, and perform weighted average on the first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process to obtain the target character probability distribution.
[0098] Specifically, the first local character probability distribution is the local probability distribution corresponding to each different type of character in the N characters before the target character predicted by the constructed neural network model in the current process, and the second local character probability distribution is the local probability distribution corresponding to each different type of character in the N characters before the previous target character predicted by the constructed neural network model in the process before the current process. For example, the target character is C N+2 , then the first local character probability distribution is the C before the target character is predicted according to the constructed neural network model in the current process 2 , C 3 , …, C N+1 , the local probability distribution corresponding to each type of character in N characters, the second local character probability distribution is the process before the current process, according to the constructed neural network model to predict the previous C N+1 Before C 1 , C 2 , ..., C N , the local probability distribution corresponding to each different type of character in the N characters. Therefore, the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0099] In some embodiments, determining the interval to which the numerical value belongs in the first interval according to the target character probability distribution includes: dividing the first interval into K second sub-intervals according to the target character probability distribution, different second sub-intervals in the K second sub-intervals correspond to the probabilities of different types of characters, and K is a positive integer; determining the second sub-interval to which the numerical value belongs in the K second sub-intervals.
[0100] Here, each time an interval corresponding to a numerical value is determined, a local character probability distribution is predicted based on the first N characters, and a more global target character probability distribution is obtained by combining the currently predicted local character probability distribution and the previously predicted local character probability distribution. The target local character probability distribution is used to divide the interval determined last time, and then the next interval corresponding to the numerical value is determined based on the division result, and the corresponding character is determined based on the interval. It should be noted that "determining the interval to which the numerical value belongs" can be understood as "decoding the numerical value". Therefore, according to the target character probability distribution, the interval corresponding to the numerical value is determined in the first interval to obtain the corresponding character. The specific decoding process is as follows:
[0101] Here, in the decompression strategy for each character after traversing the target object in L characters, the first N characters C that have been decompressed are input in order 1 , C 2 , ..., C N, and input these N characters into the RNN probability predictor model that has loaded the trained network model weights to obtain the probability distribution of K different types of characters, that is, the local character probability distribution. Then, according to the local character probability distribution and value, update the original character probability distribution and cumulative frequency to obtain C N+1 The target character probability distribution is obtained. The first interval is divided into K second sub-intervals according to the target character probability distribution, that is, the K second sub-intervals can be understood as the probability intervals corresponding to the K characters. Finally, the corresponding second sub-interval is determined according to the compressed value in the K second sub-intervals, and the character value C is determined according to the second sub-interval. N+1 , and C N+1 The corresponding second subinterval is taken as the pair C N+2 The first decoding interval is started. This process is repeated to complete the second sub-interval corresponding to the last character determined according to the numerical value, and the corresponding character value is decoded according to the second sub-interval.
[0102] Step 504: After the last character to be determined among the L characters is determined, the data stream is restored according to all the determined characters.
[0103] As described above, the corresponding interval is updated according to the value, and the data stream is restored after the last character of the L characters is determined.
[0104] From the above, it can be seen that a data processing method provided by an embodiment of the present application receives encoding information of L characters, where the encoding information is represented by a numerical value, where L is a positive integer; determines a target interval to which the numerical value belongs in an initial interval according to an initial character probability distribution, and determines the first N characters of the L characters according to the target interval; for each character to be determined after the first N characters of the L characters, the following process is performed: determines a local character probability distribution according to the N characters before the character to be determined, determines a target character probability distribution according to a local character probability distribution determined by a current process and a process before the current process, determines an interval to which the numerical value belongs in a first interval according to the target character probability distribution, and determines the character to be determined according to the interval to which the numerical value belongs, the first interval being the target interval or an interval determined by a process before the current process; after determining the last character to be determined among the L characters, performs a All determined characters are used to restore the data stream; in this way, by using fixed-mode arithmetic decoding for the first N characters and adaptive arithmetic decoding for each character after N characters, on the one hand, since the number of N characters is relatively small compared to all the characters, the fixed-mode arithmetic decoding part of the present application can avoid the problem of low efficiency in predicting symbol probability distribution; on the other hand, in the adaptive arithmetic decoding part of the present application, the local character probability distribution is predicted each time based on the N characters before the current character, and the final target character probability distribution is determined by combining the local character probability distributions predicted multiple times before, and the current character is decoded using the target character probability distribution. Since the target character probability distribution is obtained based on the weighted average of multiple local character probability distributions, the target character probability distribution is closer to the global probability distribution, thereby improving the accuracy of the character probability distribution and facilitating the improvement of the decompression and decoding efficiency.
[0105] In some embodiments, determining the local character probability distribution based on N characters before the character to be determined includes: inputting the N characters before the character to be determined into a neural network model, and predicting the local character probability distribution of the N characters through the neural network model.
[0106] Here, during the decompression process, the RNN probability predictor also uses the trained network model weights to produce the same probability estimates as during the compression process. The specific principle of the RNN probability predictor is described above.
[0107] In some embodiments, after the obtained data stream is compressed and encoded, the compressed and encoded data stream is processed based on the Log-Structured Merge Tree (LSM-Tree) technology principle. Among them, LSM-Tree is a quantitative tree storage structure that supports high-speed data search. The basic working idea is to help data storage realize network stratification through its core characteristics and improve data reading and writing performance.
[0108] That is, in some embodiments, it may also include: determining that the compressed and encoded data stream is the target data stream; storing the target data stream based on the LSM-Tree method; wherein the LSM-Tree is a tree-like storage structure formed by sequentially writing the target data stream and, when certain conditions are met, performing a series of merging operations to hierarchically store the target data stream.
[0109] In actual application, the LSM-Tree provided in the embodiment of the present application may include multiple layers of storage areas; storing the target data stream based on the log structure merge tree LSM-Tree method may include: sequentially caching the target data stream to the first layer of the multi-layer storage area; the first layer includes a sequential sub-storage area and a random sub-storage area; wherein the sequential sub-storage area caches data that is sequentially increasing in time dimension; the random sub-storage area caches data that is not sequentially increasing in time dimension; and when the data capacity in the sequential sub-storage area reaches a first threshold, the data in the sequential sub-storage area is stored in the third layer of the multi-layer storage area; when the data capacity in the random sub-storage area reaches a second threshold, the data in the random sub-storage area is written to the second layer of the multi-layer storage area.
[0110] It should be noted that the LSM-Tree storage structure may include multiple layers of storage areas; based on this, the so-called process of storing the target data stream based on the log structure merge tree LSM-Tree method may include: writing the target data stream sequentially into the first layer of the multi-layer storage area; and the first layer includes a sequential sub-storage area and a random sub-storage area, that is, divided into: a sequential sub-storage area for storing data that is continuously increasing in time, and a random sub-storage area for storing data that is non-continuously increasing in time. And when the data capacity in the sequential sub-storage area reaches a first threshold, the data in the sequential sub-storage area is stored in the third layer of the multi-layer storage area; when the data capacity in the random sub-storage area reaches a second threshold, the data in the random sub-storage area is written into the second layer of the multi-layer storage area. That is, sequential data is directly stored in the third layer; and some random data is stored in the second layer.
[0111] Here, the first layer is the memory; the second layer and the third layer are located in the storage device; the storage device includes a storage medium for storing data, for example, the storage medium is a disk.
[0112] In some implementations, a first-level merge process is performed on the data in the second layer to merge the out-of-order data into sequential data, and the sequential data is stored in the third layer.
[0113] That is, the second layer stores data that is out of order in time. Since the data in the second layer is the data transferred after the data in the out of order sub-storage area in the first layer reaches the first threshold, the second layer can store multiple out of order data. Therefore, in the second layer, the first level of merging processing can be performed to merge the out of order data into sequential data, and then the sequential data is moved to the third layer.
[0114] In some embodiments, the data in the third layer is subjected to a second-level merge processing, multiple first files are merged into a second file, and the second file is stored in a fourth layer or above in the multi-layer storage area; wherein the capacity of each first file is smaller than the capacity of the second file.
[0115] That is, a plurality of first files with smaller capacity are merged into a second file with larger capacity, and the second file is moved to the fourth layer or any layer above the fourth layer. Here, the storage layer with a larger subscript can store a larger capacity of data.
[0116] In some implementations, the priority of the first-level merge processing and the second-level merge processing is determined according to the query frequency of the stored data.
[0117] In some implementations, when frequently querying recently written data, the priority of the first-level merge processing is higher than the priority of the second-level merge processing.
[0118] It should be noted that when querying the target data stream stored in LSM-Tree format, the priority of the first-level merge processing and the second-level merge processing can be determined according to the query frequency of the stored data. For example, when frequently querying recently written data, the priority of the first-level merge processing is higher than the priority of the second-level merge processing.
[0119] To understand the above storage method, see Figure 6 , Figure 6 A schematic diagram of the architecture of the data processing method provided in the embodiment of the present application, such as Figure 6 The figure shows an LSM-Tree architecture diagram.
[0120] Specifically, the LSM-Tree provided in the embodiment of the present application can divide the storage structure into two parts: memory and disk through stratification, where the memory is C0; the disk includes C1, C2, ..., CN. And the data merging is divided into two stages. The main purpose of the first stage is to merge the disordered data, and the second stage is to merge small files, so that the system can complete the disordered data sorting as soon as possible, thereby improving the data processing efficiency and making the subsequent data query storage effective.
[0121] like Figure 6 The storage process shown is as follows:
[0122] (1) Write operation: When new industrial data needs to be written (compressed and encoded data), it is first appended to the sequential write-ahead log (WAL) file. This operation is called write-ahead logging, which ensures data persistence and consistency.
[0123] (2) Write to memory cache (Memtable): Simultaneously write new industrial data to a data structure in memory, usually an ordered data structure such as a jump table or a red-black tree. The memory cache can respond quickly to read operations and has high write performance.
[0124] For steps (1) and (2), that is, when writing new data, the data is first written sequentially to the WAL file and then written to the MemTable. The data will be written to the MemTable until the memory reaches the threshold (the first threshold or the second threshold); after the memory reaches the threshold, it will be automatically converted to an immutable Memtable (Immutable Memtable). The difference between ImmutableMemtable and Memtable is that Immutable Memtable is read-only, so the system generates a new Memtable that can continue to support data writing. Immutable Memtable can avoid blocking the client's normal write operations when writing to disk.
[0125] (3) Merge operation: Merge memory and disk (Memtable to SSTable). The data in the memory (i.e., C0 layer) will be flushed to the disk to form the C1 layer after reaching a certain size. The multiple flushes of the C0 layer cause disorder among multiple files in the C1 layer. In a time series database, the data of the same time series is sorted by timestamp. By recording the latest timestamp of each time series in the memory, it is possible to accurately determine whether the newly written data point of the sequence is sequential (i.e., the timestamp is larger) or disordered (i.e., the timestamp is smaller) compared with the existing data in the C1 layer. Using the above characteristics, the C0 layer memory structure in the LSM is split into a disordered buffer and a sequential buffer. For the data in the C0 layer sequential buffer, when its size reaches the threshold, it will be directly flushed to the C2 layer. The disordered data in the C0 layer can only be flushed to the C1 layer and wait for the LSM file to be merged. There is only a small amount of disordered data in the C1 layer. The recently written data that increases in order in the time dimension is directly in the C2 layer.
[0126] The merging process is divided into two stages: merging out-of-order files into sequential files and merging small sequential files into large files. The out-of-order data is the C1 layer, and the first stage will merge the out-of-order data into the sequential data of the C2 layer. After the first stage is completed, the second stage will merge the small sequential files into more regularized large sequential files, which are the C3 layer or more Cn layers. The writing and merging of C3, C4, ..., Cn are determined by different sequential file merging strategies.
[0127] Among them, the storage string file (Sorted String Table, SSTable), SSTable is the final ordered storage of the data in MemTable on the disk. SSTable usually adopts a hierarchical structure. When the data in Memtable reaches the specified threshold, it will be written to the new SSTable at Level 0. When the number of files under a certain level exceeds a certain value, the SSTable file under this level will be merged with the SSTable file at a higher level. Multi-way merging ensures that the merged SSTable files are orderly and generate a new SSTable file. That is, the writing of LSM-Tree: 1. When a request arrives, the data is first written to WAL; 2. Then it is written to the memory structure MemTable; 3. After MemTable exceeds a certain threshold, it is converted to Immutable Memtable. The system creates a new MemTable to continue to accept write requests; 4. The data in the memory structure ImmutableMemtable is written to the SSTable on the hard disk; 5. When the SSTable volume exceeds a certain size, it will be merged, and the merging process will also clean up the data marked for deletion. If there are multiple levels of SSTable, the data on each level will be merged with the higher level when it reaches a certain size.
[0128] (4) Query operation: First, search for industrial data in the memory cache. The purpose of the first stage of file merging is to quickly reduce disordered data, thereby supporting efficient ad hoc queries of recent data. Compared with traditional LSM, when performing the same number of IO operations, the first stage of file merging can organize more disordered data into sequential data than traditional LSM. The purpose of the second stage of file merging is to generate large-block data files, thereby reducing frequent disk seek operations when analytical queries read data in batches.
[0129] In actual applications, the resource allocation for two-stage merging can be performed based on the query load of the system. For example, when users frequently perform real-time queries on a large amount of recent data, the priority for merging out-of-order data is higher, and merging small files into large files is not very necessary. Instead, it will block the system's real-time query and write performance due to excessive IO and CPU resources. In this case, more thread resources can be given to the first stage, and the frequency of merging the first stage can be increased to speed up the merging of the first stage, and then the second stage file merging can be slowly run to eventually merge the small files into large files.
[0130] Since the memory cache is ordered and can be quickly located, a range table is maintained in the memory, which records the range of the key corresponding to each SSTable. When the key of the target key-value pair meets the range of a certain SSTable, the SSTable is loaded into the memory for inspection, and the internal Bloom filter is used to quickly determine whether the key exists, thereby reducing time-consuming overhead.
[0131] (5) If the data is not found in the memory cache, it is searched in the SSTable files on the disk in turn, usually using algorithms such as binary search for fast positioning and retrieval.
[0132] Since the data in memory is ordered, the fastest way to copy the data in memory to disk is to use sequential writing, and write the data in the Imutable MemTable into the SSTable file in sequence through the SSTable file constructor TableBuilder. In the process of generating SSTable files, the code record (TableBuilder::Rep) object will be used to store the status information of file writing, including the file write position, the last key, the cache of each part of the file data, etc.; in addition, a file meta information object (FileMetaData) will be used to record the SSTable file number, minimum key, maximum key and file size. This information provides guidance for subsequent SSTable file queries. This batch of industrial data is called a segment in SSTable, and the segments will be stacked one by one. When retrieving data, search from back to front according to the segment sequence number, such as Figure 7 As shown, Figure 7 Storage diagram of the data processing method provided in the embodiment of the present application Figure 1 .
[0133] As the data increases, the number of segments will also increase. It is unreasonable to store too many segments in one SSTable. At the same time, the same key may exist in different segments. When the number of segments increases, the read and write performance will inevitably decrease. Therefore, it is necessary to compress multiple segments into one segment, as follows Figure 8 As shown, Figure 8 Storage diagram of the data processing method provided in the embodiment of the present application Figure 2 , and by merging segments with the same key, segments will not expand infinitely to support massive data storage.
[0134] based on Figure 6 The LSM-Tree architecture diagram shown in the figure shows that the storage process is roughly as follows:
[0135] S1: Collect data from industrial field equipment, transform industrial equipment with the help of industrial gateways, IO modules, etc., and complete business data collection.
[0136] S2: Process the collected data. The collected data must first be written to the database. When writing, it is placed in the log file in a sequential manner, and the new industrial data is written into the data structure in the memory.
[0137] S3: When the data in the file memory (i.e., C0 layer) reaches a certain size or other trigger conditions are met, it will be flushed to the disk to form C1 layer. The C0 layer memory structure in LSM is split into a disordered buffer and a sequential buffer. For the data in the C0 layer sequential buffer, when its size reaches the threshold, it will be directly flushed to the C2 layer. The disordered data in the C0 layer can only be flushed to the C1 layer. There is only a small amount of disordered data in the C1 layer. The recently written data that increases in order in the time dimension is directly in C2.
[0138] S4: When there is a lot of data, the compression operation of LSM-Tree will remove invalid key-value pairs from duplicate keys, and reorganize them into new SSTable files after removing the duplicate key-value pairs, thereby improving query efficiency and supporting massive data storage.
[0139] In the first stage, only the disordered files are merged into sequential files to achieve the fastest recent hot data sorting; in the second stage, the sequential small files are merged into large files to achieve the reading of large blocks of data. In addition, in order to reduce the LSM workload in the first stage, when writing real-time data, the locally disordered data is directly written to the C1 layer, and the data with increasing order in the recent time dimension is directly in the C2 layer, thereby reducing the amount of data in the C0 layer. The comparison results of the read and write performance of the system under the traditional LSM merge strategy show that the two-stage LSM merge can improve the efficiency of data merging and can effectively improve the efficiency of data query.
[0140] This is the end of the process.
[0141] For the existing technologies, many optimization schemes have been proposed to optimize the storage performance of massive data: the file storage system based on data optimization helps to improve the data storage speed by optimizing the storage structure of logs to achieve energy-saving effects, but the system is overloaded due to the frequent writing and sending of logs, which affects the storage progress of data and reduces the overall efficiency. A classification method is adopted to help realize the energy-saving storage of data. Although the processing speed of this method is fast, the cardinality of classification recognition is large, resulting in a high error rate and affecting the storage accuracy. Reduce the amount of data, exchange space for performance, and select the best storage system. These technical schemes all seek solutions from objective factors, and do not seek optimization paths from the structure of the database system itself, and cannot efficiently solve the problems of high storage power consumption and weak processing stability caused by massive data storage and calculation. The technical scheme proposed in this application is adopted to collect, process and optimize the storage of data based on LSM-Tree, so that the system can complete the sorting of disordered data as soon as possible, bringing performance optimization of recent written data queries.
[0142] In the era of big data, we are faced with large-scale data storage and query problems. Although the traditional LSM-Tree makes full use of the sequential writing of disk batches and improves the data writing capability, it is at the expense of some reading performance. However, the technical method proposed in this proposal optimizes data storage based on LSM-Tree, which can comprehensively consider data collection, data writing, data reading and data storage capabilities, and adapt to the scenario of large-scale data acquisition and massive data access. LSM-Tree pre-write log operation, write cache operation and merge operation are used to improve data processing capabilities. Using sequential write method, a batch of industrial data in immutablememtable is copied to SSTable to form a segment, multiple segments are compressed into one segment, and the same key is merged to support massive data storage. In the large-scale data acquisition scenario, the data storage system based on LSM-Tree has the best data redundancy elimination effect, the lowest consumption and the strongest stability.
[0143] Based on this, the data processing method provided by the embodiment of the present application, in terms of data collection, in response to the characteristics of massive data streams, based on LSM-tree, with the vertical topology design of storage warning, can ensure data collection throughput and delay performance: combining the data stream distribution characteristics and LSM structural characteristics, massive data is processed based on update frequency statistics and cache aggregation processing based on data segment sparsity detection to control potential space amplification and performance degradation. In response to access-intensive application scenarios, the cache interface layer integrates the existing memory high-speed key-value storage warning while redesigning the data cache logic, realizing a unified data access cache interface for applications. In combination with different data collection methods, the data collection end realizes the classification processing and high-speed real-time transmission of collected data. In terms of data processing: pre-compressing the data using neural network RNN technology can reduce the data scale and magnitude from the root, reduce the investment cost of data storage hardware and software equipment, and improve the efficiency of database use and the company's data management level. At the same time, it has high write performance and compressed storage, which can be used to realize cache to provide fast data access and response time. It is suitable for scenarios that need to process large amounts of data and have high requirements for read operations. By concentrating write operations in memory and sequentially written log files, higher write throughput can be achieved. Query performance is also good, and key-value pairs can be quickly located and retrieved through memory cache and ordered SSTable files. Since LSM-Tree's efficient support for write operations is consistent with the characteristics of time series data, it is also widely used in time series data storage and analysis.
[0144] The data processing method provided in the embodiment of the present application, in terms of data storage, in the current big data analysis application, for the entire database, the data update is relatively small, and we can store this part of incremental data in memory. Based on the LSM-Tree storage architecture, the data update server (Update Server, UPS) stores memory data separately, and the data storage server (Chunk Server, CS) stores persistent baseline data. According to the storage scale of the data, the CS can be horizontally expanded to achieve different levels of storage. In order to improve the availability of the storage system, RS adopts a master-slave architecture, always keeping one RS in an active state to achieve strong consistency between the master and the slave.
[0145] Fig. 9 The structure of the data processing device provided in the embodiment of the present application is shown in FIG. Figure 1 ,like Fig. 9 As shown, the data processing device 900 includes:
[0146] The acquisition unit 901 is used to acquire a data stream, where the data stream includes L characters, where L is a positive integer.
[0147] The encoding unit 902 is used to intercept the first N characters of the L characters as the target object, determine the target interval corresponding to the target object in the initial interval according to the initial character probability distribution; traverse each character after the target object in the L characters to perform the following process: determine the local character probability distribution according to the N characters before the character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval corresponding to the character in the first interval according to the target character probability distribution, and the first interval is the target interval or the interval determined by the process before the current process; after determining the interval corresponding to the last character of the L characters, select a value from the interval corresponding to the last character as the encoding information of the L characters.
[0148] In some embodiments, the encoding unit 902 is also used to traverse each character in the target object and perform the following process: dividing the second interval into K first sub-intervals according to the initial character probability distribution, and the probability that different first sub-intervals in the K first sub-intervals correspond to different types of characters, K is a positive integer; determining the first sub-interval corresponding to the character in the K first sub-intervals, and the second interval is the initial interval or the interval determined by the process before the current process; and determining the first sub-interval corresponding to the last character in the target object as the target interval.
[0149] In some embodiments, the encoding unit 902 is also used to perform a weighted average on the first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process to obtain a target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0150] In some embodiments, the encoding unit 902 is also used to divide the first interval into K second sub-intervals according to the target character probability distribution, and different second sub-intervals in the K second sub-intervals correspond to the probability of different types of characters, K is a positive integer; and determine the second sub-interval corresponding to the character in the K second sub-intervals.
[0151] In some implementations, the encoding unit 902 is further configured to input N characters preceding the character into a neural network model, and predict the local character probability distribution of the N characters through the neural network model.
[0152] Those skilled in the art should understand that Fig. 9 The implementation functions of each unit in the data processing device shown can be understood by referring to the relevant description of the aforementioned method. Fig. 9 The functions of each unit in the data processing device shown may be implemented by a program running on a processor, or may be implemented by a specific logic circuit.
[0153] Fig.10 The structure of the data processing device provided in the embodiment of the present application is shown in FIG. Figure 2 ,like Fig.10 As shown, the data processing device 1000 includes:
[0154] The receiving unit 1001 is used to receive encoding information of L characters, where the encoding information is represented by a numerical value, and L is a positive integer.
[0155] The decoding unit 1002 is used to determine the target interval to which the numerical value belongs in the initial interval according to the initial character probability distribution, and determine the first N characters of the L characters according to the target interval; for each to-be-determined character after the first N characters of the L characters, perform the following process: determine the local character probability distribution according to the N characters before the to-be-determined character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval to which the numerical value belongs in the first interval according to the target character probability distribution, and determine the to-be-determined character according to the interval to which the numerical value belongs, the first interval being the target interval or the interval determined by the process before the current process; after determining the last to-be-determined character of the L characters, restore the data stream according to all the determined characters.
[0156] In some embodiments, the decoding unit 1002 is also used to execute the following process N times: dividing the second interval into K first sub-intervals according to the initial character probability distribution, different first sub-intervals in the K first sub-intervals correspond to the probability of different types of characters, and K is a positive integer; determining the first sub-interval to which the numerical value belongs in the K first sub-intervals, and determining one of the N characters according to the first sub-interval to which the numerical value belongs; the second interval is the initial interval or an interval determined by a process before the current process; and the N characters determined by the N processes are used as the first N characters of the L characters.
[0157] In some embodiments, the decoding unit 1002 is also used to perform weighted averaging on the first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process to obtain the target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
[0158] In some embodiments, the decoding unit 1002 is further used to divide the first interval into K second sub-intervals according to the target character probability distribution, different second sub-intervals in the K second sub-intervals correspond to the probability of different types of characters, and K is a positive integer; and determine the second sub-interval to which the numerical value belongs in the K second sub-intervals.
[0159] In some implementations, the decoding unit 1002 is further configured to input N characters preceding the character to be determined into a neural network model, and predict the local character probability distribution of the N characters through the neural network model.
[0160] Those skilled in the art should understand that Fig.10 The implementation functions of each unit in the data processing device shown can be understood by referring to the relevant description of the aforementioned method. Fig.10 The functions of each unit in the data processing device shown may be implemented by a program running on a processor, or may be implemented by a specific logic circuit.
[0161] Fig.11 1 is a schematic structural diagram of a processing device 1100 provided in an embodiment of the present application. The processing device may be a terminal device or a network device. Fig.11 The processing device 1100 shown includes a processor 1110, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.
[0162] Alternatively, if Fig.11 As shown, the processing device 1100 may further include a memory 1120. The processor 1110 may call and run a computer program from the memory 1120 to implement the method in the embodiment of the present application.
[0163] The memory 1120 may be a separate device independent of the processor 1110 , or may be integrated into the processor 1110 .
[0164] Alternatively, if Fig.11 As shown, the processing device 1100 may further include a transceiver 1130, and the processor 1110 may control the transceiver 1130 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.
[0165] The transceiver 1130 may include a transmitter and a receiver. The transceiver 1130 may further include an antenna, and the number of the antennas may be one or more.
[0166] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0167] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0168] It should be understood that the above-mentioned memory is exemplary but not restrictive. For example, the memory in the embodiments of the present application may also be static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synch link DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM), etc. That is to say, the memory in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memory.
[0169] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0170] Optionally, the computer-readable storage medium can be applied to the network device in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the network device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0171] Optionally, the computer-readable storage medium can be applied to the mobile terminal / terminal device in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0172] An embodiment of the present application also provides a computer program product, including computer program instructions.
[0173] Optionally, the computer program product can be applied to the network device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the network device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0174] Optionally, the computer program product can be applied to the mobile terminal / terminal device in the embodiments of the present application, and the computer program instructions enable the computer to execute the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0175] The embodiment of the present application also provides a computer program.
[0176] Optionally, the computer program can be applied to the network device in the embodiments of the present application. When the computer program runs on a computer, the computer executes the corresponding processes implemented by the network device in the various methods in the embodiments of the present application. For the sake of brevity, they are not described here.
[0177] Optionally, the computer program can be applied to the mobile terminal / terminal device in the embodiments of the present application. When the computer program runs on the computer, the computer executes the corresponding processes implemented by the mobile terminal / terminal device in the various methods of the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0178] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0180] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0183] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0184] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data processing method, characterized in that: The method comprises: Obtain a data stream, wherein the data stream includes L characters, where L is a positive integer; The first N characters of the L characters are intercepted as target objects, and a target interval corresponding to the target object is determined in an initial interval according to an initial character probability distribution; Traversing each character after the target object in the L characters, performing the following process: determining a local character probability distribution according to the N characters before the character, determining a target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, and determining an interval corresponding to the character in a first interval according to the target character probability distribution, the first interval being the target interval or an interval determined by the process before the current process; After determining the interval corresponding to the last character of the L characters, a value is selected from the interval corresponding to the last character as the encoding information of the L characters.
2. The method according to claim 1, characterized in that The step of determining the target interval corresponding to the target object in the initial interval according to the initial character probability distribution includes: Traversing each character in the target object, the following process is performed: dividing the second interval into K first sub-intervals according to the initial character probability distribution, the probability that different first sub-intervals in the K first sub-intervals correspond to different types of characters, K is a positive integer; determining the first sub-interval corresponding to the character in the K first sub-intervals, the second interval being the initial interval or an interval determined by a process before the current process; A first sub-interval corresponding to the last character in the target object is determined as the target interval.
3. The method according to claim 1, characterized in that: The step of determining the target character probability distribution according to the local character probability distribution determined in the current process and the process before the current process includes: The first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process are weighted averaged to obtain the target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
4. The method according to claim 1, characterized in that: The determining, according to the target character probability distribution, an interval corresponding to the character in the first interval includes: The first interval is divided into K second sub-intervals according to the target character probability distribution, different second sub-intervals in the K second sub-intervals correspond to the probability of different types of characters, K is a positive integer; and the second sub-interval corresponding to the character is determined in the K second sub-intervals.
5. The method according to any one of claims 1 to 4, characterized in that The determining of the local character probability distribution according to the N characters before the character includes: The N characters before the character are input into the neural network model, and the local character probability distribution of the N characters is predicted by the neural network model.
6. A data processing method, characterized in that: The method comprises: Receive L characters of coded information, where the coded information is represented by a numerical value, where L is a positive integer; Determine a target interval to which the value belongs in an initial interval according to an initial character probability distribution, and determine first N characters among the L characters according to the target interval; For each character to be determined after the first N characters among the L characters, the following process is performed: determining a local character probability distribution according to the N characters before the character to be determined, determining a target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determining the interval to which the numerical value belongs in a first interval according to the target character probability distribution, and determining the character to be determined according to the interval to which the numerical value belongs, wherein the first interval is the target interval or the interval determined by the process before the current process; After the last character to be determined among the L characters is determined, the data stream is restored according to all the determined characters.
7. The method according to claim 6, characterized in that The step of determining the target interval to which the value belongs in the initial interval according to the initial character probability distribution, and determining the first N characters of the L characters according to the target interval includes: Execute the following process N times: divide the second interval into K first sub-intervals according to the initial character probability distribution, different first sub-intervals in the K first sub-intervals correspond to the probability of different types of characters, and K is a positive integer; determine the first sub-interval to which the value belongs in the K first sub-intervals, and determine one of the N characters according to the first sub-interval to which the value belongs; the second interval is the initial interval or an interval determined by a process before the current process; The N characters determined by the N processes are used as the first N characters of the L characters.
8. The method according to claim 6, characterized in that The step of determining the target character probability distribution according to the local character probability distribution determined in the current process and the process before the current process includes: The first local character probability distribution determined by the current process and the second local character probability distribution determined by the process before the current process are weighted averaged to obtain the target character probability distribution; wherein the weight corresponding to the first local character probability distribution is greater than the weight corresponding to the second local character probability distribution.
9. The method according to claim 6, characterized in that Determining the interval to which the value belongs in the first interval according to the target character probability distribution includes: The first interval is divided into K second sub-intervals according to the target character probability distribution, different second sub-intervals in the K second sub-intervals correspond to the probability of different types of characters, and K is a positive integer; and the second sub-interval to which the numerical value belongs is determined in the K second sub-intervals.
10. The method according to any one of claims 6 to 9, characterized in that The determining of the local character probability distribution according to the N characters before the character to be determined includes: N characters before the character to be determined are input into a neural network model, and the local character probability distribution of the N characters is predicted by the neural network model.
11. A data processing device, characterized in that: The device comprises: An acquisition unit, used for acquiring a data stream, wherein the data stream includes L characters, where L is a positive integer; The encoding unit is used to intercept the first N characters of the L characters as target objects, determine the target interval corresponding to the target object in the initial interval according to the initial character probability distribution; traverse each character after the target object in the L characters to perform the following process: determine the local character probability distribution according to the N characters before the character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval corresponding to the character in the first interval according to the target character probability distribution, and the first interval is the target interval or the interval determined by the process before the current process; after determining the interval corresponding to the last character of the L characters, select a value from the interval corresponding to the last character as the encoding information of the L characters.
12. A data processing device, characterized in that: The device comprises: A receiving unit, used for receiving encoding information of L characters, wherein the encoding information is represented by a numerical value, and L is a positive integer; A decoding unit is used to determine the target interval to which the numerical value belongs in the initial interval according to the initial character probability distribution, and determine the first N characters of the L characters according to the target interval; for each to-be-determined character after the first N characters of the L characters, perform the following process: determine the local character probability distribution according to the N characters before the to-be-determined character, determine the target character probability distribution according to the local character probability distribution determined by the current process and the process before the current process, determine the interval to which the numerical value belongs in the first interval according to the target character probability distribution, and determine the to-be-determined character according to the interval to which the numerical value belongs, the first interval being the target interval or the interval determined by the process before the current process; after determining the last to-be-determined character of the L characters, restore the data stream according to all the determined characters.
13. A processing device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 10.
14. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program causes a computer to execute the method according to any one of claims 1 to 10.
15. A computer program product, characterized in that The method comprises computer program instructions which cause a computer to execute the method as claimed in any one of claims 1 to 10.
