Spatial text data caching method, device, electronic device and storage medium

By calculating the information entropy and access heat information of spatial text data, cache management is optimized, which solves the problem of low cache efficiency in the existing technology and improves data access efficiency.

CN112269947BActive Publication Date: 2024-09-13MIGU CO LTD +1
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202011010594.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-23
Publication Date
2024-09-13
Estimated Expiration
2040-09-23

AI Technical Summary

Technical Problem

When caching spatial text data, the existing technology cannot effectively maintain high efficiency when scenes change, and cannot better reflect the relationship between the popularity of spatial locations and the popularity of text keywords, resulting in a low cache hit rate.

Method used

By calculating the information entropy of spatial access heat information and keyword access heat information, the comprehensive access heat of the spatial area is determined, and data blocks with high access heat are stored in the cache queue during the cache update cycle, and information entropy and access heat ranking are used to optimize Cache management.

Benefits of technology

It improves the probability of data blocks hitting in the cache, improves data access efficiency, and solves the problem of unsatisfactory cache efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112269947B
    Figure CN112269947B
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device, electronic device and storage medium for caching spatial text data; the method comprises: determining spatial access heat information and keyword access heat information according to the number of times the stored spatial text data is accessed within a first cache update cycle; determining comprehensive access heat information of each spatial area within the first cache update cycle according to the spatial access heat information and keyword access heat information; selecting data blocks corresponding to the spatial area within a second cache update cycle and storing them in a cache queue according to the comprehensive access heat information of each spatial area within the first cache update cycle; wherein the second cache update cycle is a cache update cycle after the first cache update cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data storage technology, and in particular to a method, device, electronic device and storage medium for caching spatial text data. Background Art

[0002] Spatial text data refers to text data with spatial location information, such as microblog data containing spatial location information.

[0003] In order to improve the access efficiency of spatial text data, it is necessary to cache the spatial text data. Compared with conventional text data, spatial text data also carries spatial location information, so the text data caching method in the prior art cannot be directly applied to spatial text data.

[0004] To this end, the caching methods for spatial text data in the prior art mainly include: a caching method based on spatial position, a caching method based on text, and a caching method integrating spatial position and text.

[0005] These existing caching methods for spatial text data all have their own shortcomings. For example, whether it is a caching method based on spatial location or a caching method based on text, it can only maintain high cache efficiency in certain scenarios. Once the scenario changes, the cache hit rate will be significantly reduced. The existing caching method that integrates spatial location and text cannot well reflect the relationship between the popularity of spatial location and the popularity of keywords in the text, so the cache efficiency is still not ideal. Summary of the invention

[0006] In view of the problems existing in the prior art, embodiments of the present invention provide a method, device, electronic device and storage medium for caching spatial text data.

[0007] A first aspect of the present invention provides a method for caching spatial text data, comprising:

[0008] According to the number of times the stored spatial text data is accessed in the first cache update cycle, the spatial access heat information and the keyword access heat information are determined; wherein the spatial access heat information is used to describe the number of times the spatial area is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial area is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data;

[0009] Determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information;

[0010] According to the comprehensive access popularity information of each spatial area in the first cache update cycle, the data blocks corresponding to the spatial area are selected and stored in the cache queue in the second cache update cycle; wherein, the second cache update cycle is the cache update cycle after the first cache update cycle.

[0011] In the above technical solution, the comprehensive access heat information of each spatial area in the first cache update cycle is determined according to the spatial access heat information and the keyword access heat information, specifically including:

[0012] Calculating the information entropy of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information;

[0013] According to the information entropy, comprehensive access heat information of each spatial area in the first cache update cycle is determined.

[0014] In the above technical solution, the information entropy of each spatial area in the first cache update cycle is calculated according to the spatial access heat information and the keyword access heat information, including:

[0015] According to the keyword access popularity information, the keyword is divided into hot access words and non-hot access words;

[0016] Calculate the number of times the hotspot access words in the first spatial region are accessed in the first cache update cycle and the number of times the non-hotspot access words are accessed in the first cache update cycle according to the keyword access heat information and the space access heat information; wherein the first spatial region is any spatial region;

[0017] The information entropy of the first spatial area in the first cache update cycle is calculated based on the spatial access heat information, the number of accesses of the hot access words in the first spatial area in the first cache update cycle, and the number of accesses of the non-hot access words in the first cache update cycle.

[0018] In the above technical solution, selecting data blocks corresponding to the spatial regions and storing them in the cache queue in the second cache update cycle according to the comprehensive access heat information of the spatial regions in the first cache update cycle includes:

[0019] sorting the data blocks corresponding to the respective spatial regions according to the comprehensive access heat information of the respective spatial regions in the first cache update cycle;

[0020] The first N data blocks are stored in the first type of cache queue, and the M data blocks after the first N data blocks are stored in the second type of cache queue; wherein,

[0021] The first type of cache queue is a cache queue set in the memory, and the second type of cache queue is a cache queue set in the external memory; N and M are both positive integers.

[0022] In the above technical solution, after the step of selecting data blocks corresponding to the spatial regions and storing them in the cache queue in the second cache update cycle according to the comprehensive access heat information of the spatial regions in the first cache update cycle, the method further includes:

[0023] According to the comprehensive access heat information and the level of the cache queue where the data block is located, the life cycle of the data block in the cache queue is calculated and set; wherein,

[0024] The level of the cache queue is used to describe the priority order when storing data blocks.

[0025] In the above technical solution, the method further comprises:

[0026] Check the life cycle of each data block in the cache queue and remove the invalid data blocks;

[0027] The data block is read from the first cache queue and stored in the free storage space of the second cache queue; wherein the second cache queue is the cache queue where the cleared data block is located; and the first cache queue is a cache queue one level lower than the second cache queue.

[0028] In the above technical solution, the stored spatial text data is stored in the form of spatial index files, keyword index files and data files; wherein,

[0029] The spatial index file stores the intermediate nodes corresponding to the spatial text data together according to the index order, and stores the leaf nodes corresponding to the spatial text data together according to the index order;

[0030] The keyword index file stores the keyword information together and the leaf node information together; wherein the keyword information includes the keyword, the offset and the number of leaf node information;

[0031] The data file includes multiple data blocks, and one data block corresponds to the data in one leaf node.

[0032] A second aspect of the present invention provides a caching device for spatial text data, including:

[0033] The module for determining the spatial access heat information and the keyword access heat information is used to determine the spatial access heat information and the keyword access heat information according to the number of times the stored spatial text data is accessed in the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial region is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial region is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data;

[0034] A comprehensive access heat information determination module, used to determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information;

[0035] A cache module is used to select data blocks corresponding to the spatial areas in a second cache update cycle and store them in a cache queue based on the comprehensive access popularity information of the spatial areas in the first cache update cycle; wherein the second cache update cycle is the cache update cycle after the first cache update cycle.

[0036] The third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for caching spatial text data as described in the first aspect of the present invention are implemented.

[0037] The fourth aspect of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for caching spatial text data as described in the first aspect of the present invention are implemented.

[0038] The caching method, device, electronic device and storage medium of spatial text data provided by the embodiment of the present invention obtain the comprehensive access heat information of each spatial area according to the spatial access heat information and keyword access heat information of the spatial text data, thereby sorting the data blocks corresponding to the spatial area, and storing the data blocks with high access heat in the cache according to the sorting result. Since the spatial access heat information and the keyword access heat information are considered at the same time when selecting the data block, the probability of the data block being hit in the cache is increased, thereby improving the efficiency of data access. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A schematic diagram of using a quadtree to index spatial text data in one embodiment;

[0041] Figure 2 A flowchart of a method for caching spatial text data provided by an embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of a cache queue in one embodiment;

[0043] Figure 4 A schematic diagram of a caching device for spatial text data provided by an embodiment of the present invention;

[0044] Figure 5 It is a schematic diagram of the physical structure of an electronic device involved in an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] The caching methods for spatial text data in the prior art mainly include:

[0047] (1) Caching method based on spatial location

[0048] This type of cache method only considers the spatial location information of spatial text data. When using this method to build a cache, only the access heat of the spatial location is considered, that is, the data space is first divided into different sub-regions through spatial data partitioning methods such as spatial grids or quadtrees; spatial text data belongs to different sub-regions, and these sub-regions can correspond to different storage buckets; by comparing the access heat of data in different sub-regions (that is, the number of data accesses per unit time), the hot spots are identified and the data in the hot spots are placed in the cache, thereby reducing the number of times the external storage data is read and improving the data access efficiency. This cache method can better deal with the situation where query requests are concentrated in a certain spatial area.

[0049] (2) Text-based caching method

[0050] This type of caching method caches according to the access popularity of the text. Users usually search for keywords to obtain the information they want, and most text-based caches are also cached according to the popularity of keywords. This method stores spatial text data in the form of an inverted spatial index, that is, each keyword corresponds to a set of spatial text data, and this set is a set of all spatial text data containing the keyword. After that, hot keywords can be identified based on the access popularity of the keywords (that is, the directional frequency of the keywords per unit time), and the spatial text data containing the hot words can be put into memory to improve data access efficiency. This caching method can better cope with the scenario of certain hot words in the query set.

[0051] (3) Integrating spatial location and text caching methods

[0052] This type of caching method attempts to combine the aforementioned spatial location-based caching method with the text-based caching method, while considering both spatial access popularity and keyword access popularity. This method stores spatial text data in a relational database by row, and combines spatial access popularity and keyword access popularity through the following formula:

[0053] hot_val=α*δ(spatial_hot_val)+(1-α)*θ(keyword_hot_val)

[0054] Among them, spatial_hot_val represents spatial access heat, and keyword_hot_val represents keyword access heat. The spatial heat and keyword heat are projected into a space through the two functions δ and θ respectively, and then the influence of spatial access heat and keyword access heat is adjusted by setting the proportional weight α. The access heat of the fused spatial text data is calculated through the above formula, and the hot data is put into the cache to improve data access efficiency.

[0055] The above spatial text data caching method still has some problems in practical application, and its defects mainly include the following two aspects:

[0056] First, whether it is a cache method based on spatial access heat or keyword access heat, it can only maintain high cache efficiency in certain scenarios. For the cache method based on spatial heat, once the query is not concentrated on a certain spatial area, but on certain keywords, and these keywords are widely included in the spatial text data of different regions, it will be impossible to determine the hot data based on the spatial access heat, and the cache will lose its effect. For the cache method based on keyword heat, if certain hot words are widely included, a large number of non-hot areas in the same area may be loaded into the memory, that is, only a part of the spatial text data in a sub-area may contain hot words, but due to the characteristics of spatial storage, the data of the entire sub-area will be loaded into the memory, squeezing the cache space and reducing the cache hit rate.

[0057] Secondly, the current caching method that integrates space heat and keyword heat cannot well reflect the relationship between space heat and keyword heat. This is mainly because the weight parameter has a greater impact on its results, and it is still difficult to find a reasonable weight parameter to balance space heat and keyword heat.

[0058] To this end, an embodiment of the present invention provides a spatial text data caching method capable of improving spatial text data access efficiency.

[0059] Before describing the spatial text data caching method provided by the embodiment of the present invention, some basic concepts involved in spatial text data and the storage structure of spatial text data are described first.

[0060] Spatial text data includes spatial location information and text information. When describing spatial text data, the data space is usually divided into different areas through spatial data partitioning methods such as spatial grid or quadtree, and then the spatial text data is attributed to different spatial areas according to the spatial location information of the spatial text data.

[0061] Taking the quadtree indexing method as an example, Figure 1 FIG. 1 is a schematic diagram of using a quadtree to index spatial text data in an embodiment. Figure 1 As shown in Figure 1, according to the distribution characteristics of spatial text data, the data space is divided into 10 regions using a quadtree, so that the spatial text data in each region contains a set of keywords. The 10 regions are numbered 0, 4, 5, 6, 7, 8, 9, 10, 11, and 12 (in Figure 1 The reason why there are no numbers 1, 2, and 3 is that according to the Z-order sorting rule, if sub-area 0 is divided into 4 blocks, the corresponding sub-areas are numbered 0, 1, 2, 3).

[0062] After the data space is divided according to the quadtree index method, the spatial text data can be represented by leaf nodes or intermediate nodes. A leaf node contains keywords in a region, and an intermediate node contains keywords of all leaf nodes of the node.

[0063] Before being stored in the cache, the spatial text data is stored in a permanent storage device, such as a hard disk, an optical disk, etc. When the spatial text data needs to be read from the permanent storage device and stored in the cache, the data reading speed can affect the efficiency of the cache. The speed of reading the spatial text data from the permanent storage device is related to the storage structure of the spatial text data. Therefore, in the embodiment of the present invention, a special design is made for the storage structure of the spatial text data.

[0064] Spatial text data consists of two parts: one is the spatial position coordinates, and the other is text information (such as a collection of keywords). When storing spatial text data, there are three corresponding storage files, namely spatial index files, keyword index files, and data files. When reading data, you need to first read the index file for query and filtering to obtain the specific data storage location, and then read the detailed spatial text data from the data file.

[0065] Table 1

[0066]

[0067] Table 1 shows the data structure of the spatial index file. As shown in Table 1, the spatial index file stores the intermediate nodes together in index order first, and then stores the leaf nodes together in index order, so that the spatial data file can be accessed in a sequential read manner, and the intermediate nodes that do not intersect with the query area can be skipped according to the property of the quadtree equally dividing the spatial area, which improves the query efficiency.

[0068] Table 2

[0069]

[0070] Table 2 is the data structure of the keyword index file. The keyword index file adopts the structure of a spatial inverted file, that is, each keyword corresponds to a spatial index. As shown in Table 2, unlike a general spatial inverted file, the keyword index file in the embodiment of the present invention does not store the entire spatial index, but only stores leaf nodes. The specific structure is: the keyword information is first stored together, and then the leaf node information is stored together; wherein, each keyword information contains, in addition to the keyword, an offset and the number of leaf node information, which are used to indicate the starting position of the spatial index information corresponding to the keyword in the file. The reason for doing this is that according to the characteristics of the quadtree, the parent node of the node can be easily inferred, and only storing leaf nodes can reduce the size of the file and speed up the reading efficiency of the file.

[0071] Table 3

[0072]

[0073] Table 3 is the storage structure of the data file. As shown in Table 3, the data file is stored in a quad-tree leaf node division mode, and the data file is divided into different data blocks (for example, the data corresponding to node 1 in Table 3), each data block corresponds to a different quad-tree leaf node, and the data block only stores the data falling into the leaf node, and these data blocks can be divided by file offset. At the same time, these data blocks are also the basic units of cache management data in the spatial text data caching method provided by the embodiment of the present invention.

[0074] Spatial text data stores spatial features in the form of spatial index files and keyword features in the form of keyword index files. Since both types of files must be accessed to read any spatial text data, it is helpful to monitor the spatial popularity and keyword popularity of spatial text data being accessed. Data files are divided into spaces in the form of quadtree indexes, which is helpful to manage cache data according to spatial regions and read data in blocks, which is more efficient.

[0075] The above storage structure of spatial file data is simple in structure and can be applied to both stand-alone environment and Hadoop distributed environment. When used in Hadoop distributed environment, only three stand-alone files need to be changed into HDFS files without much modification, and the scalability is strong.

[0076] Figure 2 A flowchart of a method for caching spatial text data provided by an embodiment of the present invention, such as Figure 1 As shown, the caching method of spatial text data provided by the embodiment of the present invention includes:

[0077] Step 201: Determine spatial access heat information and keyword access heat information according to the number of times the stored spatial text data is accessed within a first cache update cycle.

[0078] In the embodiment of the present invention, the cache update cycle is a time interval set according to the system operation situation. After a cache update cycle, it is necessary to recalculate the heat of the spatial text data and update the data stored in the cache. The size of the cache update cycle can be set according to actual conditions. For example, if the cache update cycle is 5 minutes, it means that when the system is running, the access heat of the spatial text data must be recalculated and the cache must be updated every 5 minutes.

[0079] In the embodiment of the present invention, the first cache update period is any cache update period, which has a temporal sequence with the second cache update period described below.

[0080] In the embodiment of the present invention, the stored spatial text data includes spatial text data pre-stored in a permanent memory. The storage structure of these spatial text data when stored has been described in detail in the previous description, so it is not repeated here. The spatial text data also includes spatial text data pre-stored in a cache queue.

[0081] The spatial access heat information is used to describe the number of times the spatial area is accessed within the first cache update cycle. As mentioned in the previous description of the storage structure of spatial text data, the keywords in a spatial area are stored in a dedicated data block. Therefore, the spatial access heat information also refers to the number of times the data block corresponding to the spatial area is accessed within the first cache update cycle.

[0082] The keyword access popularity is used to describe the number of times a keyword is accessed within the first cache update cycle. A keyword may exist in multiple spatial regions, and the number of times a keyword is accessed within the first cache update cycle described here refers to the total number of times the same keyword in all spatial regions is accessed within the first cache update cycle.

[0083] The space access heat information and the keyword access heat information can be obtained by monitoring the number of times the space index file and the keyword index file are accessed in the first cache update cycle.

[0084] Step 202: Determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information.

[0085] Whether it is spatial access heat information or keyword access heat information, there are certain limitations in describing the heat of data blocks, which is not conducive to improving the read and write efficiency of the cache. Therefore, in an embodiment of the present invention, the spatial access heat information and the keyword access heat information are combined to determine the comprehensive access heat information of each spatial area in the first cache update cycle.

[0086] Specifically, determining the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information includes:

[0087] Step 2021: Calculate the information entropy of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information;

[0088] Step 2022: Determine the comprehensive access heat information of each spatial area in the first cache update cycle based on the information entropy.

[0089] Information entropy is a means of characterizing the amount of information. It is widely used in machine learning scenarios. For example, in decision tree algorithms, information entropy is used to calculate information gain to find attributes suitable for dividing data sets.

[0090] The information entropy in the prior art only reflects the keyword access heat information, and does not integrate the spatial access heat information with the keyword access heat information. In the embodiment of the present invention, the calculation method of the information entropy is improved, and the spatial access heat information and the keyword access heat information are integrated when calculating the information entropy. Specifically, it includes:

[0091] Step S1, according to the keyword access popularity information, the keyword is divided into hot access words and non-hot access words;

[0092] Step S2, according to the keyword access heat information and the space access heat information, calculating the number of times the hot access words in the first space area are accessed in the first cache update cycle and the number of times the non-hot access words are accessed in the first cache update cycle; wherein the first space area is any space area;

[0093] Step S3, calculate the information entropy of the first spatial area in the first cache update cycle based on the spatial access heat information, the number of accesses of the hot access words in the first spatial area in the first cache update cycle, and the number of accesses of the non-hot access words in the first cache update cycle.

[0094] As the name implies, a hot access word refers to a keyword that is accessed more frequently in the first cache update cycle, and a non-hot access word refers to a keyword that is accessed less frequently in the first cache update cycle.

[0095] When distinguishing a keyword as a hot access word and a non-hot access word, the number of times the keyword is accessed within the first cache update cycle can be obtained based on the keyword access heat information, and then compared with the preset access heat threshold. If the number of times the keyword is accessed within the first cache update cycle is greater than or equal to the access heat threshold, then the keyword is a hot access word. If the number of times the keyword is accessed within the first cache update cycle is less than the access heat threshold, then the keyword is a non-hot access word.

[0096] The access heat threshold can be set according to actual needs. A common setting method is: calculating the average number of visits of all keywords in the spatial text data, and using the average number of visits as the access heat threshold.

[0097] After obtaining the information of whether the keyword is a hot access word, this information together with the spatial access heat information can be used as basic information for calculating information entropy. Table 4 is a table containing the spatial access heat information and the information of whether the keyword is a hot access word.

[0098] Table 4

[0099] Region 0 Region 4 Area 5 Area 6 Area 7 Is it a hot word? Keyword 1 Keyword 1 Keyword 1 Keyword 1 yes Keyword 2 Keyword 2 no Keyword 3 Keyword 3 Keyword 3 Keyword 3 yes Keyword 4 Keyword 4 Keyword 4 yes Keyword 5 Keyword 5 Keyword 5 no

[0100] For any spatial area, the keywords in the spatial area have been divided into hot words and non-hot words according to the previous description. Therefore, the number of times the hot access words in the spatial area are accessed during the first cache update cycle and the number of times the non-hot access words in the spatial area are accessed during the first cache update cycle can be further calculated.

[0101] For example, there are 10 keywords in a spatial area, 4 of which are hot access words and 6 are non-hot access words. Add the number of times the 4 hot access words are accessed in the first cache update cycle to get the number of times the hot access words are accessed in the first cache update cycle; add the number of times the 6 non-hot access words are accessed in the first cache update cycle to get the number of times the non-hot access words are accessed in the first cache update cycle.

[0102] According to the spatial access heat information, and the previously calculated access times of the hot access words in a spatial area in the first cache update cycle and the access times of the non-hot access words in the first cache update cycle, the information entropy of the spatial area in the first cache update cycle is calculated. The calculation formula of information entropy is:

[0103]

[0104] Among them, β is the inverse of the spatial access heat. For example, if the spatial access heat of area 0 is 100, the value of β is 1 / 100; set D represents the set of keywords contained in the spatial area; p k It represents the ratio of the number of visits of the k-th keyword to the total number of visits of the keywords in the spatial area where it is located, wherein the number of visits of the k-th keyword refers to the number of visits of the k-th keyword within the first cache update cycle, and the total number of visits of keywords in the spatial area refers to the total number of visits of all keywords in the regional space where the k-th keyword is located within the first cache update cycle; y represents the number of sample classifications. In the embodiment of the present invention, the value of y is 2, which means that the keywords are divided into two categories: hot visited words and non-hot visited words, and || represents the absolute value.

[0105] In the above information entropy calculation formula, β reflects the access heat of the space, p kIt reflects the keyword access heat, so the information entropy SKnt(D) combines the spatial access heat and the keyword access heat at the same time.

[0106] The calculation formula of information entropy in the prior art is:

[0107]

[0108] By comparing the information entropy calculation formula in the prior art with the information entropy calculation formula provided by the embodiment of the present invention, it can be found that the information entropy in the prior art can only reflect the keyword access heat, while the information entropy used in the embodiment of the present invention integrates the spatial access heat. This is done on the one hand because the spatial access heat is actually the sum of the keyword access heat in the spatial area, and the use of spatial access heat can well reflect the difference in access magnitude between different data blocks; on the other hand, multiplying the inverse of the spatial access heat by the information entropy in the prior art will make the information entropy calculated for the data block with a larger access heat in space smaller, and the access heat value obtained will be more accurate.

[0109] After calculating the information entropy of each spatial region, since the information entropy of different spatial regions may have large differences in numerical values, which is not conducive to the subsequent calculation of the life cycle of data, the sigmoid normalization function is introduced in the embodiment of the present invention to map the information entropy to a smaller data space, reducing the impact of huge data differences. The result of information entropy mapping is the comprehensive access heat information of the spatial region.

[0110] The calculation formula for comprehensive access heat information is:

[0111] BHot=1 / (1+e -1 / (1 / SKnt(D)) ).

[0112] In the above formula, by negating the information entropy SKnt(D), the calculated comprehensive access heat information can be arranged in positive order, that is, the larger the data, the higher the access heat. This is conducive to the subsequent sorting of each spatial area according to the comprehensive access heat information.

[0113] Step 203: According to the comprehensive access popularity information of each spatial area in the first cache update cycle, select a data block corresponding to the spatial area in the second cache update cycle and store it in the cache queue.

[0114] In the embodiment of the present invention, the second cache update period is a cache update period subsequent to the first cache update period.

[0115] Since there is a corresponding relationship between the spatial region and the data block when storing spatial text data, that is, the keywords belonging to the same spatial region are stored in the same data block. Therefore, the comprehensive access heat information of the spatial region in the first cache update cycle is equal to the comprehensive access heat information of the data block corresponding to the spatial region in the first cache update cycle.

[0116] According to the basic principle of cache, data blocks with high access popularity will be stored in the cache. Therefore, by sorting the comprehensive access popularity information of the data blocks in the first cache update cycle, the corresponding data blocks can be selected and put into the cache.

[0117] The caching method for spatial text data provided by the embodiment of the present invention obtains the comprehensive access heat information of each spatial area according to the spatial access heat information and the keyword access heat information of the spatial text data, thereby sorting the data blocks corresponding to the spatial area, and storing the data blocks with high access heat in the cache according to the sorting result. Since the spatial access heat information and the keyword access heat information are considered at the same time when selecting the data block, the probability of the data block being hit in the cache is increased, thereby improving the efficiency of data access.

[0118] Based on any of the above embodiments, in an embodiment of the present invention, step 203 includes:

[0119] sorting the data blocks corresponding to the respective spatial regions according to the comprehensive access heat information of the respective spatial regions in the first cache update cycle;

[0120] The first N data blocks are stored in a first type cache queue, and the M data blocks that are after the first N data blocks are stored in a second type cache queue.

[0121] In the embodiment of the present invention, the first type of cache queue refers to a cache queue located in the memory, and the second type of cache queue refers to a cache queue located in an external memory (such as a hard disk).

[0122] Since the read speed of the memory is faster than that of the external memory, the first cache queue is used to store data blocks with higher access popularity, and the second cache queue is used to store data blocks with relatively low access popularity. The level of the first cache queue is higher than that of the second cache queue, and the level is used to reflect the priority of the cache queue when storing data blocks.

[0123] There can be one or more first - type cache queues. When there are multiple first - type cache queues, there are differences in levels among different cache queues. For example, there can be two first - type cache queues. One cache queue is used to store the n data blocks with the highest access heat, and the other cache queue is used to store the m data blocks with medium access heat. The level of the former cache queue is higher than that of the latter cache queue.

[0124] There can also be one or more second - type cache queues. When there are multiple second - type cache queues, there are differences in levels among different cache queues. For example, there are two second - type cache queues. One cache queue is used to store the x data blocks with lower access heat, and the other cache queue is used to store the y data blocks with even lower access heat. The level of the former cache queue is higher than that of the latter cache queue.

[0125] Figure 3 It is a schematic diagram of the cache queue in an embodiment. As Figure 3 shown, in this embodiment, there are two first - type cache queues, which are respectively marked as the high - heat queue and the medium - heat queue; there is one second - type cache queue, marked as the low - heat queue. The levels of these three cache queues are in descending order as the high - heat queue, the medium - heat queue, and the low - heat queue.

[0126] It should be noted that the size of N in the N data blocks depends on the amount of free storage space in the first - type cache queue. For example, if the first - type cache queue stores no data blocks during initial operation, the size of N is the total storage space of the first - type cache queue. Similarly, the size of M in the M data blocks depends on the amount of free storage space in the second - type cache queue. For example, if the second - type cache queue stores no data blocks during initial operation, the size of M is the total storage space of the second - type cache queue. Both N and M are positive integers.

[0127] In addition, there is also such a situation: some data blocks to be stored in the cache queue have been stored in the cache queue before, and no changes are made to these data blocks. The data blocks with lower access heat can be supplemented and stored in the free storage space of the cache queue. For example, according to the previous sorting result, the n data blocks with the highest access heat can be selected and stored in Figure 3 the high - heat queue. However, after comparison, it is found that w (0 < w < n) of these n data blocks have been stored in the high - heat queue before. Then, w data blocks (assuming these data blocks have not been stored in the high - heat queue before) can be selected after the n selected data blocks in the order of access heat and stored in the high - heat queue.

[0128] In addition, if some data blocks to be stored in a higher-level cache queue were previously stored in a lower-level cache queue, then these data blocks will be saved in the higher-level cache queue if there is free storage space in the higher-level cache queue, and the storage space in the lower-level cache queue will be occupied by other data blocks.

[0129] The spatial text data caching method provided by the embodiment of the present invention classifies the cache queues according to the type of memory in which the cache queues are located, stores data blocks with high access popularity in the cache queues with fast reading speed, and stores data blocks with low access popularity in the cache queues with low reading speed. This helps to improve the overall access efficiency of data.

[0130] Based on any of the above embodiments, in an embodiment of the present invention, after step 203, the method further includes:

[0131] The life cycle of the data block in the cache queue is calculated and set according to the comprehensive access heat information and the level of the cache queue where the data block is located.

[0132] Since the storage space of the cache queue is limited, the data blocks in the cache queue need to be dynamically adjusted to ensure that the cache has a high hit rate. In the embodiment of the present invention, in order to effectively utilize the cache space, it is necessary to set the time that the data blocks with high access popularity exist in the cache to be longer, which can significantly improve the hit rate of the cache.

[0133] To this end, the life cycle of the data block in the cache queue can be calculated and set according to the final access heat value of the data block and the level of the cache queue where the data block is located. The calculation formula for the life cycle is:

[0134] EXtime=(BHot×(f num / C num ))×2 n ×ConVal;

[0135] Among them, EXtime represents the life cycle; BHot represents the comprehensive access heat information of the spatial area (or data block); f num Indicates the amount of free storage space in the cache queue; C num Indicates the total amount of storage space in the cache queue; n is the level value of the cache queue; ConVal is a constant indicating the duration, which can be set to 1000ms.

[0136] From the above formula, we can see that the larger the BHot is, the longer the life cycle will be, which is in line with the purpose of keeping the data blocks with high access popularity in the cache queue for a longer time. num / C numIt plays a regulatory role. The more free storage space there is in the cache queue, the longer the data block can be stored. Conversely, the less free storage space there is, the shorter the data block storage time is. This is to maintain the real-time nature of the cache data. That is, when the data in the cache queue is about to be full, a smaller life cycle is set to make the data expire earlier, so that the storage space can be freed up for new cache data. n This is to differentiate the expiration time of cache queues at different levels. Figure 3 The level value n of the high heat queue is set to 2, and the level value n of the medium heat queue is set to 1. n The invalidation time of the high-heat queue and the medium-heat queue can be significantly different, so that the data blocks with relatively low access heat in the medium-heat queue can be invalidated as soon as possible, making it easier to load new cache data.

[0137] It should be noted that, since the second type of cache queue is a cache queue located in an external memory, its data reading speed is not substantially improved, so in the embodiment of the present invention, the life cycle is mainly calculated for the data blocks stored in the first type of cache queue.

[0138] The caching method for spatial text data provided by the embodiment of the present invention sets life cycles of different lengths for data blocks in cache queues of different levels, so that data blocks with high access popularity are retained in the cache queue for a longer time, which helps to improve the cache hit rate.

[0139] Based on any of the above embodiments, in an embodiment of the present invention, the method further includes:

[0140] Check the life cycle of each data block in the cache queue and remove the invalid data blocks;

[0141] The data block is read from the first cache queue and stored in the free storage space of the second cache queue; wherein the second cache queue is the cache queue where the cleared data block is located; and the first cache queue is a cache queue one level lower than the second cache queue.

[0142] In the previous embodiment of the present invention, the life cycle has been calculated and set for the data blocks in the cache queue. In this embodiment of the present invention, at the beginning of a cache update cycle, the life cycle of each data block in the cache queue is checked. If the life cycle of a data block has been reached, it means that the data block is in an invalid state, and the data block that has been in an invalid state is cleared.

[0143] After the invalid data block is cleared, the storage space used to store the data block becomes free storage space. In order to improve the utilization of cache space, data read from the lower-level cache queue is stored in the free storage space of the higher-level cache queue. For example, suppose Figure 3 The high-heat queue in the cache has a data block in an invalid state, and the data block is cleared. At this time, data blocks can be selected from the medium-heat queue (one level lower than the high-heat queue) to fill the free storage space of the high-heat queue. Similarly, if a data block in the medium-heat queue is in an invalid state and the data block is cleared; at this time, data blocks can be selected from the low-heat queue (one level lower than the medium-heat queue) to fill the free storage space of the medium-heat queue. When a data block in a cache queue is filled into a higher-level cache queue, the storage space before the data block becomes free storage space, and data blocks can be selected from a lower-level cache queue to fill the free storage space.

[0144] The operation of clearing the invalid data blocks and selecting data blocks from the low-level cache queue to supplement the storage space previously occupied by the invalid data blocks described in the embodiment of the present invention can be performed multiple times within a cache update cycle. For example, the above operation is performed at the beginning of the cache update cycle, or it can be performed in the process of monitoring the cache status after the cache is updated. In the embodiment of the present invention, the execution time of the above operation is not limited.

[0145] The caching method for spatial text data provided by the embodiment of the present invention can make hot data stay in the memory longer before the system recalculates the access heat of all data by clearing the invalid data blocks and selecting data blocks from the low-level cache queue to supplement the storage space previously occupied by the invalid data blocks, and reduce the waste of cache space, so that most of the storage space of the cache is stored with hot data, thereby improving the cache hit rate. In addition, if the filled data block happens to be hot data in the subsequent access heat calculation, some data reading overhead can be saved, thereby improving the update efficiency.

[0146] Based on any of the above embodiments, Figure 4 A schematic diagram of a caching device for spatial text data provided by an embodiment of the present invention, such as Figure 4 As shown, a caching device for spatial text data provided by an embodiment of the present invention includes:

[0147] The spatial access heat information and keyword access heat information determination module 401 is used to determine the spatial access heat information and keyword access heat information according to the number of times the stored spatial text data is accessed in the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial region is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial region is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data;

[0148] A comprehensive access heat information determination module 402, configured to determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information;

[0149] The cache module 403 is used to select data blocks corresponding to the spatial areas in the second cache update cycle and store them in the cache queue based on the comprehensive access popularity information of the spatial areas in the first cache update cycle; wherein the second cache update cycle is the cache update cycle after the first cache update cycle.

[0150] The caching device for spatial text data provided by the embodiment of the present invention obtains the comprehensive access heat information of each spatial area according to the spatial access heat information and the keyword access heat information of the spatial text data, thereby sorting the data blocks corresponding to the spatial area, and storing the data blocks with high access heat in the cache according to the sorting result. Since the spatial access heat information and the keyword access heat information are considered at the same time when selecting the data block, the probability of the data block being hit in the cache is increased, thereby improving the efficiency of data access.

[0151] Figure 5 FIG. 1 is a schematic diagram of the physical structure of an electronic device involved in an embodiment of the present invention, such as Figure 5 As shown, the electronic device may include: a processor (processor) 510, a communication interface (Communications Interface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logic instructions in the memory 530 to execute the following method: determine the spatial access heat information and the keyword access heat information according to the number of times the stored spatial text data is accessed in the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial area is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial area is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data; according to the spatial access heat information and the keyword access heat information, determine the comprehensive access heat information of each spatial area in the first cache update cycle; according to the comprehensive access heat information of each spatial area in the first cache update cycle, select the data block corresponding to the spatial area in the second cache update cycle and store it in the cache queue; wherein the second cache update cycle is the cache update cycle after the first cache update cycle.

[0152] It should be noted that the electronic device in this embodiment can be a server, a PC, or other devices in specific implementation, as long as its structure includes the following: Figure 5 The processor 510, communication interface 520, memory 530 and communication bus 540 shown in the figure, wherein the processor 510, communication interface 520, memory 530 communicate with each other through the communication bus 540, and the processor 510 can call the logic instructions in the memory 530 to execute the above method. This embodiment does not limit the specific implementation form of the electronic device.

[0153] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the 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 a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0154] Furthermore, an embodiment of the present invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: determining spatial access heat information and keyword access heat information according to the number of times the stored spatial text data is accessed in the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial area is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial area is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data; according to the spatial access heat information and the keyword access heat information, determining the comprehensive access heat information of each spatial area in the first cache update cycle; according to the comprehensive access heat information of each spatial area in the first cache update cycle, selecting the data block corresponding to the spatial area in the second cache update cycle and storing it in the cache queue; wherein the second cache update cycle is the cache update cycle after the first cache update cycle.

[0155] On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when executed by a processor to execute the methods provided by the above embodiments, for example, including: determining spatial access heat information and keyword access heat information based on the number of times the stored spatial text data is accessed within the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial area is accessed within the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed within the first cache update cycle; the spatial area is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data; based on the spatial access heat information and the keyword access heat information, determining the comprehensive access heat information of each spatial area within the first cache update cycle; based on the comprehensive access heat information of each spatial area within the first cache update cycle, selecting the data block corresponding to the spatial area in the second cache update cycle and storing it in the cache queue; wherein the second cache update cycle is the cache update cycle after the first cache update cycle.

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

[0157] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

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

Claims

1. A method for caching spatial text data, characterized in that: include: According to the number of times the stored spatial text data is accessed in the first cache update cycle, the spatial access heat information and the keyword access heat information are determined; wherein the spatial access heat information is used to describe the number of times the spatial area is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial area is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data; Determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information; According to the comprehensive access heat information of each spatial area in the first cache update cycle, select the data block corresponding to the spatial area in the second cache update cycle and store it in the cache queue; wherein the second cache update cycle is a cache update cycle after the first cache update cycle; The step of determining the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information specifically includes: Calculating the information entropy of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information; Determine, based on the information entropy, comprehensive access heat information of each spatial region in a first cache update cycle; The calculating the information entropy of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information includes: According to the keyword access popularity information, the keyword is divided into hot access words and non-hot access words; Calculate the number of times the hotspot access words in the first spatial region are accessed in the first cache update cycle and the number of times the non-hotspot access words are accessed in the first cache update cycle according to the keyword access heat information and the space access heat information; wherein the first spatial region is any spatial region; Calculate the information entropy of the first spatial region in the first cache update period according to the spatial access heat information, the number of accesses of the hot access words in the first spatial region in the first cache update period, and the number of accesses of the non-hot access words in the first cache update period; The selecting, according to the comprehensive access heat information of each spatial area in the first cache update cycle, data blocks corresponding to the spatial area are stored in the cache queue in the second cache update cycle, including: sorting the data blocks corresponding to the respective spatial regions according to the comprehensive access heat information of the respective spatial regions in the first cache update cycle; The first N data blocks are stored in a first type of cache queue, and the M data blocks after the first N data blocks are stored in a second type of cache queue; The first type of cache queue is a cache queue set in the memory, and the second type of cache queue is a cache queue set in the external memory; N and M are both positive integers.

2. The method for caching spatial text data according to claim 1, characterized in that: After the step of selecting data blocks corresponding to the spatial regions and storing them in the cache queue in the second cache update cycle according to the comprehensive access heat information of the spatial regions in the first cache update cycle, the method further includes: According to the comprehensive access heat information and the level of the cache queue where the data block is located, the life cycle of the data block in the cache queue is calculated and set; wherein, The level of the cache queue is used to describe the priority order when storing data blocks.

3. The method for caching spatial text data according to claim 2, characterized in that: The method also includes: Check the life cycle of each data block in the cache queue and remove the invalid data blocks; The data block is read from the first cache queue and stored in the free storage space of the second cache queue; wherein the second cache queue is the cache queue where the cleared data block is located; and the first cache queue is a cache queue one level lower than the second cache queue.

4. The method for caching spatial text data according to claim 1, characterized in that: The stored spatial text data is stored in the form of spatial index files, keyword index files and data files; wherein, The spatial index file stores the intermediate nodes corresponding to the spatial text data together according to the index order, and stores the leaf nodes corresponding to the spatial text data together according to the index order; The keyword index file stores the keyword information together and the leaf node information together; wherein the keyword information includes the keyword, the offset and the number of leaf node information; The data file includes multiple data blocks, and one data block corresponds to the data in one leaf node.

5. A caching device for spatial text data, characterized in that: include: The module for determining the spatial access heat information and the keyword access heat information is used to determine the spatial access heat information and the keyword access heat information according to the number of times the stored spatial text data is accessed in the first cache update cycle; wherein the spatial access heat information is used to describe the number of times the spatial region is accessed in the first cache update cycle, and the keyword access heat is used to describe the number of times the keyword is accessed in the first cache update cycle; the spatial region is the result of dividing the data space based on the distribution of the stored spatial text data; the keyword is the word segmentation result of the text information of the stored spatial text data; The comprehensive access heat information determination module is used to determine the comprehensive access heat information of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information, including: calculating the information entropy of each spatial area in the first cache update cycle according to the spatial access heat information and the keyword access heat information; determining the comprehensive access heat information of each spatial area in the first cache update cycle according to the information entropy; Among them, the information entropy of each spatial area in the first cache update cycle is calculated according to the spatial access heat information and the keyword access heat information, including: according to the keyword access heat information, the keyword is divided into hot access words and non-hot access words; according to the keyword access heat information and the spatial access heat information, the number of times the hot access words in the first spatial area are accessed in the first cache update cycle and the number of times the non-hot access words are accessed in the first cache update cycle; the first spatial area is any spatial area; according to the spatial access heat information, the number of times the hot access words in the first spatial area are accessed in the first cache update cycle, and the number of times the non-hot access words are accessed in the first cache update cycle, the information entropy of the first spatial area in the first cache update cycle is calculated; A cache module, configured to select data blocks corresponding to the spatial regions in a second cache update cycle and store them in a cache queue according to the comprehensive access heat information of the spatial regions in the first cache update cycle; wherein the second cache update cycle is a cache update cycle subsequent to the first cache update cycle; The selecting, according to the comprehensive access heat information of each spatial area in the first cache update cycle, data blocks corresponding to the spatial area and storing them in the cache queue in the second cache update cycle includes: sorting the data blocks corresponding to the respective spatial regions according to the comprehensive access heat information of the respective spatial regions in the first cache update cycle; The first N data blocks are stored in a first type of cache queue, and the M data blocks after the first N data blocks are stored in a second type of cache queue; The first type of cache queue is a cache queue set in the memory, and the second type of cache queue is a cache queue set in the external memory; N and M are both positive integers.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for caching spatial text data as described in any one of claims 1 to 4 are implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for caching spatial text data as claimed in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Massive data distributed storage system

    CN105608155A

  • Distributed real-time full-text search method and system

    CN105740472A

  • Access heat regarded cyber space information service high performance memory caching method

    CN105915619A

  • Heat management method based on cached data, server, and storage medium

    CN109471875A

  • Cache data processing method and system and readable storage medium

    CN110147331A