Data reading and writing method, computing device and storage medium

By determining the data index and association relationship in the time series database, optimizing the data reading and writing process, the problem of insufficient real-time data collection and storage performance of the time series database in industrial production is solved, the data reading and writing performance is significantly improved, and the digital Twin factories require real-time data processing.

CN114185887BActive Publication Date: 2024-10-15ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing time series database has poor performance in real-time data collection and storage in the industrial production process, which affects the real-time, accuracy and availability of data, resulting in the failure to effectively guarantee the data processing requirements of the digital twin factory.

Method used

By receiving the data to be written, determine the correlation between its index and collection time and data type, use the index and correlation to read and write data, improve data reading performance, and merge the buffer queue and data type. and other technologies to optimize the read and write performance of the database.

Benefits of technology

Significantly improves the data reading and writing performance, solves the bottleneck of real-time data reading and writing in industrial scenarios, ensures the processing requirements of digital twin applications for industrial real-time data, doubles the writing performance, and more than 10 times the query performance, solving the problem Time series database read and write performance bottleneck.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114185887B_ABST
    Figure CN114185887B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a data reading and writing method, computing device and storage medium. In the embodiment of the present application, data to be written is received, and the data to be written is data collected according to different collection times, and the data has a corresponding data type; according to the data type corresponding to the data to be written, the index of the data to be written is determined; the association between the collection time corresponding to the data to be written and the data type is determined, so that data is read through the index and the association; after determining the index and the association, the data to be written is written into a preset database. In the case where the index determined according to the data type causes weak reading accuracy under a rough force, the data type can be further accurately determined through the association, so that based on the more accurate data type, more accurate reading data can be obtained, thereby improving the data reading performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data reading and writing method, a computing device, and a storage medium. Background Art

[0002] In the field of intelligent manufacturing, it is necessary to conduct real-time indicator monitoring and process optimization for the actual production processes of industries such as automobiles and electricity. However, this realization requires the real-time collection and playback of production process data. However, for real-time data in the actual production process in industry, the general time series database does not have good performance in the collection and storage of production process data, which will affect the real-time, accuracy and availability of the data implemented above. How to improve performance is the key to solving this problem. Summary of the invention

[0003] Multiple aspects of the present application provide a data reading and writing method, a computing device, and a storage medium, so as to improve data reading performance.

[0004] An embodiment of the present application provides a method for reading and writing data, including: receiving data to be written, the data to be written is data collected according to different collection times, and the data has a corresponding data type; determining an index of the data to be written according to the data type corresponding to the data to be written; determining an association between the collection time corresponding to the data to be written and the data type, so that data is read through the index and the association; after determining the index and the association, writing the data to be written into a preset database.

[0005] An embodiment of the present application also provides a computing device, including: a memory and a processor; the memory is used to store a computer program; the processor executes the computer program to: receive data to be written, the data to be written is data collected according to different collection times, and the data has a corresponding data type; determine an index of the data to be written according to the data type corresponding to the data to be written; determine the association between the collection time corresponding to the data to be written and the data type, so that data is read through the index and the association; after determining the index and the association, write the data to be written into a preset database.

[0006] An embodiment of the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by one or more processors, the one or more processors implement the steps in the above method.

[0007] In an embodiment of the present application, data to be written is received, and the data to be written is data collected according to different collection times, and the data has a corresponding data type; according to the data type corresponding to the data to be written, an index of the data to be written is determined; the association between the collection time and the data type corresponding to the data to be written is determined, so that data is read through the index and the association; after determining the index and the association, the data to be written is written into a preset database.

[0008] Among them, the association between the acquisition time and the data type corresponding to the data to be written is determined, so that the data type of the data to be written is determined through the association, so as to read the data; after determining the index and the association, the data to be written is written into the preset database. In the case where the reading accuracy is weak under a rough force, the index determined according to the data type can be further accurately determined through the association, so that based on the more accurate data type, more accurate reading data can be obtained, thereby improving the data reading performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0010] Figure 1 A flowchart of a method for reading and writing data according to an exemplary embodiment of the present application;

[0011] Figure 2 A schematic diagram of a data reading and writing process of an exemplary embodiment of the present application;

[0012] Figure 3 A structural diagram of a data reading and writing system of an exemplary embodiment of the present application;

[0013] Figure 4 A schematic diagram of the structure of a data reading and writing device provided for an exemplary embodiment of the present application;

[0014] Figure 5 A schematic diagram of the structure of a computing device provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0015] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only 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 making creative work are within the scope of protection of the present application.

[0016] In order to facilitate real-time indicator monitoring and process optimization of the production process, it is necessary to build a corresponding virtual digital twin factory. This realization requires the real-time collection and playback of production process data, but for the real-time data in the actual production process in the industry, there are generally many data points, large data volume, and low data value density per unit time. General time series databases focus on the collection and analysis of real-time data. For the collection and storage of full data, the performance is not very good, which will affect the real-time, accuracy and availability of data in the digital twin factory.

[0017] Based on this, the embodiments of the present application provide a data reading and writing method, computing device and storage medium, which greatly improves the reading and writing performance of the database, solves the bottleneck of real-time data reading and writing problems in industrial scenarios, and can effectively guarantee the digital twin application's needs for industrial real-time data processing and processing.

[0018] The data reading and writing process is described in detail below in conjunction with the method embodiment.

[0019] Figure 1 This is a flowchart of a data reading and writing method according to an exemplary embodiment of the present application. The method 100 provided in the embodiment of the present application is executed by a computing device, such as a cloud server. The method 100 includes the following steps:

[0020] 101: receiving data to be written.

[0021] The data to be written is data collected at different collection times, and the data has a corresponding data type.

[0022] 102: Determine the index of the data to be written according to the data type corresponding to the data to be written.

[0023] 103: Determine the association relationship between the collection time and the data type corresponding to the data to be written, so that the data can be read through the index and the association relationship.

[0024] 104: After determining the index and the association relationship, the data to be written is written into the preset database.

[0025] The following is a detailed description of the above steps:

[0026] 101: receiving data to be written.

[0027] Among them, the data to be written is data collected according to different collection times, such as time series data. The data has a corresponding data type. For example, the data to be written may be data in an industrial scenario (such as automobile and electric power industries, etc.), and the data may be time series data collected by corresponding sensors in a factory, such as temperature time series data, pressure time series data, and current time series data collected in a corresponding factory under the electric power industry. When the time series data is collected, it has a corresponding collection time and data type. Among them, the data type refers to a data indicator, such as voltage, temperature, or current. The corresponding data type can be determined in the form of a data tag.

[0028] For example, the factory collects the temperature of the power equipment through the corresponding sensor, such as the temperature sensor, and sends the collected temperature data value to the factory's data receiving device, which can be a server or a host computer. After receiving the data value, the data receiving device can determine the current collection time (also called a timestamp). And determine the data label corresponding to the value, that is, the temperature. Thus, data to be written in a certain data format can be generated.

[0029] It should be noted that, for the data of the data type, or the data of the data tag, the data type is the same. However, the acquisition time and the data value may be different. In addition, the data to be written may also have other information, such as information used to describe the data, and supplementary information such as the device to which the data belongs.

[0030] The data receiving device sends the data to be written to the cloud server. The cloud server receives the data to be written. Alternatively, the data receiving device sends the data to be written to the Kafka distributed publish-subscribe messaging system, which is then sent to the cloud server by Kafka.

[0031] It should be understood that different sensors may collect different time series data, which may correspond to different data types and may belong to different devices.

[0032] More specifically, data may be received by dividing the architecture of the server, such as receiving the data to be written through an interface in the cloud server.

[0033] For example, Figure 2 As shown, the data receiving service 2011 in the service interface layer 201 of the cloud server executes step 211: receiving the data to be written.

[0034] 102: Determine the index of the data to be written according to the data type corresponding to the data to be written.

[0035] For example, according to the above, when the cloud server receives the data to be written, the index value of the data to be written can be determined according to the data tag of the data to be written, such as temperature. The temperature can be directly used as the index value.

[0036] It should be noted that, for data of the same data type, the corresponding index value may be the same. The data may be located and searched for reading by the index value. The index value may be preset or established according to the storage location.

[0037] However, since the data type is limited, that is, it can support limited data types and limited indexes, it cannot support the case of large and large data. In order to support this situation, the data type needs to be processed to support more different data types, such as by merging different data types to meet the limited number of data types.

[0038] Specifically, the index of the data to be written is determined according to the data type corresponding to the data to be written, including: according to different preset data types, the preset data types are merged so that at least two preset data types are merged into one data type; according to the merged data type, the data type corresponding to the data to be written is matched to determine the merged data type corresponding to the data to be written; according to the corresponding merged data type, the index of the data to be written is determined.

[0039] The preset data type can be determined by the preset data tag, such as temperature, pressure, etc., which can correspond to the data type of the data to be written.

[0040] For example, according to the foregoing, the cloud server can merge or compress two preset data tags, such as merging temperature and pressure into an environmental monitoring value, or merging them into one type of temperature or pressure, that is, the two preset data types can be merged into one preset data type. Then the index value is determined based on the merged environmental monitoring value, or temperature. The data belonging to the merged environmental monitoring value, or temperature is: the data to be written with the data tag of temperature, and the data to be written with the data tag of pressure. When the cloud server receives the data to be written, it determines the corresponding merged data tag based on the data tag corresponding to the data. For example, when the data tag of the received data to be written is pressure, the merged data tag of the data to be written is the environmental monitoring value, or temperature. The corresponding index is determined based on the merged data tag environmental monitoring value, or temperature.

[0041] In this way, the above-mentioned problem of supporting a limited number of data types and data indexes can be solved.

[0042] In addition, after the cloud server receives the data to be written, in order to better write the data in sequence, a buffer queue can be set up.

[0043] For example, according to the above description, after receiving the data to be written, the cloud server, or the service interface layer of the cloud server, can send the data to be written to a buffer queue. The buffer queue can be set to one. Then, the data to be written in the queue is indexed by the buffer queue.

[0044] However, in order to improve data writing performance, the queue can contain more data to be written so that the data to be written is not waiting at the service interface layer. On this basis, multiple buffer queues can be set to store the data to be written. The data to be written is obtained from multiple buffer queues and the index is determined.

[0045] Specifically, the method 100 also includes: creating at least one buffer queue; after receiving the data to be written, placing the data to be written into at least one buffer queue for data buffering; obtaining multiple data to be written from at least one buffer queue, and executing the step of determining the index of the data to be written according to the data type corresponding to the data to be written based on the multiple data to be written.

[0046] The buffer queue may refer to an asynchronous cache queue. The buffer queue may have multiple ones. The buffer queue may be a ring queue, and each buffer queue may correspond to at least one consumer, that is, the consumer extracts the data to be written in the queue, that is, extracts the data to be written from the buffer queue.

[0047] For example, according to the above, if Figure 2 As shown, after the service interface layer 201 receives the data to be written, it sends the data to be written to the parallel consumption queue 2021 (i.e., multiple buffer queues) in the data parallel processing layer 202. That is, step 212 is executed: put the data to be written. The parallel consumption queue 2021, i.e., the buffer queue, can have multiple. Extract multiple data to be written from the parallel consumption queue 2021. Based on the extracted multiple data to be written, the cloud server executes step 102, which will not be repeated.

[0048] It should be noted that before sending the data to be written to the buffer queue, the queue can be selected according to the current queue status of the buffer queue. If the buffer queue is currently in a ready state, that is, the queue has no data to be written to be put in, the data to be written can be put into the queue first. When the queue is busy or processing, that is, the queue is put by the data to be written. The cloud server can determine the state of the buffer queue according to different situations, so that the data to be written can be selectively put into the corresponding buffer queue for different states. As a result, the buffer queue has better concurrent processing performance through the circular queue and queue status. In addition, the buffer queue can also have other queue states, such as idle, full, etc. The problem of batch writing of time series data at this layer is solved by the buffer queue.

[0049] 103: Determine the association relationship between the collection time and the data type corresponding to the data to be written, so that the data can be read through the index and the association relationship.

[0050] The data type of the data to be written can be determined through the association relationship to complete the data reading.

[0051] As can be seen from the previous text, although the complexity of indexes and data types can be reduced by merging or compressing preset data types, when querying and reading data subsequently, the merging or compression of preset data types will reduce the index accuracy, so the queried data may be inaccurate, that is, the accuracy is reduced. This causes data overwriting. Therefore, in order to solve this problem, the data type and the collection time can be associated, that is, the data type corresponding to the data to be written can be determined through the association relationship, so as to accurately determine the data type, and then help accurately locate and query the data.

[0052] For example, the acquisition time corresponding to the acquired data to be written may be associated with its corresponding data label, such as pressure, or its acquisition time may be marked with "pressure", thereby achieving association.

[0053] In order to realize the association more conveniently, it can be achieved in the following way.

[0054] Specifically, determining the association relationship between the collection time corresponding to the to-be-written data and the data type includes: encoding according to the collection time, associating the encoded result with the data type, and determining the association relationship.

[0055] For example, according to the above, if Figure 2As shown, the data encoder 2031 in the data encoding and decoding layer 203 of the cloud server obtains the data to be written as described above. That is, according to the above, it can be that the consumer in the data parallel processing layer extracts the data to be written in the buffer queue, that is, executes step 213: sends multiple data to be written to the data encoder 2031 in the data encoding and decoding layer 203. The data encoder 2031 encodes the acquisition time corresponding to the multiple data to be written, that is, the timestamp through an encoding method or encoding algorithm. Such as hash algorithm and base64 encoding method. Then the encoded result is associated with the data tag.

[0056] Therefore, when the data is subsequently read or queried, the data label can be determined from the encoded result according to the association relationship, thereby determining whether to obtain the data.

[0057] Specifically, determining the association between the acquisition time corresponding to the data to be written and the data type includes: encoding the time data at the corresponding position in the acquisition time according to the data type to determine the association; wherein the corresponding position refers to the corresponding position of the preset time unit in the acquisition time.

[0058] The preset time unit refers to the time unit in the acquisition time, such as the preset time unit in year, month, day, hour, minute, second, millisecond and nanosecond, etc. Each time unit can correspond to a time value, such as 1 in January, 13 in 13 hours, 30 in 30 minutes, etc.

[0059] The time data at the corresponding position may refer to the time data at the corresponding position of the preset time unit in the acquisition time. For example, the second digit "3" or the first digit "1" in 13:00 in the acquisition time. Or the first digit "0" or the second digit "0" in the nanosecond in the acquisition time. Different data types may be encoded according to different digits of time data. For example, the first digit of the time data in the nanosecond in the acquisition time is encoded to the corresponding data type: temperature, and the second digit of the time data is encoded to the corresponding data type: pressure, etc.

[0060] For example, according to the above, if Figure 2 As shown, the data encoder 2031 obtains the nanosecond time values ​​in the acquisition time corresponding to the multiple data to be written, and then encodes the first time data in the nanosecond time value, such as "0", according to the data label of the data to be written, such as temperature. Thus, the data label is associated with the acquisition time. After encoding, the data to be written can be written.

[0061] It should be noted that other time units corresponding to the time data of the position can also be selected for encoding, and then the encoding result is recorded without affecting the acquisition time. However, since nanoseconds are generally not used, directly encoding nanoseconds will not affect the acquisition time.

[0062] 104: After determining the index and the association relationship, the data to be written is written into the preset database.

[0063] Among them, the preset database can be a time series database, which is an underlying storage system mainly used to store data.

[0064] For example, according to the above, if Figure 2 As shown, after encoding, the data encoder 2031 in the data encoding and decoding layer 203 can write the encoded multiple data to be written into the time series database 2041 in the data storage layer 204, that is, execute step 214: store the data to be written.

[0065] It should be noted that, during the storage process, the data may be stored according to different data dimensions, such as storing data of the same data type together, or storing data of the same device together.

[0066] It should be noted that when switching to a different database, such as a time series database, it is only necessary to add the corresponding encoding method mentioned above without adjusting the encoding algorithm itself and the deployment architecture of the physical machine equipment (such as the host of the cloud server). The embodiment of the present application can also be expanded at the hardware level, but the corresponding switching data cost will be higher.

[0067] The embodiment of the present application can flexibly adjust the encoding scheme by providing encoding methods for different databases to support the operating environment of different databases, and execute different execution scripts in different databases to implement the above encoding. When the data type increases, the encoding scheme can be flexibly adjusted to quickly support the need for data reading and writing. In addition, the write performance can be flexibly configured by adjusting the number of buffer queues.

[0068] After the data is written, the data can be read based on it.

[0069] Specifically, the method 100 also includes: receiving a data read request, and splitting the data read request into multiple sub-requests according to the dimension of the requested data; and reading corresponding data through multiple corresponding threads according to the multiple sub-requests.

[0070] For example, according to the foregoing, the operator of the corresponding factory can send a data reading request to the cloud server through a data receiving device, or a data query request. After receiving the request, the cloud server can split the request and can split the request into multiple tasks based on the dimensions of the request to query data or request to read data, such as the device dimension, data type dimension, and factory dimension. If the data for the same device is a task, then the data for different device dimensions can be split into multiple tasks for the data of each device, and each task corresponds to the data of one device. Or for the same data type dimension, then the data for different data type dimensions can be split into multiple tasks for the data of each data type, and each task corresponds to the data of one data type, etc.

[0071] More specifically, it could be, Figure 2 As shown, according to the foregoing, the data query service 2012 in the service interface layer 201 in the cloud server executes step 215: receiving a query request, that is, receiving a data query request, and then splitting the request.

[0072] After splitting the request, each task obtained can correspond to a sub-request, and then each task is executed by calling the thread, and one thread can execute one task.

[0073] In order to execute requests quickly, the thread pool can be used to split and execute requests.

[0074] Specifically, the method 100 also includes: after receiving a data read request, placing the data read request into a thread pool; splitting the data read request into multiple sub-requests through the thread pool; and reading corresponding data through multiple corresponding threads according to the multiple sub-requests through the thread pool.

[0075] For example, according to the above, if Figure 2 As shown, after receiving the request, the data query service 2012 puts the data reading request, that is, the query request, into the parallel query thread pool 2022 of the data parallel processing layer 202. That is, step 216 is executed: the query request is put into the parallel query thread pool 2022 of the data parallel processing layer 202. Then the parallel query thread pool 2022 splits the request according to the method described above, and executes the corresponding data reading of the multiple sub-requests after the split through threads.

[0076] Specifically, according to multiple sub-requests, corresponding data are read through multiple corresponding threads, including: determining the data type of the read data through the corresponding threads according to the read conditions in the corresponding sub-requests; obtaining the index of the read data according to the data type; and reading the corresponding read data according to the data type, the corresponding index and the association relationship.

[0077] For example, as described above, the corresponding thread determines the corresponding data tag based on the read condition in the sub-request, which can also be a query condition, according to the data tag carried in the condition. If it is not carried, it can be determined based on the default data tag (i.e., the preset data tag). As can be seen from the above, the corresponding index can then be obtained based on the data tag, and the corresponding data can be found based on the index to query and read. In order to query and read data more accurately, it is also possible to ultimately determine whether the indexed data is accurate through data tags and associations, and inaccurate data can be eliminated through data tags and associations.

[0078] Among them, reading the corresponding read data according to the data type, the corresponding index and the association relationship includes: obtaining candidate read data according to the corresponding index; determining the data type in the candidate read data according to the association relationship and the encoded data in the candidate read data; obtaining the corresponding read data from the candidate read data according to the determined data type; decoding the encoded data in the obtained read data to obtain the decoded read data.

[0079] For example, according to the foregoing, by executing the corresponding sub-request through the corresponding process, the corresponding read data can be found through the index. According to the foregoing, since the index may have been merged or compressed. So in order to accurately find the corresponding read data. The found read data is used as the candidate read data, and then the data type of the candidate read data is determined according to the above association relationship and the encoded data in the candidate read data. For example, if the encoded data is encoded for the first bit of time data in nanoseconds in the acquisition time, then its data type can be determined, or the data label is temperature. In this way, it is determined whether the data is the data to be found. If the data type or data label to be found is pressure, the data is ignored. In this way, the corresponding read data is selected. Of course, further selection can be made based on conditions such as acquisition time.

[0080] like Figure 2As shown, the time series database 2041 executes step 217: sends the queried read data (i.e., the read data) to the data decoder 2032 in the data encoding and decoding layer 203 for data decoding, i.e., the corresponding time data is decoded. Then, the data decoder 2032 sends the decoded data to the parallel query thread pool 2022. That is, step 218 is executed: the queried read data (i.e., the read data) is sent. After the parallel query thread pool 2022 receives the data, it sends the read data corresponding to multiple sub-requests together, i.e., step 219 is executed: the queried read data (i.e., the read data) is sent to the data query service 2012. After the data query service 2012 receives the data, step 220 is executed: the queried read data is sent to the corresponding receiving device, such as a data receiving device, for receiving and display.

[0081] It should be noted that, when reading data, the embodiment of the present application searches for data according to a coarser index value, which can significantly improve the efficiency of data search and ensure the accuracy of the search.

[0082] Therefore, the factory data receiving equipment can simulate the factory production process according to these data and simulation models as needed, greatly improving the data reading and writing performance, thereby ensuring the digital twin application used to simulate factory production and the reading and writing needs of the full amount of industrial site data.

[0083] The embodiments of the present application optimize the read and write performance. Under the configuration of a single machine 32C core, 64G (gigabyte) memory, and a 500G high-efficiency cloud disk, the write performance is improved from 1.3 million + (or more) measurement points / second to 2.2 million + measurement points / second. The detailed data query performance is improved from 22 million + measurement points / second to 3 million + measurement points / second. The write performance can be doubled and the query performance can be improved by more than 10 times while consuming the same machine resources. This greatly improves the data throughput, solves the performance bottleneck of reading and writing detailed data in the time series database, avoids the adjustment of the hardware architecture layer, reduces resource consumption, and also has better scalability and compatibility.

[0084] Figure 3 The structure diagram of a data reading and writing system provided by an exemplary embodiment of the present application is as follows. Figure 3 As shown, the system 300 may include: a first device 301 and a second device 302 .

[0085] Among them, the first device 301 can be a device with certain computing capabilities, which can realize the function of sending data to the second device 302, and can also receive data sent by the second device 302. The basic structure of the first device 301 may include: at least one processor. The number of processors may depend on the configuration and type of the device with certain computing capabilities. The device with certain computing capabilities may also include a memory, which may be volatile, such as RAM, or non-volatile, such as read-only memory (ROM), flash memory, etc., or may include both types at the same time. The memory usually stores an operating system (OS), one or more application programs, and may also store program data, etc. In addition to the processing unit and the memory, the device with certain computing capabilities also includes some basic configurations, such as a network card chip, an IO bus, a display component, and some peripheral devices, etc. Optionally, some peripheral devices may include, for example, a keyboard, an input pen, etc. Other peripheral devices are well known in the art and will not be described in detail here. Optionally, the first device 301 may be an intelligent terminal, such as a mobile phone, a desktop computer, a notebook, a tablet computer, etc.

[0086] The second device 302 refers to a device that can provide computing and processing services in a network virtual environment, and can refer to a device that uses the network to read and write data. In physical implementation, the second device 302 can be any device that can provide computing services, respond to service requests, and read data, such as a cloud server, cloud host, virtual center, conventional server, etc., on which a database is constructed. The second device 302 mainly includes a processor, a hard disk, a memory, a system bus, etc., which is similar to a general computer architecture.

[0087] Specifically, the second device 302 receives data to be written, which is data collected at different collection times, and the data has a corresponding data type; determines the index of the data to be written according to the data type corresponding to the data to be written; determines the association between the collection time and the data type corresponding to the data to be written, so that data is read through the index and the association; after determining the index and the association, writes the data to be written into a preset database.

[0088] In addition, the first device 301 sends the data to be written to the second device 302 .

[0089] Specifically, the second device 302 performs encoding according to the acquisition time, associates the encoded result with the data type, and determines the association relationship.

[0090] Specifically, the second device 302 encodes the time data at the corresponding position in the acquisition time according to the data type to determine the association relationship; wherein the corresponding position refers to the corresponding position of the preset time unit in the acquisition time.

[0091] In addition, the second device 302 creates at least one buffer queue; after receiving the data to be written, puts the data to be written into at least one buffer queue; obtains multiple data to be written from the at least one buffer queue, and according to the multiple data to be written, executes the step of determining the index of the data to be written according to the data type corresponding to the data to be written.

[0092] Specifically, the second device 302 merges the preset data types according to different preset data types, so that at least two preset data types are merged into one data type; matches the data type corresponding to the data to be written according to the merged data type, and determines the merged data type corresponding to the data to be written; and determines the index of the data to be written according to the corresponding merged data type.

[0093] In addition, the second device 302 receives a data read request, and splits the data read request into multiple sub-requests according to the dimension of the requested data; and reads corresponding data through multiple corresponding threads according to the multiple sub-requests.

[0094] In addition, after receiving the data read request, the second device 302 puts the data read request into the thread pool; splits the data read request into multiple sub-requests through the thread pool; and reads the corresponding data through multiple corresponding threads according to the multiple sub-requests through the thread pool.

[0095] Specifically, the second device 302, through the corresponding thread, determines the data type of the read data according to the read condition in the corresponding sub-request; obtains the index of the read data according to the data type; and reads the corresponding read data according to the data type, the corresponding index and the association relationship.

[0096] Specifically, the second device 302 obtains candidate read data according to the corresponding index; determines the data type in the candidate read data according to the association relationship and the encoded data in the candidate read data; obtains corresponding read data from the candidate read data according to the determined data type; decodes the encoded data in the obtained read data to obtain decoded read data.

[0097] In the data reading scenario under the industrial scenario, the power plant can collect the data of the corresponding device through the corresponding sensor, such as the temperature of the device, and then send the collected temperature data to the first device 301, such as the host computer. Then, through the first device 301, step 311 is executed: send the data to be written to the second device 302, such as the cloud server. After receiving the data to be written, the cloud server can determine the index value of the data to be written according to the data tag of the data to be written, such as temperature. For example, the cloud server can merge or compress two preset data tags, such as merging temperature and pressure into an environmental monitoring value. Then determine the index value according to the merged environmental monitoring value. The data belonging to the merged environmental monitoring value is: the data to be written with the data tag of temperature, and the data to be written with the data tag of pressure. When the cloud server receives the data to be written, it determines the corresponding merged data tag according to the data tag corresponding to the data. For example, when the data tag of the received data to be written is pressure, the merged data tag of the data to be written is the environmental monitoring value. Then determine the corresponding index according to the merged data tag environmental monitoring value.

[0098] For example, after the service interface layer of the cloud server receives the data to be written, it sends the data to be written to the parallel consumption queue in the data parallel processing layer. The parallel consumption queue (also a parallel buffer queue) can have multiple. Extract multiple data to be written from the parallel consumption queue. Based on the extracted multiple data to be written, determine the index.

[0099] The data encoder of the cloud server receives the above-mentioned multiple data to be written, obtains the nanosecond time values ​​in the acquisition time corresponding to the multiple data to be written, and then encodes the first time data in the nanosecond time value, such as "0", according to the data label of the data to be written, such as temperature. Thus, the data label is associated with the acquisition time. After encoding, the data to be written can be written to the time series database.

[0100] The operator of the corresponding factory can send a data read request or a data query request to the cloud server through the first device 301. That is, execute step 312: send a query request. After receiving the request, the data query service in the cloud server puts the data read request, that is, the query request, into the parallel query thread pool of the data parallel processing layer. Then the parallel query thread pool splits the request according to the method described above, and executes the corresponding data reading through threads for the multiple sub-requests after the split.

[0101] By executing the corresponding sub-request through the corresponding process, the corresponding read data can be found through the index. The found read data is used as the candidate read data, and then the data type of the candidate read data is determined based on the above association relationship and the encoding data in the candidate read data. For example, if the encoding data is encoded for the first bit of time data in nanoseconds in the acquisition time, then its data type can be determined, or the data label is temperature. In this way, it is determined whether the data is the data to be found. If the data type or data label to be found is pressure, the data is ignored. In this way, the corresponding read data is selected. Of course, further selection can be made based on conditions such as acquisition time to query the read data.

[0102] Then, the time series database sends the queried read data (i.e., the read data) to the data decoder in the data encoding and decoding layer for data decoding, i.e., the corresponding time data is decoded. Then, the data decoder sends the decoded data to the parallel query thread pool. After receiving the data, the parallel query thread pool sends the queried read data (i.e., the read data) to the data query service. After receiving the data, the data query service sends the read data corresponding to multiple sub-requests together to the data query service. After receiving the data, the data query service sends the queried read data to the corresponding first device 301 for reception and display. That is, execute step 313: send the queried read data.

[0103] For the contents not recorded in detail here, please refer to the previous content and I will not repeat them here.

[0104] In the above embodiment, the first device 301 and the second device 302 are connected to the network. If the first device 301 and the second device 302 are connected for communication, the network standard of the mobile network can be any one of 2G (GSM), 2.5G (GPRS), 3G (WCDMA, TD-SCDMA, CDMA2000, UTMS), 4G (LTE), 4G+ (LTE+), WiMax, 5G, etc.

[0105] Figure 4 A schematic diagram of the structure of a data reading and writing device provided as an exemplary embodiment of the present application. The device 400 can be applied to a computing device, such as a cloud server. The device 400 includes: a receiving module 401, a determining module 402, and a writing module 403; the functions of each module are described in detail below:

[0106] The receiving module 401 is used to receive data to be written, where the data to be written is data collected at different collection times, and the data has a corresponding data type;

[0107] The determination module 402 is used to determine the index of the data to be written according to the data type corresponding to the data to be written.

[0108] The determination module 402 is used to determine the association between the acquisition time and the data type corresponding to the data to be written, so that the data can be read through the index and the association.

[0109] The writing module 403 is used to write the data to be written into the preset database after determining the index and the association relationship.

[0110] Specifically, the determination module 402 is used to perform encoding according to the acquisition time, associate the encoded result with the data type, and determine the association relationship.

[0111] Specifically, the determination module 402 is used to encode the time data at the corresponding position in the acquisition time according to the data type, and determine the association relationship; wherein the corresponding position refers to the corresponding position of the preset time unit in the acquisition time.

[0112] In addition, the device 400 also includes: a creation module, used to create at least one buffer queue; a placement module, used to place the data to be written into at least one buffer queue after receiving the data to be written; an acquisition module, used to obtain multiple data to be written from at least one buffer queue, and based on the multiple data to be written, execute the step of determining the index of the data to be written according to the data type corresponding to the data to be written.

[0113] Specifically, the determination module 402 includes: a merging unit, used to merge the preset data types according to different preset data types, so that at least two preset data types are merged into one data type; a matching unit, used to match the data type corresponding to the data to be written according to the merged data type, and determine the corresponding merged data type; a first determination unit, used to determine the index of the data to be written according to the corresponding merged data type.

[0114] In addition, the device 400 also includes: a splitting module, which is used to receive a data reading request and split the data reading request into multiple sub-requests according to the dimension of the requested data; a reading module, which is used to read corresponding data through multiple corresponding threads according to the multiple sub-requests.

[0115] In addition, the placing module is also used to place the data reading request into the thread pool after receiving the data reading request; the splitting module is also used to split the data reading request into multiple sub-requests through the thread pool; the reading module is also used to read the corresponding data through multiple corresponding threads according to the multiple sub-requests through the thread pool.

[0116] Specifically, the reading module includes: a second determination unit, used to determine the data type of the read data according to the reading condition in the corresponding sub-request through the corresponding thread; an acquisition unit, used to obtain the index of the read data according to the data type; and a reading unit, used to read the corresponding read data according to the data type, the corresponding index and the association relationship.

[0117] Specifically, the reading unit is used to obtain candidate reading data according to a corresponding index; determine the data type in the candidate reading data according to the association relationship and the encoded data in the candidate reading data; obtain corresponding reading data from the candidate reading data according to the determined data type; decode the encoded data in the obtained reading data to obtain decoded reading data.

[0118] For details of the device 400 that are not fully described, please refer to the above description and will not be repeated here.

[0119] The above describes Figure 4 The internal functions and structure of the device 400 shown, in one possible design, Figure 4 The structure of the device 400 shown can be implemented as a computing device, such as a cloud server. Figure 5 As shown, the device 500 may include: a memory 501, a processor 502;

[0120] The memory 501 is used to store computer programs.

[0121] Processor 502 is used to execute a computer program to: receive data to be written, the data to be written is data collected according to different collection times, and the data has a corresponding data type; determine the index of the data to be written according to the data type corresponding to the data to be written; determine the association between the collection time and the data type corresponding to the data to be written, so that data is read through the index and the association; after determining the index and the association, write the data to be written into a preset database.

[0122] Specifically, the processor 502 is specifically configured to: perform encoding according to the acquisition time, associate the encoded result with the data type, and determine the association relationship.

[0123] Specifically, the processor 502 is specifically used to: encode the time data of the corresponding position in the acquisition time according to the data type, and determine the association relationship; wherein the corresponding position refers to the corresponding position of the preset time unit in the acquisition time.

[0124] In addition, the processor 502 is also used to: create at least one buffer queue; after receiving the data to be written, place the data to be written into at least one buffer queue; obtain multiple data to be written from the at least one buffer queue, and based on the multiple data to be written, execute the step of determining the index of the data to be written according to the data type corresponding to the data to be written.

[0125] Specifically, the processor 502 is specifically used to: merge the preset data types according to different preset data types, so that at least two preset data types are merged into one data type; match the data type corresponding to the data to be written according to the merged data type, and determine the corresponding merged data type; determine the index of the data to be written according to the corresponding merged data type.

[0126] In addition, the processor 502 is also used to: receive a data read request, and split the data read request into multiple sub-requests according to the dimension of the requested data; and read corresponding data through multiple corresponding threads according to the multiple sub-requests.

[0127] In addition, the processor 502 is also used to: after receiving a data read request, place the data read request into a thread pool; split the data read request into multiple sub-requests through the thread pool; and read corresponding data through multiple corresponding threads according to multiple sub-requests through the thread pool.

[0128] Specifically, processor 502 is specifically used to: determine the data type of the read data according to the read condition in the corresponding sub-request through the corresponding thread; obtain the index of the read data according to the data type; read the corresponding read data according to the data type, the corresponding index and the association relationship.

[0129] Specifically, the processor 502 is specifically used to: obtain candidate read data according to a corresponding index; determine the data type in the candidate read data according to an association relationship and the encoded data in the candidate read data; obtain corresponding read data from the candidate read data according to the determined data type; decode the encoded data in the obtained read data to obtain decoded read data.

[0130] An embodiment of the present invention provides a computer storage medium, which, when a computer program is executed by one or more processors, causes the one or more processors to implement Figure 1-Figure 2 The steps of a method for reading and writing data in the method embodiment will not be described in detail.

[0131] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel, and the sequence numbers of the operations, such as 101, 102, 103, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.

[0132] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0133] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0134] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable multimedia data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable multimedia data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0135] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable multimedia data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0136] These computer program instructions may also be loaded onto a computer or other programmable multimedia data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0137] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0138] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0139] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for reading and writing data, characterized in that: include: receiving data to be written, wherein the data to be written is data collected at different collection times, and the data has a corresponding data type; Determine the index of the data to be written according to the data type corresponding to the data to be written; wherein, determining the index of the data to be written according to the data type corresponding to the data to be written comprises: merging the preset data types according to different preset data types so that at least two preset data types are merged into one data type; matching the data type corresponding to the data to be written according to the merged data type, and determining the merged data type corresponding to the data to be written; and determining the index of the data to be written according to the corresponding merged data type; Determine the association relationship between the collection time corresponding to the data to be written and the data type, so that the data is read through the index and the association relationship; After determining the index and the association relationship, the data to be written is written into a preset database.

2. The method according to claim 1, characterized in that The determining of the association between the acquisition time corresponding to the data to be written and the data type includes: Encoding is performed according to the acquisition time, and the encoded result is associated with the data type to determine the association relationship.

3. The method according to claim 1, characterized in that: The determining of the association between the acquisition time corresponding to the data to be written and the data type includes: According to the data type, encoding the time data of the corresponding position in the acquisition time to determine the association relationship; The corresponding position refers to the corresponding position of the preset time unit in the acquisition time.

4. The method according to claim 1, characterized in that: The method further comprises: Create at least one buffer queue; After receiving the data to be written, placing the data to be written into at least one buffer queue; A plurality of data to be written is obtained from at least one buffer queue, and according to the plurality of data to be written, the step of determining the index of the data to be written according to the data type corresponding to the data to be written is performed.

5. The method according to claim 1, characterized in that The method further comprises: Receive a data read request, and split the data read request into multiple sub-requests according to the dimensions of the requested data; According to the multiple sub-requests, corresponding data is read through multiple corresponding threads.

6. The method according to claim 5, characterized in that The method further comprises: After receiving a data read request, placing the data read request into a thread pool; Splitting the data read request into multiple sub-requests through the thread pool; Through the thread pool, corresponding data is read through multiple corresponding threads according to the multiple sub-requests.

7. The method according to claim 5, characterized in that The reading corresponding data through a plurality of corresponding threads according to the plurality of sub-requests includes: Determine the data type of the read data according to the read condition in the corresponding sub-request through the corresponding thread; Get the index of the read data according to the data type; Read the corresponding data according to the data type, corresponding index and association relationship.

8. The method according to claim 7, characterized in that The step of reading corresponding data according to the data type, the corresponding index and the association relationship includes: Get candidate read data according to the corresponding index; Determine the data type in the candidate read data according to the association relationship and the encoded data in the candidate read data; According to the determined data type, corresponding read data is obtained from the candidate read data; The encoded data in the acquired read data is decoded to obtain decoded read data.

9. A computing device, characterized in that include: Memory, processor; The memory is used to store computer programs; The processor executes the computer program to: receiving data to be written, wherein the data to be written is data collected at different collection times, and the data has a corresponding data type; According to different preset data types, the preset data types are merged so that at least two preset data types are merged into one data type; according to the merged data type, the data type corresponding to the data to be written is matched to determine the merged data type corresponding to the data to be written; according to the corresponding merged data type, the index of the data to be written is determined; Determine the association relationship between the collection time corresponding to the data to be written and the data type, so that the data is read through the index and the association relationship; After determining the index and the association relationship, the data to be written is written into a preset database.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by one or more processors, the one or more processors are caused to implement the steps of the method according to any one of claims 1 to 8.