A power grid signal writing method, reading method, device and storage medium

By employing high-speed caching and slice storage technologies, the problem of power grid signal loss in the power grid dispatch automation system has been solved, enabling high-speed reading and writing and rapid positioning of power grid signals, thereby improving signal processing efficiency.

CN115185883BActive Publication Date: 2026-03-17NARI TECH CO LTD +5
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-10
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In existing power grid dispatch automation systems, complex power grid signals are easily lost during processing, causing upper-level operations to be unable to detect risks in a timely manner.

Method used

By employing high-speed caching technology and sliced ​​storage, combined with the matching of power grid signal scenarios, sub-scenarios, and channel triples, high-speed writing and reading of power grid signals are achieved, and the target signal can be quickly located through the index file.

Benefits of technology

This ensures that the power grid signal is not lost, improves the efficiency of signal reading and writing, reduces disk usage, and improves the operational efficiency of signal processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185883B_ABST
    Figure CN115185883B_ABST
Patent Text Reader

Abstract

This invention discloses a method, device, and storage medium for writing and reading power grid signals in the field of power automation systems. The writing method includes: determining a cache based on the triplet of the power grid signal; if the power grid signal is written to the cache but the storage threshold is not exceeded, the power grid signal is written to the cache; otherwise, the power grid signal is written to an active data file. The reading method includes: determining a matching cache based on the triplet of the target power grid signal; if the target power grid signal is written in the cache, the power grid signal is directly returned; otherwise, a storage file directory is determined based on the triplet of the target power grid signal; the index file for the target power grid signal is searched from all index files in the storage file directory; and the target power grid signal is then searched from the corresponding data file based on the index file. This invention ensures that the power grid signal is not lost and achieves high-speed reading and writing of the power grid signal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for writing and reading power grid signals, an apparatus for doing so, and a storage medium, belonging to the technical field of power automation systems. Background Technology

[0002] In existing power grid dispatch automation systems, the message bus does not store received power grid signals. For complex power grid signals, when upper-layer applications experience long processing times and a large volume of signals are generated, these important signals are often discarded before being processed, preventing upper-layer power grid dispatch services from recognizing potential risks. Therefore, providing a high-speed read / write method for power grid signals is crucial for supporting upper-layer operations. Summary of the Invention

[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, a method, a device and a storage medium for writing and reading power grid signals, which can ensure that power grid signals are not lost and realize high-speed reading and writing of power grid signals.

[0004] To achieve the above objectives, the present invention is implemented using the following technical solution:

[0005] In a first aspect, the present invention provides a method for writing power grid signals, comprising:

[0006] Receive power grid signals and determine the cache that matches the scene, sub-scene, and channel triplet specified by the power grid signal:

[0007] In response to the situation where the power grid signal is stored in the cache and the cache does not exceed the storage threshold, the power grid signal is written into the cache.

[0008] In response to the cache exceeding the storage threshold after storing the power grid signal, the data file in the cache that matches the scene, sub-scene, and channel triplet of the power grid signal and is in an active state is retrieved.

[0009] Write the power grid signal in the cache and the received power grid signal together into the data file.

[0010] In conjunction with the first aspect, the method further includes:

[0011] An index is created for the data file for every predetermined number of bytes of data or a predetermined number of power grid signals, and stored in the index file.

[0012] In conjunction with the first aspect, the data file and its corresponding index file are named according to the record number of the last power grid signal in the previous data file.

[0013] In conjunction with the first aspect, the data file and its corresponding index file are named by adding 1 to the record number of the last power grid signal in the previous data file.

[0014] In conjunction with the first aspect, the index in the index file further includes at least the record number of the corresponding power grid signal and the position offset of the power grid signal in the data file.

[0015] In conjunction with the first aspect, further, when the storage volume of the data file exceeds a set threshold, the state of the data file is changed to an inactive state, a new data file is created, and the state of the new data file is set to an active state.

[0016] Secondly, the present invention provides a method for reading power grid signals, comprising:

[0017] Receive power grid signal reading requests and analyze to obtain the specified scene, sub-scene, and channel triplet of the target power grid signal;

[0018] The matching cache is determined based on the scenario, sub-scenario, and channel triplet specified by the target power grid signal;

[0019] If the target power grid signal is written in the cache, the target power grid signal is returned directly to the requester.

[0020] In response to the absence of the target power grid signal in the cache, the storage directory corresponding to the target power grid signal is determined based on the scenario, sub-scenario, and channel triplet specified by the target power grid signal.

[0021] Search for the index file that determines the target power grid signal from all the index files in the storage directory;

[0022] The data file corresponding to the index file is determined, the target power grid signal is located in the determined data file, and returned to the requester.

[0023] In conjunction with the second aspect, furthermore, before searching for the index file that determines the target power grid signal from all index files in the storage directory, all index files in the storage directory are loaded into memory using memory mapping technology.

[0024] In conjunction with the second aspect, the method for finding the target power grid signal based on the index file further includes:

[0025] Based on the record number of the target power grid signal, the corresponding index file is searched using a binary search algorithm;

[0026] Find the position offset of the target power grid signal in the data file based on the index file;

[0027] Starting from the position offset, read the power grid signal sequentially until the record number of the currently read power grid signal is equal to the record number of the target power grid signal. The currently read power grid signal is the target power grid signal.

[0028] Thirdly, the present invention provides a power grid signal writing device, comprising:

[0029] Signal receiving module: used to receive power grid signals;

[0030] The lookup module is used to look up the cache of the specified scene, sub-scene, and channel triplet matching of the received power grid signal;

[0031] First write module: used to write the power grid signal into the cache if the cache does not exceed the storage threshold after the power grid signal is written into the cache;

[0032] The second writing module is used to respond to the situation where the cache exceeds the storage threshold after the power grid signal is written to the cache, to obtain the data file in the cache that matches the scene, sub-scene and channel triplet of the power grid signal and is in an active state, and to write the power grid signal in the cache and the received power grid signal together into the data file.

[0033] In conjunction with the third aspect, the writing device further includes:

[0034] Index creation module: used to create an index for the data file every predetermined number of bytes of data or a predetermined number of power grid signals, and store it in an index file.

[0035] Fourthly, the present invention provides a device for reading power grid signals, comprising:

[0036] The second receiving module is used to receive power grid signal reading requests and analyze and obtain the specified scene, sub-scene, and channel triplet of the target power grid signal.

[0037] Determining module: used to determine the matching cache based on the scene, sub-scene, and channel triplet specified by the target power grid signal;

[0038] First return module: In response to the target power grid signal being written in the cache, the target power grid signal is directly returned to the requester;

[0039] The second return module is used to respond to the absence of the target power grid signal in the cache by determining the storage directory corresponding to the target power grid signal based on the scenario, sub-scenario, and channel triplet specified by the target power grid signal; searching for the index file that determines the target power grid signal from all index files in the storage directory; determining the data file corresponding to the index file; searching for the target power grid signal in the determined data file; and returning it to the requester.

[0040] In conjunction with the fourth aspect, further, the method by which the second return module searches for the target power grid signal based on the index file includes:

[0041] Based on the record number of the target power grid signal, the corresponding index file is searched using a binary search algorithm;

[0042] Find the position offset of the target power grid signal in the data file based on the index file;

[0043] Starting from the position offset, read the power grid signal sequentially until the record number of the currently read power grid signal is equal to the record number of the target power grid signal. The currently read power grid signal is the target power grid signal.

[0044] Fifthly, the present invention provides a terminal, including a processor and a storage medium;

[0045] The storage medium is used to store instructions;

[0046] The processor is configured to operate according to the instructions to perform the steps of the method described in either the first aspect or the second aspect.

[0047] In a sixth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in either the first or second aspect.

[0048] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0049] The power grid signal writing method provided by this invention first considers writing the received power grid signal into a cache. When the cache stores the power grid signal and the storage threshold is exceeded, the method further matches the active data file according to the triplet specified by the power grid signal and writes the cache and the received power grid signal together into the matched data file. The sliced ​​power grid signal storage method combined with cache technology can ensure high-speed writing of the power grid signal.

[0050] Both the data files and index files are named according to the record number of the power grid signal, which helps to quickly locate the data file and index file where the target power grid signal is located when reading the power grid signal;

[0051] The index file creates an index every predetermined number of bytes of data or a predetermined number of power grid signals, but does not create an index for every single power grid signal. This sparse storage method not only reduces disk usage but also makes it easier to map the index file into memory, thus improving the efficiency of index lookup.

[0052] The status of the data is determined based on its current storage volume. When the storage volume of the data file exceeds a set threshold, the status of the data file is changed to an inactive state, and a new data file is created. The status of the new data file is set to an active state. The received power grid signals can be sequentially appended to the newly created data file. Power grid signals are stored in slice-style small files, which facilitates signal processing using the entire data file as the operation unit.

[0053] The power grid signal reading method provided by this invention first searches for the target power grid signal in the cache. If the power grid signal exists in the cache, it is directly transmitted to the requester, eliminating the need for operations on the underlying disk and improving the efficiency of power grid signal reading. Attached Figure Description

[0054] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:

[0055] Figure 1 This is a flowchart of a method for writing power grid signals according to an embodiment of the present invention;

[0056] Figure 2 This is a schematic diagram of writing power grid signals based on the method described in Embodiment 1, provided by an embodiment of the present invention;

[0057] Figure 3 This is a flowchart of a method for reading power grid signals provided in an embodiment of the present invention;

[0058] Figure 4 This is a schematic diagram of reading power grid signals based on the method described in Embodiment 2, provided by an embodiment of the present invention. Detailed Implementation

[0059] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments and specific features in the embodiments are detailed descriptions of the technical solution of the present application, rather than limitations thereof. In the absence of conflict, the embodiments and technical features in the embodiments can be combined with each other.

[0060] Example 1:

[0061] Figure 1 This is a flowchart illustrating a method for writing power grid signals according to Embodiment 1 of the present invention. This flowchart merely shows the logical sequence of the method described in this embodiment. Without conflict, different methods may be used in other possible embodiments of the present invention. Figure 1 Complete the steps shown or described in the order indicated.

[0062] The power grid signal writing method provided in this embodiment can be applied to a terminal and can be executed by a power grid signal writing device. This device can be implemented in software and / or hardware and can be integrated into the terminal, such as any smartphone, tablet, or computer device with communication capabilities. See also... Figure 1 The method implemented in this way specifically includes the following steps:

[0063] Step A: Receive the power grid signal and check the cache that matches the scene, sub-scene, and channel triplet specified by the power grid signal;

[0064] In power grid dispatch and control systems, power grid signals are isolated using triples of scenario, sub-scenario, and channel number. For example, a scenario could be realtime, a sub-scenario could be public, and the channel number could be 9; in this case, the storage directory would be realtime_public_9. Storing power grid signals in a storage directory determined by the specified triples ensures the isolation of power grid signals between different scenarios, sub-scenarios, and channels, thus improving the security of power grid signals.

[0065] Step B: In response to the fact that the cache has not exceeded the storage threshold after the power grid signal is written to the cache, the power grid signal is written to the cache.

[0066] Step C: In response to the cache exceeding the storage threshold after the power grid signal is written to the cache, obtain the active data file matching the scene, sub-scene, and channel triplet of the power grid signal in the cache, and write the power grid signal in the cache and the received power grid signal together into the data file.

[0067] like Figure 2 As shown, the .data file is used to store power grid signals, and the .index file is used to store the index corresponding to the .data file. Each .data file has at least one corresponding .index file.

[0068] Each data file, when created, has a set threshold to limit its storage size. An active data file can be understood as one whose current storage size exceeds the set threshold. When the storage size of a data file exceeds the set threshold, its status is changed to inactive, and a new data file is created (e.g., ...). Figure 2The data file connected by the solid black line at the bottom is used to create a new data file. Simultaneously, the new data file is set to an active state. At this point, the power grid signals stored in the cache and the received power grid signals can be sequentially appended to the newly created data file. This sliced ​​power grid signal storage method, combined with caching technology, effectively prevents the technical problem of low data file location efficiency caused by excessively large data files, ensuring high-speed writing of power grid signals. Furthermore, when deleting data, the sliced ​​storage method allows the entire data file to be used as the operation unit, greatly improving operational efficiency.

[0069] As an embodiment of the present invention, the .index file does not create an index for every single power grid signal. Instead, it adopts a sparse storage method, that is, an index is created every certain number of bytes of data or a certain number of power grid signals. This not only reduces disk usage but also makes it easier to map the index file into memory, thereby improving the efficiency of index lookup.

[0070] In this embodiment of the invention, both the .data file and the .index file are named according to the record number of the power grid signal, which facilitates the rapid location of the data file containing the target power grid signal using a binary search algorithm when reading the power grid signal. Specifically, the naming rules for the .data file and the .index file are consistent, and can be named by adding 1 to the record number (offset) of the last power grid signal in the previous data file. The maximum value is 64-bit long, with a length of 20 numeric characters. If there are no numbers, they can be padded with 0, such as... Figure 2 The files 00000000000003925423.data and 0000000000003925423.index shown are... Figure 2 The data file 00000000000003925423.data, connected by the solid black line, is the currently active data file. Subsequent received grid signals can be appended sequentially to the end of 00000000000003925423.data. When a predetermined number of bytes of data or a predetermined number of grid signals are received, an index is created for the data file and stored in an index file to ensure high-speed retrieval of grid signals later.

[0071] The index stored in the index file includes at least: the record number (offset) of the power grid signal and the position offset of the power grid signal in the .data file. See [link to relevant documentation]. Figure 4The index in the 00000000000000000000.index file is an array of binary tuples. The left column, such as 123, 528, 1024, 4023, and 5145, are the record numbers of the power grid signals. The right column, such as 4328, 9742, 18652, 78667, and 93767, are the position offsets of the power grid signals corresponding to the aforementioned record numbers in the data file.

[0072] Example 2:

[0073] Figure 3 This is a method for reading power grid signals provided in Embodiment 2 of the present invention. The method for reading power grid signals provided in this embodiment is based on the power grid signal writing method described in Embodiment 1. For details not described in this embodiment, please refer to Embodiment 1. Figure 3 As shown, the method for reading power grid signals provided in this embodiment includes:

[0074] Step a: Receive the power grid signal reading request, analyze and obtain the specified scene, sub-scene and channel triplet of the target power grid signal;

[0075] Step b: Determine the matching cache based on the scene, sub-scene, and channel triplet specified by the target power grid signal;

[0076] Step c: In response to the target power grid signal being written in the cache, return the target power grid signal directly to the requester;

[0077] Step d: In response to the absence of the target power grid signal in the cache, determine the storage directory corresponding to the target power grid signal based on the scenario, sub-scenario, and channel triplet specified by the target power grid signal; search for the index file that determines the target power grid signal from all index files in the storage directory; determine the data file corresponding to the index file, search for the target power grid signal in the determined data file, and return it to the requester.

[0078] In this embodiment of the invention, before searching for the index file that determines the target power grid signal from all index files in the storage directory, all index files in the storage directory are loaded into memory using memory mapping technology to improve addressing efficiency. For example... Figure 4 The 0000000000000000000.index file shown on the left is an array of tuples. Each tuple consists of two numbers: one representing the record number of the power grid signal, and the other representing the position offset of that signal. Figure 4 As can be seen, the index file does not create an index for every power grid signal. Instead, it uses a sparse storage method to build the index of power grid signals. This method can reduce the size of the index file and improve the efficiency of mapping the index file into memory.

[0079] Since the naming convention for index files and data files is based on the record number of the power grid signal, a binary search algorithm can efficiently locate the index file containing a specific power grid signal. Specifically, the method for finding the target power grid signal based on the index file includes:

[0080] Based on the record number of the target power grid signal, the corresponding index file is searched using a binary search algorithm;

[0081] Find the position offset of the target power grid signal in the data file based on the index file;

[0082] Starting from the position offset, read the power grid signal sequentially until the record number of the currently read power grid signal is equal to the record number of the target power grid signal. The currently read power grid signal is the target power grid signal.

[0083] by Figure 4 For example, the left side of the diagram represents the .index file, and the right side represents the .data file. Assuming the record number of the target power grid signal the requester wants to find is 4090, the process first navigates to the storage directory determined by the specified triplet of the target power grid signal. It then examines all the .index files in this directory. Since the naming convention for index files is based on the record number of the power grid signal, a binary search algorithm can quickly retrieve the corresponding .index file. For instance, the index file corresponding to the power grid signal with record number 4090 is 000000000000000000000.index. Because the record number of the target power grid signal is 4090, it is necessary to search the index file for records with record numbers less than 4090 but relatively close to or equal to 4090. Figure 4 The index is [4023, 78667]. Further into the 00000000000000000000.data file, starting from the specified offset of 78667, the system searches for each power grid signal, comparing the record number of each signal with 4090, until a signal with record number 4090 is found. This signal is then returned to the requester as the target power grid signal.

[0084] The power grid signal reading method provided in this embodiment of the invention first searches for the target power grid signal in the cache. If the power grid signal exists in the cache, it is directly transmitted to the requester, eliminating the need for operations on the underlying disk and improving the efficiency of power grid signal reading.

[0085] Example 3:

[0086] This invention provides a power grid signal writing device, which can be used to implement the method described in Embodiment 1. The writing device includes:

[0087] First receiving module: used to receive power grid signals;

[0088] The lookup module is used to retrieve the cache of triplet matches for the specified scene, sub-scene, and channel of the power grid signal.

[0089] First storage module: used to write the power grid signal into the cache if the cache does not exceed the storage threshold after the power grid signal is written into the cache;

[0090] The second writing module is used to respond to the situation where the cache exceeds the storage threshold after the power grid signal is written to the cache, to obtain the data file in the cache that matches the scene, sub-scene and channel triplet of the power grid signal and is in an active state, and to write the power grid signal in the cache and the received power grid signal together into the data file.

[0091] As one embodiment of the present invention, the writing device further includes:

[0092] Index creation module: used to create an index for the data file every predetermined number of bytes of data or a predetermined number of power grid signals, and store it in an index file.

[0093] The apparatus provided in this embodiment of the invention can execute the method provided in Embodiment 1 of the invention, and has the corresponding functional modules and beneficial effects for executing the method. For the contents not covered in this embodiment, please refer to Embodiment 1, which will not be repeated here.

[0094] Example 4:

[0095] This invention provides a device for reading power grid signals. It should be noted that the power grid signal should be written as described in Embodiment 1, and can be used to implement the reading method described in Embodiment 2. The reading device includes:

[0096] The second receiving module is used to receive power grid signal reading requests and analyze and obtain the specified scene, sub-scene, and channel triplet of the target power grid signal.

[0097] Determining module: used to determine the matching cache based on the scene, sub-scene, and channel triplet specified by the target power grid signal;

[0098] First return module: In response to the target power grid signal being written in the cache, the target power grid signal is directly returned to the requester;

[0099] The second return module is used to respond to the absence of the target power grid signal in the cache by determining the storage directory corresponding to the target power grid signal based on the scenario, sub-scenario, and channel triplet specified by the target power grid signal; searching for the index file that determines the target power grid signal from all index files in the storage directory; determining the data file corresponding to the index file; searching for the target power grid signal in the determined data file; and returning it to the requester.

[0100] In one embodiment, the method by which the second return module searches for a target power grid signal based on the index file includes:

[0101] Based on the record number of the target power grid signal, the corresponding index file is searched using a binary search algorithm;

[0102] Find the position offset of the target power grid signal in the data file based on the index file;

[0103] Starting from the position offset, read the power grid signal sequentially until the record number of the currently read power grid signal is equal to the record number of the target power grid signal. The currently read power grid signal is the target power grid signal.

[0104] The apparatus provided in this embodiment of the invention can execute the method provided in Embodiment 2 of the invention, and has the corresponding functional modules and beneficial effects for executing the method. For any content not covered in this embodiment, please refer to Embodiment 2, which will not be repeated here.

[0105] Example 5:

[0106] This invention provides a terminal, including a processor and a storage medium;

[0107] The storage medium is used to store instructions;

[0108] The processor is configured to operate according to the instructions to execute the steps of the method described in Embodiment 1 or Embodiment 2.

[0109] Example 6:

[0110] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method described in Embodiment 1 or Embodiment 2.

[0111] It should be noted that, unless otherwise specified in this document, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some steps may include multiple steps or multiple stages, which are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0112] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0113] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0114] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0115] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0116] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method of writing a power grid signal, characterized by, The method comprises: receiving a power grid signal and determining a cache matching a scene, a sub-scene and a channel triplet specified by the power grid signal; in response to storing the power grid signal in the cache, if the cache does not exceed a storage threshold, writing the power grid signal into the cache; in response to storing the power grid signal in the cache, if the cache exceeds the storage threshold, obtaining an active data file matching the scene, the sub-scene and the channel triplet of the power grid signal in the cache; writing the power grid signal in the cache and the received power grid signal into the data file; the method further comprises: every predetermined bytes of data or a predetermined number of power grid signals, establishing an index for the data file and storing it in an index file; the index in the index file at least records a record number of a corresponding power grid signal and a position offset of the power grid signal in the data file; when the storage amount of the data file exceeds a set threshold, the state of the data file is changed to an inactive state, and a new data file is created, and the state of the new data file is set to an active state.

2. The method of writing power grid signals according to claim 1, wherein, The data file and the index file corresponding thereto are named according to the record number of the last power grid signal in the previous data file.

3. The method of writing a power grid signal according to claim 2, wherein, The data file and the index file corresponding thereto are named according to the record number of the last power grid signal in the previous data file + 1.

4. A reading method of a power grid signal, characterized by, The method comprises: receiving a power grid signal reading request and analyzing a target power grid signal specified by a scene, a sub-scene and a channel triplet; determining a cache matching the scene, the sub-scene and the channel triplet specified by the target power grid signal; in response to the target power grid signal being written in the cache, directly returning the target power grid signal to the requester; in response to the target power grid signal not existing in the cache, determining a storage directory corresponding to the target power grid signal according to the scene, the sub-scene and the channel triplet specified by the target power grid signal; from all index files under the storage directory, determining an index file of the target power grid signal; determining a data file corresponding to the index file, and finding the target power grid signal in the determined data file and returning it to the requester; the method for finding the target power grid signal according to the index file comprises: according to the record number of the target power grid signal, finding the corresponding index file through a binary search algorithm; according to the index file, finding a position offset of the target power grid signal in the data file; starting from the position offset, sequentially reading power grid signals until the record number of the currently read power grid signal is equal to the record number of the target power grid signal, and the currently read power grid signal is the target power grid signal.

5. The method of reading grid signals according to claim 4, characterized in that, Before determining the index file of the target power grid signal from all index files under the storage directory, all index files under the storage directory are loaded into the memory through a memory mapping technology.

6. A power grid signal writing device, characterized by The method comprises: a signal receiving module for receiving a power grid signal; a consulting module for consulting a cache matching a scene, a sub-scene and a channel triplet specified by the received power grid signal; a first writing module for, in response to writing the power grid signal into the cache, if the cache does not exceed a storage threshold, writing the power grid signal into the cache; The second writing module is configured to, in response to the power grid signal being written into the cache, acquire a data file in an active state which matches the scene, the sub-scene and the channel triplet of the power grid signal in the cache when the cache exceeds a storage threshold, and write the power grid signal in the cache and the received power grid signal into the data file together; The index creating module is configured to create an index for the data file every predetermined bytes of data or a predetermined number of power grid signals, and store the index in an index file; The index in the index file at least records the record number of the corresponding power grid signal and the position offset of the power grid signal in the data file; When the storage amount of the data file exceeds a set threshold, the state of the data file is changed to an inactive state, and a new data file is created, and the state of the new data file is set to an active state.

7. A reading device of a power grid signal, characterized in that The second receiving module is configured to receive a power grid signal reading request and analyze and acquire the scene, the sub-scene and the channel triplet specified by the target power grid signal; The determining module is configured to determine the matching cache according to the scene, the sub-scene and the channel triplet specified by the target power grid signal; The first returning module is configured to, in response to the target power grid signal being written in the cache, directly return the target power grid signal to the requester; The second returning module is configured to, in response to the target power grid signal not existing in the cache, determine the storage directory corresponding to the target power grid signal according to the scene, the sub-scene and the channel triplet specified by the target power grid signal; From all the index files under the storage directory, the index file corresponding to the target power grid signal is determined; The data file corresponding to the index file is determined, and the target power grid signal is searched in the determined data file and returned to the requester; The method for the second returning module to search the target power grid signal according to the index file comprises: According to the record number of the target power grid signal, the corresponding index file is searched by using a binary search algorithm; According to the index file, the position offset of the target power grid signal in the data file is searched; The power grid signal is sequentially read from the position offset, and the currently read power grid signal is the target power grid signal when the record number of the currently read power grid signal is equal to the record number of the target power grid signal. The storage medium is configured to store instructions; 8. A terminal, characterized by comprising: The processor is configured to operate according to the instructions to perform the steps of the method according to any one of claims 1-5. The program is executed by the processor to implement the steps of the method according to any one of claims 1-5. ​ 9. A computer readable storage medium having stored thereon a computer program, characterized in that, ​

Citation Information

Patent Citations

  • Method, equipment and computer program product for providing cache services

    CN111124945A

  • Caching files in a directory

    US20200341694A1