Data reading method and device, electronic equipment and storage medium

By setting up hot data areas and cold data areas in the buffer pool, and updating the sorting of index addresses based on access frequency and existence time, the problem of low data reading efficiency in computer equipment is solved, and more efficient data reading and CPU are achieved. Load optimization.

CN118626412AActive Publication Date: 2024-09-10GUANGDONG LEHUA HOME FURNISHING CO LTD +2

Patent Information

Application Number
CN202410744088.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-10
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

In computer equipment, the continuous addition and elimination of data pages during the data reading process causes the CPU load to increase, thereby reducing the data reading efficiency, especially when the amount of data continues to grow.

Method used

A data reading method is proposed. By setting up a hot data area and a cold data area in the buffer pool, the index address is transferred to the head position of the hot data area according to the access frequency and existence time of the data, and the active information and data are used Quality information updates the sort order of index addresses to improve data reading efficiency.

Benefits of technology

By reducing direct access to storage media, the CPU load is reduced, data reading efficiency is improved, and the sorting of index addresses in the buffer pool is optimized to ensure efficient data reading and subsequent data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626412A
    Figure CN118626412A
Patent Text Reader

Abstract

The embodiment of the invention provides a data reading method and device, electronic equipment and a storage medium, and belongs to the technical field of data caching. The method comprises the steps of obtaining an access request for target data; in response to the access request, when a target index address of the target data exists in a preset buffer pool, target description data of the target data are obtained at a corresponding position in a preset data pool based on the target index address, the target description data are returned, and index addresses of multiple data are stored in the buffer pool; the plurality of index addresses are arranged according to a sorting sequence, and description data corresponding to each index address is stored in the data pool; and when the target index address is located in a hot data area in the buffer pool, or the target index address is located in a cold data area of the buffer pool and the existence time meets a preset condition, transferring the target index address to a head position of the hot data area so as to update a sorting sequence of the index addresses in the buffer pool. According to the invention, the data reading efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data cache, and in particular to a data reading method, device, electronic device and storage medium. Background Art

[0002] In computer equipment, data reading includes the process of the central processing unit (CPU) obtaining data from storage media (such as disk, memory, etc.) and loading it into the memory.

[0003] Usually, a cache is also set in a computer device. Due to the advantages of cache location and high hit rate, in the related technology, the read data is placed in the cache. Since the cache can exchange data with the CPU before the storage medium, it is convenient for subsequent data reading operations. However, this data reading method requires continuous addition, transfer or elimination of data pages, especially when the amount of data is growing, which increases the CPU load and reduces the data reading efficiency. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to provide a data reading method, device, electronic device and storage medium, which can improve the data reading efficiency.

[0005] To achieve the above object, a first aspect of an embodiment of the present application proposes a data reading method, the method comprising:

[0006] Obtain access requests for target data;

[0007] In response to the access request, when the target index address of the target data exists in the preset buffer pool, the target description data of the target data is obtained based on the target index address pointing to the corresponding position in the preset data pool, and the target description data is returned, wherein the buffer pool stores the index addresses of multiple data, and the multiple index addresses are arranged in the order of address sorting, and the data pool stores the description data corresponding to each index address;

[0008] When the target index address is located in the hot data area in the buffer pool, or the target index address is located in the cold data area in the buffer pool and the existence time meets the preset condition, the target index address is transferred to the head position of the hot data area to update the sorting order of the index addresses in the buffer pool.

[0009] In some embodiments, each index address in the data pool is provided with corresponding activity information, and the activity information is used to indicate the probability that the data corresponding to the corresponding index address is read;

[0010] After returning the target description data, it also includes:

[0011] When the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, the corresponding access control information and change time information are determined according to the target description data;

[0012] Determine target active information corresponding to the target index address, calculate a first ratio between the access control information and the target active information, calculate a second ratio between the change time information and the target active information, and update the target active information according to the first ratio and the second ratio;

[0013] According to the sorting order of the updated target active information and other active information, the target index address is transferred to the first position of the hot data area.

[0014] In some embodiments, after returning the target description data, the method further includes:

[0015] When the target index address is located in the cold data area of ​​the buffer pool and the existence time does not meet the preset conditions, the corresponding data quality information is determined according to the target description data;

[0016] Determine target active information corresponding to the target index address, calculate a third ratio between the data quality information and the target active information, and update the target active information according to the third ratio;

[0017] According to the sorting order of the updated target active information and other active information, the target index address is transferred to the second position of the hot data area.

[0018] In some embodiments, after obtaining the access request for the target data, the method further includes:

[0019] In response to the access request, when the target index address of the target data does not exist in the preset buffer pool, acquiring target description data of the target data based on the target index address pointing to the corresponding position in the storage medium, and returning the target description data, wherein the storage medium stores addresses of multiple data;

[0020] Determine the space occupation value of the target data, and calculate the numerical difference between the space occupation value and each free position value in the data pool, wherein each free position in the data pool includes a corresponding free position value;

[0021] If there is an idle position whose value difference is less than the preset space threshold, the target index address and target description data are added to the idle position;

[0022] Target activity information is determined according to the target description data, and the target index address is added to the third position of the cold data area according to the target activity information.

[0023] In some embodiments, determining target activity information according to target description data includes:

[0024] Determine data attribute information and predicted access information of target data;

[0025] A first sub-value is calculated based on the data attribute information and a preset first weight value, and a second sub-value is calculated based on the predicted access information and a preset second weight value;

[0026] The first sub-value and the second sub-value are added to obtain target activity information corresponding to the target data.

[0027] In some embodiments, after calculating the numerical difference between the space occupancy value and the free position values ​​in the data pool, the method further includes:

[0028] If there is no free position whose value difference is less than the preset space threshold, any target description data between two adjacent free positions is moved toward one of the free positions;

[0029] Until two free positions are merged, an updated free position is obtained.

[0030] In some embodiments, after determining target activity information according to the target description data and adding the target index address to the third position of the cold data area according to the target activity information, the method further includes:

[0031] Determine and clear the index address of the last area in the cold data area, and the description data corresponding to the index address in the data pool.

[0032] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a data reading device, the device comprising:

[0033] An acquisition module, used for acquiring an access request for target data;

[0034] A data reading module, for responding to an access request, when a target index address of the target data exists in a preset buffer pool, obtaining target description data of the target data based on the target index address pointing to a corresponding position in a preset data pool, and returning the target description data, wherein the buffer pool stores index addresses of multiple data, and the multiple index addresses are arranged in a sorted order, and the data pool stores description data corresponding to each index address;

[0035] The update module is used to transfer the target index address to the head position of the hot data area when the target index address is located in the hot data area of ​​the buffer pool, or the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, so as to update the sorting order of the index addresses in the buffer pool.

[0036] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the data reading method of the above-mentioned first aspect when executing the computer program.

[0037] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the data reading method of the above-mentioned first aspect is implemented.

[0038] The data reading method, device, electronic device and storage medium proposed in the present application, the method obtains an access request for target data; in response to the access request, when there is a target index address of the target data in a preset buffer pool, the target description data of the target data is obtained based on the target index address pointing to the corresponding position in the preset data pool, and the target description data is returned, wherein the buffer pool stores multiple index addresses of data, and the multiple index addresses are arranged in a sorted order, and the data pool stores description data corresponding to each index address; when the target index address is located in the hot data area in the buffer pool, or the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, the target index address is transferred to the head position of the hot data area to update the sorting order of the index address in the buffer pool. In the embodiment of the present application, only the index address is stored in the buffer pool. Since the data content of the index address is small and the space occupied is not large, the CPU can easily find the corresponding index address from the buffer pool. At the same time, the update of the positions of each index address in the buffer pool can be realized based on less computing resources. In this way, on the basis of ensuring the efficiency of current data reading, the efficiency of subsequent data reading is also improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 is a schematic diagram of the structure of a data reading device provided in an embodiment of the present application;

[0040] Figure 2 is an optional flow chart of the data reading method provided in an embodiment of the present application;

[0041] Figure 3 is an optional data pool schematic diagram of the data reading method provided in the embodiment of the present application;

[0042] Figure 4 It is a schematic diagram of an optional functional module of the data reading device provided in an embodiment of the present application;

[0043] Figure 5 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0045] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0047] First, some nouns involved in this application are analyzed:

[0048] Uniform Resource Locator (URL), a URL specifies the location of a resource that a client program wishes to access. It contains information such as the protocol (such as HTTP or HTTPS), host name, and path, and is used to uniquely identify and locate resources.

[0049] Request method: The request method specifies the operation that the client wants the server to perform on the resource. Common request methods include: resource acquisition method (GET method). When using the GET method, the client requests to obtain the representation of the resource specified by the target URL, and the server returns the resource as the response body; resource acquisition method (POST method), submitting data to the server to create a new resource or perform an operation. When using the POST method, the client sends the data included in the request body to the target URL. The server performs the corresponding operation according to the content of the request body and returns the result.

[0050] An Application Programming Interface (API) is a set of rules and conventions that define the interactions between software components. It allows different software systems to communicate and interact, enabling them to connect to each other and share data and functions. There are many types of APIs, such as the Representational State Transfer Application Programming Interface (RESTful API) and the Simple Object Access Protocol (SOAP).

[0051] A smart toilet is a sanitary ware that integrates intelligent technology and high-tech equipment, aiming to provide a more comfortable, convenient and hygienic user experience.

[0052] In computer equipment, data reading includes the process of the central processing unit program obtaining data from the storage medium (such as disk, memory, etc.) and loading it into the memory.

[0053] Usually, a cache is also set in a computer device. Due to the advantages of cache location and high hit rate, in the related technology, the read data is placed in the cache. Since the cache can exchange data with the CPU before the storage medium, it is convenient for subsequent data reading operations. However, this data reading method requires continuous addition, transfer or elimination of data pages, especially when the amount of data is growing, which increases the CPU load and reduces the data reading efficiency.

[0054] Based on this, the present application proposes a data reading method, device, electronic device and storage medium, which can improve the data reading efficiency. First, the data reading device in the embodiment of the present application is introduced. Figure 1 As shown, Figure 1 1 is a schematic diagram of the device structure of the data reading device provided by the embodiment of the present application. Among them, the data reading device (for the convenience of description, it can be referred to as "device" below) is provided with a buffer pool and a data pool. When the data in the storage medium is read, the data will be written into the buffer pool of the device. The index address corresponding to the data is stored in the buffer pool, and the index address and the corresponding description data are stored in the data pool. When a certain target data such as description data 10 is to be read, the buffer pool is first traversed. If the index address 10 corresponding to the description data 10 can be found in the buffer pool, the corresponding description data 10 is directly found from the data pool according to the index address 10; if the corresponding index address 10 is not found from the buffer pool, the description data 10 is read from the storage medium. It can be understood that only the index address corresponding to the data is stored in the buffer pool. When the corresponding index address is read, the corresponding data will be found from the data pool based on the index address. In this way, when reading data, it is not necessary to search for data from the storage medium with a large amount of data every time, and the index address stored in the buffer pool occupies a small storage space, so that the reading speed of data is greatly improved.

[0055] It should be noted first that in the embodiments of the present application, when it is necessary to read data from a buffer pool, a data pool or a storage medium, the user's permission or consent will be obtained first, and the collection, use and processing of the read data will comply with relevant laws, regulations and standards. In addition, when the embodiments of the present application need to obtain sensitive personal information of a user, the user's separate permission or consent will be obtained first. After the user's separate permission or consent is clearly obtained, the necessary target description data for the normal operation of the embodiments of the present application will be obtained. For example, in the embodiments of the present application, the user's related account information needs to be read from the data pool. Before obtaining an access request for the target data, the relevant user's consent will be obtained first. Only when the user's permission or consent is obtained, the target description data required by the embodiments of the present application will be obtained.

[0056] Next, the data reading method in the embodiment of the present application is specifically described through the following embodiments.

[0057] In the embodiment of the present application, the data reading device will be described from the perspective of the data reading device. The data reading device can be integrated into a computer device, such as a server. Figure 2 As shown, Figure 2 is an optional flow chart of the data reading method provided in the embodiment of the present application. Figure 2 The method in the embodiment may include but is not limited to the following steps 101 to 103, wherein the data reading device performs the data reading method in the following specific process. It should be noted that the present embodiment Figure 2 The order of step 101 to step 103 is not specifically limited, and the order of steps can be adjusted or some steps can be reduced or added according to actual needs.

[0058] Step 101: Obtain an access request for target data.

[0059] The following is a detailed description of step 101.

[0060] Among them, the CPU will first obtain an access request from the program, and the access request indicates the target data to be read. The access request is used to indicate the identifier, index address, and data type, size, structure, etc. of the target data to be read. The data operation type indicated by the access request can be read, write, update, or delete. It can be understood that no matter which type, the target data needs to be read first before subsequent operations can be performed. Therefore, the embodiment of the present application needs to first obtain an access request so that the target data can be subsequently read based on the access request.

[0061] Among them, the access request can adopt different formats according to the different computer or server hardware devices actually operated or the different interface requirements indicated by the program. For example, the format of the access request can be the Hypertext Transfer Protocol (HTTP) request format, HTTP request usually includes the request method (such as GET, POST), the target URL, the request header and the optional request body; the Structured Query Language (SQL) format, the SQL query format usually includes the selection (SELECT) statement and conditions, which are used to specify the target data to be queried; the API call format, the API call format depends on the API and protocol used, which may be RESTful API, SOAP, etc.; the remote procedure call format (RPC call format), in a distributed system, the remote procedure call (RPC) can be used to request access to the target data. The RPC call format depends on the RPC framework and protocol used.

[0062] The target data can be various types of information or resources, and its specific form depends on the application scenario and actual needs. Common target data types include: text data, such as articles, documents, logs, chat records and other text data; image data, such as photos, charts, paintings and other image data; audio data: such as music, voice recordings, sound effects and other sound data; video data, such as movies, TV programs, videos and other video data. According to the data type, storage method and application scenario of the data, a unique index address in the storage medium can be generated accordingly, and the index address can be written into the buffer pool accordingly. At the same time, the description data and the corresponding index address can be written into the data pool.

[0063] Furthermore, data is usually stored in data pages. When a certain descriptive data is accessed, the access probability of other data in the data page where the descriptive data is located is higher. Therefore, the target index address corresponding to the target data can be the index address of the data page. At this time, the data stored in the data pool includes all data on the data page.

[0064] The storage medium is set in the computer or server. The storage medium can be a hardware device or material such as a hard disk, a solid-state drive, a memory chip, etc. that can store various types of data, so as to completely store all data related to the program. Compared with the buffer pool and the data pool, the storage medium has a larger storage capacity, a slower reading and writing speed, and a longer data storage persistence. Therefore, while ensuring that there is enough space to store the required data, the use of the buffer pool and the data pool can be used to improve the data reading efficiency.

[0065] Step 102, in response to an access request, when a target index address of the target data exists in a preset buffer pool, target description data of the target data is obtained based on the target index address pointing to a corresponding position in a preset data pool, and the target description data is returned, wherein the buffer pool stores index addresses of multiple data, and the multiple index addresses are arranged in a sorted order, and the data pool stores description data corresponding to each index address.

[0066] The following is a detailed description of step 102.

[0067] Among them, in order to facilitate data addressing and access, the data stored in the storage medium includes two aspects: address and specific content (description data). When the data in the storage medium is accessed, the data is called target data, the address corresponding to the target data is the target address, and the specific content of the target data is the target description data.

[0068] Among them, the buffer pool and the data pool are set on a medium with a faster reading speed, such as a cache. Since the cache is usually located at a location with a shorter physical distance between the data user (such as a CPU) and the data source (such as a memory or a disk), and the reading speed of the medium used by the cache is usually faster, the speed of reading data from the cache is usually faster than reading data from the storage medium.

[0069] Further, the buffer pool and the data pool jointly form a high-speed storage area, and the target index address corresponding to the target data is stored in the buffer pool, and the target description data and the corresponding target index address are stored in the data pool. The target index address in the buffer pool corresponds to the target index address in the data pool, that is, the target index address in the data pool can be found through the target index address in the buffer pool. For example, the target index address corresponding to a certain target data A is address A, and the target description data is description data A. Then, after successfully accessing the target data A, it is necessary to store address A in the buffer pool, and store (address A+description data A) in the data pool. It can be understood that the reading of data involves the update of multiple information data in the cache. Compared with storing the specific content and the corresponding address of the data in the cache area, the cache pool in the embodiment of the present application only stores the index address. Since the data content of the index address is less and the space occupied is not large, the CPU can easily find the corresponding index address from the buffer pool. At the same time, it can also be based on less computing power resources to realize the update of each index address position in the buffer pool. In this way, on the basis of ensuring the high efficiency of the current data reading, the efficiency of subsequent data reading is also improved.

[0070] The index addresses in the buffer pool are sorted in a certain order, for example, the index addresses can be sorted from small to large. Since the addresses of adjacent data are also adjacent, arranging the index addresses in order can help the CPU hit the required data in a shorter time, thereby improving the data reading efficiency.

[0071] Step 103, when the target index address is located in the hot data area in the buffer pool, or the target index address is located in the cold data area in the buffer pool and the existence time meets the preset condition, the target index address is transferred to the head position of the hot data area to update the sorting order of the index addresses in the buffer pool.

[0072] The following is a detailed description of step 103.

[0073] The buffer pool includes two areas, one is the hot data area, which is used to store data with a higher access frequency; the other is the cold data area, which is used to store data with a lower access frequency. In order to ensure the accuracy of data access, the device will update the target index address arrangement order in the buffer pool within a preset interval. If the target data is read from the hot data area, it means that the access frequency of the target data itself is relatively high. On this basis, the CPU accesses the data again, which means that the probability of the CPU accessing it again is still relatively high. Then, the target index address corresponding to the target data is moved to the head position of the hot data area to speed up the CPU's data reading efficiency.

[0074] Furthermore, if the target index address is read from the cold data area, it means that the access probability of the corresponding target data is not high before. On this basis, the CPU accesses the target index address, and the movement of the target index address is determined based on the time the target index address exists in the cold data area. If the existence time is greater than the preset time, it means that the CPU may have read the data of the data page where the target data is located multiple times, resulting in a longer residence time of the target index address in the cold data area, and the subsequent CPU has a higher probability of accessing other data on the data page. Therefore, the target index address can be moved to the head position of the hot data area to improve data reading efficiency; and if the existence time is not greater than the preset time, it means that the CPU has only read one or several data on the data page, so the residence time of the data page is short, indicating that the probability of the subsequent CPU accessing other data on the data page is not high, so no operation can be performed on the target index address.

[0075] Exemplarily, the preset time may be 1 second. Since a data page can usually access a lot of content within 1 second, if the target index address stays in the cold data area for more than 1 second, it indicates that the CPU has accessed the same data or different data of the data page multiple times. In this case, the target index address may be moved to the head position of the hot data area to avoid a large number of new target index addresses being loaded into the cold data area, thereby eliminating frequently accessed data.

[0076] It should be noted that the preset time can be set according to actual conditions, and the embodiments of the present application do not impose any specific limitation.

[0077] It can be understood that the embodiment of the present application sets up a double buffer area to exchange space for time. In this way, the target data corresponding to the target index data stored in the buffer pool represents the index address corresponding to the frequently accessed data, and on this basis, it is further divided into more frequently accessed (hot data area) and less frequently accessed (cold data area). When the target index address corresponding to the accessed target data exists in the buffer pool, the position of the target index address is further adjusted according to the position and existence time of the target index address, so as to improve the hit rate of the target data when the CPU traverses the buffer pool in order later, thereby speeding up the data reading efficiency.

[0078] In some embodiments, after returning the target description data, the following steps 201 to 203 are further included:

[0079] Step 201: when the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, the corresponding access control information and change time information are determined according to the target description data.

[0080] The following is a detailed description of step 201.

[0081] In some embodiments, in order to further improve the data reading efficiency, each index address in the data pool is further provided with corresponding activity information, and the activity information is used to indicate the probability that the data corresponding to the corresponding index address is read.

[0082] In some embodiments, when the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, in addition to moving the target index address to the head position of the hot data area, the moving position of the target index address can also be determined according to the active information corresponding to each target data. Among them, the active information is pre-set, and when the CPU accesses a certain target data, the corresponding active information can be updated according to the target description information of the target data, and then the moving position of the target index address is determined according to the size of the updated active information and other active information in the hot data area.

[0083] Furthermore, the access control information is used to indicate the access rights of the target data. If the access rights are high, the access control information score is low, indicating that the target data is most likely not accessed very often. The change time information is used to indicate the last access timestamp of the target data. If the current timestamp and the last access timestamp are close, the change time information score is high, indicating that the target data is accessed frequently.

[0084] Step 202, determine the target active information corresponding to the target index address, calculate a first ratio between the access control information and the target active information, calculate a second ratio between the change time information and the target active information, and update the target active information according to the first ratio and the second ratio.

[0085] Step 202 is described in detail below.

[0086] In some embodiments, the active information is updated using the determined access control information and change time information. Specifically, the ratio of the access control information to the target active information can be used as the first ratio, and the ratio of the change time information to the target active information can be used as the second ratio. The updated target active information is obtained based on the original target active information and the sum of the first ratio and the second ratio.

[0087] Furthermore, different weight values ​​can be set for the first ratio and the second ratio, and under the constraint of the weight value, the updated first ratio and the second ratio are calculated to obtain the updated target activity information. The specific numerical value of the weight value can be set according to the actual situation, and the embodiment of the present application does not make any specific restrictions.

[0088] Step 203 : According to the sorting order of the updated target active information and other active information, the target index address is transferred to the first position of the hot data area.

[0089] Furthermore, after obtaining the updated target active information, the target active information is compared with the size of other active information in the hot data area to determine the first position of the target index address in the hot data area after the target index address is moved. The first position may be the head position of the hot data area or other positions, which needs to be determined according to the actual value of the target active information.

[0090] Alternatively, when the active information represents the activity level, the corresponding target index address can be placed at the head position of the corresponding activity level, so as to avoid traversing all index addresses in the buffer pool before determining the moving position of the target index address, thereby improving the efficiency of the sorting order of the index addresses in the buffer pool. For example, the hot data area includes three active information levels A1, B1, and C1, and the cold data area includes three active information levels A2, B2, and C2. When the residence time of the target data in the cold data area A2 is greater than 1s, the target data is moved to the head position of the hot data area A1.

[0091] In some embodiments, after returning the target description data, the following steps 301 to 303 are further included:

[0092] Step 301: when the target index address is located in the cold data area of ​​the buffer pool and the existence time does not meet the preset condition, the corresponding data quality information is determined according to the target description data.

[0093] The following is a detailed description of step 301.

[0094] In some embodiments, if the target index address is located in the cold data area of ​​the buffer pool and the existence time does not meet the preset conditions, in addition to not performing any operation on the target index address, the access probability of the currently accessed target data in the future can be predicted when active information is set. To achieve this purpose, simple data quality information can be determined based on the target description data, so as to make a simple prediction of the read probability of the target data in the future based on the data quality information.

[0095] Furthermore, data quality information is used to indicate the quality of target data. For example, if the data accounts for a large proportion, the data quality information is high, indicating that the data content is complete and rich. Since data with a small proportion usually indicates the core content of the data, the CPU tends to access data with a smaller proportion, that is, data with high data quality information has a lower quality information score, indicating that the probability of being accessed subsequently is not high.

[0096] Step 302: determine the target active information corresponding to the target index address, calculate a third ratio between the data quality information and the target active information, and update the target active information according to the third ratio.

[0097] Step 302 is described in detail below.

[0098] Furthermore, the determined data quality information is used to update the active information. Specifically, the ratio of the data quality information may be used as a third ratio, and the updated target active information may be obtained according to the sum of the original target active information and the third ratio.

[0099] Furthermore, a corresponding weight value can be set for the third ratio, and under the constraint of the weight value, the updated third ratio is calculated to obtain the updated target activity information. The specific numerical value of the weight value can be set according to actual conditions, and the embodiments of the present application do not impose specific restrictions.

[0100] Step 303: transfer the target index address to the second position of the hot data area according to the updated sorting order of the target active information and other active information.

[0101] The following is a detailed description of step 303.

[0102] Furthermore, after obtaining the updated target active information, the target active information is compared with the size of other active information in the hot data area to determine the second position of the target index address in the hot data area after the target index address is moved. The second position may be the head position of the hot data area or other positions in the hot data area, which needs to be determined according to the actual value of the target active information.

[0103] Furthermore, this target index address movement method can be applied to scenarios where the access request interval is relatively long, such as a smart toilet, where the CPU receives instructions issued by the user at a long interval. At this time, the update accuracy of the target index address position in the buffer pool can be improved based on the target description information, so as to improve the efficiency of data reading when the next data access comes.

[0104] Furthermore, in actual situations, the target index address moving method can be selected according to specific circumstances, and the one with higher data reading efficiency can be selected, or two target index address moving methods can be used alternately to improve the data reading efficiency as a whole.

[0105] It is understandable that if the currently accessed data is in the cold data area, in addition to determining whether to place the corresponding index address at the head position of the hot data area based on the existence time, the position of the index address in the hot data area can also be determined based on the pre-determined and real-time updated active information. In this way, it is avoided that the index address is directly placed at the head position of the hot data area, resulting in the frequent traversal of the position when the data is no longer accessed in the future, or the excessive waste of resources caused by copying and pasting each index address generated by updating the buffer pool. The compromise-based solution ensures that the data originally in the hot data area is always at the front of the traversal, and the newly accessed data is placed in a reasonable position in the hot data area. If the data is no longer accessed later, it can be eliminated at a faster speed, and if the data is still accessed later, it can also be hit at a faster speed.

[0106] In some embodiments, after obtaining the access request for the target data, the following steps 401 to 404 are also included:

[0107] Step 401, in response to an access request, when the target index address of the target data does not exist in the preset buffer pool, obtain the target description data of the target data based on the target index address pointing to the corresponding position in the storage medium, and return the target description data, wherein the storage medium stores the addresses of multiple data.

[0108] Step 402, determining the space occupation value of the target data, and calculating the numerical difference between the space occupation value and each free position value in the data pool, wherein each free position in the data pool includes a corresponding free position value.

[0109] Step 403, if there is an idle position whose value difference is less than the preset space threshold, add the target index address and target description data to the idle position;

[0110] Step 404 , determining target activity information according to the target description data, and adding the target index address to the third position of the cold data area according to the target activity information.

[0111] Steps 401 to 404 are described in detail below.

[0112] In some embodiments, if the target index address corresponding to the target data to be read is not in the buffer pool, the target data is read from a storage medium storing complete data according to the target index address, and the target index address corresponding to the target data is stored in the buffer pool, and the target index address and target description data corresponding to the target data are stored in the data pool.

[0113] Furthermore, the target index addresses in the buffer pool are usually arranged in order of address size or according to active information, while the target index addresses in the data pool are in a mapping relationship with the target index addresses in the buffer pool, that is, the target index addresses in the data pool do not need to be arranged in order of size. This method causes that when the target index address in the buffer pool is deleted, the free positions left after deleting the corresponding target index address and target description data in the data pool are often not continuous. Therefore, after completing the insertion action of the target index address in the buffer pool, it is necessary to determine the space occupancy value of the target data, so as to determine the adding position of the target data in the data pool according to the space occupancy value, wherein the space occupancy value is determined based on the size of the target index address and the size of the target description data.

[0114] Furthermore, the space occupancy value is compared with the free position value corresponding to the free position in the data pool to obtain the numerical difference between the two, and the free position corresponding to the preset space threshold is determined, and the target index address and target description data are stored in the free position.

[0115] Furthermore, if the target index address corresponding to the target data is not in the buffer pool before this access, the target index address can be stored in the head position of the cold data area after the data access is completed, or the target active information corresponding to the target data is first determined, and then the target index address is determined in the third position corresponding to the buffer pool based on the size relationship between the target active information and other active information in the buffer pool, where the third position may be the head position of the cold data area or other positions in the cold data area, which needs to be determined based on the actual value of the target active information.

[0116] In some embodiments, after calculating the numerical difference between the space occupancy value and the free position values ​​in the data pool, the following steps 501 to 502 are also included:

[0117] Step 501: If there is no free position whose value difference is less than a preset space threshold, any object description data between two adjacent free positions is moved toward one of the free positions.

[0118] Step 502, until two free positions are merged, an updated free position is obtained.

[0119] Steps 501 to 502 are described in detail below.

[0120] In some embodiments, if there is no free position with a numerical difference less than a preset space threshold, e.g. Figure 3 As shown, Figure 3 It is an optional data pool diagram of the data reading method provided in an embodiment of the present application. The space occupied by the target data B (target index address B+target description data B) currently to be stored is larger than free position 1, free position 2 and free position 3, that is, the space of each free position in the current data pool is too small to meet the storage requirements of the target data B. Therefore, it is necessary to merge the remaining free positions through fragmentation to meet the storage needs of the new target data.

[0121] For example, Figure 3As shown, (index address 10+data 10) between free position 1 and free position 2 can be moved toward free position 2, so that the position of free position 1 is continuously increased, until the updated free position 1=free position 1+free position 2, and the updated free position is obtained. Among them, the target data stored in the data pool can also only include target description data. In this case, the target index address stored in the buffer pool indicates the corresponding target description data in the data pool by pointing to a pointer.

[0122] In some embodiments, determining target activity information according to target description data includes the following steps 601 to 603:

[0123] Step 601, determining data attribute information and predicted access information of target data.

[0124] Step 602: Calculate a first sub-value based on data attribute information and a preset first weight value, and calculate a second sub-value based on predicted access information and a preset second weight value.

[0125] Step 603: Add the first sub-value and the second sub-value to obtain target activity information corresponding to the target data.

[0126] Steps 601 to 603 are described in detail below.

[0127] Among them, the active information is set before the data is stored in the high-speed storage area, and the active information is set based on comprehensive consideration of multiple dimensions. The active information corresponding to the target data is called the target active information. In the embodiment of the present application, the setting of the active information takes into account two aspects: data attribute information and predicted access information. Among them, the data attribute information is used to indicate the characteristics of the data itself to characterize the importance of the data itself; the predicted access information is used to indicate the probability that the data may be accessed in the future.

[0128] Furthermore, the activity information can be a specific activity value or an activity level. Data attribute information and predicted access information can both be represented by scores, and the data attribute score and predicted access score are determined based on the descriptive data corresponding to the data. For example, a batch of data includes core data and edge data. The core data can be the user's name, gender, etc., and the edge data can be the user's notes information. It can be determined that the data attribute score corresponding to the core data is greater than the edge data; and based on experience, the access frequency of the core data is higher than that of the edge data, so it is determined that the predicted access score of the core data is greater than that of the edge data.

[0129] Furthermore, the data attribute score can also be determined based on the data type, data source, data destination, etc., and the predicted access score can also be determined based on the number of historical visits and the last visit time. That is, the specific content of the data attribute information and the predicted access information can be set according to actual conditions, and the embodiments of the present application do not impose specific restrictions on this.

[0130] Furthermore, the first weight value corresponds to the data attribute information, and the second weight value corresponds to the predicted access information. The first weight value can be set higher than the second weight value, which indicates that in the process of determining active information, the characteristics of the data itself are more important than the predicted results obtained by empirical judgment.

[0131] It should be noted that the first weight value and the second weight value can be set according to actual conditions, and the second weight value can also be higher than the first weight value to emphasize the importance of the prediction results based on empirical judgment. The embodiments of the present application do not make specific restrictions on this.

[0132] Furthermore, the embodiment of the present application obtains active information by performing weighted calculation on the features corresponding to the description data from multiple dimensions. When the data is accessed and stored in the buffer pool, it can be sorted according to the size of the active information. In this way, data with a higher access probability can be arranged before data with a lower access probability. When the next access request comes, the CPU can find the corresponding target data with a higher hit rate.

[0133] In some embodiments, after updating the target activity information according to the target description data and adding the target index address to the third position of the cold data area according to the target activity information, the following steps are also included:

[0134] Determine and clear the index address of the last area in the cold data area, and the description data corresponding to the index address in the data pool.

[0135] In some embodiments, the space of the buffer pool is usually limited to avoid unlimited growth of data. When the data in the buffer pool is full and a new index address needs to be added, the index address that is not frequently accessed needs to be deleted from the buffer pool. The last area of ​​the cold data area of ​​the buffer pool is set as the data elimination area. The data capacity of the last area can be one or more data. When the preset interval time is reached to update the index address in the buffer pool, all index data in the last area will be deleted. In addition, the corresponding index address written in the data pool and the corresponding description data are deleted to store data with higher access frequency.

[0136] Furthermore, active information is pre-set before data enters the buffer, which comprehensively considers multiple aspects in depth. The active information update after the data is accessed is some simpler information directly obtained based on the description data corresponding to the accessed data, and the active information is updated based on this real-time information. These are two different aspects.

[0137] It should be noted that the amount of data that can be accommodated in the last area can be set according to actual conditions, and the embodiments of the present application do not impose specific limitations on this.

[0138] like Figure 4 As shown, Figure 4 : is an optional functional module diagram of a data reading device provided in an embodiment of the present application, wherein the data reading device may include:

[0139] An acquisition module 801 is used to acquire an access request for target data;

[0140] The data reading module 802 is used to, in response to the access request, obtain target description data of the target data based on the target index address pointing to the corresponding position in the preset data pool, and return the target description data when the target index address of the target data exists in the preset buffer pool, wherein the buffer pool stores the index addresses of multiple data, and the multiple index addresses are arranged in a sorted order, and the data pool stores the description data corresponding to each index address;

[0141] Update module 803 is used to transfer the target index address to the head position of the hot data area to update the sorting order of the index addresses in the buffer pool when the target index address is located in the hot data area in the buffer pool, or when the target index address is located in the cold data area in the buffer pool and the existence time meets the preset conditions.

[0142] The data reading method, device, electronic device and storage medium proposed in the present application, the method obtains an access request for target data; in response to the access request, when there is a target index address of the target data in a preset buffer pool, the target description data of the target data is obtained based on the target index address pointing to the corresponding position in the preset data pool, and the target description data is returned, wherein the buffer pool stores multiple index addresses of data, and the multiple index addresses are arranged in a sorted order, and the data pool stores description data corresponding to each index address; when the target index address is located in the hot data area in the buffer pool, or the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset conditions, the target index address is transferred to the head position of the hot data area to update the sorting order of the index address in the buffer pool. In the embodiment of the present application, only the index address is stored in the buffer pool. Since the data content of the index address is small and the space occupied is not large, the CPU can easily find the corresponding index address from the buffer pool. At the same time, the update of the positions of each index address in the buffer pool can be realized based on less computing resources. In this way, on the basis of ensuring the efficiency of current data reading, the efficiency of subsequent data reading is also improved.

[0143] The specific implementation of the data reading device is substantially the same as the specific implementation of the above-mentioned data reading method, and will not be described in detail herein.

[0144] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above data reading method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0145] like Figure 5 As shown, Figure 5 : is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application, the electronic device includes:

[0146] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.

[0147] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the data reading method of the embodiment of this application;

[0148] Input / output interface 903, used to implement information input and output;

[0149] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WI FI, Bluetooth, etc.);

[0150] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);

[0151] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0152] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above-mentioned data reading method when executed by a processor.

[0153] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0154] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0155] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0156] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0157] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0158] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0159] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0160] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0161] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0162] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0163] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0164] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A data reading method, characterized in that: The method comprises: Obtain access requests for target data; In response to the access request, when the target index address of the target data exists in the preset buffer pool, target description data of the target data is obtained based on the corresponding position in the preset data pool pointed to by the target index address, and the target description data is returned, wherein the buffer pool stores the index addresses of multiple data, and the multiple index addresses are arranged in a sorted order, and the data pool stores the description data corresponding to each index address; When the target index address is located in the hot data area in the buffer pool, or the target index address is located in the cold data area in the buffer pool and the existence time meets the preset condition, the target index address is transferred to the head position of the hot data area to update the sorting order of the index addresses in the buffer pool.

2. The method according to claim 1, characterized in that Each of the index addresses in the data pool is provided with corresponding activity information, where the activity information is used to indicate the probability that the data corresponding to the corresponding index address is read; After returning the target description data, the method further includes: When the target index address is located in the cold data area of ​​the buffer pool and the existence time meets the preset condition, the corresponding access control information and change time information are determined according to the target description data; Determine the target active information corresponding to the target index address, calculate a first ratio between the access control information and the target active information, calculate a second ratio between the change time information and the target active information, and update the target active information according to the first ratio and the second ratio; According to the updated sorting order of the target active information and other active information, the target index address is transferred to the first position of the hot data area.

3. The method according to claim 2, characterized in that After returning the target description data, the method further includes: When the target index address is located in the cold data area of ​​the buffer pool and the existence time does not meet the preset condition, determining the corresponding data quality information according to the target description data; Determine the target active information corresponding to the target index address, calculate a third ratio between the data quality information and the target active information, and update the target active information according to the third ratio; The target index address is transferred to a second position of the hot data area according to the updated sorting order of the target active information and other active information.

4. The method according to claim 2, characterized in that: After obtaining the access request for the target data, the method further includes: In response to the access request, when the target index address of the target data does not exist in the preset buffer pool, acquiring target description data of the target data based on the corresponding position in the storage medium pointed to by the target index address, and returning the target description data, wherein the storage medium stores addresses of multiple data; Determine the space occupation value of the target data, and calculate the numerical difference between the space occupation value and each free position value in the data pool, wherein each free position in the data pool includes the corresponding free position value; If there is an idle position where the numerical difference is less than a preset space threshold, adding the target index address and the target description data to the idle position; The target activity information is determined according to the target description data, and the target index address is added to a third position of the cold data area according to the target activity information.

5. The method according to claim 4, characterized in that The determining the target activity information according to the target description data includes: Determining data attribute information and predicted access information of the target data; A first sub-value is calculated based on the data attribute information and a preset first weight value, and a second sub-value is calculated based on the predicted access information and a preset second weight value; The first sub-value and the second sub-value are added to obtain the activity information corresponding to the target data.

6. The method according to claim 4, characterized in that After calculating the numerical difference between the space occupancy value and the free position values ​​in the data pool, the method further includes: If there is no idle position whose value difference is less than the preset space threshold, any target description data between two adjacent idle positions is moved toward the direction of one of the idle positions; Until the two idle positions are merged, the updated idle position is obtained.

7. The method according to claim 4, characterized in that After determining the target activity information according to the target description data and adding the target index address to the third position of the cold data area according to the target activity information, the method further includes: Determine to clear the index address in the last area of ​​the cold data area and the description data corresponding to the index address in the data pool.

8. A data reading device, characterized in that: The device comprises: An acquisition module, used for acquiring an access request for target data; a data reading module, for, in response to the access request, obtaining target description data of the target data based on the target index address pointing to a corresponding position in the preset data pool, and returning the target description data when the target index address of the target data exists in the preset buffer pool, wherein the buffer pool stores index addresses of a plurality of data, and the plurality of index addresses are arranged in a sorted order, and the data pool stores description data corresponding to each index address; An update module is used to transfer the target index address to the head position of the hot data area when the target index address is located in the hot data area in the buffer pool, or when the target index address is located in the cold data area of ​​the buffer pool and the existence time meets a preset condition, so as to update the sorting order of the index addresses in the buffer pool.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the data reading method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the data reading method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Index management method, device, storage medium and equipment used for log query

    CN107220287A

  • Data caching method, caching equipment and storage system

    CN110196818A

  • Cache control method and device, equipment and medium

    CN115599821A

  • Business data storage method and device, computer equipment and storage medium

    CN116185305A

  • File storage method and system, storage medium and electronic equipment

    CN116774940A

Cited By

  • Data processing method and device, electronic equipment and storage medium

    CN119718686A

  • Data processing method, device, electronic device and storage medium

    CN119718686B

  • Buffer method and device based on dynamic linked list structure, computer equipment and medium

    CN122332334A

  • Data sampling method and apparatus, and electronic device and storage medium

    WO2026207786A1