WO2019056958A1 - Trending keyword acquisition method, device and server - Google Patents
Trending keyword acquisition method, device and server Download PDFInfo
- Publication number
- WO2019056958A1 WO2019056958A1 PCT/CN2018/104799 CN2018104799W WO2019056958A1 WO 2019056958 A1 WO2019056958 A1 WO 2019056958A1 CN 2018104799 W CN2018104799 W CN 2018104799W WO 2019056958 A1 WO2019056958 A1 WO 2019056958A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- keyword
- accesses
- linked list
- data block
- hotspot
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
Definitions
- the present application relates to the field of the Internet, and in particular, to a hotkey keyword acquisition method, apparatus, and server.
- Distributed systems are one of the mainstream solutions to the current demand for big data storage.
- multiple database servers can be deployed, and each database server is used to store the same data.
- the application server determines the database server by using a hash algorithm, and sends a data request to the database server.
- the database server After receiving the data request, the database server returns the data corresponding to the data request to the application server, so that the application server returns the data to the client.
- the data request for acquiring the same data is located to the same database server, which results in load balancing and the stability of the distributed system is poor.
- the application server performs hash processing on the data identifier, and determines the database server according to the processing result. All data requests for the data identifier A are located to the database server A, and all data requests for the data identifier B are located to the database server B. . If the number of data requests of the data identifier A is much larger than the number of data requests of the data identifier B, the processing pressure of the database server A is large, and the processing pressure of the database server B is small, and load balancing cannot be implemented between the database servers.
- the application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
- the hotspot keyword When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
- the hash table is configured to record a correspondence between a keyword and a data block location;
- the hotspot keyword When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
- the linked list with the lowest priority is searched according to the correspondence between the access number interval and the linked list, and the content in the last data block of the lowest priority linked list is deleted;
- the lowest-level linked list is the linked list corresponding to the minimum number of access times;
- the hotspot keyword When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
- An obtaining module configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword
- a determining module configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;
- the determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the keyword.
- the present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
- An obtaining module configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a corresponding data block position; the hash table is configured to record a correspondence between a keyword and a data block position; Querying the number of accesses in the data block corresponding to the location of the data block, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;
- the determining module is configured to read the number of accesses of the keyword from the linked list when the hotkey keyword needs to be determined, and determine the hotspot keyword according to the number of accesses of the read keyword.
- the present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
- An obtaining module configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword
- a determining module configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;
- the deleting module is configured to: when the content in the data block needs to be deleted, query the linked list with the lowest priority according to the correspondence between the access number interval and the linked list, and delete the content in the last data block of the lowest priority linked list.
- the lowest priority linked list is a linked list corresponding to the smallest number of access times;
- the determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the read keyword.
- the application provides a database server, the database server comprising:
- a processor configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times; Different access times intervals correspond to different linked lists; update the position of the number of accesses of the keyword in the linked list; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and according to the keyword The number of visits determines the hotspot keyword.
- the application provides a database server, the database server comprising:
- a processor configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a data block location corresponding to the keyword; wherein the hash table is used to record a keyword and Corresponding relationship of the location of the data block; querying the number of accesses from the data block corresponding to the location of the data block, and obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to In the data block; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the application provides a database server, the database server comprising:
- a processor configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times;
- the different access times interval corresponds to different linked lists; the number of access times of the keywords is updated in the linked list; when the content in the data block needs to be deleted, the priority is queried according to the correspondence between the access times interval and the linked list a lowest linked list, and deleting content in a last data block of the lowest priority linked list; wherein the lowest priority linked list is a linked list corresponding to a minimum number of access times; when a hot keyword needs to be determined, The number of visits to the keyword is read from the linked list, and the hotspot keyword is determined based on the number of visits to the keyword.
- the database server may collect the hotspot keyword and notify the application server of the hotspot keyword, so that the application server performs load balancing processing on the data request of the hotkey keyword, thereby implementing distributed Load balancing of the system improves the stability and efficiency of the system and improves the overall processing capability of data requests for hot keywords. Moreover, the most valuable data is retained by dividing a plurality of linked lists and deleting the contents of the data blocks of the lowest priority linked list.
- FIG. 1 is a schematic diagram of an application scenario in an implementation manner of the present application
- FIGS. 2A and 2B are flowcharts of a method for acquiring a hotspot keyword in an embodiment of the present application
- 3 is an example of a data structure of a hash table and a linked list in an embodiment of the present application
- FIG. 4 is a flowchart of a method for acquiring a hotspot keyword in another embodiment of the present application.
- FIG. 5 is a flowchart of a method for acquiring a hotspot keyword in another embodiment of the present application.
- FIG. 6 is a structural diagram of a hotspot keyword acquiring apparatus in an embodiment of the present application.
- FIG. 7 is a structural diagram of a hotspot keyword obtaining apparatus in another embodiment of the present application.
- FIG. 8 is a structural diagram of a hotspot keyword acquiring apparatus in another embodiment of the present application.
- first, second, third, etc. may be used to describe various information in the embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other.
- first information may also be referred to as the second information without departing from the scope of the present application.
- second information may also be referred to as the first information.
- word “if” may be interpreted to mean “at time” or "when” or "in response to determination.”
- FIG. 1 is a schematic diagram of an application scenario of an embodiment of the present application
- a distributed system may include multiple database servers and multiple application servers.
- Figure 1 shows two database servers and three application servers as examples. In practical applications, the number of database servers and the number of application servers can be more. There is no limit to the number of database servers and the number of application servers.
- the database server can obtain the hotspot keywords and notify the application server of the hotspot keywords, so that the application server performs load balancing processing on the data requests of the hotkey keywords, thereby implementing the database.
- the load balancing between servers avoids the processing pressure of some database servers, while the processing pressure of other database servers is small.
- the database server may count the number of accesses of the keyword, and determine whether the keyword is a hotspot keyword based on the number of accesses of the keyword. For example, when the number of accesses of the keyword is greater than the preset number of thresholds, the keyword is determined to be a hotspot keyword. When the number of accesses of the keyword is not greater than the preset number of times, the keyword is determined to be not a hotspot keyword.
- the key (Key) is a unique identifier of the data stored in the database server.
- the data request may carry a keyword, and after receiving the data request, the database server receives the data request.
- the keyword may include, but is not limited to, a data identifier, a user identifier, a product identifier, and the like.
- the keyword is not limited, and the database server may query the locally stored data based on the keyword.
- the database server can query the data corresponding to the data identifier, and based on the user identifier, the database server can query the data corresponding to the user identifier. Based on the item identification, the database server can query the data corresponding to the item identification. And so on.
- the database server can set the statistics period and count the number of visits to the keyword in each statistical period. For example, the duration of the statistical period is 1 second, then 0-1 seconds is 1 statistical period, 1-2 seconds is 1 statistical period, and so on.
- the database server counts the number of accesses of the keyword, and determines whether the keyword is a hot keyword based on the number of accesses of the keyword.
- the database server re-counts the number of accesses of the keyword, and determines whether the keyword is a hotspot keyword based on the number of accesses of the keyword. And so on.
- the database server may use the data block to store the number of accesses of the keyword, each keyword occupies one data block, such as data block 1 stores the number of accesses of keyword 1, and data block 2 stores the number of accesses of keyword 2, And so on.
- the database server may receive a large number of keyword data requests during the statistical period, such as hundreds of thousands or even millions. When each keyword occupies one data block, it occupies a large number of data blocks, that is, access for storing keywords. The number of times will occupy a large number of data blocks.
- the hotkey keyword acquisition function is only an auxiliary function of the database server.
- the database server does not allocate a large number of data blocks for this function, that is, it cannot use a large number of data blocks to store the number of accesses of keywords, and then obtain hotspot keywords.
- an LRU (Least Recently Used) algorithm is proposed, which uses the LRU algorithm to store the number of accesses of keywords based on a small number of data blocks.
- the database server allocates 100 data blocks for the "hotkey keyword acquisition" function (for example, 100 data blocks are used as an example. In actual applications, more data blocks can be allocated, and no limitation is imposed on this).
- the data request of the keyword 1 is received in the first to the first time, the number of accesses of the keyword 1 is recorded in the data block 1, and the data block 1 is updated to the first data block of the LRU linked list. .
- the data request of the keyword 2 is received at the 102nd time, the number of accesses of the keyword 2 is recorded in the data block 2, and the data block 2 is updated to the first data block of the LRU linked list, and the data block 1 is updated to The second data block of the LRU list.
- the data request of the keyword 100 is received in the 200th time, the number of accesses of the keyword 100 is recorded in the data block 100, and the data block 100 is updated to the first data block of the LRU linked list, and the data is Block 99 is updated to the second data block of the LRU linked list, and so on, and data block 1 is updated to the 100th data block of the LRU linked list (the last data block of the LRU linked list).
- the database server deletes the content of the last data block record from the LRU linked list, that is, deletes the keyword 1 recorded in the data block 1.
- the number of accesses, the number of accesses of the keyword 101 is recorded in the data block 1 is recorded in the data block 1, the data block 1 is updated to the first data block of the LRU linked list, and the data block 100 is updated to the second data block of the LRU linked list, and the data block 99 is Updated to the third data block of the LRU list, and so on.
- the keyword 1 may be a hotspot keyword, and after receiving the data request of the keyword 101, The number of accesses of the keyword 1 recorded in the data block 1 is deleted, and the number of accesses of the hot keyword cannot be retained until the end of the statistical period, and it is impossible to count that the keyword 1 is a hot keyword.
- each access time interval corresponds to a linked list
- different access times intervals correspond to different linked lists.
- the linked list may include, but is not limited to, an LRU linked list.
- LRU linked list For convenience of description, the following takes a linked list as an example for description.
- the linked list 1 corresponds to the access number interval 1, and the access number interval 1 corresponds to (the number of accesses 1 - the number of accesses 100); the linked list 2 corresponds to the access number interval 2, and the access number interval 2 corresponds to (the number of accesses 101) - the number of accesses 200); the linked list 3 corresponds to the access number interval 3, and the access number interval 3 corresponds to (the number of accesses 201 - infinity), that is, the number of accesses 201 is greater than or equal to.
- the above example is described by taking three linked lists and three access times intervals as an example. In practical applications, the number of linked lists and the number of access times can be more, and the number is not limited.
- the numerical value corresponding to the above-mentioned access number interval is only an example of the present application, and no limitation is imposed thereon.
- FIG. 2A is a flowchart of a method for acquiring a hotspot keyword according to an embodiment of the present application
- the method may be applied to a database server, and the method may include:
- step 201 during the statistical period, the keyword is obtained, and the number of accesses of the keyword is obtained.
- the database server can obtain the keyword and obtain the number of accesses of the keyword in each statistical period.
- a statistical period is taken as an example for description.
- the application server (such as the APP server) may determine the database server by using a hash algorithm and send a data request to the database server. After receiving the data request, the database server parses the keyword from the data request.
- the keyword may include, but is not limited to, a data identifier, a user identifier, a product identifier, and the like.
- the keyword is not limited, and the database server may query the locally stored data based on the keyword. For example, based on the data identifier, the database server can query the data corresponding to the data identifier, and based on the user identifier, the database server can query the data corresponding to the user identifier.
- the client may be an APP of a terminal device (such as a PC (Personal Computer), a notebook computer, a mobile terminal, or the like), or may be a browser of the terminal device, and the type of the client is not limited, and all of the clients may be Clients accessing the application server are within the scope of this application.
- a terminal device such as a PC (Personal Computer), a notebook computer, a mobile terminal, or the like
- a browser of the terminal device such as a PC (Personal Computer), a notebook computer, a mobile terminal, or the like
- the type of the client is not limited, and all of the clients may be Clients accessing the application server are within the scope of this application.
- the application server may be a server that provides services for the client, and the application server may obtain data requested by the client from the database server, and send the data to the client.
- the application server may be a data platform, an e-commerce platform, etc., and the type of the application server is not limited.
- the database server may be a server that stores data. After receiving the data request sent by the application server, the database server parses the keyword from the data request, and locally queries the data corresponding to the keyword, and sends the data. Give the application server and then return the data to the client.
- the process of “acquiring the number of accesses of the keyword” may include:
- Step 2011 Obtain a data block location corresponding to the keyword.
- the process of “acquiring the location of the data block corresponding to the keyword” may include, but is not limited to, the following manner: mode 1. Since the data block can record the correspondence between the keyword and the number of accesses, the database server may Each data block is traversed in turn, and if the keyword is recorded in the traversed data block, the data block position of the data block is the data block position corresponding to the keyword. In the second method, the database server may store a hash table, where the hash table is used to record the correspondence between the keyword and the data block location; based on the hash table, the database server may query the hash table by using the keyword, if If the keyword exists in the hash table, the data block position corresponding to the keyword can be obtained.
- the data block position corresponding to the keyword can be queried from the hash table, thereby avoiding the traversal operation of the database server. Reduce the processing pressure of the database server and save time in traversal operations.
- the hash table may include, but is not limited to, a HashMap table, which may include, but is not limited to, an N-level LRU linked list.
- the hash table is used to record the correspondence between the keyword and the location of the data block.
- the database server can parse the keyword from the data request and query the hash table through the keyword. . If the keyword does not exist in the hash table, the database server selects a data block for the keyword, records the number of accesses of the keyword into the selected data block, and records the keyword and the selection in the hash table. The correspondence of the data block positions of the data blocks. If the keyword exists in the hash table, the database server can obtain the data block location corresponding to the keyword from the hash table.
- the N-level linked list refers to N linked lists, and each linked list corresponds to an access number interval, such as the linked list corresponding access times interval 1 (the number of accesses 1 - the number of accesses 100), and the linked list 2 corresponds to the access times interval 2 (accesses The number of times 101 - the number of accesses 200), the linked list 3 corresponds to the access number interval 3 (the number of accesses 201 - infinity), which may indicate that when the number of accesses of the keywords recorded in the data block is located in the access number interval 1, then The data block belongs to the linked list 1; when the number of accesses of the keywords recorded in the data block is located in the access number interval 2, the data block belongs to the linked list 2; when the number of accesses of the keywords recorded in the data block is located in the access When the number of times is 3, the data block belongs to the linked list 3.
- the linked list corresponds to an access number interval, such as the linked list corresponding access times interval 1 (the number of accesses 1 - the
- the data block is used to record the keyword, the number of accesses of the keyword, and for the second mode, the data block is used to record the number of accesses of the keyword.
- the data block can also record the keyword.
- the data block record keyword and the number of accesses of the keyword are taken as an example.
- the example of “acquiring the data block location corresponding to the keyword” may be: after receiving the data request of the keyword 1 , the database server queries the hash table by using the keyword 1 . If the keyword 1 does not exist in the hash table, the database server selects a data block for the keyword 1 (such as an unoccupied data block or a currently released data block; an unoccupied data block means that the data block has not been recorded yet) The number of accesses of the keyword and the keyword; the currently released data block means that the data block has recorded the keyword and the number of accesses of the keyword, but the content recorded in the data block is deleted, and the subsequent process introduces the deletion process).
- a data block for the keyword 1 such as an unoccupied data block or a currently released data block; an unoccupied data block means that the data block has not been recorded yet.
- the number of accesses of the keyword and the keyword; the currently released data block means that the data block has recorded the keyword and the number of accesses of the keyword, but the content recorded in the data block is deleted, and
- the data block 80 is used to record the number of accesses of the keyword 1 and the keyword 1, and the correspondence relationship between the key 1 and the data block position of the data block 80 is recorded in the hash table.
- the database server After the database server receives the data request of the keyword 1 again, the hash table is queried by the keyword 1. Since the keyword 1 already exists in the hash table, the database server can directly obtain the keyword 1 from the hash table. The corresponding data block position, that is, the data block position of the data block 80.
- step 2012 the number of accesses is queried from the data block corresponding to the data block location.
- the database server can query the number of accesses from the data block corresponding to the data block position after obtaining the data block position.
- step 2013 the number of accesses of the keyword is obtained by using the number of accesses queried.
- the process for obtaining the number of accesses of the keyword by using the number of accesses queried may include, but is not limited to, the following method: determining the number of accesses of the keyword is a preset number of accesses (for example, 1); Alternatively, the resource information corresponding to the keyword is obtained, and the weight value of the keyword is determined according to the resource information, and the number of accesses of the keyword is determined to be a weighted value of the number of access times.
- step 2014 the number of accesses of the keyword is updated to the data block corresponding to the data block position.
- the number of accesses queried from the data block is the number of times the keyword is recorded in the data block when the data block was last updated.
- the number of accesses is called a keyword.
- the number of accesses of the currently obtained keyword is the number of times the keyword is recorded in the data block when the data block is updated this time.
- the number of accesses is referred to as the second keyword. The number of visits. Obviously, the next time the data block needs to be updated, the second number of accesses becomes the first number of accesses to the keywords recorded in the data block.
- each time a keyword (such as keyword 1) is obtained, the first access number of the keyword 1 is read from the data block corresponding to the data block position (such as the data block 80), and the first access number is obtained. Add 1 to get the second number of visits. For example, after the keyword 1 is obtained for the 100th time, the first access number 99 of the keyword 1 is read from the data block 80, the first access number 99 is incremented by 1, the second access number 100 is obtained, and the second access is obtained. The number of times 100 is updated into data block 80. After obtaining the keyword for the 101st time, the first access number 100 of the keyword 1 is read from the data block 80, and the first access number 100 is incremented by 1, the second access number 101 is obtained, and the second access number 101 is obtained. Update to data block 80. And so on.
- the first access number of the keyword 1 can be read from a data block corresponding to the data block location (such as the data block 80), and the The first number of visits weights the weight value to obtain the second number of accesses.
- the weight value is 5 as an example.
- the first access number 495 of the keyword 1 can be read from the data block 80, and the first access number 495 is weighted. 5.
- the second access number 500 is obtained, and the second access number 500 is updated to the data block 80.
- the first access number 500 of the keyword 1 can be read from the data block 80, and the first access number 100 is weighted by 5 to obtain the second access number 505, and the second is obtained.
- the number of accesses 505 is updated into data block 80. And so on.
- the resource information corresponding to the keyword 1 can be obtained, and the keyword 1 is determined according to the resource information. Weights.
- the resource information corresponding to the keyword 1 may be acquired, and the weight value of the keyword 1 is determined according to the resource information; then, the weight value is recorded to the data block 80, and the key is obtained again. After word 1, the weight value can be read directly from data block 80.
- the resource information may include, but is not limited to, a data size of the keyword corresponding data, and/or a processing time of the keyword corresponding request.
- the process of determining the weight value of the keyword according to the resource information may include, but is not limited to, the following manner: if the resource information includes the data size of the keyword corresponding data, the relationship between the data size and the preset size may be Determine the weight value of the keyword. If the resource information includes the processing time of the keyword corresponding request, the weight value of the keyword may be determined according to the relationship between the processing time and the preset time.
- the first sub-weight value of the keyword may be determined according to the relationship between the data size and the preset size; according to the processing time and the preset time a relationship, determining a second sub-weight value of the keyword; determining a weight value of the keyword according to the first sub-weight value and the second sub-weight value.
- the process of determining the weight value of the keyword according to the relationship between the data size and the preset size includes: configuring the preset size according to experience, and determining the keyword if the data size of the keyword corresponding data is less than or equal to the preset size.
- the weight value is 1. If the data size of the keyword corresponding data is greater than the preset size, determine the weight value of the keyword is “round the data size by the preset size.” If the data size is 8, and the preset size is 5, the weight value is "Right 8/5 up", that is, the weight value is 2; the data size is 11, and the preset size is 5, the weight value is "rounded up to 11/5", that is, the weight value is 3.
- the process of determining the weight value of the keyword according to the relationship between the processing time and the preset time includes: configuring the preset time according to experience, and determining the keyword if the processing time of the keyword corresponding request is less than or equal to the preset time
- the weight value is 1. If the processing time of the keyword corresponding request is greater than the preset time, the weight of the keyword is determined to be “rounded by the preset time divided by the preset time”. For example, if the processing time is 8, and the preset time is 5, the weight value is "Right 8/5 up", that is, the weight value is 2; the processing time is 11, when the preset time is 5, the weight value is "rounded up to 11/5", that is, the weight value is 3.
- the process of determining the first sub-weight value of the keyword according to the relationship between the data size and the preset size may include: determining the keyword if the data size of the keyword corresponding data is less than or equal to the preset size.
- the first sub-weight value is 1. If the data size of the keyword corresponding data is greater than the preset size, it is determined that the first sub-weight value of the keyword is “rounded up by dividing the data size by the preset size”.
- the process of determining the second sub-weight value of the keyword according to the relationship between the processing time and the preset time may include: determining the keyword if the processing time of the keyword corresponding request is less than or equal to the preset time The second sub-weight value is 1. If the processing time of the keyword corresponding request is greater than the preset time, it is determined that the second sub-weight value of the keyword is “rounded up by the preset time divided by the preset time”.
- the process of determining the weight value of the keyword according to the first sub-weight value and the second sub-weight value may include: determining a weight value of the keyword as the first sub-weight value plus the second sub-weight value.
- the first sub-weight value is “rounded up to 8/5”, that is, the first sub-weight value is 2.
- the data size of the keyword correspondence data means that, assuming that the application server requests the data A corresponding to the keyword 1, the data size of the data corresponding to the keyword 1 is the size of the data A. Since the database server stores data A, the database server can know the size of the data A.
- the processing time of the keyword correspondence request is: if the application server requests the data A corresponding to the keyword 1, the processing time of the keyword 1 corresponding to the request is, and the keyword 1 is received from the database server.
- the data request to the time when the database server returns a response carrying the data A to the application server, and the database server can analyze the size of the time.
- Step 202 Determine the number of access times in which the number of accesses (ie, the number of accesses obtained in step 201) is located, and query a linked list (such as an LRU linked list, etc.) corresponding to the number of access times.
- a linked list such as an LRU linked list, etc.
- the number of accesses of the acquired keywords is 105
- the number of accesses 105 is located in the access number interval 2
- the number of accesses interval 2 corresponds to the linked list 2.
- the number of accesses of the acquired keywords is 260
- it is determined that the number of accesses 206 is located in the access number interval 3
- the number of accesses interval 3 corresponds to the linked list 3.
- Step 203 Update the position of the number of accesses of the keyword in the linked list (ie, the linked list corresponding to the access number interval), for example, the data block in which the number of access times of the keyword is located may be updated to the first data block of the linked list.
- the data block 80 in which the number of accesses 105 of the keyword 1 is located can be updated to the first data block of the linked list 2.
- the data block 80 in which the number of accesses 260 of the keyword 1 is located can be updated to the first data block of the linked list 3.
- the linked list 1 includes, in order, a data block 1, a data block 2, a data block 80, and a data block 3 - a data block 79.
- the linked list 2 sequentially includes a data block 81 - a data block 90, which in turn includes a data block 91 - a data block 100.
- step 201 it is assumed that the number of accesses recorded by the data block 80 is updated from 100 to 105.
- step 202 it is determined that the linked list is the linked list 2, and in step 203, the data block 80 can be updated to the linked list 2.
- the first data block That is, the linked list 1 includes the data block 1 - the data block 79 in turn, and the linked list 2 includes the data block 80 - the data block 90 in turn, and the linked list 3 sequentially includes the data block 91 - the data block 100.
- step 201 it is assumed that the number of accesses recorded by the data block 60 is updated from 50 to 51.
- step 202 it is determined that the linked list is the linked list 1, that is, the linked list of the data block 60 does not change, in step 203.
- the data block 60 can be updated to the first data block of the linked list 1. That is, the linked list 1 may sequentially include a data block 60, a data block 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 90, and the linked list 3 may sequentially include the data block 91.
- - Data block 100 the linked list 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 90, and the linked list 3 may sequentially include the data block 91.
- - Data block 100 the linked list 1 - a data block
- step 201 it is assumed that the number of accesses recorded by the data block 90 is updated from 199 to 208.
- the linked list is the linked list 3, that is, the linked list of the data block 90 has changed.
- the data block 90 can be updated to the first data block of the linked list 3. That is, the linked list 1 may sequentially include a data block 60, a data block 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 89, and the linked list 3 may include the data block 90 in sequence.
- - Data block 100 the linked list 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 89, and the linked list 3 may include the data block 90 in sequence.
- the linked list with the lowest priority may be queried, and the content in the last data block of the lowest priority linked list is deleted;
- the linked list with the lowest priority is a linked list corresponding to the smallest number of access times.
- the database server receives the data request sent by the application server, if the keyword carried by the data request is a new keyword (that is, the number of accesses of the keyword is not recorded in all the data blocks), and all the data blocks are already If it is occupied, it is determined that the content in one data block needs to be deleted.
- the linked list in the embodiment of the present application has a priority, and the lowest priority linked list is a linked list corresponding to the smallest access number interval, and the highest priority linked list is the linked list corresponding to the largest access number interval, and the access number interval The larger the score, the higher the priority of the linked list corresponding to the access number interval.
- the access number interval 3 (the number of accesses 201 - infinity) is larger than the access number interval 2 (the number of accesses 101 - the number of accesses 200), it is determined that the priority of the linked list 3 corresponding to the access number interval 3 is higher than the access number interval 2 The priority of the linked list 2. Since the access number interval 2 is larger than the access number interval 1 (the number of accesses 1 - the number of accesses 100), it can be determined that the priority of the linked list 2 corresponding to the access number interval 2 is higher than the priority of the linked list 1 corresponding to the access number interval 1. In summary, the priority of the linked list 1 can be the lowest, the priority of the linked list 3 can be the highest, and the priority of the linked list 2 is in the middle.
- the linked list 1 includes the data block 1 - the data block 79 in sequence
- the linked list 2 includes the data block 80 - the data block 90 in sequence
- the linked list 3 includes the data block 91 - the data block 100 in sequence
- the content in the data block needs to be deleted
- the linked list 1 with the lowest priority is queried, and the content (such as the keyword, the number of accesses of the keyword, etc.) in the last data block of the linked list 1 (such as the data block 79) is deleted.
- data block 79 can record new keywords as well as the number of accesses to new keywords.
- the data block 79 is then updated to the first data block of the linked list 1.
- the linked list 1 may sequentially include a data block 79, a data block 1 - a data block 78, and the linked list 2 sequentially includes a data block 80 - a data block 90, which in turn includes a data block 91 - a data block 100.
- the keyword in the data block 79 and the data block position of the data block 79 can also be deleted from the hash table. Correspondence relationship, and the correspondence between the new keyword and the data block position of the data block 79 is recorded in the hash table.
- each data block of the linked list with high priority has a large number of access records
- each data block of the linked list with a low priority has a small number of access records, for example, the highest priority linked list 3
- Each data block, wherein the number of accesses recorded is greater than or equal to 201, such as 10000, and the data block of the linked list 3 having the lowest priority, wherein the number of accesses recorded is less than or equal to 100, and may be 1, therefore, needs to be deleted.
- the keyword in the linked list 1 with the lowest priority is deleted, so that the keyword with a small number of accesses is deleted, and the keyword with a large number of accesses is not deleted, that is, the key of the hot keyword may be Words will not be deleted, so you can keep the number of visits to hot keywords to the end of the statistical period, so you can improve the validity of the statistics when counting hot keywords.
- Step 204 When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list (eg, from the data block of the linked list), and the hotspot keyword is determined according to the number of accesses of the keyword.
- the linked list eg, from the data block of the linked list
- the hotspot keyword needs to be determined, and the process of determining the hotspot keyword according to the number of accesses of the keyword is performed, and then the next statistical period can be entered, and the above steps 201-203 are performed again.
- it is necessary to determine a hotspot keyword perform a process of "determining a hotspot keyword according to the number of accesses of the keyword", and then, proceed to the next statistical cycle, and re- Perform the above steps 201-203.
- the hotspot keyword may also be notified to the application server.
- the database server may sequentially read the number of accesses of the keyword from each data block (such as data block 1 - data block 100), if the number of accesses of the keyword is greater than a preset number of thresholds (may be If the experience is configured, the keyword may be a hot keyword. If the number of accesses of the keyword is not greater than the preset threshold, the keyword may be determined to be not a hot keyword.
- a preset number of thresholds may be If the experience is configured, the keyword may be a hot keyword. If the number of accesses of the keyword is not greater than the preset threshold, the keyword may be determined to be not a hot keyword.
- the process of "reading the number of accesses of a keyword from a linked list and determining a hotspot keyword according to the number of accesses of the keyword” may include, but is not limited to, according to the highest priority linked list to the lowest priority
- the order of the linked list sequentially traverses the data blocks of the linked list; the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the linked list corresponding to the smallest access number interval.
- the number of accesses of the keywords recorded in the traversed data block is greater than the preset number of times threshold, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword.
- After traversing to the linked list that is not a hotkey keyword stop traversing the data block of the next linked list.
- the linked list 1 includes the data block 1 - the data block 79 in turn
- the linked list 2 includes the data block 80 - the data block 90 in turn
- the linked list 3 includes the data block 91 - the data block 100 in sequence
- the preset number of thresholds is 210
- the database server first traverses each data block of the linked list 3 (such as data block 91 - data block 100), and then traverses each data block of the linked list 2 (such as data block 80) - Data block 90), and then traverse each data block of the linked list 1 (e.g., data block 1 - data block 79).
- the key recorded in the data block 91-data block 99 is a hotspot.
- the keyword, and the keyword recorded in the data block 100 is not a hot keyword.
- the traversal to the linked list 3 that is not a hotkey keyword the traversal of the data block of the next linked list is stopped, that is, each data block of the linked list 2 is no longer traversed, and each data block of the linked list 1 is no longer traversed, and the end Traversing.
- each data block of the linked list 3 is traversed, and each data block of the linked list 2 is no longer traversed, and each data block of the linked list 1 is no longer traversed, thereby reducing the processing pressure of the database server and saving the database.
- the server's resources can speed up the process of data block traversal and save processing time.
- the contents of all the linked data blocks can be cleared, and all the contents of the hash table are cleared, so that the data block, the hash table, and the linked list are all returned to the initial state, that is, In the initial state, the above steps 201-203 are re-executed, and the process will not be described again.
- the above-described execution order is only an example given for convenience of description. In an actual application, the execution order between the steps may also be changed, and the order of execution is not limited. Moreover, in other embodiments, the steps of the respective methods are not necessarily performed in the order shown and described herein, and the methods may include more or less steps than those described in this specification. In addition, the individual steps described in this specification may be decomposed into a plurality of steps for description in other embodiments; the various steps described in the present specification may be combined into a single step for description in other embodiments.
- the hotspot keyword can be notified to the application server.
- the application server can cache the data corresponding to the hotkey keyword locally. In this way, after receiving the data request for the hotspot keyword sent by the client, the application server can locally query the data corresponding to the hotkey keyword, and send the data corresponding to the hotkey keyword to the client without using the database server. Get the data corresponding to the hot keyword.
- the application server may also change the hash algorithm for the hotspot keyword, so as to avoid the data request for the hotkey keyword being located to the same database server, thereby achieving load balancing and improving The stability of the distributed system. For example, after receiving the data request for the hotspot keyword sent by the client, the application server periodically changes the hash algorithm, so that the data request 1 - the data request 100 is sent to the database server A, and the data request 101 - the data request 200 is sent to the database. Server B, and so on, to achieve load balancing between database servers.
- the application server can change the hash algorithm to change the database server to achieve load balancing between the database servers.
- the database server may also cache the data corresponding to the hotspot keyword in the HotZone storage area of the database server (ie, the pre-divided area for storing hotspot data).
- the database server can directly query the data corresponding to the hotspot keyword from the HotZone storage area, and send the data corresponding to the hotspot keyword to the application server instead of using the data.
- the data storage medium to the database server obtains data corresponding to the hotkey keyword, thereby speeding up data acquisition.
- an example of the data acquisition process may be: after receiving the data request carrying the keyword sent by the client, the application server first queries the data corresponding to the keyword locally; if the keyword exists locally, the keyword corresponds to The application server directly sends the data corresponding to the keyword to the client; if the data corresponding to the keyword does not exist locally, the application server sends a data request carrying the keyword to the database server.
- the database server queries the data corresponding to the keyword from the HotZone storage area; if the data corresponding to the keyword exists in the HotZone storage area, the database server obtains the data from the HotZone storage area.
- the data corresponding to the keyword is sent to the application server; if the data corresponding to the keyword does not exist in the HotZone storage area, the data corresponding to the keyword may be obtained from the data storage medium of the database server, and Send the data corresponding to the keyword to the application server.
- the application server may also set an expiration time for the data, and after the expiration time arrives, the cached data is deleted locally.
- the database server caches the data corresponding to the hotkey keyword in the HotZone storage area
- the database may also set an expiration time for the data. After the expiration time arrives, the cached data is deleted from the HotZone storage area.
- the database server may collect the hotspot keyword and notify the application server of the hotspot keyword, so that the application server performs load balancing processing on the data request of the hotkey keyword, thereby implementing distributed Load balancing of the system improves the stability and efficiency of the system and improves the overall processing capability of data requests for hot keywords.
- the database server does not need to traverse each data block in turn, only need to store the hash table, the data block position corresponding to the keyword can be queried from the hash table, thereby avoiding the traversal operation of the database server and reducing the database server.
- the processing pressure saves time in traversing operations.
- the keywords in the lowest priority linked list are deleted, so that the keywords with small access times are deleted, and the keywords with large access times are not deleted, that is, hot keywords may be deleted.
- the keywords will not be deleted, so the number of visits to the hot keywords can be retained until the end of the statistical period.
- the hot keywords are counted, the validity of the statistics can be improved. It is possible to traverse only each data block of the linked list with high priority, and not to traverse each data block of the linked list with low priority, and then count the hotspot keywords, thereby alleviating the processing pressure of the database server and saving the resources of the database server. Save processing time.
- the method may be applied to a database server, and the method may include:
- Step 401 Acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a data block location corresponding to the keyword.
- the hash table is used to record the correspondence between the keyword and the data block position. Therefore, the data block position corresponding to the keyword can be obtained from the hash table.
- Step 402 Query the number of accesses from the data block corresponding to the data block location, and obtain the number of accesses of the keyword by using the number of accesses queried, and update the number of accesses of the keyword into the data block.
- Step 403 When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the data block is selected for the keyword; the number of accesses of the keyword is recorded in the selected data block. And the correspondence between the keyword and the data block position of the selected data block is recorded in the hash table.
- the process of obtaining the number of accesses of the keyword by using the number of accesses queried may include, but is not limited to, determining that the number of accesses of the keyword is a preset value of the number of accesses queried; or Obtaining resource information corresponding to the keyword, determining a weight value of the keyword according to the resource information, and determining that the number of access times of the keyword is a weighted value of the number of times of the query; wherein the resource information includes a data size of the keyword corresponding data, and / or, the keyword corresponds to the processing time of the request.
- FIG. 4 The flow shown in FIG. 4 is similar to the flow shown in FIG. 2A, and details are not repeated herein.
- the method may be applied to a database server, and the method may include:
- Step 501 Acquire a keyword in a statistical period, and obtain the number of accesses of the keyword.
- Step 502 Determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals may correspond to different linked lists.
- Step 503 Update the location of the number of accesses of the keyword in the linked list.
- Step 504 when the content in the data block needs to be deleted, according to the correspondence between the access number interval and the linked list, query the lowest priority linked list, and delete the content in the last data block of the lowest priority linked list;
- the lowest priority linked list is the linked list corresponding to the smallest number of access times.
- Step 505 When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- the process of "reading the number of accesses of a keyword from a linked list and determining a hotspot keyword according to the number of accesses of the keyword” may include, but is not limited to, according to the highest priority linked list to the lowest priority The sequence of the linked list sequentially traverses the data blocks of the linked list; wherein, the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the linked list corresponding to the smallest access number interval; if the traversed data block is traversed If the number of accesses of the recorded keyword is greater than the preset number threshold, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword; after traversing to the linked list that is not a hotkey keyword, stopping traversing the next one The data block of the linked list.
- FIG. 5 The flow shown in FIG. 5 is similar to the flow shown in FIG. 2A, and details are not repeated herein.
- the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 6, which is a structural diagram of a hotspot keyword acquiring apparatus.
- the obtaining module 601 is configured to acquire a keyword in a statistical period, and obtain a number of access times of the keyword;
- a determining module 602 configured to determine an access number interval in which the number of accesses is located, and query a linked list corresponding to the access number interval; wherein different access times intervals correspond to different linked lists; and update the keyword The number of visits in the linked list;
- the determining module 602 is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the keyword.
- the obtaining module 601 is configured to: obtain a data block location corresponding to the keyword, and query the number of accesses from the data block corresponding to the data block location in the process of acquiring the number of accesses of the keyword, And obtaining the number of accesses of the keyword by using the number of accesses queried;
- the obtaining module 601 is specifically configured to: when the location of the data block corresponding to the keyword is obtained, query the hash table by using the keyword to obtain a data block location corresponding to the keyword;
- the hash table is used to record a correspondence between a keyword and a data block position;
- the number of times of accessing the keyword is determined by adding a preset value to the number of times the query is accessed; or obtaining the resource information corresponding to the keyword. And determining, according to the resource information, a weight value of the keyword, and determining that the number of accesses of the keyword is the number of accesses that are queried plus the weight value; wherein the resource information includes: the keyword corresponding data The data size, and/or, the keyword corresponds to the processing time of the request.
- the hotspot keyword acquisition means further includes (not shown in the figure):
- a deleting module configured to: when the content in the data block needs to be deleted, query the lowest priority linked list, and delete the content in the last data block of the lowest priority linked list;
- the determining module 602 is specifically configured to: in the process of determining a hotspot keyword according to the number of accesses of the keyword, sequentially traversing the data block of the linked list according to the order of the highest priority linked list to the lowest priority linked list; if traversing If the number of accesses of the keywords recorded in the data block is greater than the preset number of thresholds, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword; after traversing to the linked list that is not a hotkey keyword, stopping Traversing the data blocks of the next linked list;
- the linked list with the highest priority is a linked list corresponding to the largest number of access times
- the linked list with the lowest priority is a linked list corresponding to the smallest number of access times.
- the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword. Determining the number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; updating the number of accesses of the keywords in the linked list The location; when the hotkey keyword needs to be determined, the number of visits to the keyword is read from the linked list, and the hotkey keyword is determined according to the number of visits to the keyword.
- the database server includes: a processor, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword. Determining the number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; updating the number of accesses of the keywords in the linked list The location; when the hotkey keyword needs to
- the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed.
- the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed. Performing the following steps: acquiring a keyword in a statistical period, and obtaining the number of accesses of the keyword; determining a number of access times in which the number of accesses is located, and querying a linked list corresponding to the number of access times; different accesses The number of times interval corresponds to a different linked list; the number of access times of the keyword is updated in the linked list; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the number of accesses of the keyword is determined according to the number of accesses of the keyword Hot keywords.
- the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 7 , which is a structural diagram of a hotspot keyword acquiring apparatus.
- the obtaining module 701 is configured to: acquire a keyword in the statistical period, query the hash table by using the keyword, and obtain a corresponding data block position; the hash table is configured to record a correspondence between the keyword and the data block position; Querying the number of accesses from the data block corresponding to the data block location, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;
- the determining module 702 is configured to read the number of accesses of the keyword from the linked list when the hotspot keyword needs to be determined, and determine the hotspot keyword according to the number of accesses of the read keyword.
- the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and query a hash by using the keyword a table, the data block location corresponding to the keyword is obtained; wherein the hash table is used to record a correspondence between a keyword and a data block location; and the number of accesses is queried from a data block corresponding to the data block location, And obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to the data block; when the hotkey keyword needs to be determined, reading the keyword from the linked list The number of times, and the hotspot keyword is determined based on the number of visits to the keyword.
- the database server includes: a processor, configured to acquire a keyword in a statistical period, and query a hash by using the keyword a table, the data block location corresponding to the keyword is obtained; wherein the hash table is used to record a correspondence between a keyword
- the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed.
- the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed.
- the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 8 , which is a structural diagram of a hotspot keyword acquiring apparatus.
- the obtaining module 801 is configured to acquire a keyword and obtain the number of access times of the keyword in a statistical period
- a determining module 802 configured to determine an access number interval in which the number of accesses is located, and query a linked list corresponding to the access number interval; wherein different access times intervals correspond to different linked lists; and update the keyword The number of visits in the linked list;
- the deleting module 803 is configured to: when the content in the data block needs to be deleted, query the lowest priority linked list according to the correspondence between the access number interval and the linked list, and select the content in the last data block of the lowest priority linked list. Delete; the lowest priority linked list is the linked list corresponding to the smallest number of access times;
- the determining module 802 is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the read keyword.
- the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword. Determining the number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; updating the number of accesses of the keywords in the linked list Position; when the content in the data block needs to be deleted, according to the correspondence between the access number interval and the linked list, the lowest priority linked list is queried, and the content in the last data block of the lowest priority linked list is deleted;
- the lowest-priority linked list is a linked list corresponding to the minimum access number interval; when the hot-spot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hot-spot keyword is determined according to the number of accesses of the keyword.
- the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed.
- the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed.
- the system, device, module or unit illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product having a certain function.
- a typical implementation device is a computer, and the specific form of the computer may be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, and a game control.
- embodiments of the present application can be provided as a method, system, or computer program product.
- the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
- embodiments of the present application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
- these computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- the instruction means implements the functions specified in one or more blocks of the flowchart or in a flow or block diagram of the flowchart.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present application provides a trending keyword acquisition method, a device and a server. The method comprises: acquiring a keyword within a reference period and acquiring a view count of the keyword; determining a view count interval in which the view count is located, querying to get a linked list corresponding to the view count interval, wherein different view count intervals correspond to different linked lists; updating a position of the view count of the keyword in the linked list; and when needing to determine a trending keyword, reading a view count of the keyword from the linked list and determining a trending keyword according to the view count of the keyword. The technical solution of the present application can be used to realize balanced loading of a distributed system and to improve stability and effectiveness of the system, thereby increasing overall processing capability of data requests with respect to trending keywords.
Description
本申请要求2017年09月22日递交的申请号为201710865548.6、发明名称为“一种热点关键字获取方法、装置及服务器”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims the priority of the Chinese Patent Application No. 201710865548.6, entitled "A Hotspot Keys Acquisition Method, Apparatus, and Server", which is hereby incorporated by reference. .
本申请涉及互联网领域,尤其是一种热点关键字获取方法、装置及服务器。The present application relates to the field of the Internet, and in particular, to a hotkey keyword acquisition method, apparatus, and server.
分布式系统是应对当下大数据存储需求的主流方案之一,在分布式系统中,可以部署多个数据库服务器,各数据库服务器用于存储相同的数据。应用服务器在接收到客户端发送的数据请求后,采用hash算法确定数据库服务器,并向该数据库服务器发送数据请求。数据库服务器在接收到数据请求后,将与该数据请求对应的数据返回给应用服务器,以使应用服务器将该数据返回给客户端。Distributed systems are one of the mainstream solutions to the current demand for big data storage. In a distributed system, multiple database servers can be deployed, and each database server is used to store the same data. After receiving the data request sent by the client, the application server determines the database server by using a hash algorithm, and sends a data request to the database server. After receiving the data request, the database server returns the data corresponding to the data request to the application server, so that the application server returns the data to the client.
由于hash算法是固定的,因此,用于获取同一数据的数据请求会被定位到同一数据库服务器,从而导致无法实现负载均衡,分布式系统的稳定性较差。Since the hash algorithm is fixed, the data request for acquiring the same data is located to the same database server, which results in load balancing and the stability of the distributed system is poor.
例如,应用服务器对数据标识进行hash处理,并根据处理结果确定数据库服务器,针对数据标识A的所有数据请求,被定位到数据库服务器A,针对数据标识B的所有数据请求,被定位到数据库服务器B。若数据标识A的数据请求数量远大于数据标识B的数据请求数量,则数据库服务器A的处理压力较大,数据库服务器B的处理压力较小,无法在数据库服务器之间实现负载均衡。For example, the application server performs hash processing on the data identifier, and determines the database server according to the processing result. All data requests for the data identifier A are located to the database server A, and all data requests for the data identifier B are located to the database server B. . If the number of data requests of the data identifier A is much larger than the number of data requests of the data identifier B, the processing pressure of the database server A is large, and the processing pressure of the database server B is small, and load balancing cannot be implemented between the database servers.
发明内容Summary of the invention
本申请提供一种热点关键字获取方法,应用于数据库服务器,包括:The application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
在统计周期内,获取关键字,并获取所述关键字的访问次数;In the statistical period, obtain a keyword and obtain the number of accesses of the keyword;
确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;Determining a number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists;
更新所述关键字的访问次数在所述链表中的位置;Updating the location of the number of accesses of the keyword in the linked list;
在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
本申请提供一种热点关键字获取方法,应用于数据库服务器,包括:The application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
在统计周期内,获取关键字,通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;Obtaining a keyword, querying a hash table by using the keyword, and obtaining a data block location corresponding to the keyword; the hash table is configured to record a correspondence between a keyword and a data block location;
从所述数据块位置对应的数据块中查询出访问次数,利用查询出的访问次数获得所述关键字的访问次数,将所述关键字的访问次数更新到所述数据块中;Querying the number of accesses from the data block corresponding to the data block location, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;
在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
本申请提供一种热点关键字获取方法,应用于数据库服务器,包括:The application provides a hotspot keyword acquisition method, which is applied to a database server, and includes:
在统计周期内,获取关键字,并获取所述关键字的访问次数;In the statistical period, obtain a keyword and obtain the number of accesses of the keyword;
确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;Determining a number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists;
更新所述关键字的访问次数在所述链表中的位置;Updating the location of the number of accesses of the keyword in the linked list;
在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,优先级最低的链表是最小的访问次数区间对应的链表;When the content in the data block needs to be deleted, the linked list with the lowest priority is searched according to the correspondence between the access number interval and the linked list, and the content in the last data block of the lowest priority linked list is deleted; The lowest-level linked list is the linked list corresponding to the minimum number of access times;
在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
本申请提供一种热点关键字获取装置,应用于数据库服务器,包括:The present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
获取模块,用于在统计周期内,获取关键字,获取所述关键字的访问次数;An obtaining module, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword;
确定模块,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module, configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;
所述确定模块,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。The determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the keyword.
本申请提供一种热点关键字获取装置,应用于数据库服务器,包括:The present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
获取模块,用于在统计周期内,获取关键字,通过所述关键字查询哈希表,得到对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,利用查询出的访问次数获得所述关键字的访问次数,将所述关键字的访问次数更新到所述数据块中;An obtaining module, configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a corresponding data block position; the hash table is configured to record a correspondence between a keyword and a data block position; Querying the number of accesses in the data block corresponding to the location of the data block, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;
确定模块,用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根 据读取的关键字的访问次数确定热点关键字。The determining module is configured to read the number of accesses of the keyword from the linked list when the hotkey keyword needs to be determined, and determine the hotspot keyword according to the number of accesses of the read keyword.
本申请提供一种热点关键字获取装置,应用于数据库服务器,包括:The present application provides a hotspot keyword obtaining apparatus, which is applied to a database server, and includes:
获取模块,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;An obtaining module, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword;
确定模块,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module, configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;
删除模块,用于在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,将所述优先级最低的链表的最后一个数据块中的内容删除;所述优先级最低的链表是最小的访问次数区间对应的链表;The deleting module is configured to: when the content in the data block needs to be deleted, query the linked list with the lowest priority according to the correspondence between the access number interval and the linked list, and delete the content in the last data block of the lowest priority linked list. The lowest priority linked list is a linked list corresponding to the smallest number of access times;
所述确定模块,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据读取的关键字的访问次数确定热点关键字。The determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the read keyword.
本申请提供一种数据库服务器,所述数据库服务器包括:The application provides a database server, the database server comprising:
处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times; Different access times intervals correspond to different linked lists; update the position of the number of accesses of the keyword in the linked list; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and according to the keyword The number of visits determines the hotspot keyword.
本申请提供一种数据库服务器,所述数据库服务器包括:The application provides a database server, the database server comprising:
处理器,用于在统计周期内,获取关键字,并通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;其中,所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数,并将所述关键字的访问次数更新到所述数据块中;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a data block location corresponding to the keyword; wherein the hash table is used to record a keyword and Corresponding relationship of the location of the data block; querying the number of accesses from the data block corresponding to the location of the data block, and obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to In the data block; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
本申请提供一种数据库服务器,所述数据库服务器包括:The application provides a database server, the database server comprising:
处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,所述优 先级最低的链表是最小的访问次数区间对应的链表;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times; The different access times interval corresponds to different linked lists; the number of access times of the keywords is updated in the linked list; when the content in the data block needs to be deleted, the priority is queried according to the correspondence between the access times interval and the linked list a lowest linked list, and deleting content in a last data block of the lowest priority linked list; wherein the lowest priority linked list is a linked list corresponding to a minimum number of access times; when a hot keyword needs to be determined, The number of visits to the keyword is read from the linked list, and the hotspot keyword is determined based on the number of visits to the keyword.
基于上述技术方案,本申请实施例中,数据库服务器可以统计出热点关键字,并将热点关键字通知给应用服务器,以使应用服务器对热点关键字的数据请求进行负载均衡处理,从而实现分布式系统的负载均衡,提高系统的稳定性和高效性,提升对热点关键字的数据请求的整体处理能力。而且,通过划分多个链表,且删除优先级最低的链表的数据块中内容,从而保留最有价值的数据。Based on the foregoing technical solution, in the embodiment of the present application, the database server may collect the hotspot keyword and notify the application server of the hotspot keyword, so that the application server performs load balancing processing on the data request of the hotkey keyword, thereby implementing distributed Load balancing of the system improves the stability and efficiency of the system and improves the overall processing capability of data requests for hot keywords. Moreover, the most valuable data is retained by dividing a plurality of linked lists and deleting the contents of the data blocks of the lowest priority linked list.
为了更加清楚地说明本申请实施例或者现有技术中的技术方案,下面将对本申请实施例或者现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据本申请实施例的这些附图获得其它的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments of the present application or the description of the prior art will be briefly described below. Obviously, the drawings in the following description For example, some of the embodiments described in the present application can be obtained by those skilled in the art from the drawings of the embodiments of the present application.
图1是本申请一种实施方式中的应用场景示意图;1 is a schematic diagram of an application scenario in an implementation manner of the present application;
图2A和图2B是本申请一种实施方式中的热点关键字获取方法的流程图;2A and 2B are flowcharts of a method for acquiring a hotspot keyword in an embodiment of the present application;
图3是本申请一种实施方式中的哈希表与链表的数据结构示例;3 is an example of a data structure of a hash table and a linked list in an embodiment of the present application;
图4是本申请另一种实施方式中的热点关键字获取方法的流程图;4 is a flowchart of a method for acquiring a hotspot keyword in another embodiment of the present application;
图5是本申请另一种实施方式中的热点关键字获取方法的流程图;FIG. 5 is a flowchart of a method for acquiring a hotspot keyword in another embodiment of the present application;
图6是本申请一种实施方式中的热点关键字获取装置的结构图;6 is a structural diagram of a hotspot keyword acquiring apparatus in an embodiment of the present application;
图7是本申请另一种实施方式中的热点关键字获取装置的结构图;7 is a structural diagram of a hotspot keyword obtaining apparatus in another embodiment of the present application;
图8是本申请另一种实施方式中的热点关键字获取装置的结构图。FIG. 8 is a structural diagram of a hotspot keyword acquiring apparatus in another embodiment of the present application.
在本申请实施例使用的术语仅仅是出于描述特定实施例的目的,而非限制本申请。本申请和权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其它含义。还应当理解,本文中使用的术语“和/或”是指包含一个或多个相关联的列出项目的任何或所有可能组合。The terms used in the embodiments of the present application are for the purpose of describing the specific embodiments, and are not intended to limit the application. The singular forms "a", "the", and "the" It should also be understood that the term "and/or" as used herein refers to any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本申请实施例可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本申请范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也 可以被称为第一信息。取决于语境,此外,所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information may also be referred to as the second information without departing from the scope of the present application. Similarly, the second information may also be referred to as the first information. Depending on the context, in addition, the word "if" may be interpreted to mean "at time" or "when" or "in response to determination."
本申请实施例中提出一种热点关键字获取方法,该方法可以应用于分布式系统。参见图1所示,为本申请实施例的应用场景示意图,分布式系统可以包括多个数据库服务器、多个应用服务器。图1中以两个数据库服务器,三个应用服务器为例进行说明。在实际应用中,数据库服务器的数量,应用服务器的数量还可以更多,对此数据库服务器的数量,应用服务器的数量不做限制。A hotspot keyword acquisition method is proposed in the embodiment of the present application, and the method can be applied to a distributed system. Referring to FIG. 1 , which is a schematic diagram of an application scenario of an embodiment of the present application, a distributed system may include multiple database servers and multiple application servers. Figure 1 shows two database servers and three application servers as examples. In practical applications, the number of database servers and the number of application servers can be more. There is no limit to the number of database servers and the number of application servers.
为了在数据库服务器之间实现负载均衡,则数据库服务器可以获取到热点关键字,并将热点关键字通知给应用服务器,以使应用服务器对热点关键字的数据请求进行负载均衡处理,从而可以实现数据库服务器之间的负载均衡,避免某些数据库服务器的处理压力较大,而其它数据库服务器的处理压力较小。In order to implement load balancing between the database servers, the database server can obtain the hotspot keywords and notify the application server of the hotspot keywords, so that the application server performs load balancing processing on the data requests of the hotkey keywords, thereby implementing the database. The load balancing between servers avoids the processing pressure of some database servers, while the processing pressure of other database servers is small.
本申请实施例中,为了获取热点关键字,则数据库服务器可以统计关键字的访问次数,并基于关键字的访问次数确定该关键字是否为热点关键字。例如,当关键字的访问次数大于预设次数阈值时,则确定该关键字是热点关键字,当关键字的访问次数不大于预设次数阈值时,则确定该关键字不是热点关键字。In the embodiment of the present application, in order to obtain a hotspot keyword, the database server may count the number of accesses of the keyword, and determine whether the keyword is a hotspot keyword based on the number of accesses of the keyword. For example, when the number of accesses of the keyword is greater than the preset number of thresholds, the keyword is determined to be a hotspot keyword. When the number of accesses of the keyword is not greater than the preset number of times, the keyword is determined to be not a hotspot keyword.
本申请实施例中,关键字(Key)是数据库服务器内存储的数据的唯一标识,应用服务器向数据库服务器发送数据请求时,该数据请求可以携带关键字,数据库服务器在接收到该数据请求后,通过这个关键字,就可以从数据库服务器中查询到与该关键字对应的数据,并将这个数据返回给应用服务器。其中,该关键字可以包括但不限于:数据标识、用户标识、商品标识等,对此关键字不做限制,只要基于该关键字,数据库服务器可以查询到本地存储的数据即可。例如,基于数据标识,数据库服务器可以查询到与该数据标识对应的数据,基于用户标识,数据库服务器可以查询到与该用户标识对应的数据。基于商品标识,数据库服务器可以查询到与该商品标识对应的数据。以此类推。In the embodiment of the present application, the key (Key) is a unique identifier of the data stored in the database server. When the application server sends a data request to the database server, the data request may carry a keyword, and after receiving the data request, the database server receives the data request. With this keyword, the data corresponding to the keyword can be queried from the database server and returned to the application server. The keyword may include, but is not limited to, a data identifier, a user identifier, a product identifier, and the like. The keyword is not limited, and the database server may query the locally stored data based on the keyword. For example, based on the data identifier, the database server can query the data corresponding to the data identifier, and based on the user identifier, the database server can query the data corresponding to the user identifier. Based on the item identification, the database server can query the data corresponding to the item identification. And so on.
为了统计关键字的访问次数,数据库服务器可以设置统计周期,并在每个统计周期内统计关键字的访问次数。例如,统计周期的时长是1秒,则0-1秒是1个统计周期,1-2秒是1个统计周期,以此类推。在0-1秒这个统计周期内,数据库服务器统计关键字的访问次数,基于关键字的访问次数确定该关键字是否为热点关键字。在1-2秒这个统计周期内,数据库服务器重新统计关键字的访问次数,基于关键字的访问次数确定该关键字是否为热点关键字。以此类推。To count the number of visits to a keyword, the database server can set the statistics period and count the number of visits to the keyword in each statistical period. For example, the duration of the statistical period is 1 second, then 0-1 seconds is 1 statistical period, 1-2 seconds is 1 statistical period, and so on. In the statistical period of 0-1 seconds, the database server counts the number of accesses of the keyword, and determines whether the keyword is a hot keyword based on the number of accesses of the keyword. In the statistical period of 1-2 seconds, the database server re-counts the number of accesses of the keyword, and determines whether the keyword is a hotspot keyword based on the number of accesses of the keyword. And so on.
在一个例子中,数据库服务器可以使用数据块存储关键字的访问次数,每个关键字 占用一个数据块,如数据块1存储关键字1的访问次数,数据块2存储关键字2的访问次数,以此类推。此外,数据库服务器在统计周期内可能接收到大量关键字的数据请求,如几十万甚至上百万,每个关键字占用一个数据块时,则占用大量数据块,即为了存储关键字的访问次数,会占用大量数据块。In one example, the database server may use the data block to store the number of accesses of the keyword, each keyword occupies one data block, such as data block 1 stores the number of accesses of keyword 1, and data block 2 stores the number of accesses of keyword 2, And so on. In addition, the database server may receive a large number of keyword data requests during the statistical period, such as hundreds of thousands or even millions. When each keyword occupies one data block, it occupies a large number of data blocks, that is, access for storing keywords. The number of times will occupy a large number of data blocks.
但是,热点关键字获取这个功能,只是数据库服务器的辅助功能,数据库服务器不会为这个功能分配大量数据块,即无法使用大量数据块存储关键字的访问次数,继而获取热点关键字。为此,提出了LRU(Least Recently Used,最近最少使用)算法,即基于少量数据块,采用LRU算法存储关键字的访问次数。However, the hotkey keyword acquisition function is only an auxiliary function of the database server. The database server does not allocate a large number of data blocks for this function, that is, it cannot use a large number of data blocks to store the number of accesses of keywords, and then obtain hotspot keywords. To this end, an LRU (Least Recently Used) algorithm is proposed, which uses the LRU algorithm to store the number of accesses of keywords based on a small number of data blocks.
例如,数据库服务器为“热点关键字获取”功能分配100个数据块(以100个数据块为例进行说明,实际应用中,分配的数据块可以更多,对此不做限制)。For example, the database server allocates 100 data blocks for the "hotkey keyword acquisition" function (for example, 100 data blocks are used as an example. In actual applications, more data blocks can be allocated, and no limitation is imposed on this).
在统计周期内,若第1-101次接收到的是关键字1的数据请求,则在数据块1中记录关键字1的访问次数,并将数据块1更新为LRU链表的首个数据块。若第102次接收到的是关键字2的数据请求,则在数据块2中记录关键字2的访问次数,并将数据块2更新为LRU链表的首个数据块,将数据块1更新为LRU链表的第2个数据块。以此类推,若第200次接收到的是关键字100的数据请求,则在数据块100中记录关键字100的访问次数,并将数据块100更新为LRU链表的首个数据块,将数据块99更新为LRU链表的第2个数据块,以此类推,将数据块1更新为LRU链表的第100个数据块(LRU链表的最后一个数据块)。In the statistical period, if the data request of the keyword 1 is received in the first to the first time, the number of accesses of the keyword 1 is recorded in the data block 1, and the data block 1 is updated to the first data block of the LRU linked list. . If the data request of the keyword 2 is received at the 102nd time, the number of accesses of the keyword 2 is recorded in the data block 2, and the data block 2 is updated to the first data block of the LRU linked list, and the data block 1 is updated to The second data block of the LRU list. By analogy, if the data request of the keyword 100 is received in the 200th time, the number of accesses of the keyword 100 is recorded in the data block 100, and the data block 100 is updated to the first data block of the LRU linked list, and the data is Block 99 is updated to the second data block of the LRU linked list, and so on, and data block 1 is updated to the 100th data block of the LRU linked list (the last data block of the LRU linked list).
若第201次接收到的是关键字101的数据请求,由于已经没有可用数据块,因此,数据库服务器从LRU链表中删除最后一个数据块记录的内容,即删除数据块1中记录的关键字1的访问次数,在数据块1中记录关键字101的访问次数,将数据块1更新为LRU链表的首个数据块,将数据块100更新为LRU链表的第2个数据块,将数据块99更新为LRU链表的第3个数据块,以此类推。If the data request of the keyword 101 is received in the 201st time, since there is no data block available, the database server deletes the content of the last data block record from the LRU linked list, that is, deletes the keyword 1 recorded in the data block 1. The number of accesses, the number of accesses of the keyword 101 is recorded in the data block 1, the data block 1 is updated to the first data block of the LRU linked list, and the data block 100 is updated to the second data block of the LRU linked list, and the data block 99 is Updated to the third data block of the LRU list, and so on.
显然,在接收到关键字101的数据请求之前,数据块1中记录的关键字1的访问次数是最大的,关键字1可能是热点关键字,而在接收到关键字101的数据请求后,数据块1中记录的关键字1的访问次数被删除,导致热点关键字的访问次数无法保留到统计周期结束,也就无法统计出关键字1是热点关键字。Obviously, before receiving the data request of the keyword 101, the number of accesses of the keyword 1 recorded in the data block 1 is the largest, the keyword 1 may be a hotspot keyword, and after receiving the data request of the keyword 101, The number of accesses of the keyword 1 recorded in the data block 1 is deleted, and the number of accesses of the hot keyword cannot be retained until the end of the statistical period, and it is impossible to count that the keyword 1 is a hot keyword.
针对上述发现,本申请实施例中,可以划分多个访问次数区间,每个访问次数区间对应一个链表,且不同的访问次数区间对应不同的链表。其中,所述链表可以包括但不限于LRU链表,为了方便描述,后续以链表为例进行说明。For the above findings, in the embodiment of the present application, multiple access times intervals may be divided, each access time interval corresponds to a linked list, and different access times intervals correspond to different linked lists. The linked list may include, but is not limited to, an LRU linked list. For convenience of description, the following takes a linked list as an example for description.
例如,链表1对应访问次数区间1,且所述访问次数区间1对应于(访问次数1-访问次数100);链表2对应访问次数区间2,且所述访问次数区间2对应于(访问次数101-访问次数200);链表3对应访问次数区间3,且所述访问次数区间3对应于(访问次数201-无穷大),即大于等于访问次数201即可。当然,上述示例是以三个链表、三个访问次数区间为例进行说明的,在实际应用中,链表的数量、访问次数区间的数量还可以更多,对此数量不做限制。此外,上述访问次数区间对应的数值,也只是本申请的一个示例,对此不做限制。For example, the linked list 1 corresponds to the access number interval 1, and the access number interval 1 corresponds to (the number of accesses 1 - the number of accesses 100); the linked list 2 corresponds to the access number interval 2, and the access number interval 2 corresponds to (the number of accesses 101) - the number of accesses 200); the linked list 3 corresponds to the access number interval 3, and the access number interval 3 corresponds to (the number of accesses 201 - infinity), that is, the number of accesses 201 is greater than or equal to. Of course, the above example is described by taking three linked lists and three access times intervals as an example. In practical applications, the number of linked lists and the number of access times can be more, and the number is not limited. In addition, the numerical value corresponding to the above-mentioned access number interval is only an example of the present application, and no limitation is imposed thereon.
在上述应用场景下,参见图2A所示,为本申请实施例中提出的热点关键字获取方法的流程图,该方法可以应用于数据库服务器,且该方法可以包括:In the above application scenario, as shown in FIG. 2A, which is a flowchart of a method for acquiring a hotspot keyword according to an embodiment of the present application, the method may be applied to a database server, and the method may include:
步骤201,在统计周期内,获取关键字,并获取该关键字的访问次数。In step 201, during the statistical period, the keyword is obtained, and the number of accesses of the keyword is obtained.
在一个例子中,在每个统计周期内,数据库服务器均可以获取关键字,并获取该关键字的访问次数,为了方便描述,后续以一个统计周期为例进行说明。In an example, the database server can obtain the keyword and obtain the number of accesses of the keyword in each statistical period. For convenience of description, a statistical period is taken as an example for description.
在一个例子中,应用服务器(如APP服务器)在接收到客户端发送的数据请求后,可以采用hash算法确定数据库服务器,并向该数据库服务器发送数据请求。数据库服务器在接收到该数据请求后,从该数据请求中解析出关键字。In an example, after receiving the data request sent by the client, the application server (such as the APP server) may determine the database server by using a hash algorithm and send a data request to the database server. After receiving the data request, the database server parses the keyword from the data request.
其中,该关键字可以包括但不限于:数据标识、用户标识、商品标识等,对此关键字不做限制,只要基于该关键字,数据库服务器可以查询到本地存储的数据即可。例如,基于数据标识,数据库服务器可以查询到与该数据标识对应的数据,基于用户标识,数据库服务器可以查询到与该用户标识对应的数据。The keyword may include, but is not limited to, a data identifier, a user identifier, a product identifier, and the like. The keyword is not limited, and the database server may query the locally stored data based on the keyword. For example, based on the data identifier, the database server can query the data corresponding to the data identifier, and based on the user identifier, the database server can query the data corresponding to the user identifier.
其中,该客户端可以是终端设备(如PC(Personal Computer,个人计算机)、笔记本电脑、移动终端等)的APP,也可以是终端设备的浏览器,对此客户端的类型不做限制,所有能够访问应用服务器的客户端,均在本申请保护范围内。The client may be an APP of a terminal device (such as a PC (Personal Computer), a notebook computer, a mobile terminal, or the like), or may be a browser of the terminal device, and the type of the client is not limited, and all of the clients may be Clients accessing the application server are within the scope of this application.
其中,应用服务器可以是为客户端提供服务的服务器,且所述应用服务器可以从数据库服务器获取到客户端请求的数据,并将该数据发送给客户端。如应用服务器可以是数据平台、电商平台等,对此应用服务器的类型不做限制。The application server may be a server that provides services for the client, and the application server may obtain data requested by the client from the database server, and send the data to the client. For example, the application server may be a data platform, an e-commerce platform, etc., and the type of the application server is not limited.
其中,数据库服务器可以是存储数据的服务器,数据库服务器在接收到应用服务器发送的数据请求后,从该数据请求中解析出关键字,从本地查询出与该关键字对应的数据,将该数据发送给应用服务器,继而将数据返回给客户端。The database server may be a server that stores data. After receiving the data request sent by the application server, the database server parses the keyword from the data request, and locally queries the data corresponding to the keyword, and sends the data. Give the application server and then return the data to the client.
参见图2B所示,针对“获取该关键字的访问次数”的过程,可以包括:Referring to FIG. 2B, the process of “acquiring the number of accesses of the keyword” may include:
步骤2011,获取该关键字对应的数据块位置。Step 2011: Obtain a data block location corresponding to the keyword.
在一个例子中,针对“获取该关键字对应的数据块位置”的过程,可以包括但不限于如下方式:方式一、由于数据块可以记录关键字与访问次数的对应关系,因此,数据库服务器可以依次遍历每个数据块,若遍历到的数据块中记录有该关键字,则该数据块的数据块位置就是该关键字对应的数据块位置。方式二、数据库服务器可以存储哈希表,该哈希表用于记录关键字与数据块位置的对应关系;基于此哈希表,数据库服务器可以通过该关键字查询所述哈希表,若该哈希表中存在该关键字,则可以得到与该关键字对应的数据块位置。In an example, the process of “acquiring the location of the data block corresponding to the keyword” may include, but is not limited to, the following manner: mode 1. Since the data block can record the correspondence between the keyword and the number of accesses, the database server may Each data block is traversed in turn, and if the keyword is recorded in the traversed data block, the data block position of the data block is the data block position corresponding to the keyword. In the second method, the database server may store a hash table, where the hash table is used to record the correspondence between the keyword and the data block location; based on the hash table, the database server may query the hash table by using the keyword, if If the keyword exists in the hash table, the data block position corresponding to the keyword can be obtained.
在方式二中,由于数据库服务器不需要依次遍历每个数据块,只需要存储哈希表,就可以从哈希表中查询到与关键字对应的数据块位置,从而避免数据库服务器的遍历操作,减轻数据库服务器的处理压力,节省遍历操作的时间。In the second method, since the database server does not need to traverse each data block in turn, and only needs to store the hash table, the data block position corresponding to the keyword can be queried from the hash table, thereby avoiding the traversal operation of the database server. Reduce the processing pressure of the database server and save time in traversal operations.
参见图3所示,为哈希表与链表的数据结构示例,该哈希表可以包括但不限于HashMap(哈希图)表,该链表可以包括但不限于N级的LRU链表。Referring to FIG. 3, which is an example of a data structure of a hash table and a linked list, the hash table may include, but is not limited to, a HashMap table, which may include, but is not limited to, an N-level LRU linked list.
在一个例子中,哈希表用于记录关键字与数据块位置的对应关系,数据库服务器在接收到数据请求后,可以从该数据请求中解析出关键字,并通过该关键字查询哈希表。若该哈希表中不存在该关键字,则数据库服务器为该关键字选取数据块,将该关键字的访问次数记录到选取的数据块中,并在哈希表中记录该关键字与选取的数据块的数据块位置的对应关系。若该哈希表中存在该关键字,则数据库服务器可以从哈希表中得到与该关键字对应的数据块位置。In an example, the hash table is used to record the correspondence between the keyword and the location of the data block. After receiving the data request, the database server can parse the keyword from the data request and query the hash table through the keyword. . If the keyword does not exist in the hash table, the database server selects a data block for the keyword, records the number of accesses of the keyword into the selected data block, and records the keyword and the selection in the hash table. The correspondence of the data block positions of the data blocks. If the keyword exists in the hash table, the database server can obtain the data block location corresponding to the keyword from the hash table.
在一个例子中,N级链表是指N个链表,每个链表对应一个访问次数区间,如链表1对应访问次数区间1(访问次数1-访问次数100),链表2对应访问次数区间2(访问次数101-访问次数200),链表3对应访问次数区间3(访问次数201-无穷大),这一情况可以表示:当数据块中记录的关键字的访问次数位于所述访问次数区间1时,则该数据块属于链表1;当数据块中记录的关键字的访问次数位于所述访问次数区间2时,则该数据块属于链表2;当数据块中记录的关键字的访问次数位于所述访问次数区间3时,则该数据块属于链表3。In an example, the N-level linked list refers to N linked lists, and each linked list corresponds to an access number interval, such as the linked list corresponding access times interval 1 (the number of accesses 1 - the number of accesses 100), and the linked list 2 corresponds to the access times interval 2 (accesses The number of times 101 - the number of accesses 200), the linked list 3 corresponds to the access number interval 3 (the number of accesses 201 - infinity), which may indicate that when the number of accesses of the keywords recorded in the data block is located in the access number interval 1, then The data block belongs to the linked list 1; when the number of accesses of the keywords recorded in the data block is located in the access number interval 2, the data block belongs to the linked list 2; when the number of accesses of the keywords recorded in the data block is located in the access When the number of times is 3, the data block belongs to the linked list 3.
在一个例子中,针对方式一,数据块用于记录关键字、该关键字的访问次数,针对方式二,数据块用于记录关键字的访问次数,当然,数据块也可以记录关键字。为了方便描述,以数据块记录关键字、该关键字的访问次数为例。In one example, for mode one, the data block is used to record the keyword, the number of accesses of the keyword, and for the second mode, the data block is used to record the number of accesses of the keyword. Of course, the data block can also record the keyword. For convenience of description, the data block record keyword and the number of accesses of the keyword are taken as an example.
针对方式二,“获取该关键字对应的数据块位置”的示例可以为:数据库服务器在接收到关键字1的数据请求后,通过关键字1查询哈希表。若哈希表中不存在关键字1, 则数据库服务器为关键字1选取数据块(如未被占用的数据块或者当前释放的数据块;未被占用的数据块是指:数据块还没有记录关键字、关键字的访问次数;当前释放的数据块是指:数据块已经记录关键字、关键字的访问次数,但是将这个数据块中记录的内容删除,后续过程介绍删除过程)。For the second method, the example of “acquiring the data block location corresponding to the keyword” may be: after receiving the data request of the keyword 1 , the database server queries the hash table by using the keyword 1 . If the keyword 1 does not exist in the hash table, the database server selects a data block for the keyword 1 (such as an unoccupied data block or a currently released data block; an unoccupied data block means that the data block has not been recorded yet) The number of accesses of the keyword and the keyword; the currently released data block means that the data block has recorded the keyword and the number of accesses of the keyword, but the content recorded in the data block is deleted, and the subsequent process introduces the deletion process).
假设为关键字1选取数据块80,则数据块80用于记录关键字1、关键字1的访问次数,并在哈希表中记录关键字1与数据块80的数据块位置的对应关系。Assuming that the data block 80 is selected for the keyword 1, the data block 80 is used to record the number of accesses of the keyword 1 and the keyword 1, and the correspondence relationship between the key 1 and the data block position of the data block 80 is recorded in the hash table.
当数据库服务器再次接收到关键字1的数据请求后,通过关键字1查询哈希表,由于哈希表中已经存在关键字1,因此,数据库服务器可以直接从哈希表中得到与关键字1对应的数据块位置,也就是,数据块80的数据块位置。After the database server receives the data request of the keyword 1 again, the hash table is queried by the keyword 1. Since the keyword 1 already exists in the hash table, the database server can directly obtain the keyword 1 from the hash table. The corresponding data block position, that is, the data block position of the data block 80.
步骤2012,从该数据块位置对应的数据块中查询出访问次数。In step 2012, the number of accesses is queried from the data block corresponding to the data block location.
由于数据块用于记录关键字、关键字的访问次数,因此,数据库服务器在得到数据块位置后,可以从该数据块位置对应的数据块中查询出访问次数。Since the data block is used to record the number of accesses of the keyword and the keyword, the database server can query the number of accesses from the data block corresponding to the data block position after obtaining the data block position.
步骤2013,利用查询出的访问次数获得关键字的访问次数。In step 2013, the number of accesses of the keyword is obtained by using the number of accesses queried.
其中,针对“利用查询出的访问次数获得关键字的访问次数”的过程,可以包括但不限于如下方式:确定该关键字的访问次数为查询出的访问次数加预设数值(如1);或者,获取该关键字对应的资源信息,并根据该资源信息确定该关键字的权重值,并确定该关键字的访问次数为查询出的访问次数加权重值。The process for obtaining the number of accesses of the keyword by using the number of accesses queried may include, but is not limited to, the following method: determining the number of accesses of the keyword is a preset number of accesses (for example, 1); Alternatively, the resource information corresponding to the keyword is obtained, and the weight value of the keyword is determined according to the resource information, and the number of accesses of the keyword is determined to be a weighted value of the number of access times.
步骤2014,将该关键字的访问次数更新到该数据块位置对应的数据块中。In step 2014, the number of accesses of the keyword is updated to the data block corresponding to the data block position.
其中,从数据块中查询出的访问次数,是上一次更新该数据块时,记录到该数据块中的关键字的访问次数,为了方便描述,后续过程中,将该访问次数称为关键字的第一访问次数。当前获得的关键字的访问次数,是本次更新该数据块时,记录到该数据块中的关键字的访问次数,为了方便描述,后续过程中,将该访问次数称为关键字的第二访问次数。显然,在下一次需要更新该数据块时,第二访问次数也就变成了记录到该数据块中的关键字的第一访问次数。The number of accesses queried from the data block is the number of times the keyword is recorded in the data block when the data block was last updated. For convenience of description, in the subsequent process, the number of accesses is called a keyword. The number of first visits. The number of accesses of the currently obtained keyword is the number of times the keyword is recorded in the data block when the data block is updated this time. For convenience of description, in the subsequent process, the number of accesses is referred to as the second keyword. The number of visits. Obviously, the next time the data block needs to be updated, the second number of accesses becomes the first number of accesses to the keywords recorded in the data block.
在一个例子中,每次获得关键字(如关键字1)后,从数据块位置对应的数据块(如数据块80)中读取关键字1的第一访问次数,并将第一访问次数加1,得到第二访问次数。例如,在第100次获得关键字1后,从数据块80中读取关键字1的第一访问次数99,将第一访问次数99加1,得到第二访问次数100,并将第二访问次数100更新到数据块80中。在第101次获得关键字后,从数据块80中读取关键字1的第一访问次数100,并将第一访问次数100加1,得到第二访问次数101,并将第二访问次数101更新到数据 块80中。以此类推。In one example, each time a keyword (such as keyword 1) is obtained, the first access number of the keyword 1 is read from the data block corresponding to the data block position (such as the data block 80), and the first access number is obtained. Add 1 to get the second number of visits. For example, after the keyword 1 is obtained for the 100th time, the first access number 99 of the keyword 1 is read from the data block 80, the first access number 99 is incremented by 1, the second access number 100 is obtained, and the second access is obtained. The number of times 100 is updated into data block 80. After obtaining the keyword for the 101st time, the first access number 100 of the keyword 1 is read from the data block 80, and the first access number 100 is incremented by 1, the second access number 101 is obtained, and the second access number 101 is obtained. Update to data block 80. And so on.
在另一个例子中,每次获得关键字(如关键字1)后,可以从数据块位置对应的数据块(如数据块80)中读取该关键字1的第一访问次数,并将该第一访问次数加权重值,从而得到第二访问次数。例如,以权重值是5为例进行说明,则在第100次获得关键字1后,可以从数据块80中读取关键字1的第一访问次数495,将第一访问次数495加权重值5,得到第二访问次数500,并将第二访问次数500更新到数据块80中。在第101次获得关键字后,可以从数据块80中读取关键字1的第一访问次数500,并将第一访问次数100加权重值5,得到第二访问次数505,并将第二访问次数505更新到数据块80中。以此类推。In another example, each time a keyword (such as keyword 1) is obtained, the first access number of the keyword 1 can be read from a data block corresponding to the data block location (such as the data block 80), and the The first number of visits weights the weight value to obtain the second number of accesses. For example, the weight value is 5 as an example. After the keyword 1 is obtained for the 100th time, the first access number 495 of the keyword 1 can be read from the data block 80, and the first access number 495 is weighted. 5. The second access number 500 is obtained, and the second access number 500 is updated to the data block 80. After obtaining the keyword for the 101st time, the first access number 500 of the keyword 1 can be read from the data block 80, and the first access number 100 is weighted by 5 to obtain the second access number 505, and the second is obtained. The number of accesses 505 is updated into data block 80. And so on.
为了获得关键字(如关键字1)的权重值(如上述权重值5),在每次获得关键字1后,可以获取关键字1对应的资源信息,并根据该资源信息确定关键字1的权重值。或者,在第一次获得关键字1后,可以获取关键字1对应的资源信息,并根据该资源信息确定关键字1的权重值;然后,将该权重值记录到数据块80,再次获得关键字1后,可以直接从数据块80中读取到该权重值。In order to obtain the weight value of the keyword (such as the keyword 1) (such as the weight value 5 described above), after each keyword 1 is obtained, the resource information corresponding to the keyword 1 can be obtained, and the keyword 1 is determined according to the resource information. Weights. Alternatively, after the keyword 1 is obtained for the first time, the resource information corresponding to the keyword 1 may be acquired, and the weight value of the keyword 1 is determined according to the resource information; then, the weight value is recorded to the data block 80, and the key is obtained again. After word 1, the weight value can be read directly from data block 80.
在一个例子中,该资源信息可以包括但不限于:关键字对应数据的数据尺寸,和/或,关键字对应请求的处理时间。基于此,针对“根据资源信息确定关键字的权重值”的过程,可以包括但不限于如下方式:若资源信息包括关键字对应数据的数据尺寸,则可以根据数据尺寸与预设尺寸的关系,确定关键字的权重值。若资源信息包括关键字对应请求的处理时间,则可以根据处理时间与预设时间的关系,确定关键字的权重值。若资源信息包括关键字对应数据的数据尺寸和关键字对应请求的处理时间,则可以根据数据尺寸与预设尺寸的关系,确定关键字的第一子权重值;根据处理时间与预设时间的关系,确定关键字的第二子权重值;根据该第一子权重值和该第二子权重值确定关键字的权重值。In one example, the resource information may include, but is not limited to, a data size of the keyword corresponding data, and/or a processing time of the keyword corresponding request. Based on this, the process of determining the weight value of the keyword according to the resource information may include, but is not limited to, the following manner: if the resource information includes the data size of the keyword corresponding data, the relationship between the data size and the preset size may be Determine the weight value of the keyword. If the resource information includes the processing time of the keyword corresponding request, the weight value of the keyword may be determined according to the relationship between the processing time and the preset time. If the resource information includes the data size of the keyword corresponding data and the processing time of the keyword corresponding request, the first sub-weight value of the keyword may be determined according to the relationship between the data size and the preset size; according to the processing time and the preset time a relationship, determining a second sub-weight value of the keyword; determining a weight value of the keyword according to the first sub-weight value and the second sub-weight value.
其中,针对“根据数据尺寸与预设尺寸的关系,确定关键字的权重值”的过程,包括:根据经验配置预设尺寸,若关键字对应数据的数据尺寸小于等于预设尺寸,确定关键字的权重值为1。若关键字对应数据的数据尺寸大于预设尺寸,确定关键字的权重值为“对数据尺寸除以预设尺寸向上取整”,如数据尺寸为8,预设尺寸为5时,权重值为“对8/5向上取整”,即权重值为2;数据尺寸为11,预设尺寸为5时,权重值为“对11/5向上取整”,即权重值为3。The process of determining the weight value of the keyword according to the relationship between the data size and the preset size includes: configuring the preset size according to experience, and determining the keyword if the data size of the keyword corresponding data is less than or equal to the preset size. The weight value is 1. If the data size of the keyword corresponding data is greater than the preset size, determine the weight value of the keyword is “round the data size by the preset size.” If the data size is 8, and the preset size is 5, the weight value is "Right 8/5 up", that is, the weight value is 2; the data size is 11, and the preset size is 5, the weight value is "rounded up to 11/5", that is, the weight value is 3.
其中,针对“根据处理时间与预设时间的关系,确定关键字的权重值”的过程,包 括:根据经验配置预设时间,若关键字对应请求的处理时间小于等于预设时间,确定关键字的权重值为1。若关键字对应请求的处理时间大于预设时间,确定关键字的权重值为“对处理时间除以预设时间向上取整”,如处理时间为8,预设时间为5时,权重值为“对8/5向上取整”,即权重值为2;处理时间为11,预设时间为5时,权重值为“对11/5向上取整”,即权重值为3。The process of determining the weight value of the keyword according to the relationship between the processing time and the preset time includes: configuring the preset time according to experience, and determining the keyword if the processing time of the keyword corresponding request is less than or equal to the preset time The weight value is 1. If the processing time of the keyword corresponding request is greater than the preset time, the weight of the keyword is determined to be “rounded by the preset time divided by the preset time”. For example, if the processing time is 8, and the preset time is 5, the weight value is "Right 8/5 up", that is, the weight value is 2; the processing time is 11, when the preset time is 5, the weight value is "rounded up to 11/5", that is, the weight value is 3.
其中,针对“根据数据尺寸与预设尺寸的关系,确定关键字的第一子权重值”的过程,可以包括:若关键字对应数据的数据尺寸小于等于预设尺寸,则确定该关键字的第一子权重值为1。若关键字对应数据的数据尺寸大于预设尺寸,则确定该关键字的第一子权重值为“对数据尺寸除以预设尺寸向上取整”。The process of determining the first sub-weight value of the keyword according to the relationship between the data size and the preset size may include: determining the keyword if the data size of the keyword corresponding data is less than or equal to the preset size. The first sub-weight value is 1. If the data size of the keyword corresponding data is greater than the preset size, it is determined that the first sub-weight value of the keyword is “rounded up by dividing the data size by the preset size”.
其中,针对“根据处理时间与预设时间的关系,确定关键字的第二子权重值”的过程,可以包括:若关键字对应请求的处理时间小于等于预设时间,则确定该关键字的第二子权重值为1。若关键字对应请求的处理时间大于预设时间,则确定该关键字的第二子权重值为“对处理时间除以预设时间向上取整”。The process of determining the second sub-weight value of the keyword according to the relationship between the processing time and the preset time may include: determining the keyword if the processing time of the keyword corresponding request is less than or equal to the preset time The second sub-weight value is 1. If the processing time of the keyword corresponding request is greater than the preset time, it is determined that the second sub-weight value of the keyword is “rounded up by the preset time divided by the preset time”.
其中,针对“根据该第一子权重值和该第二子权重值确定关键字的权重值”的过程,可以包括:确定关键字的权重值为该第一子权重值加该第二子权重值。The process of determining the weight value of the keyword according to the first sub-weight value and the second sub-weight value may include: determining a weight value of the keyword as the first sub-weight value plus the second sub-weight value.
例如,若数据尺寸为8,预设尺寸为5,处理时间为11,预设时间为5,则第一子权重值为“对8/5向上取整”,即第一子权重值为2;第二子权重值为“对11/5向上取整”,即第二子权重值为3;因此,关键字的权重值为2+3=5。For example, if the data size is 8, the preset size is 5, the processing time is 11, and the preset time is 5, the first sub-weight value is “rounded up to 8/5”, that is, the first sub-weight value is 2. The second sub-weight value is "rounded up to 11/5", that is, the second sub-weight value is 3; therefore, the weight value of the keyword is 2+3=5.
在上述实施例中,关键字对应数据的数据尺寸是指:假设应用服务器请求的是关键字1对应的数据A,则关键字1对应数据的数据尺寸是数据A的大小。由于数据库服务器存储有数据A,因此,数据库服务器可以获知数据A的大小。In the above embodiment, the data size of the keyword correspondence data means that, assuming that the application server requests the data A corresponding to the keyword 1, the data size of the data corresponding to the keyword 1 is the size of the data A. Since the database server stores data A, the database server can know the size of the data A.
在上述实施例中,关键字对应请求的处理时间是指:假设应用服务器请求的是关键字1对应的数据A,则关键字1对应请求的处理时间是,从数据库服务器接收到针对关键字1的数据请求,至数据库服务器向应用服务器返回携带数据A的响应的这段时间,而且,数据库服务器可以分析出这段时间的大小。In the above embodiment, the processing time of the keyword correspondence request is: if the application server requests the data A corresponding to the keyword 1, the processing time of the keyword 1 corresponding to the request is, and the keyword 1 is received from the database server. The data request, to the time when the database server returns a response carrying the data A to the application server, and the database server can analyze the size of the time.
步骤202,确定该访问次数(即步骤201中获取到的访问次数)所在的访问次数区间,并查询出与该访问次数区间对应的链表(如LRU链表等)。Step 202: Determine the number of access times in which the number of accesses (ie, the number of accesses obtained in step 201) is located, and query a linked list (such as an LRU linked list, etc.) corresponding to the number of access times.
假设获取到的关键字的访问次数为105,则确定访问次数105位于访问次数区间2,且访问次数区间2对应链表2。假设获取到的关键字的访问次数为260,则确定访问次数206位于访问次数区间3,且访问次数区间3对应链表3。Assuming that the number of accesses of the acquired keywords is 105, it is determined that the number of accesses 105 is located in the access number interval 2, and the number of accesses interval 2 corresponds to the linked list 2. Assuming that the number of accesses of the acquired keywords is 260, it is determined that the number of accesses 206 is located in the access number interval 3, and the number of accesses interval 3 corresponds to the linked list 3.
步骤203,更新关键字的访问次数在链表(即访问次数区间对应的链表)中的位置,如可以将关键字的访问次数所在的数据块更新为该链表的首个数据块。Step 203: Update the position of the number of accesses of the keyword in the linked list (ie, the linked list corresponding to the access number interval), for example, the data block in which the number of access times of the keyword is located may be updated to the first data block of the linked list.
假设关键字1的访问次数为105,则可以将关键字1的访问次数105所在的数据块80更新为链表2的首个数据块。假设关键字1的访问次数为260,则可以将关键字1的访问次数260所在的数据块80更新为链表3的首个数据块。Assuming that the number of accesses of the keyword 1 is 105, the data block 80 in which the number of accesses 105 of the keyword 1 is located can be updated to the first data block of the linked list 2. Assuming that the number of accesses of the keyword 1 is 260, the data block 80 in which the number of accesses 260 of the keyword 1 is located can be updated to the first data block of the linked list 3.
假设链表1依次包括数据块1、数据块2、数据块80、数据块3-数据块79,链表2依次包括数据块81-数据块90,链表3依次包括数据块91-数据块100。It is assumed that the linked list 1 includes, in order, a data block 1, a data block 2, a data block 80, and a data block 3 - a data block 79. The linked list 2 sequentially includes a data block 81 - a data block 90, which in turn includes a data block 91 - a data block 100.
进一步的,在步骤201中,假设将数据块80记录的访问次数从100更新到105,在步骤202中,确定出链表为链表2,在步骤203中,可以将数据块80更新为链表2的首个数据块。也就是说,链表1依次包括数据块1-数据块79,链表2依次包括数据块80-数据块90,链表3依次包括数据块91-数据块100。Further, in step 201, it is assumed that the number of accesses recorded by the data block 80 is updated from 100 to 105. In step 202, it is determined that the linked list is the linked list 2, and in step 203, the data block 80 can be updated to the linked list 2. The first data block. That is, the linked list 1 includes the data block 1 - the data block 79 in turn, and the linked list 2 includes the data block 80 - the data block 90 in turn, and the linked list 3 sequentially includes the data block 91 - the data block 100.
又例如,在步骤201中,假设将数据块60记录的访问次数从50更新到51,在步骤202中,确定出链表为链表1,即数据块60的链表并没有发生变化,在步骤203中,可以将数据块60更新为链表1的首个数据块。也就是说,链表1可以依次包括数据块60、数据块1-数据块59,数据块61-数据块79,链表2可以依次包括数据块80-数据块90,链表3可以依次包括数据块91-数据块100。For another example, in step 201, it is assumed that the number of accesses recorded by the data block 60 is updated from 50 to 51. In step 202, it is determined that the linked list is the linked list 1, that is, the linked list of the data block 60 does not change, in step 203. The data block 60 can be updated to the first data block of the linked list 1. That is, the linked list 1 may sequentially include a data block 60, a data block 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 90, and the linked list 3 may sequentially include the data block 91. - Data block 100.
又例如,在步骤201中,假设将数据块90记录的访问次数从199更新到208,在步骤202中,确定出链表为链表3,即数据块90的链表发生了变化,在步骤203中,可以将数据块90更新为链表3的首个数据块。也就是说,链表1可以依次包括数据块60、数据块1-数据块59,数据块61-数据块79,链表2可以依次包括数据块80-数据块89,链表3可以依次包括数据块90-数据块100。For another example, in step 201, it is assumed that the number of accesses recorded by the data block 90 is updated from 199 to 208. In step 202, it is determined that the linked list is the linked list 3, that is, the linked list of the data block 90 has changed. In step 203, The data block 90 can be updated to the first data block of the linked list 3. That is, the linked list 1 may sequentially include a data block 60, a data block 1 - a data block 59, a data block 61 - a data block 79, and the linked list 2 may sequentially include a data block 80 - a data block 89, and the linked list 3 may include the data block 90 in sequence. - Data block 100.
在一个例子中,在统计周期内,若需要删除数据块中的内容,则可以查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,所述优先级最低的链表是最小的访问次数区间对应的链表。In an example, if the content in the data block needs to be deleted in the statistical period, the linked list with the lowest priority may be queried, and the content in the last data block of the lowest priority linked list is deleted; The linked list with the lowest priority is a linked list corresponding to the smallest number of access times.
其中,数据库服务器在接收到应用服务器发送的数据请求时,若该数据请求携带的关键字是新关键字(即所有数据块中均没有记录该关键字的访问次数),且所有数据块均已经被占用,则确定需要删除一个数据块中的内容。The database server receives the data request sent by the application server, if the keyword carried by the data request is a new keyword (that is, the number of accesses of the keyword is not recorded in all the data blocks), and all the data blocks are already If it is occupied, it is determined that the content in one data block needs to be deleted.
其中,本申请实施例中的多个链表,均具有优先级,优先级最低的链表是最小的访问次数区间对应的链表,优先级最高的链表是最大的访问次数区间对应的链表,访问次数区间越大时,则该访问次数区间对应的链表的优先级越高。The linked list in the embodiment of the present application has a priority, and the lowest priority linked list is a linked list corresponding to the smallest access number interval, and the highest priority linked list is the linked list corresponding to the largest access number interval, and the access number interval The larger the score, the higher the priority of the linked list corresponding to the access number interval.
例如,由于访问次数区间3(访问次数201-无穷大)大于访问次数区间2(访问次数101-访问次数200),因此,确定访问次数区间3对应的链表3的优先级高于访问次数区间2对应的链表2的优先级。由于访问次数区间2大于访问次数区间1(访问次数1-访问次数100),因此,可以确定访问次数区间2对应的链表2的优先级高于访问次数区间1对应的链表1的优先级。综上所述,链表1的优先级可以最低,链表3的优先级可以最高,且链表2的优先级位于中间。For example, since the access number interval 3 (the number of accesses 201 - infinity) is larger than the access number interval 2 (the number of accesses 101 - the number of accesses 200), it is determined that the priority of the linked list 3 corresponding to the access number interval 3 is higher than the access number interval 2 The priority of the linked list 2. Since the access number interval 2 is larger than the access number interval 1 (the number of accesses 1 - the number of accesses 100), it can be determined that the priority of the linked list 2 corresponding to the access number interval 2 is higher than the priority of the linked list 1 corresponding to the access number interval 1. In summary, the priority of the linked list 1 can be the lowest, the priority of the linked list 3 can be the highest, and the priority of the linked list 2 is in the middle.
假设链表1依次包括数据块1-数据块79,链表2依次包括数据块80-数据块90,链表3依次包括数据块91-数据块100,则:在需要删除数据块中的内容时,可以查询出优先级最低的链表1,并将链表1的最后一个数据块(如数据块79)中的内容(如关键字、关键字的访问次数等)删除。这样,数据块79可以记录新关键字以及新关键字的访问次数。然后,将数据块79更新为链表1的首个数据块。也就是说,链表1可以依次包括数据块79、数据块1-数据块78,链表2依次包括数据块80-数据块90,链表3依次包括数据块91-数据块100。It is assumed that the linked list 1 includes the data block 1 - the data block 79 in sequence, and the linked list 2 includes the data block 80 - the data block 90 in sequence, and the linked list 3 includes the data block 91 - the data block 100 in sequence, when the content in the data block needs to be deleted, The linked list 1 with the lowest priority is queried, and the content (such as the keyword, the number of accesses of the keyword, etc.) in the last data block of the linked list 1 (such as the data block 79) is deleted. Thus, data block 79 can record new keywords as well as the number of accesses to new keywords. The data block 79 is then updated to the first data block of the linked list 1. That is to say, the linked list 1 may sequentially include a data block 79, a data block 1 - a data block 78, and the linked list 2 sequentially includes a data block 80 - a data block 90, which in turn includes a data block 91 - a data block 100.
在将链表1的数据块79中的内容(如关键字、关键字的访问次数等)删除之后,还可以从哈希表中删除数据块79中的关键字与数据块79的数据块位置的对应关系,并在哈希表中记录新关键字与数据块79的数据块位置的对应关系。After the content (such as the keyword, the number of accesses of the keyword, etc.) in the data block 79 of the linked list 1 is deleted, the keyword in the data block 79 and the data block position of the data block 79 can also be deleted from the hash table. Correspondence relationship, and the correspondence between the new keyword and the data block position of the data block 79 is recorded in the hash table.
综上所述,优先级高的链表的各数据块,其中记录的访问次数较大,而优先级低的链表的各数据块,其中记录的访问次数较小,例如,优先级最高的链表3的各数据块,其中记录的访问次数大于等于201,如可以是10000,而优先级最低的链表3的各数据块,其中记录的访问次数小于等于100,如可以是1,因此,在需要删除数据块中的内容时,是删除优先级最低的链表1中的关键字,使得访问次数小的关键字被删除,而访问次数大的关键字不会被删除,即可能是热点关键字的关键字不会被删除,从而可以将热点关键字的访问次数保留到统计周期结束,这样,在统计热点关键字时,可以提高统计数据的有效性。In summary, each data block of the linked list with high priority has a large number of access records, and each data block of the linked list with a low priority has a small number of access records, for example, the highest priority linked list 3 Each data block, wherein the number of accesses recorded is greater than or equal to 201, such as 10000, and the data block of the linked list 3 having the lowest priority, wherein the number of accesses recorded is less than or equal to 100, and may be 1, therefore, needs to be deleted. When the content in the data block is deleted, the keyword in the linked list 1 with the lowest priority is deleted, so that the keyword with a small number of accesses is deleted, and the keyword with a large number of accesses is not deleted, that is, the key of the hot keyword may be Words will not be deleted, so you can keep the number of visits to hot keywords to the end of the statistical period, so you can improve the validity of the statistics when counting hot keywords.
步骤204,在需要确定热点关键字时,从链表(如从链表的数据块)中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Step 204: When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list (eg, from the data block of the linked list), and the hotspot keyword is determined according to the number of accesses of the keyword.
其中,当统计周期结束后,则需要确定热点关键字,执行“根据关键字的访问次数确定热点关键字”的过程,然后,可以进入到下一个统计周期,并重新执行上述步骤201-步骤203。或者,当接收到用于确定热点关键字的指令时,则需要确定热点关键字,执行“根据关键字的访问次数确定热点关键字”的过程,然后,可以进入到下一个统计周 期,并重新执行上述步骤201-步骤203。After the statistics period ends, the hotspot keyword needs to be determined, and the process of determining the hotspot keyword according to the number of accesses of the keyword is performed, and then the next statistical period can be entered, and the above steps 201-203 are performed again. . Alternatively, when receiving an instruction for determining a hotspot keyword, it is necessary to determine a hotspot keyword, perform a process of "determining a hotspot keyword according to the number of accesses of the keyword", and then, proceed to the next statistical cycle, and re- Perform the above steps 201-203.
其中,确定热点关键字后,还可以将所述热点关键字通知给应用服务器。After determining the hotspot keyword, the hotspot keyword may also be notified to the application server.
例如,在统计周期结束后,数据库服务器可以依次从每个数据块(如数据块1-数据块100)中读取关键字的访问次数,若关键字的访问次数大于预设次数阈值(可以根据经验进行配置),则可以确定该关键字是热点关键字,若关键字的访问次数不大于预设次数阈值,则可以确定该关键字不是热点关键字。For example, after the end of the statistical period, the database server may sequentially read the number of accesses of the keyword from each data block (such as data block 1 - data block 100), if the number of accesses of the keyword is greater than a preset number of thresholds (may be If the experience is configured, the keyword may be a hot keyword. If the number of accesses of the keyword is not greater than the preset threshold, the keyword may be determined to be not a hot keyword.
在一个例子中,针对“从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字”的过程,可以包括但不限于:按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;优先级最高的链表是最大的访问次数区间对应的链表,优先级最低的链表是最小的访问次数区间对应的链表。然后,若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字。在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块。In one example, the process of "reading the number of accesses of a keyword from a linked list and determining a hotspot keyword according to the number of accesses of the keyword" may include, but is not limited to, according to the highest priority linked list to the lowest priority The order of the linked list sequentially traverses the data blocks of the linked list; the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the linked list corresponding to the smallest access number interval. Then, if the number of accesses of the keywords recorded in the traversed data block is greater than the preset number of times threshold, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword. After traversing to the linked list that is not a hotkey keyword, stop traversing the data block of the next linked list.
例如,假设链表1依次包括数据块1-数据块79,链表2依次包括数据块80-数据块90,链表3依次包括数据块91-数据块100,且预设次数阈值为210,则:按照优先级最高的链表到优先级最低的链表的顺序,数据库服务器先遍历链表3的每个数据块(如数据块91-数据块100),再遍历链表2的每个数据块(如数据块80-数据块90),再遍历链表1的每个数据块(如数据块1-数据块79)。For example, suppose that the linked list 1 includes the data block 1 - the data block 79 in turn, the linked list 2 includes the data block 80 - the data block 90 in turn, and the linked list 3 includes the data block 91 - the data block 100 in sequence, and the preset number of thresholds is 210, then: The order of the highest priority linked list to the lowest priority linked list, the database server first traverses each data block of the linked list 3 (such as data block 91 - data block 100), and then traverses each data block of the linked list 2 (such as data block 80) - Data block 90), and then traverse each data block of the linked list 1 (e.g., data block 1 - data block 79).
假设数据块91-数据块99中记录的访问次数大于预设次数阈值,而数据块100中记录的访问次数不大于预设次数阈值,则数据块91-数据块99中记录的关键字是热点关键字,而数据块100中记录的关键字不是热点关键字。而且,由于遍历到存在不是热点关键字的链表3,因此,停止遍历下一个链表的数据块,即不再遍历链表2的每个数据块,也不再遍历链表1的每个数据块,结束遍历。Assuming that the number of accesses recorded in the data block 91-data block 99 is greater than the preset number of times threshold, and the number of accesses recorded in the data block 100 is not greater than the preset number of times threshold, the key recorded in the data block 91-data block 99 is a hotspot. The keyword, and the keyword recorded in the data block 100 is not a hot keyword. Moreover, since the traversal to the linked list 3 that is not a hotkey keyword, the traversal of the data block of the next linked list is stopped, that is, each data block of the linked list 2 is no longer traversed, and each data block of the linked list 1 is no longer traversed, and the end Traversing.
显然,在上述方式中,只遍历链表3的每个数据块,而不再遍历链表2的每个数据块,不再遍历链表1的每个数据块,从而减轻数据库服务器的处理压力,节省数据库服务器的资源,可以加快数据块遍历的过程,节省处理时间。Obviously, in the above manner, only each data block of the linked list 3 is traversed, and each data block of the linked list 2 is no longer traversed, and each data block of the linked list 1 is no longer traversed, thereby reducing the processing pressure of the database server and saving the database. The server's resources can speed up the process of data block traversal and save processing time.
在一个例子中,在统计周期结束后,还可以清除所有链表的数据块中的内容,并清除哈希表中的所有内容,这样,数据块、哈希表、链表均回到初始状态,即在初始状态下,重新执行上述步骤201-步骤203,对此过程不再赘述。In an example, after the end of the statistical period, the contents of all the linked data blocks can be cleared, and all the contents of the hash table are cleared, so that the data block, the hash table, and the linked list are all returned to the initial state, that is, In the initial state, the above steps 201-203 are re-executed, and the process will not be described again.
在一个例子中,上述执行顺序只是为了方便描述给出的一个示例,在实际应用中, 还可以改变步骤之间的执行顺序,对此执行顺序不做限制。而且,在其它实施例中,并不一定按照本说明书示出和描述的顺序来执行相应方法的步骤,其方法所包括的步骤可以比本说明书所描述的更多或更少。此外,本说明书中所描述的单个步骤,在其它实施例中可能被分解为多个步骤进行描述;本说明书中所描述的多个步骤,在其它实施例也可能被合并为单个步骤进行描述。In one example, the above-described execution order is only an example given for convenience of description. In an actual application, the execution order between the steps may also be changed, and the order of execution is not limited. Moreover, in other embodiments, the steps of the respective methods are not necessarily performed in the order shown and described herein, and the methods may include more or less steps than those described in this specification. In addition, the individual steps described in this specification may be decomposed into a plurality of steps for description in other embodiments; the various steps described in the present specification may be combined into a single step for description in other embodiments.
在一个例子中,数据库服务器在获取到热点关键字后,可以将热点关键字通知给应用服务器。应用服务器在获取到热点关键字后,可以在本地缓存热点关键字对应的数据。这样,应用服务器在接收到客户端发送的针对热点关键字的数据请求后,可以从本地查询到热点关键字对应的数据,并将热点关键字对应的数据发送给客户端,而不用到数据库服务器获取热点关键字对应的数据。In an example, after the database server obtains the hotspot keyword, the hotspot keyword can be notified to the application server. After the application server obtains the hotspot keyword, the application server can cache the data corresponding to the hotkey keyword locally. In this way, after receiving the data request for the hotspot keyword sent by the client, the application server can locally query the data corresponding to the hotkey keyword, and send the data corresponding to the hotkey keyword to the client without using the database server. Get the data corresponding to the hot keyword.
在另一个例子中,应用服务器在获取到热点关键字后,还可以改变针对热点关键字的hash算法,避免将针对热点关键字的数据请求都定位到同一个数据库服务器,从而实现负载均衡,提高分布式系统的稳定性。例如,应用服务器在接收到客户端发送的针对热点关键字的数据请求后,通过定期改变hash算法,使得数据请求1-数据请求100发送给数据库服务器A,数据请求101-数据请求200发送给数据库服务器B,以此类推,从而实现数据库服务器之间的负载均衡。In another example, after obtaining the hotspot keyword, the application server may also change the hash algorithm for the hotspot keyword, so as to avoid the data request for the hotkey keyword being located to the same database server, thereby achieving load balancing and improving The stability of the distributed system. For example, after receiving the data request for the hotspot keyword sent by the client, the application server periodically changes the hash algorithm, so that the data request 1 - the data request 100 is sent to the database server A, and the data request 101 - the data request 200 is sent to the database. Server B, and so on, to achieve load balancing between database servers.
例如,应用服务器每接收到100个针对热点关键字的数据请求后,就可以改变hash算法,从而变更数据库服务器,实现数据库服务器之间的负载均衡。For example, after receiving 100 data requests for hotspot keywords, the application server can change the hash algorithm to change the database server to achieve load balancing between the database servers.
在另一个例子中,数据库服务器在获取到热点关键字后,还可以在数据库服务器的HotZone存储区域(即预先划分的用于存储热点数据的区域)缓存热点关键字对应的数据。这样,数据库服务器在接收到应用服务器发送的针对热点关键字的数据请求后,可以直接从HotZone存储区域查询到热点关键字对应的数据,并将热点关键字对应的数据发送给应用服务器,而不用到数据库服务器的数据存储介质获取热点关键字对应的数据,从而加快数据获取速度。In another example, after obtaining the hotspot keyword, the database server may also cache the data corresponding to the hotspot keyword in the HotZone storage area of the database server (ie, the pre-divided area for storing hotspot data). In this way, after receiving the data request for the hotspot keyword sent by the application server, the database server can directly query the data corresponding to the hotspot keyword from the HotZone storage area, and send the data corresponding to the hotspot keyword to the application server instead of using the data. The data storage medium to the database server obtains data corresponding to the hotkey keyword, thereby speeding up data acquisition.
综上所述,则数据获取过程的一个示例可以为:应用服务器在接收到客户端发送的携带关键字的数据请求后,先从本地查询该关键字对应的数据;若本地存在该关键字对应的数据,则应用服务器直接将该关键字对应的数据发送给客户端;若本地不存在该关键字对应的数据,则应用服务器向数据库服务器发送携带该关键字的数据请求。数据库服务器在接收到应用服务器发送的携带关键字的数据请求后,从HotZone存储区域查询该关键字对应的数据;若HotZone存储区域存在该关键字对应的数据,则数据库服务器 从HotZone存储区域获取该关键字对应的数据,并将该关键字对应的数据发送给应用服务器;若HotZone存储区域不存在该关键字对应的数据,则可以从数据库服务器的数据存储介质获取该关键字对应的数据,并将该关键字对应的数据发送给应用服务器。In summary, an example of the data acquisition process may be: after receiving the data request carrying the keyword sent by the client, the application server first queries the data corresponding to the keyword locally; if the keyword exists locally, the keyword corresponds to The application server directly sends the data corresponding to the keyword to the client; if the data corresponding to the keyword does not exist locally, the application server sends a data request carrying the keyword to the database server. After receiving the data request of the keyword sent by the application server, the database server queries the data corresponding to the keyword from the HotZone storage area; if the data corresponding to the keyword exists in the HotZone storage area, the database server obtains the data from the HotZone storage area. The data corresponding to the keyword is sent to the application server; if the data corresponding to the keyword does not exist in the HotZone storage area, the data corresponding to the keyword may be obtained from the data storage medium of the database server, and Send the data corresponding to the keyword to the application server.
在一个例子中,应用服务器在本地缓存热点关键字对应的数据后,还可以为该数据设置过期时间,在过期时间到达后,则从本地删除缓存的数据。数据库服务器在HotZone存储区域缓存热点关键字对应的数据后,还可以为该数据设置过期时间,在过期时间到达后,则从HotZone存储区域删除缓存的数据。In an example, after the application server caches the data corresponding to the hotkey keyword locally, the application server may also set an expiration time for the data, and after the expiration time arrives, the cached data is deleted locally. After the database server caches the data corresponding to the hotkey keyword in the HotZone storage area, the database may also set an expiration time for the data. After the expiration time arrives, the cached data is deleted from the HotZone storage area.
基于上述技术方案,本申请实施例中,数据库服务器可以统计出热点关键字,并将热点关键字通知给应用服务器,以使应用服务器对热点关键字的数据请求进行负载均衡处理,从而实现分布式系统的负载均衡,提高系统的稳定性和高效性,提升对热点关键字的数据请求的整体处理能力。而且,由于数据库服务器不需要依次遍历每个数据块,只需要存储哈希表,就可以从哈希表中查询到与关键字对应的数据块位置,从而避免数据库服务器的遍历操作,减轻数据库服务器的处理压力,节省遍历操作的时间。在需要删除数据块中的内容时,是删除优先级最低的链表中的关键字,使得访问次数小的关键字被删除,而访问次数大的关键字不会被删除,即可能是热点关键字的关键字不会被删除,从而可以将热点关键字的访问次数保留到统计周期结束,在统计热点关键字时,可以提高统计数据的有效性。可以只遍历优先级高的链表的每个数据块,而不再遍历优先级低的链表的每个数据块,就统计出热点关键字,从而减轻数据库服务器的处理压力,节省数据库服务器的资源,节省处理时间。Based on the foregoing technical solution, in the embodiment of the present application, the database server may collect the hotspot keyword and notify the application server of the hotspot keyword, so that the application server performs load balancing processing on the data request of the hotkey keyword, thereby implementing distributed Load balancing of the system improves the stability and efficiency of the system and improves the overall processing capability of data requests for hot keywords. Moreover, since the database server does not need to traverse each data block in turn, only need to store the hash table, the data block position corresponding to the keyword can be queried from the hash table, thereby avoiding the traversal operation of the database server and reducing the database server. The processing pressure saves time in traversing operations. When the content in the data block needs to be deleted, the keywords in the lowest priority linked list are deleted, so that the keywords with small access times are deleted, and the keywords with large access times are not deleted, that is, hot keywords may be deleted. The keywords will not be deleted, so the number of visits to the hot keywords can be retained until the end of the statistical period. When the hot keywords are counted, the validity of the statistics can be improved. It is possible to traverse only each data block of the linked list with high priority, and not to traverse each data block of the linked list with low priority, and then count the hotspot keywords, thereby alleviating the processing pressure of the database server and saving the resources of the database server. Save processing time.
基于与上述方法同样的申请构思,参见图4所示,为另一种热点关键字获取方法的流程图,该方法可以应用于数据库服务器,且该方法可以包括:Based on the same application concept as the above method, as shown in FIG. 4, which is a flowchart of another hotspot keyword acquisition method, the method may be applied to a database server, and the method may include:
步骤401,在统计周期内,获取关键字,并通过该关键字查询哈希表,得到与该关键字对应的数据块位置。其中,该哈希表用于记录关键字与数据块位置的对应关系,因此,可以从该哈希表中得到与该关键字对应的数据块位置。Step 401: Acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a data block location corresponding to the keyword. The hash table is used to record the correspondence between the keyword and the data block position. Therefore, the data block position corresponding to the keyword can be obtained from the hash table.
步骤402,从该数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得关键字的访问次数,将该关键字的访问次数更新到该数据块中。Step 402: Query the number of accesses from the data block corresponding to the data block location, and obtain the number of accesses of the keyword by using the number of accesses queried, and update the number of accesses of the keyword into the data block.
步骤403,在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Step 403: When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
在一个例子中,在通过关键字查询哈希表之后,若哈希表中不存在该关键字,则为该关键字选取数据块;将该关键字的访问次数记录到选取的数据块中,并在哈希表中记 录该关键字与选取的数据块的数据块位置的对应关系。In an example, after the hash table is queried by the keyword, if the keyword does not exist in the hash table, the data block is selected for the keyword; the number of accesses of the keyword is recorded in the selected data block. And the correspondence between the keyword and the data block position of the selected data block is recorded in the hash table.
在一个例子中,针对“利用查询出的访问次数获得关键字的访问次数”的过程,可以包括但不限于如下方式:确定关键字的访问次数为查询出的访问次数加预设数值;或者,获取关键字对应的资源信息,根据资源信息确定关键字的权重值,并确定关键字的访问次数为查询出的访问次数加权重值;其中,该资源信息包括关键字对应数据的数据尺寸,和/或,关键字对应请求的处理时间。In an example, the process of obtaining the number of accesses of the keyword by using the number of accesses queried may include, but is not limited to, determining that the number of accesses of the keyword is a preset value of the number of accesses queried; or Obtaining resource information corresponding to the keyword, determining a weight value of the keyword according to the resource information, and determining that the number of access times of the keyword is a weighted value of the number of times of the query; wherein the resource information includes a data size of the keyword corresponding data, and / or, the keyword corresponds to the processing time of the request.
其中,针对图4所示流程,与图2A所示流程类似,在此不再重复赘述。The flow shown in FIG. 4 is similar to the flow shown in FIG. 2A, and details are not repeated herein.
基于与上述方法同样的申请构思,参见图5所示,为另一种热点关键字获取方法的流程图,该方法可以应用于数据库服务器,且该方法可以包括:Based on the same application concept as the above method, as shown in FIG. 5, which is a flowchart of another hotspot keyword acquisition method, the method may be applied to a database server, and the method may include:
步骤501,在统计周期内,获取关键字,并获取该关键字的访问次数。Step 501: Acquire a keyword in a statistical period, and obtain the number of accesses of the keyword.
步骤502,确定该访问次数所在的访问次数区间,并查询出与该访问次数区间对应的链表;其中,不同的访问次数区间可以对应不同的链表。Step 502: Determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals may correspond to different linked lists.
步骤503,更新所述关键字的访问次数在该链表中的位置。Step 503: Update the location of the number of accesses of the keyword in the linked list.
步骤504,在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将优先级最低的链表的最后一个数据块中的内容删除;其中,优先级最低的链表是最小的访问次数区间对应的链表。 Step 504, when the content in the data block needs to be deleted, according to the correspondence between the access number interval and the linked list, query the lowest priority linked list, and delete the content in the last data block of the lowest priority linked list; The lowest priority linked list is the linked list corresponding to the smallest number of access times.
步骤505,在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Step 505: When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
在一个例子中,针对“从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字”的过程,可以包括但不限于:按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;其中,优先级最高的链表是最大的访问次数区间对应的链表,优先级最低的链表是最小的访问次数区间对应的链表;若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字;在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块。In one example, the process of "reading the number of accesses of a keyword from a linked list and determining a hotspot keyword according to the number of accesses of the keyword" may include, but is not limited to, according to the highest priority linked list to the lowest priority The sequence of the linked list sequentially traverses the data blocks of the linked list; wherein, the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the linked list corresponding to the smallest access number interval; if the traversed data block is traversed If the number of accesses of the recorded keyword is greater than the preset number threshold, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword; after traversing to the linked list that is not a hotkey keyword, stopping traversing the next one The data block of the linked list.
其中,针对图5所示流程,与图2A所示流程类似,在此不再重复赘述。The flow shown in FIG. 5 is similar to the flow shown in FIG. 2A, and details are not repeated herein.
基于与上述方法同样的申请构思,本申请实施例还提供一种热点关键字获取装置,应用于数据库服务器,如图6所示,为热点关键字获取装置的结构图。Based on the same application concept as the above method, the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 6, which is a structural diagram of a hotspot keyword acquiring apparatus.
获取模块601,用于在统计周期内,获取关键字,并获取关键字的访问次数;The obtaining module 601 is configured to acquire a keyword in a statistical period, and obtain a number of access times of the keyword;
确定模块602,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问 次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module 602, configured to determine an access number interval in which the number of accesses is located, and query a linked list corresponding to the access number interval; wherein different access times intervals correspond to different linked lists; and update the keyword The number of visits in the linked list;
所述确定模块602,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。The determining module 602 is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the keyword.
所述获取模块601,具体用于在获取所述关键字的访问次数的过程中,获取所述关键字对应的数据块位置,并从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数;The obtaining module 601 is configured to: obtain a data block location corresponding to the keyword, and query the number of accesses from the data block corresponding to the data block location in the process of acquiring the number of accesses of the keyword, And obtaining the number of accesses of the keyword by using the number of accesses queried;
其中,所述获取模块601,具体用于在获取所述关键字对应的数据块位置的过程中,通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;其中,所述哈希表用于记录关键字与数据块位置的对应关系;The obtaining module 601 is specifically configured to: when the location of the data block corresponding to the keyword is obtained, query the hash table by using the keyword to obtain a data block location corresponding to the keyword; The hash table is used to record a correspondence between a keyword and a data block position;
在利用查询出的访问次数获得所述关键字的访问次数的过程中,确定所述关键字的访问次数为查询出的访问次数加预设数值;或者,获取所述关键字对应的资源信息,并根据所述资源信息确定所述关键字的权重值,并确定所述关键字的访问次数为查询出的访问次数加所述权重值;其中,所述资源信息包括:所述关键字对应数据的数据尺寸,和/或,所述关键字对应请求的处理时间。In the process of obtaining the number of accesses of the keyword by using the number of times of the query, the number of times of accessing the keyword is determined by adding a preset value to the number of times the query is accessed; or obtaining the resource information corresponding to the keyword. And determining, according to the resource information, a weight value of the keyword, and determining that the number of accesses of the keyword is the number of accesses that are queried plus the weight value; wherein the resource information includes: the keyword corresponding data The data size, and/or, the keyword corresponds to the processing time of the request.
在一个例子中,所述热点关键字获取装置还包括(在图中未视出):In one example, the hotspot keyword acquisition means further includes (not shown in the figure):
删除模块,用于在需要删除数据块中的内容时,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;a deleting module, configured to: when the content in the data block needs to be deleted, query the lowest priority linked list, and delete the content in the last data block of the lowest priority linked list;
所述确定模块602,具体用于在根据关键字的访问次数确定热点关键字的过程中,按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字;在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块;The determining module 602 is specifically configured to: in the process of determining a hotspot keyword according to the number of accesses of the keyword, sequentially traversing the data block of the linked list according to the order of the highest priority linked list to the lowest priority linked list; if traversing If the number of accesses of the keywords recorded in the data block is greater than the preset number of thresholds, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword; after traversing to the linked list that is not a hotkey keyword, stopping Traversing the data blocks of the next linked list;
其中,所述优先级最高的链表是最大的访问次数区间对应的链表,所述优先级最低的链表是最小的访问次数区间对应的链表。The linked list with the highest priority is a linked list corresponding to the largest number of access times, and the linked list with the lowest priority is a linked list corresponding to the smallest number of access times.
基于与上述方法同样的申请构思,本申请实施例中还提供一种数据库服务器,所述数据库服务器包括:处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关 键字的访问次数确定热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword. Determining the number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; updating the number of accesses of the keywords in the linked list The location; when the hotkey keyword needs to be determined, the number of visits to the keyword is read from the linked list, and the hotkey keyword is determined according to the number of visits to the keyword.
基于与上述方法同样的申请构思,本申请实施例还提供一种机器可读存储介质,可以应用于数据库服务器,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时进行如下处理:在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed. Performing the following steps: acquiring a keyword in a statistical period, and obtaining the number of accesses of the keyword; determining a number of access times in which the number of accesses is located, and querying a linked list corresponding to the number of access times; different accesses The number of times interval corresponds to a different linked list; the number of access times of the keyword is updated in the linked list; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the number of accesses of the keyword is determined according to the number of accesses of the keyword Hot keywords.
基于与上述方法同样的申请构思,本申请实施例还提供一种热点关键字获取装置,应用于数据库服务器,如图7所示,为热点关键字获取装置的结构图。Based on the same application concept as the above method, the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 7 , which is a structural diagram of a hotspot keyword acquiring apparatus.
获取模块701,用于在统计周期内,获取关键字,通过所述关键字查询哈希表,得到对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块查询出访问次数,利用查询出的访问次数获得所述关键字的访问次数,将所述关键字的访问次数更新到所述数据块中;The obtaining module 701 is configured to: acquire a keyword in the statistical period, query the hash table by using the keyword, and obtain a corresponding data block position; the hash table is configured to record a correspondence between the keyword and the data block position; Querying the number of accesses from the data block corresponding to the data block location, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;
确定模块702,用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据读取的关键字的访问次数确定热点关键字。The determining module 702 is configured to read the number of accesses of the keyword from the linked list when the hotspot keyword needs to be determined, and determine the hotspot keyword according to the number of accesses of the read keyword.
基于与上述方法同样的申请构思,本申请实施例中还提供一种数据库服务器,所述数据库服务器包括:处理器,用于在统计周期内,获取关键字,并通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;其中,所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数,并将所述关键字的访问次数更新到所述数据块中;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and query a hash by using the keyword a table, the data block location corresponding to the keyword is obtained; wherein the hash table is used to record a correspondence between a keyword and a data block location; and the number of accesses is queried from a data block corresponding to the data block location, And obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to the data block; when the hotkey keyword needs to be determined, reading the keyword from the linked list The number of times, and the hotspot keyword is determined based on the number of visits to the keyword.
基于与上述方法同样的申请构思,本申请实施例还提供一种机器可读存储介质,可以应用于数据库服务器,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时进行如下处理:在统计周期内,获取关键字,并通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数,并将所述关键字的访问次数更新到所述数据块中;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定 热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed. Performing a process of: acquiring a keyword in a statistical period, and querying a hash table by using the keyword to obtain a data block location corresponding to the keyword; the hash table is used to record a keyword and a data block location Corresponding relationship; querying the number of accesses from the data block corresponding to the location of the data block, and obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to the data In the block; when the hotkey keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotkey keyword is determined according to the number of accesses of the keyword.
基于与上述方法同样的申请构思,本申请实施例还提供一种热点关键字获取装置,应用于数据库服务器,如图8所示,为热点关键字获取装置的结构图。Based on the same application concept as the above method, the embodiment of the present application further provides a hotspot keyword obtaining apparatus, which is applied to a database server, as shown in FIG. 8 , which is a structural diagram of a hotspot keyword acquiring apparatus.
获取模块801,用于在统计周期内,获取关键字,获取关键字的访问次数;The obtaining module 801 is configured to acquire a keyword and obtain the number of access times of the keyword in a statistical period;
确定模块802,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module 802, configured to determine an access number interval in which the number of accesses is located, and query a linked list corresponding to the access number interval; wherein different access times intervals correspond to different linked lists; and update the keyword The number of visits in the linked list;
删除模块803,用于在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,将所述优先级最低的链表的最后一个数据块中的内容删除;优先级最低的链表是最小的访问次数区间对应的链表;The deleting module 803 is configured to: when the content in the data block needs to be deleted, query the lowest priority linked list according to the correspondence between the access number interval and the linked list, and select the content in the last data block of the lowest priority linked list. Delete; the lowest priority linked list is the linked list corresponding to the smallest number of access times;
所述确定模块802,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据读取的关键字的访问次数确定热点关键字。The determining module 802 is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the read keyword.
基于与上述方法同样的申请构思,本申请实施例中还提供一种数据库服务器,所述数据库服务器包括:处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,所述优先级最低的链表是最小的访问次数区间对应的链表;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a database server, where the database server includes: a processor, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword. Determining the number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; updating the number of accesses of the keywords in the linked list Position; when the content in the data block needs to be deleted, according to the correspondence between the access number interval and the linked list, the lowest priority linked list is queried, and the content in the last data block of the lowest priority linked list is deleted; The lowest-priority linked list is a linked list corresponding to the minimum access number interval; when the hot-spot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hot-spot keyword is determined according to the number of accesses of the keyword.
基于与上述方法同样的申请构思,本申请实施例还提供一种机器可读存储介质,可以应用于数据库服务器,所述机器可读存储介质上存储有若干计算机指令,所述计算机指令被执行时进行如下处理:在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,所述优先级最低的链表是最小的访问次数区间对应的链表;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。Based on the same application concept as the above method, the embodiment of the present application further provides a machine readable storage medium, which can be applied to a database server, where the computer readable storage medium stores a plurality of computer instructions, when the computer instructions are executed. Performing the following steps: acquiring a keyword in a statistical period, and obtaining the number of accesses of the keyword; determining a number of access times in which the number of accesses is located, and querying a linked list corresponding to the number of access times; different accesses The time interval corresponds to a different linked list; the number of access times of the keyword is updated in the linked list; when the content in the data block needs to be deleted, the lowest priority linked list is searched according to the correspondence between the access number interval and the linked list And deleting the content in the last data block of the lowest priority linked list; wherein the lowest priority linked list is a linked list corresponding to the smallest access number interval; when the hotspot keyword needs to be determined, from the linked list Read the number of visits to the keyword and determine the hotspot key based on the number of visits to the keyword .
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现, 或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任意几种设备的组合。The system, device, module or unit illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product having a certain function. A typical implementation device is a computer, and the specific form of the computer may be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, and a game control. A combination of a tablet, a tablet, a wearable device, or any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described separately by function into various units. Of course, the functions of each unit may be implemented in the same software or software and/or hardware when implementing the present application.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware. Moreover, embodiments of the present application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可以由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其它可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其它可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the production of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
而且,这些计算机程序指令也可以存储在能引导计算机或其它可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或者多个流程和/或方框图一个方框或者多个方框中指定的功能。Moreover, these computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The instruction means implements the functions specified in one or more blocks of the flowchart or in a flow or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其它可编程数据处理设备上,使得在计算机或者其它可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其它可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above description is only an embodiment of the present application and is not intended to limit the application. Various changes and modifications can be made to the present application by those skilled in the art. Any modifications, equivalents, improvements, etc. made within the spirit and scope of the present application are intended to be included within the scope of the appended claims.
Claims (24)
- 一种热点关键字获取方法,其特征在于,应用于数据库服务器,包括:A hotspot keyword acquisition method, which is characterized by being applied to a database server, comprising:在统计周期内,获取关键字,并获取所述关键字的访问次数;In the statistical period, obtain a keyword and obtain the number of accesses of the keyword;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;Determining a number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists;更新所述关键字的访问次数在所述链表中的位置;Updating the location of the number of accesses of the keyword in the linked list;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- 根据权利要求1所述的方法,其特征在于,The method of claim 1 wherein所述获取所述关键字的访问次数的过程,具体包括:The process of obtaining the number of accesses of the keyword includes:获取所述关键字对应的数据块位置;Obtaining a data block location corresponding to the keyword;从所述数据块位置对应的数据块中查询出访问次数;Querying the number of accesses from the data block corresponding to the data block location;利用查询出的访问次数获得所述关键字的访问次数。The number of visits to the keyword is obtained using the number of visits queried.
- 根据权利要求2所述的方法,其特征在于,The method of claim 2 wherein:所述获取所述关键字对应的数据块位置的过程,具体包括:The process of obtaining the location of the data block corresponding to the keyword includes:通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;Querying a hash table by using the keyword to obtain a data block location corresponding to the keyword;其中,所述哈希表用于记录关键字与数据块位置的对应关系。The hash table is used to record a correspondence between a keyword and a data block position.
- 根据权利要求3所述的方法,其特征在于,The method of claim 3 wherein:所述通过所述关键字查询哈希表之后,所述方法还包括:After the hash table is queried by the keyword, the method further includes:若所述哈希表中不存在所述关键字,则为所述关键字选取数据块;If the keyword does not exist in the hash table, selecting a data block for the keyword;将所述关键字的访问次数记录到选取的数据块中,并在所述哈希表中记录所述关键字与所述选取的数据块的数据块位置的对应关系。Recording the number of accesses of the keyword into the selected data block, and recording a correspondence between the keyword and the data block position of the selected data block in the hash table.
- 根据权利要求2所述的方法,其特征在于,The method of claim 2 wherein:所述利用查询出的访问次数获得所述关键字的访问次数的过程,具体包括:The process of obtaining the number of accesses of the keyword by using the number of accesses that are queried includes:确定所述关键字的访问次数为查询出的访问次数加预设数值;或者,Determining the number of accesses of the keyword is a preset value of the number of accesses queried; or获取所述关键字对应的资源信息,并根据所述资源信息确定所述关键字的权重值,并确定所述关键字的访问次数为查询出的访问次数加所述权重值。Obtaining resource information corresponding to the keyword, and determining a weight value of the keyword according to the resource information, and determining that the number of accesses of the keyword is the number of accesses that are queried plus the weight value.
- 根据权利要求5所述的方法,其特征在于,所述资源信息包括:所述关键字对应数据的数据尺寸,和/或,所述关键字对应请求的处理时间;The method according to claim 5, wherein the resource information comprises: a data size of the keyword corresponding data, and/or a processing time of the keyword corresponding request;所述根据所述资源信息确定所述关键字的权重值的过程,具体包括:The process of determining the weight value of the keyword according to the resource information includes:根据所述数据尺寸与预设尺寸的关系,确定所述关键字的权重值;或者,Determining a weight value of the keyword according to a relationship between the data size and a preset size; or根据所述处理时间与预设时间的关系,确定所述关键字的权重值;或者,Determining a weight value of the keyword according to the relationship between the processing time and a preset time; or根据所述数据尺寸与预设尺寸的关系,确定所述关键字的第一子权重值;Determining a first sub-weight value of the keyword according to a relationship between the data size and a preset size;根据所述处理时间与预设时间的关系,确定所述关键字的第二子权重值;Determining, according to the relationship between the processing time and the preset time, a second sub-weight value of the keyword;根据所述第一子权重值和所述第二子权重值确定所述关键字的权重值。Determining a weight value of the keyword according to the first sub-weight value and the second sub-weight value.
- 根据权利要求2所述的方法,其特征在于,所述利用查询出的访问次数获得所述关键字的访问次数之后,所述方法还包括:The method according to claim 2, wherein after the obtaining the number of accesses of the keyword by using the number of accesses queried, the method further comprises:将所述关键字的访问次数更新到所述数据块位置对应的数据块中。Updating the number of accesses of the keyword to a data block corresponding to the data block location.
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:在需要删除数据块中的内容时,查询出优先级最低的链表;When the content in the data block needs to be deleted, the lowest priority list is queried;将所述优先级最低的链表的最后一个数据块中的内容删除;Deleting the content in the last data block of the lowest priority linked list;其中,优先级最低的链表是最小的访问次数区间对应的链表。Among them, the list with the lowest priority is the linked list corresponding to the smallest number of access times.
- 根据权利要求1所述的方法,其特征在于,The method of claim 1 wherein所述更新所述关键字的访问次数在所述链表中的位置的过程,具体包括:The process of updating the location of the number of accesses of the keyword in the linked list includes:将所述关键字的访问次数所在的数据块更新为所述链表的首个数据块。The data block in which the number of accesses of the keyword is located is updated to the first data block of the linked list.
- 根据权利要求1所述的方法,其特征在于,The method of claim 1 wherein所述根据关键字的访问次数确定热点关键字的过程,具体包括:The process of determining a hotspot keyword according to the number of accesses of the keyword includes:按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;其中,所述优先级最高的链表是最大的访问次数区间对应的链表,所述优先级最低的链表是最小的访问次数区间对应的链表;The data block of the linked list is sequentially traversed according to the order of the highest priority linked list to the lowest priority linked list; wherein the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the smallest a linked list corresponding to the number of access times;若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字;If the number of accesses of the keywords recorded in the traversed data block is greater than a preset number of times threshold, determining that the keyword is a hotspot keyword; otherwise, determining that the keyword is not a hotspot keyword;在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块。After traversing to the linked list that is not a hotkey keyword, stop traversing the data block of the next linked list.
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:在统计周期结束后,清除所有链表的数据块中的内容。After the statistical period ends, the contents of the data blocks of all linked lists are cleared.
- 一种热点关键字获取方法,其特征在于,应用于数据库服务器,包括:A hotspot keyword acquisition method, which is characterized by being applied to a database server, comprising:在统计周期内,获取关键字,通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;Obtaining a keyword, querying a hash table by using the keyword, and obtaining a data block location corresponding to the keyword; the hash table is configured to record a correspondence between a keyword and a data block location;从所述数据块位置对应的数据块中查询出访问次数,利用查询出的访问次数获得所述关键字的访问次数,将所述关键字的访问次数更新到所述数据块中;Querying the number of accesses from the data block corresponding to the data block location, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- 根据权利要求12所述的方法,其特征在于,The method of claim 12 wherein:所述通过所述关键字查询哈希表之后,所述方法还包括:After the hash table is queried by the keyword, the method further includes:若所述哈希表中不存在所述关键字,则为所述关键字选取数据块;If the keyword does not exist in the hash table, selecting a data block for the keyword;将所述关键字的访问次数记录到选取的数据块中,并在所述哈希表中记录所述关键字与所述选取的数据块的数据块位置的对应关系。Recording the number of accesses of the keyword into the selected data block, and recording a correspondence between the keyword and the data block position of the selected data block in the hash table.
- 根据权利要求12所述的方法,其特征在于,The method of claim 12 wherein:所述利用查询出的访问次数获得所述关键字的访问次数的过程,具体包括:The process of obtaining the number of accesses of the keyword by using the number of accesses that are queried includes:确定所述关键字的访问次数为查询出的访问次数加预设数值;或者,Determining the number of accesses of the keyword is a preset value of the number of accesses queried; or获取所述关键字对应的资源信息,根据所述资源信息确定所述关键字的权重值,并确定所述关键字的访问次数为查询出的访问次数加所述权重值;所述资源信息包括关键字对应数据的数据尺寸,和/或,关键字对应请求的处理时间。Obtaining resource information corresponding to the keyword, determining a weight value of the keyword according to the resource information, and determining that the number of accesses of the keyword is the number of accesses that are queried plus the weight value; the resource information includes The data size of the keyword corresponding data, and/or the processing time of the keyword corresponding request.
- 一种热点关键字获取方法,其特征在于,应用于数据库服务器,包括:A hotspot keyword acquisition method, which is characterized by being applied to a database server, comprising:在统计周期内,获取关键字,并获取所述关键字的访问次数;In the statistical period, obtain a keyword and obtain the number of accesses of the keyword;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;Determining a number of access times of the number of accesses, and querying a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists;更新所述关键字的访问次数在所述链表中的位置;Updating the location of the number of accesses of the keyword in the linked list;在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,优先级最低的链表是最小的访问次数区间对应的链表;When the content in the data block needs to be deleted, the linked list with the lowest priority is searched according to the correspondence between the access number interval and the linked list, and the content in the last data block of the lowest priority linked list is deleted; The lowest-level linked list is the linked list corresponding to the minimum number of access times;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。When the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- 根据权利要求15所述的方法,其特征在于,The method of claim 15 wherein:所述根据关键字的访问次数确定热点关键字的过程,具体包括:The process of determining a hotspot keyword according to the number of accesses of the keyword includes:按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;其中,所述优先级最高的链表是最大的访问次数区间对应的链表,所述优先级最低的链表是最小的访问次数区间对应的链表;The data block of the linked list is sequentially traversed according to the order of the highest priority linked list to the lowest priority linked list; wherein the highest priority linked list is the linked list corresponding to the largest access number interval, and the lowest priority linked list is the smallest a linked list corresponding to the number of access times;若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字;If the number of accesses of the keywords recorded in the traversed data block is greater than a preset number of times threshold, determining that the keyword is a hotspot keyword; otherwise, determining that the keyword is not a hotspot keyword;在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块。After traversing to the linked list that is not a hotkey keyword, stop traversing the data block of the next linked list.
- 一种热点关键字获取装置,其特征在于,应用于数据库服务器,包括:A hotspot keyword obtaining device, which is applied to a database server, and includes:获取模块,用于在统计周期内,获取关键字,获取所述关键字的访问次数;An obtaining module, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword;确定模块,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module, configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;所述确定模块,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。The determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the keyword.
- 根据权利要求17所述的装置,其特征在于,The device of claim 17 wherein:所述获取模块,具体用于在获取所述关键字的访问次数的过程中,获取所述关键字对应的数据块位置,并从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数;The obtaining module is configured to: obtain a data block position corresponding to the keyword, and query the number of accesses from the data block corresponding to the data block position in the process of acquiring the number of accesses of the keyword, and Obtaining the number of accesses of the keyword by using the number of visits queried;其中,所述获取模块,具体用于在获取所述关键字对应的数据块位置的过程中,通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;其中,所述哈希表用于记录关键字与数据块位置的对应关系;The obtaining module is specifically configured to: when the location of the data block corresponding to the keyword is obtained, query the hash table by using the keyword to obtain a data block location corresponding to the keyword; The hash table is used to record the correspondence between the keyword and the location of the data block;在利用查询出的访问次数获得所述关键字的访问次数的过程中,确定所述关键字的访问次数为查询出的访问次数加预设数值;或者,获取所述关键字对应的资源信息,并根据所述资源信息确定所述关键字的权重值,并确定所述关键字的访问次数为查询出的访问次数加所述权重值;其中,所述资源信息包括:所述关键字对应数据的数据尺寸,和/或,所述关键字对应请求的处理时间。In the process of obtaining the number of accesses of the keyword by using the number of times of the query, the number of times of accessing the keyword is determined by adding a preset value to the number of times the query is accessed; or obtaining the resource information corresponding to the keyword. And determining, according to the resource information, a weight value of the keyword, and determining that the number of accesses of the keyword is the number of accesses that are queried plus the weight value; wherein the resource information includes: the keyword corresponding data The data size, and/or, the keyword corresponds to the processing time of the request.
- 根据权利要求17所述的装置,其特征在于,还包括:The device according to claim 17, further comprising:删除模块,用于在需要删除数据块中的内容时,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;a deleting module, configured to: when the content in the data block needs to be deleted, query the lowest priority linked list, and delete the content in the last data block of the lowest priority linked list;所述确定模块,具体用于在根据关键字的访问次数确定热点关键字的过程中,按照优先级最高的链表到优先级最低的链表的顺序,依次遍历链表的数据块;若遍历到的数据块中记录的关键字的访问次数大于预设次数阈值,则确定该关键字是热点关键字;否则,确定该关键字不是热点关键字;在遍历到存在不是热点关键字的链表后,停止遍历下一个链表的数据块;The determining module is specifically configured to: in the process of determining a hotspot keyword according to the number of accesses of the keyword, sequentially traversing the data block of the linked list according to the order of the highest priority linked list to the lowest priority linked list; if the traversed data is traversed If the number of accesses of the keywords recorded in the block is greater than the preset number of thresholds, it is determined that the keyword is a hotspot keyword; otherwise, it is determined that the keyword is not a hotspot keyword; after traversing to the linked list that is not a hotkey keyword, the traversal is stopped. The data block of the next linked list;其中,所述优先级最高的链表是最大的访问次数区间对应的链表,所述优先级最低的链表是最小的访问次数区间对应的链表。The linked list with the highest priority is a linked list corresponding to the largest number of access times, and the linked list with the lowest priority is a linked list corresponding to the smallest number of access times.
- 一种热点关键字获取装置,其特征在于,应用于数据库服务器,包括:A hotspot keyword obtaining device, which is applied to a database server, and includes:获取模块,用于在统计周期内,获取关键字,通过所述关键字查询哈希表,得到对应的数据块位置;所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,利用查询出的访问次数获得所述关键字的访问次数,将所述关键字的访问次数更新到所述数据块中;An obtaining module, configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a corresponding data block position; the hash table is configured to record a correspondence between a keyword and a data block position; Querying the number of accesses in the data block corresponding to the location of the data block, obtaining the number of accesses of the keyword by using the number of accesses that are queried, and updating the number of accesses of the keyword to the data block;确定模块,用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据读取的关键字的访问次数确定热点关键字。The determining module is configured to read the number of accesses of the keyword from the linked list when the hotkey keyword needs to be determined, and determine the hotspot keyword according to the number of accesses of the read keyword.
- 一种热点关键字获取装置,其特征在于,应用于数据库服务器,包括:A hotspot keyword obtaining device, which is applied to a database server, and includes:获取模块,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;An obtaining module, configured to acquire a keyword in a statistical period, and obtain the number of accesses of the keyword;确定模块,用于确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;以及,更新所述关键字的访问次数在所述链表中的位置;a determining module, configured to determine a number of access times of the number of accesses, and query a linked list corresponding to the number of access times; wherein different access times intervals correspond to different linked lists; and update access of the keywords The number of times in the linked list;删除模块,用于在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,将所述优先级最低的链表的最后一个数据块中的内容删除;所述优先级最低的链表是最小的访问次数区间对应的链表;The deleting module is configured to: when the content in the data block needs to be deleted, query the linked list with the lowest priority according to the correspondence between the access number interval and the linked list, and delete the content in the last data block of the lowest priority linked list. The lowest priority linked list is a linked list corresponding to the smallest number of access times;所述确定模块,还用于在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据读取的关键字的访问次数确定热点关键字。The determining module is further configured to: when the hotspot keyword needs to be determined, read the number of accesses of the keyword from the linked list, and determine the hotspot keyword according to the number of accesses of the read keyword.
- 一种数据库服务器,其特征在于,所述数据库服务器包括:A database server, characterized in that the database server comprises:处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times; Different access times intervals correspond to different linked lists; update the position of the number of accesses of the keyword in the linked list; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and according to the keyword The number of visits determines the hotspot keyword.
- 一种数据库服务器,其特征在于,所述数据库服务器包括:A database server, characterized in that the database server comprises:处理器,用于在统计周期内,获取关键字,并通过所述关键字查询哈希表,得到与所述关键字对应的数据块位置;其中,所述哈希表用于记录关键字与数据块位置的对应关系;从所述数据块位置对应的数据块中查询出访问次数,并利用查询出的访问次数获得所述关键字的访问次数,并将所述关键字的访问次数更新到所述数据块中;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and query a hash table by using the keyword to obtain a data block location corresponding to the keyword; wherein the hash table is used to record a keyword and Corresponding relationship of the location of the data block; querying the number of accesses from the data block corresponding to the location of the data block, and obtaining the number of accesses of the keyword by using the number of accesses queried, and updating the number of accesses of the keyword to In the data block; when the hotspot keyword needs to be determined, the number of accesses of the keyword is read from the linked list, and the hotspot keyword is determined according to the number of accesses of the keyword.
- 一种数据库服务器,其特征在于,所述数据库服务器包括:A database server, characterized in that the database server comprises:处理器,用于在统计周期内,获取关键字,并获取所述关键字的访问次数;确定所述访问次数所在的访问次数区间,并查询出与所述访问次数区间对应的链表;其中,不同的访问次数区间对应不同的链表;更新所述关键字的访问次数在所述链表中的位置;在需要删除数据块中的内容时,根据访问次数区间与链表的对应关系,查询出优先级最低的链表,并将所述优先级最低的链表的最后一个数据块中的内容删除;其中,所述优先级最低的链表是最小的访问次数区间对应的链表;在需要确定热点关键字时,从链表中读取关键字的访问次数,并根据关键字的访问次数确定热点关键字。a processor, configured to acquire a keyword in a statistical period, and obtain a number of accesses of the keyword; determine a number of access times in which the number of accesses is located, and query a linked list corresponding to the number of access times; The different access times interval corresponds to different linked lists; the number of access times of the keywords is updated in the linked list; when the content in the data block needs to be deleted, the priority is queried according to the correspondence between the access times interval and the linked list a lowest linked list, and deleting content in a last data block of the lowest priority linked list; wherein the lowest priority linked list is a linked list corresponding to a minimum number of access times; when a hot keyword needs to be determined, The number of visits to the keyword is read from the linked list, and the hotspot keyword is determined based on the number of visits to the keyword.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710865548.6 | 2017-09-22 | ||
CN201710865548.6A CN109542612A (en) | 2017-09-22 | 2017-09-22 | A kind of hot spot keyword acquisition methods, device and server |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019056958A1 true WO2019056958A1 (en) | 2019-03-28 |
Family
ID=65810693
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/104799 WO2019056958A1 (en) | 2017-09-22 | 2018-09-10 | Trending keyword acquisition method, device and server |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109542612A (en) |
WO (1) | WO2019056958A1 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110768894B (en) * | 2019-09-02 | 2022-04-26 | 上海掌门科技有限公司 | Method and equipment for deleting session message |
CN111464629B (en) * | 2020-03-31 | 2022-08-02 | 中国建设银行股份有限公司 | Hot spot data determination method and device |
CN111355580B (en) * | 2020-05-25 | 2020-09-11 | 腾讯科技(深圳)有限公司 | Data interaction method and device based on Internet of things |
CN112487326B (en) * | 2020-11-27 | 2024-03-19 | 杭州安恒信息技术股份有限公司 | Data caching method, system, storage medium and equipment |
CN114510640A (en) * | 2022-02-17 | 2022-05-17 | 平安普惠企业管理有限公司 | Search record ordering method and device and terminal equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103178989A (en) * | 2013-02-18 | 2013-06-26 | 中兴通讯股份有限公司 | Method and device for calculating visit hotness |
CN103559313A (en) * | 2013-11-20 | 2014-02-05 | 北京奇虎科技有限公司 | Searching method and device |
US20140351255A1 (en) * | 2012-08-07 | 2014-11-27 | Naver Corporation | Method and system for recommending keyword based on semantic area |
CN104750873A (en) * | 2015-04-22 | 2015-07-01 | 百度在线网络技术(北京)有限公司 | Popular search term push method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102937993B (en) * | 2012-11-09 | 2016-01-06 | 小米科技有限责任公司 | A kind of method for access key and device |
US10545956B2 (en) * | 2015-06-05 | 2020-01-28 | Insight Engines, Inc. | Natural language search with semantic mapping and classification |
-
2017
- 2017-09-22 CN CN201710865548.6A patent/CN109542612A/en active Pending
-
2018
- 2018-09-10 WO PCT/CN2018/104799 patent/WO2019056958A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140351255A1 (en) * | 2012-08-07 | 2014-11-27 | Naver Corporation | Method and system for recommending keyword based on semantic area |
CN103178989A (en) * | 2013-02-18 | 2013-06-26 | 中兴通讯股份有限公司 | Method and device for calculating visit hotness |
CN103559313A (en) * | 2013-11-20 | 2014-02-05 | 北京奇虎科技有限公司 | Searching method and device |
CN104750873A (en) * | 2015-04-22 | 2015-07-01 | 百度在线网络技术(北京)有限公司 | Popular search term push method and device |
Also Published As
Publication number | Publication date |
---|---|
CN109542612A (en) | 2019-03-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019056958A1 (en) | Trending keyword acquisition method, device and server | |
US10176057B2 (en) | Multi-lock caches | |
CN110109953B (en) | Data query method, device and equipment | |
US10198363B2 (en) | Reducing data I/O using in-memory data structures | |
WO2021008311A1 (en) | Method and apparatus for accessing hybrid cache in electronic device | |
US10275489B1 (en) | Binary encoding-based optimizations at datastore accelerators | |
US9229869B1 (en) | Multi-lock caches | |
CN108683695A (en) | Hot spot access processing method, cache access agent equipment and distributed cache system | |
Ma et al. | An improved web cache replacement algorithm based on weighting and cost | |
CN110798332B (en) | Method and system for searching directory access groups | |
CN106528451A (en) | Cloud storage framework for second level cache prefetching for small files and construction method thereof | |
CN114138840B (en) | Data query method, device, equipment and storage medium | |
CN117539915B (en) | Data processing method and related device | |
Pan et al. | Penalty-and locality-aware memory allocation in Redis using enhanced AET | |
JP7192645B2 (en) | Information processing device, distributed processing system and distributed processing program | |
US10146833B1 (en) | Write-back techniques at datastore accelerators | |
WO2024114497A1 (en) | Hot and cold page management acceleration device and method, mmu, processor, and electronic device | |
JP6406254B2 (en) | Storage device, data access method, and data access program | |
CN109844723B (en) | Method and system for master control establishment using service-based statistics | |
WO2021008301A1 (en) | Method and apparatus for accessing hybrid cache in electronic device | |
US11269784B1 (en) | System and methods for efficient caching in a distributed environment | |
CN114390069B (en) | Data access method, system, equipment and storage medium based on distributed cache | |
CN110334073A (en) | A kind of metadata forecasting method, device, terminal, server and storage medium | |
US12008041B2 (en) | Shared cache for multiple index services in nonrelational databases | |
Song et al. | A Novel Hot-cold Data Identification Mechanism Based on Multidimensional Data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18858827 Country of ref document: EP Kind code of ref document: A1 |