WO2013167080A2 - 一种存储信息的处理方法及装置 - Google Patents

一种存储信息的处理方法及装置 Download PDF

Info

Publication number
WO2013167080A2
WO2013167080A2 PCT/CN2013/080072 CN2013080072W WO2013167080A2 WO 2013167080 A2 WO2013167080 A2 WO 2013167080A2 CN 2013080072 W CN2013080072 W CN 2013080072W WO 2013167080 A2 WO2013167080 A2 WO 2013167080A2
Authority
WO
WIPO (PCT)
Prior art keywords
hash value
type
target data
index
node
Prior art date
Application number
PCT/CN2013/080072
Other languages
English (en)
French (fr)
Other versions
WO2013167080A3 (zh
Inventor
郭帅
王立
魏红泼
罗迤宝
马海蓉
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2013167080A2 publication Critical patent/WO2013167080A2/zh
Publication of WO2013167080A3 publication Critical patent/WO2013167080A3/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9027Trees

Definitions

  • the present invention relates to the field of information management, and in particular, to a method and an apparatus for processing stored information. Background technique
  • NFC technology evolved from the combination of non-contact radio frequency identification (RFID) technology and point-to-point communication technology. It operates in the 13.56MHz frequency range from 0 to 20cm, and is 106kbit/s, 212kbit/s, and 424kbit/s. The transmission rate is for data transmission and can be automatically switched between different transmission rates.
  • RFID technology complies with ISO 18092, IS021481, ECMA (340, 352 and 356) and ETSITS102 standards, and is also compatible with the IS014441A-based inductive smart card infrastructure.
  • NFC Application Middleware is a stand-alone system software or service program that combines the underlying NFC hardware with the specific application of the upper layer.
  • a common set of application interfaces provided by the middleware is used on the application side of the NFC application system. , you can access the NFC reader and read NFC data, effectively shielding the differences between devices.
  • the data management module of the NFC application middleware system needs to store and manage a large number of temporary NFC data records, and for the NFC middleware system, the execution efficiency of the data management module is related to the performance of the entire system. Therefore, an efficient indexing method is needed for the data management module to speed up system throughput and improve storage space management efficiency.
  • the tree structure index is the most popular index structure currently used in massive data management systems.
  • the AVL tree, B-tree, and T-tree are the three most common index structures in the tree structure index.
  • most of these index structures are designed for disk indexing, and are not optimized for NFC data characteristics, and it is difficult to meet the requirements of NFC middleware for high-speed data access. Therefore, it is necessary to design a lightweight and efficient data index structure for the characteristics of NFC data. Summary of the invention
  • the technical problem to be solved by the embodiments of the present invention is to provide a method and a device for processing stored information, which can improve the processing efficiency of the stored information, thereby improving the throughput of the data information.
  • an embodiment of the present invention provides a method for processing data storage information, including:
  • the storage information of the target data is processed based on the primary index and the secondary index.
  • the step of processing the storage information of the target data according to the primary index and the secondary index includes:
  • Finding the secondary index according to a characteristic condition in the primary index saving storage information of the target data into the secondary index;
  • the secondary index is found based on a characteristic condition in the primary index, and the storage information of the target data is queried in the secondary index.
  • the step of finding the secondary index according to the feature condition in the primary index, and storing the storage information of the target data into the secondary index includes:
  • the step of saving the second type of hash value of the target data to the secondary index includes:
  • A2 determining whether the second type of hash value of the target data belongs to a threshold range of the current node; if yes, performing A3; if not, performing A9;
  • A3 determining whether the storage quantity of the current node reaches a preset upper limit; if the preset upper limit is not reached, performing A4; if the preset upper limit is reached, performing A6;
  • A7 saving the second type of hash value of the target data to the current node, extracting a minimum second type hash value of the current node, and waiting for the extracted minimum second type hash value
  • the saved second type of hash value with the root node of the left subtree of the current node as the new current node, returns to A2, and saves the second type of hash value to be saved;
  • A8 save the second type of hash value of the target data to the current node, generate a new left subtree at its current node, extract the minimum second type hash value of the current node, and save to In the new left subtree, the left subtree is the new current node; then returns to A5;
  • A9 determining whether the second type of hash value of the target data is greater than a threshold range of the current node; if greater than, performing A10; otherwise, performing A12;
  • A10 determining whether the current node has a right subtree; if yes, taking the right subtree as a new current node and returning to A2; otherwise, performing Al1;
  • step A12 determining whether the current node has a left subtree; if yes, taking the subtree as a new current node, and returning to step A2; otherwise, returning to step Al1.
  • the step of finding the secondary index according to the feature condition in the primary index, and querying the storage information of the target data in the secondary index includes:
  • B10 the query failed;
  • Bl l determine whether the current node is a leaf node; if yes, proceed to B10; if not, proceed to B12;
  • B12 determining whether the second hash value of the target data is greater than a threshold range of the current node; if greater than, then proceeding to B13; if less than, performing B14;
  • B15 selecting the root node of the right subtree of the current node as the new current node; then returning to B7; B14, determining whether the current node has a left subtree; if so, proceeding to B17; if not, returning
  • B17 Select the root node of the left subtree of the current node as the new current node; then return to B7. Wherein, if the height difference between the left sub-tree and the right sub-tree of the same node in the secondary index exceeds the range of the preset balance factor, the secondary cable I is rotated.
  • the embodiment of the present invention further provides a data storage information processing apparatus, including: a first establishing module configured to establish a primary index, and storing a characteristic condition of the data; and a second establishing module configured to be configured for the primary index
  • the condition establishes a primary level index, wherein the secondary index is a binary tree structure, and the storage information of the data is saved to the secondary index, and the left subtree of one node only stores the storage information smaller than the threshold range of the node.
  • the right subtree only stores storage information larger than the threshold range of the node;
  • the processing module is configured to process the storage information of the target data according to the primary index and the secondary index.
  • the processing module further includes:
  • a saving unit configured to: find the secondary index according to a feature condition in the primary index, save storage information of the target data into the secondary index; and/or
  • the query unit finds the secondary index according to the feature condition in the primary index, and queries the storage information of the target data in the secondary index.
  • the device of the embodiment of the present invention further includes:
  • the characteristic condition is a first type of hash value calculated by reading time of the data and/or publisher information; the storage information is a second type of hash value calculated according to content of the data;
  • the threshold range is the minimum second type of hash value saved to the maximum second type of hash value after the storage information of one node reaches the preset upper limit in the secondary index.
  • the saving unit is specifically configured to:
  • a rotation module configured to perform a rotation operation on the secondary index if a height difference between a left sub-tree and a right sub-tree of the same node in the secondary index exceeds a preset balance factor.
  • the secondary index When processing the stored information of the data (such as searching or saving), the secondary index can be found in the primary index by the characteristic condition of the data, and since the secondary index adopts a binary tree structure, the left child in one node The tree only stores the storage information smaller than the threshold range of the node, and the right subtree only stores the storage information larger than the threshold range of the node. Therefore, it is only necessary to determine the threshold range of each node, so that the storage information needs to be saved in the secondary index. The location or the location that has been saved, which greatly improves the processing efficiency of the stored information and the throughput of the data. BRIEF DESCRIPTION OF DRAWINGS FIG.
  • FIG. 1 is a schematic diagram showing the steps of a method for processing data storage information according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram showing a relationship between a primary index and a secondary index according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram showing the steps of storing the storage information of the target data in the embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of the apparatus for processing data storage information according to the embodiment of the present invention.
  • An embodiment of the present invention provides a method for processing data storage information. As shown in FIG. 1, the method includes the following steps:
  • Step 1 establishing a primary index for storing characteristic conditions of the data
  • Step 2 Establish a primary level index for storing the storage information of the data to the secondary index, where the secondary index is a binary tree structure, and the left side of one node The subtree only stores storage information smaller than the threshold range of the node, and the right subtree only stores storage information larger than the threshold range of the node;
  • Step 3 processing the storage information of the target data according to the primary index and the secondary index.
  • step 3 when processing the stored information of the data (such as searching or saving), the secondary index can be found in the primary index by the characteristic condition of the data, and since the secondary index adopts a binary tree structure, one node thereof The left subtree only stores the storage information smaller than the threshold range of the node, and the right subtree only stores the storage information larger than the threshold range of the node. Therefore, it is only necessary to determine the threshold range of each node, so that the storage information needs to be in the secondary. The location to be saved in the index or the location that has been saved, which greatly improves the processing efficiency of the stored information and the throughput of the data.
  • step 3 may further include:
  • Step A Find the secondary index according to a characteristic condition in the primary index, and save storage information of the target data into the secondary index;
  • Step B Find the secondary index according to the feature condition in the primary index, and query the storage information of the target data in the secondary index.
  • the first type of hash value; the storage information is a second type of hash value calculated according to the content of the data; the threshold range is the secondary index, after the storage information of one node reaches a preset upper limit , the smallest second type of hash value saved to the largest second type of hash value.
  • step A includes:
  • the step of saving the second type of hash value of the target data to the secondary index comprises:
  • A2 determining whether the second type of hash value of the target data belongs to a threshold range of the current node; if yes, performing A3; if not, performing A9;
  • A3 determining whether the storage quantity of the current node reaches a preset upper limit; if the preset upper limit is not reached, performing A4; if the preset upper limit is reached, performing A6; A4, saving a second type of hash value of the target data to the current node;
  • A7 saving the second type of hash value of the target data to the current node, extracting a minimum second type hash value of the current node, and waiting for the extracted minimum second type hash value
  • the saved second type of hash value with the root node of the left subtree of the current node as the new current node, returns to A2, and saves the second type of hash value to be saved;
  • A8 save the second type of hash value of the target data to the current node, generate a new left subtree at its current node, extract the minimum second type hash value of the current node, and save it to the In the new left subtree, the left subtree is the new current node; then return to A5;
  • A9 determining whether the second type of hash value of the target data is greater than a threshold range of the current node; if greater than, performing A10; otherwise, performing A12;
  • A10 determining whether the current node has a right subtree; if yes, taking the right subtree as a new current node and returning to A2; otherwise, performing All;
  • A12 Determine whether the current node has a left subtree; if yes, use the subtree as a new current node, and return to step A2; otherwise, return to step All.
  • step B includes:
  • B3 searching, in the primary index, a hash value that is the same as the first type of hash value of the target data; B4, determining a result of the searching; if the primary index includes a hash value equal to the first type of hash value of the target data, performing B6; if not, the query fails;
  • B11 determining whether the current node is a leaf node; if yes, proceeding to B10; if not, proceeding to B12;
  • B12 determining whether the second hash value of the target data is greater than a threshold range of the current node; if greater than, then proceeding to B13; if less than, performing B14;
  • B15 selecting the root node of the right subtree of the current node as the new current node; then returning to B7; B14, determining whether the current node has a left subtree; if so, proceeding to B17; if not, returning
  • B17 Select the root node of the left subtree of the current node as the new current node; then return to B7. Considering that if the data stored in the secondary index is deleted, the binary tree structure may not be balanced, so
  • the method may further include:
  • Step 4 If the height difference between the left sub-tree and the right sub-tree of the same node in the secondary index exceeds a range of a preset balance factor, perform a rotation operation on the secondary index.
  • the first part of the information is the characteristic condition of the data, including the reading time of the data and/or the publisher information; the second part of the information is the content of the data.
  • the hash value is defined as the first type of hash value (ie, the primary encoding); the second type of hash value calculated according to the second part of information (ie, the second Level coding).
  • a primary index is first constructed to hold the primary encoding of each data; then a secondary index is constructed for each primary encoding; it should be noted that because the amount of data stored is extremely large, it may be the same publisher and / Or if there is multiple data in the same reading time (that is, the primary encoding is the same), then the secondary encoding of the data is shared by one primary encoding, and the secondary encoding al-an as shown in FIG. 2 is saved in correspondence with the primary encoding 2. In the secondary index.
  • the storage information of the target data can be processed.
  • Step 301 First, information that the user needs to input the target data when searching is obtained;
  • Step 302 using primary coding and secondary coding of the target data of the SHA1 algorithm;
  • Step 303 performing a binary search in the primary index;
  • Step 304 Determine the result of the binary search; if there is a hash value in the primary index table that is the same as the primary code, go to step 306; otherwise, go to step 305, and the query fails;
  • Step 306 Enter a secondary index corresponding to the primary encoding, and start to query a second type of hash value corresponding to the secondary encoding at a root node of the secondary index table.
  • Step 307 determining whether the second type of hash value corresponding to the secondary code is within the range of the hash value possessed by the root node; if it is within the range, proceeding to step 308, otherwise proceeding to step 311;
  • Step 308 further determining whether the node has a hash value equal to the primary encoding. If yes, proceed to step 309, the query is successful; if not, proceed to step 310, the query fails; Step 311: Determine whether the current node is a leaf node of a binary tree. If yes, proceed to step 310, the query fails; if not, proceed to step 312;
  • Step 312 Determine whether the second type of hash value corresponding to the secondary code is greater than the largest second type of hash value saved by the current node. If yes, go to step 313, otherwise go to step 314;
  • Step 313 Determine whether the current node has a right subtree. If yes, go to step 315; otherwise, go to step 316 and the query fails;
  • Step 315 since the right subtree of the node in the binary tree only contains a record larger than the maximum hash value of the node, the root node of the right subtree of the current node is selected as the new current node, and the second type of hash saved from the node is selected. Continue the query in the value;
  • Step 314 Determine whether the current node has a left subtree. If yes, go to step 317; otherwise, go to step 316 and the query fails;
  • Step 317 Since the left subtree of the node in the binary tree only contains a record smaller than the minimum hash value of the node, the root node of the left subtree of the current node is selected as the new current node, and the second type of hash saved from the node is selected. Continue the query in the value;
  • step 315 and step 317 repeat the loop of step 307 to step 313 and steps 307 to 314 until the query is successful or the query fails.
  • Step 401 Acquire an instruction for searching for the target data storage information
  • Step 402 Calculate a primary encoding and a secondary encoding of the target data by using the SHA1 algorithm.
  • Step 403 Perform a binary search in the primary index. If there is no hash value identical to the primary encoding of the target data, proceed to step 404, otherwise enter the step. 407;
  • Step 404 insert the primary code of the target data into the primary index, and create a new secondary index corresponding thereto, proceeds to step 405;
  • Step 405 a new root node is created, the secondary code of the target data is inserted into the secondary index table as the hash value of the root node, and the addition of the secondary index record is completed, and the process proceeds to step 406;
  • the secondary index table is a balanced binary tree structure, the addition of the record causes the binary tree to be unbalanced, so the rotation operation needs to be performed at this step. Since the rotation operation belongs to the basic content in the balanced binary tree, it will not be described in detail in the embodiment of the present invention; after the rotation operation is completed, the process proceeds to step 420, and the entire adding process ends; and the query starts from the root node of the secondary index.
  • Step 408 determining whether the hash value of the secondary code of the target data is within the range of the hash value possessed by the root node, that is, whether: the minimum hash value target of the node The secondary encoding of the data encodes the maximum hash value of the node; if not, the process proceeds to step 409, otherwise proceeds to step 414; Step 409, it is determined whether there is sufficient storage space in the node; , that is, it is judged whether the number of the second type of hash values saved by the node is satisfied ⁇ 50; if yes, the process proceeds to step 410; otherwise, the process proceeds to step 411;
  • Step 410 Perform a binary search in the hash value of the current node, find a location of the secondary code that should be inserted into the target data, and insert the secondary code; after the insertion, all the hash values of the node may remain small to large. Arrange; after the insertion is completed, proceed to step 406 to perform a rotation operation to complete the entire adding process;
  • Step 411 it is determined whether the current node has a left subtree, if there is a left subtree, then proceeds to step 412, otherwise proceeds to step 413;
  • Step 412 Perform a binary search in the second type of hash value of the current node, find a location of the secondary code that should be inserted into the target data, and insert the secondary code; after the insertion, all the hash values of the node remain small.
  • the node After the insertion, the node has 51 hashes, and a node can only store 50 hashes, so a replacement operation is required, which is to extract the current minimum hash value of the node; Among the hash values stored in the current node, the smallest hash value becomes the lower limit of the node's new threshold range (ie, the minimum hash value); the hash value just extracted is used as the new secondary code to be saved, to the current The root node of the node's left subtree as the new current section Point, restart the process of inserting the secondary code to be saved, and proceed to step 408; the replacement operation is equivalent to the secondary of the target data if the second type of hash value of the current node has reached the preset upper limit
  • the code inserts this node, then inserts the smallest second type of hash in the node into the left subtree of the node, and so on, and restarts the recursive insert operation; Step 413, the hash value of the current node Find
  • Step 414 determining the secondary of the target data Greater than the maximum value of the hash code whether the current node; if yes, proceeds to step 415, otherwise, proceed to step 417;
  • Step 415 determining whether the current node has a right subtree, if yes, proceeding to step 416, otherwise proceeding to step 419;
  • Step 416 since the right subtree of the node only contains the record whose hash value is greater than the maximum hash value of the node, the root node of the right subtree of the current node is taken as the new current node, and the process proceeds to step 408 to restart the recursive insertion.
  • Step 417 determining whether the current node has a left subtree, if yes, proceeding to step 418, otherwise proceeding to step 419;
  • step 418 since the left subtree of the node only contains the record whose hash value is smaller than the minimum hash value of the node, the root node of the left subtree of the current node is taken as the new current node, and the process proceeds to step 408 to restart the recursion. Insert operation
  • step 419 it is judged whether there is enough storage space in the node, that is, whether the number of the second type of hash values saved by the node is satisfied ⁇ 50; if yes, the process proceeds to step 410, otherwise, the process proceeds to step 413.
  • the storage letter in the secondary index may also be deleted.
  • the information is deleted, but this will cause the secondary index to be unbalanced. Therefore, a balance factor B can be set for each node to indicate the height difference between the left and right subtrees of the node, that is, left. The height of the subtree minus the result of the height of the right subtree. If the B values on all nodes are -1, 0, 1, the binary tree is balanced; if there is a node with
  • > 2, the secondary index is not a balanced binary tree structure and needs to be rotated.
  • the secondary index can be found in the primary index by the characteristic condition of the data, and due to the secondary index
  • the left subtree in one node only stores the storage information smaller than the threshold range of the node
  • the right subtree only stores the storage information larger than the threshold range of the node, so only the threshold range of each node needs to be determined, Determining where the storage information needs to be saved in the secondary index or the location that has been saved, thereby greatly improving the processing efficiency of the stored information and the throughput of the data; in addition, the storage information of the data having the same characteristic condition is shared by the same
  • the primary index further speeds up the storage and query time of the stored information; in addition, the balance factor is preset to the secondary index, and the secondary index exceeding the preset balance factor is rotated to maintain the balance of the secondary index.
  • an embodiment of the present invention further provides a data storage information processing apparatus, including:
  • a first establishing module configured to establish a primary index, and storing a characteristic condition of the data
  • the second establishing module configured to establish a primary index for the characteristic condition of the primary index, where the secondary index is a binary tree structure,
  • the storage information of the data is sent to the secondary index, and the left subtree of one node only stores the storage information smaller than the threshold range of the node, and the right subtree only stores the storage information larger than the threshold range of the node;
  • the processing module is configured to process the storage information of the target data according to the primary index and the secondary index.
  • the secondary index is found in the primary index by the characteristic condition of the data, and since the secondary index adopts a binary tree structure, the left subtree in one node only stores the storage information smaller than the threshold range of the node, and the right subtree only saves greater than
  • the node threshold range stores information, so only the threshold range of each node needs to be determined, and the location where the storage information needs to be saved in the secondary index or the saved location is determined, thereby greatly improving the processing of the stored information. Efficiency and throughput of data.
  • the processing module further includes:
  • a saving unit configured to: find the secondary index according to a feature condition in the primary index, save storage information of the target data into the secondary index; and/or
  • a query unit searching for the secondary index according to a feature condition in the primary index, querying, in the secondary index, storage information of the target data; a first type of hash value; the storage information is based on data a second type of hash value calculated by the content; the threshold range is a minimum second type of hash value saved to a maximum second after the storage information of one node reaches a preset upper limit in the secondary index Class hash value;
  • the saving unit is specifically configured to:
  • A2 determining whether the second type of hash value of the target data belongs to a threshold range of the current node; if yes, performing A3; if not, performing A9;
  • A3 determining whether the storage quantity of the current node reaches a preset upper limit; if the preset upper limit is not reached, performing A4; if the preset upper limit is reached, performing A6;
  • A7 saving the second type of hash value of the target data to the current node, extracting a minimum second type hash value of the current node, and waiting for the extracted minimum second type hash value
  • the saved second type of hash value with the root node of the left subtree of the current node as the new current node, returns to A2, and saves the second type of hash value to be saved;
  • A8 save the second type of hash value of the target data to the current node, generate a new left subtree at its current node, extract the minimum second type hash value of the current node, and save it to the In the new left subtree, the left subtree is the new current node; then return to A5;
  • A9 determining whether the second type of hash value of the target data is greater than a threshold range of the current node; if greater than, performing A10; otherwise, performing A12;
  • A10 determining whether the current node has a right subtree; if yes, taking the right subtree as a new current node and returning to A2; otherwise, performing All;
  • A12 determining whether the current node has a left subtree; if yes, taking the subtree as a new current node, and returning to step A2; otherwise, returning to step All.
  • the following steps are performed for the query unit to find the secondary index according to the feature condition in the primary index, and the step of querying the storage information of the target data in the secondary index is described in detail:
  • B8 further determining whether the current node has a hash value equal to the second hash value of the target data; if yes, performing B9, the query is successful; if not, performing B10, the query fails; B11, determining current Whether the node is a leaf node; if yes, proceed to B10, the query fails; if not, proceed to B2;
  • B12 determining whether the second hash value of the target data is greater than a threshold range of the current node; if greater than, then proceeding to B13; if less than, performing B14;
  • the device may further include:
  • a rotation unit configured to rotate the secondary index if the height difference between the left sub-tree and the right sub-tree of the same node in the secondary index exceeds a preset balance factor, thereby maintaining the secondary index balance.
  • the above embodiment is an apparatus embodiment corresponding to a method for processing data storage information according to the present invention.
  • the technical effect achieved by the method for processing the data storage information can also be achieved by the apparatus of the embodiment.
  • the secondary index when the storage information of the data is processed (such as searching or saving), the secondary index can be found in the primary index by the characteristic condition of the data, and since the secondary index adopts a binary tree structure, one node thereof
  • the left subtree only stores the storage information smaller than the threshold range of the node
  • the right subtree only stores the storage information larger than the threshold range of the node. Therefore, it is only necessary to determine the threshold range of each node, so that the storage information needs to be in the secondary.
  • the location to be saved in the index or the location that has been saved which greatly improves the processing efficiency of the stored information and the throughput of the data.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供了一种数据存储信息的处理方法及装置,涉及信息管理领域。方法包括:建立一初级索引,用于保存数据的特征条件;建立一初级索引,用于保存数据的特征条件;针对所述初级索引的特征条件建立一次级索引,用于保存所述数据的存储信息至所述次级索引中;其中,所述次级索引为二叉树结构,其一个节点中的左子树只保存小于该节点门限范围的存储信息,右子树只保存大于该节点门限范围的存储信息;根据所述初级索引以及所述次级索引,对目标数据的存储信息进行处理。采用本发明的方法及装置,为存储信息提供了高效率的索引方式,从而提高数据信息的吞吐。

Description

一种存储信息的处理方法及装置 技术领域
本发明涉及信息管理领域, 尤其涉及一种存储信息的处理方法及装置。 背景技术
NFC技术由非接触式射频识别 (RFID, Radio Frequency Identification ) 技术和点对点通信技术融合演变而来, 在 0到 20cm距离内工作于 13.56MHz 频率范围, 以 106kbit/s、 212kbit/s、 424kbit/s的传输速率进行数据传输, 并 可以在不同的传输速率之间自动切换。 NFC技术符合 ISO 18092、 IS021481、 ECMA ( 340、 352和 356 )及 ETSITS102标准, 同时也兼容以 IS014441A为 基础的感应式智能卡基础架构。
NFC应用中间件是一种独立的系统软件或服务程序, 负责将底层 NFC 硬件和上层不同的具体应用结合在一起, 在 NFC应用系统的应用程序端使 用中间件提供的一组通用的应用程序接口,即可访问 NFC阅读器并进行 NFC 数据的读取, 有效地屏蔽设备间的差异性。 NFC应用中间件系统的数据管 理模块需要存储和管理大量的临时 NFC数据记录, 而且对于 NFC中间件系 统来说, 数据管理模块的执行效率关系到整个系统的性能。 因此, 需要为 数据管理模块设计高效的索引方式, 以加快系统吞吐率, 提高存储空间的 管理效率。
传统的中间件系统中, 树结构索引是目前应用在海量数据管理系统中 最流行的索引结构, AVL树、 B-树、 T树是树结构索引中最常见的三种索 引结构。 但是这些索引结构大多是针对磁盘索引而设计, 也没有针对 NFC 的数据特点进行优化, 难以满足 NFC中间件对高速数据存取的要求。 因此, 需要针对 NFC数据的特点, 设计一种轻量, 高效的数据索引结构。 发明内容
本发明实施例要解决的技术问题是提供一种存储信息的处理方法及装 置, 能够提高存储信息的处理效率, 从而提高数据信息的吞吐率。
为解决上述技术问题, 本发明实施例提供了一种数据存储信息的处理 方法, 包括:
建立一初级索引, 用于保存数据的特征条件;
针对所述初级索引的特征条件建立一次级索引, 用于保存所述数据的 存储信息至所述次级索引中; 其中, 所述次级索引为二叉树结构, 其一个 节点中的左子树只保存小于该节点门限范围的存储信息, 右子树只保存大 于该节点门限范围的存储信息;
根据所述初级索引以及所述次级索引, 对目标数据的存储信息进行处 理。
其中, 根据所述初级索引以及所述次级索引, 对目标数据的存储信息 进行处理的步骤包括:
根据所述初级索引中的特征条件找到所述次级索引, 将所述目标数据 的存储信息保存进所述次级索引中; 和 /或
根据所述初级索引中的特征条件找到所述次级索引, 在所述次级索引 中查询所述目标数据的存储信息。 的第一类哈希值; 所述存储信息为根据数据的内容计算得出的第二类哈希 值; 所述门限范围为所述次级索引中, 一个节点的存储信息达到预设上限 后, 所保存的最小第二类哈希值到最大第二类哈希值。
其中, 根据所述初级索引中的特征条件找到所述次级索引, 将所述目 标数据的存储信息保存进所述次级索引中的步骤包括:
计算目标数据的第一类哈希值与第二类哈希值; 判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
其中, 将所述目标数据的第二类哈希值保存至该次级索引中的步骤包 括:
A1 , 以次级索引中根节点为当前节点;
A2, 判断所述目标数据的第二类哈希值是否属于所述当前节点的门限 范围; 若属于, 则进行 A3; 若不属于则进行 A9;
A3 , 判断该当前节点的存储数量是否达到预设上限; 若未达到预设上 限, 则进行 A4; 若达到预设上限, 则进行 A6;
A4, 将所述目标数据的第二类哈希值保存至所述当前节点; 之后进行
A5;
A5 , 根据二叉树平衡特性对次级索引进行旋转, 并结束;
A6, 判断所述当前节点是否含有还有左子树; 若含有, 则以该左子树 为当前节点, 并进行 A7; 若未含有, 则进行 A8;
A7, 将所述目标数据的第二类哈希值保存至当前节点中, 将当前节点 的最小第二类哈希值提取出, 并以所述提取出的最小第二类哈希值为待保 存的第二类哈希值, 以当前节点的左子树的根节点作为新的当前节点, 重 新回到 A2, 保存所述待保存的第二类哈希值;
A8, 将所述目标数据的第二类哈希值保存至当前节点中, 在其当前节 点生成一新的左子树, 将当前节点的最小第二类哈希值提取出, 并保存至 所述新的左子树中, 以该左子树为新的当前节点; 之后回到 A5;
A9,判断所述目标数据的第二类哈希值是否大于当前节点的门限范围; 若大于, 则进行 A10; 否, 则进行 A12;
A10,判断当前节点是否有右子树;是,则以该右子树为新的当前节点, 并回到 A2; 否, 则进行 Al l ;
Al l , 判断当前节点的是否达到所述预设上限; 否, 则回到步骤 A4; 是, 则回到步骤 A8;
A12 ,判断当前节点是否有左子树;是,则以该做子树为新的当前节点, 并回到步骤 A2; 否, 则回到步骤 Al l。
其中, 根据所述初级索引中的特征条件找到所述次级索引, 在所述次 级索引中查询所述目标数据的存储信息的步骤包括:
B1, 获取查找目标数据存储信息的指令;
B2, 计算所述目标数据的第一类哈希值和第二类哈希值;
B3, 在所述初级索引中搜索与所述目标数据的第一类哈希值相同的哈 希值;
B4, 对查找的结果进行判断; 若所述初级索引中包含与所述目标数据 的第一类哈希值相等的哈希值, 则进行 B6; 否, 则查询失败;
B6, 进入与所述目标数据的第一类哈希值对应的次级索引, 以次级索 引的根节点为当前节点, 开始查询所述目标数据的第二类哈希值;
B7 ,判断所述目标数据的第二哈希值是否属于当前节点的门限范围内; 若属于, 则进行 B8; 若不属于, 则进行 B11 ;
B8, 进一步判断当前节点是否拥有与所述目标数据的第二哈希值相等 的哈希值; 若有, 则进行 B9; 若无, 则进行 B10;
B9, 查询成功;
B10, 查询失败; Bl l , 判断当前节点是不是叶子节点; 若是, 则进行 B10; 若不是, 则 进行 B12;
B12 , 判断所述目标数据的第二哈希值是否大于当前节点的门限范围; 若大于, 是则进行 B13; 若小于, 则进行 B14;
B13 , 判断当前节点是否有右子树; 若有, 则进行 B15; 若没有, 则进 行 B10;
B15,选择当前节点的右子树的根节点作为新的当前节点;之后回到 B7; B14, 判断当前节点是否有左子树; 若有, 则进行 B17; 若没有, 回到
B10;
B17,选择当前节点的左子树的根节点作为新的当前节点;之后回到 B7。 其中, 若所述次级索引中的同一节点的左子树与右子树的高度差超出 预设平衡因子的范围, 对所述次级索弓 I进行旋转操作。
本发明实施例还提供了一种数据存储信息的处理装置, 包括: 第一建立模块, 配置为建立一初级索引, 保存数据的特征条件; 第二建立模块, 配置为针对所述初级索引的特征条件建立一次级索引, 其中所述次级索引为二叉树结构, 保存所述数据的存储信息至所述次级索 引中, 其一个节点中的左子树只保存小于该节点门限范围的存储信息, 右 子树只保存大于该节点门限范围的存储信息;
处理模块, 配置为根据所述初级索引以及所述次级索引, 对目标数据 的存储信息进行处理。
其中, 所述处理模块还包括:
保存单元, 配置为根据所述初级索引中的特征条件找到所述次级索引, 将所述目标数据的存储信息保存进所述次级索引中; 和 /或
查询单元, 根据所述初级索引中的特征条件找到所述次级索引, 在所 述次级索引中查询所述目标数据的存储信息。 其中, 本发明实施例的装置还包括:
所述特征条件为通过数据的读取时间和 /或发布者信息计算得出的第一 类哈希值; 所述存储信息为根据数据的内容计算得出的第二类哈希值; 所 述门限范围为所述次级索引中, 一个节点的存储信息达到预设上限后, 所 保存的最小第二类哈希值到最大第二类哈希值。
其中, 所述保存单元具体配置为:
计算目标数据的第一类哈希值与第二类哈希值;
判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
其中, 本发明实施例的装置包括:
旋转模块, 配置为若所述次级索引中的同一节点的左子树与右子树的 高度差超出预设平衡因子的范围, 对所述次级索引进行旋转操作。
本发明实施例的上述技术方案的有益效果如下:
在对数据的存储信息进行处理时(如进行查找或保存), 能够通过数据 的特征条件在初级索引中找到次级索引, 并且由于所述次级索引采用二叉 树结构, 其一个节点中的左子树只保存小于该节点门限范围的存储信息, 右子树只保存大于该节点门限范围的存储信息, 因此只需要判断每个节点 的门限范围, 即可确定存储信息需在次级索引中要保存的位置或者已经保 存了的位置, 从而极大提高了存储信息的处理效率以及数据的吞吐量。 附图说明 图 1为本发明实施例中数据存储信息的处理方法的步骤示意图; 图 2为本发明实施例中初级索引与次级索引对应的关系示意图; 图 3为本发明实施例中对目标数据的存储信息进行查询的步骤示意图; 图 4为本发明实施例中对目标数据的存储信息进行保存的步骤示意图; 图 5为本发明实施例中数据存储信息的处理装置的结构示意图。 具体实施方式 为使本发明要解决的技术问题、 技术方案和优点更加清楚, 下面将结 合附图及具体实施例进行详细描述。
本发明实施例提供了一种数据存储信息的处理方法, 如图 1所示, 包括 如下步骤:
步骤 1, 建立一初级索引, 用于保存数据的特征条件;
步骤 2, 针对所述初级索引的特征条件建立一次级索引, 用于保存所述 数据的存储信息至所述次级索引中; 其中, 所述次级索引为二叉树结构, 其一个节点中的左子树只保存小于该节点门限范围的存储信息, 右子树只 保存大于该节点门限范围的存储信息;
步骤 3, 根据所述初级索引以及所述次级索引, 对目标数据的存储信息 进行处理。
上述方法中, 在对数据的存储信息进行处理时(如进行查找或保存), 能够通过数据的特征条件在初级索引中找到次级索引, 并且由于所述次级 索引采用二叉树结构, 其一个节点中的左子树只保存小于该节点门限范围 的存储信息, 右子树只保存大于该节点门限范围的存储信息, 因此只需要 判断每个节点的门限范围, 即可确定存储信息需在次级索引中要保存的位 置或者已经保存了的位置, 从而极大提高了存储信息的处理效率以及数据 的吞吐量。 在本发明的上述实施例中, 步骤 3还可包括:
步骤 A, 根据所述初级索引中的特征条件找到所述次级索引, 将所述目 标数据的存储信息保存进所述次级索引中; 或
步骤 B, 根据所述初级索引中的特征条件找到所述次级索引, 在所述次 级索引中查询所述目标数据的存储信息。 的第一类哈希值; 所述存储信息为根据数据的内容计算得出的第二类哈希 值; 所述门限范围为所述次级索引中, 一个节点的存储信息达到预设上限 后, 所保存的最小第二类哈希值到最大第二类哈希值。
在本发明的上述实施例中, 步骤 A包括:
计算目标数据的第一类哈希值与第二类哈希值;
判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
在本发明的上述实施例中, 将所述目标数据的第二类哈希值保存至该 次级索引中的步骤包括:
A1 , 以次级索引中根节点为当前节点;
A2, 判断所述目标数据的第二类哈希值是否属于所述当前节点的门限 范围; 若属于, 则进行 A3; 若不属于则进行 A9;
A3 , 判断该当前节点的存储数量是否达到预设上限; 若未达到预设上 限, 则进行 A4; 若达到预设上限, 则进行 A6; A4, 将所述目标数据的第二类哈希值保存至所述当前节点; 之后进行
A5;
A5 , 根据二叉树平衡特性对次级索引进行旋转, 并结束;
A6, 判断所述当前节点是否含有还有左子树; 若含有, 则以该左子树 为当前节点, 并进行 A7; 若未含有, 则进行 A8;
A7, 将所述目标数据的第二类哈希值保存至当前节点中, 将当前节点 的最小第二类哈希值提取出, 并以所述提取出的最小第二类哈希值为待保 存的第二类哈希值, 以当前节点的左子树的根节点作为新的当前节点, 重 新回到 A2, 保存所述待保存的第二类哈希值;
A8, 将所述目标数据的第二类哈希值保存至当前节点中, 在其当前节 点生成一新的左子树, 将当前节点的最小第二类哈希值提取出, 并保存至 所述新的左子树中, 以该左子树为新的当前节点; 之后回到 A5;
A9,判断所述目标数据的第二类哈希值是否大于当前节点的门限范围; 若大于, 则进行 A10; 否, 则进行 A12;
A10,判断当前节点是否有右子树;是,则以该右子树为新的当前节点, 并回到 A2; 否, 则进行 All ;
All , 判断当前节点的是否达到所述预设上限; 否, 则回到步骤 A4; 是, 则回到步骤 A8;
A12,判断当前节点是否有左子树;是,则以该做子树为新的当前节点, 并回到步骤 A2; 否, 则回到步骤 All。
在本发明的上述实施例中, 步骤 B包括:
B1, 获取查找目标数据存储信息的指令;
B2, 计算所述目标数据的第一类哈希值和第二类哈希值;
B3, 在所述初级索引中搜索与所述目标数据的第一类哈希值相同的哈 希值; B4, 对查找的结果进行判断; 若所述初级索引中包含与所述目标数据 的第一类哈希值相等的哈希值, 则进行 B 6; 否, 则查询失败;
B6, 进入与所述目标数据的第一类哈希值对应的次级索引, 以次级索 引的根节点为当前节点, 开始查询所述目标数据的第二类哈希值;
B7 ,判断所述目标数据的第二哈希值是否属于当前节点的门限范围内; 若属于, 则进行 B8; 若不属于, 则进行 B11 ;
B8, 进一步判断当前节点是否拥有与所述目标数据的第二哈希值相等 的哈希值; 若有, 则进行 B9; 若无, 则进行 B10;
B9, 查询成功;
B10, 查询失败;
B11 , 判断当前节点是不是叶子节点; 若是, 则进行 B10; 若不是, 则 进行 B12;
B12 , 判断所述目标数据的第二哈希值是否大于当前节点的门限范围; 若大于, 是则进行 B13; 若小于, 则进行 B14;
B13 , 判断当前节点是否有右子树; 若有, 则进行 B15; 若没有, 则进 行 B10;
B15,选择当前节点的右子树的根节点作为新的当前节点;之后回到 B7; B14, 判断当前节点是否有左子树; 若有, 则进行 B17; 若没有, 回到
B10;
B17,选择当前节点的左子树的根节点作为新的当前节点;之后回到 B7。 考虑到如果所述次级索引中存储数据进行删除后, 可能会造成二叉树 结构不能保持平衡, 因此
在本发明的上述实施例中, 在步骤 3之后还可以包括:
步骤 4, 若所述次级索引中的同一节点的左子树与右子树的高度差超出 预设平衡因子的范围, 对所述次级索引进行旋转操作。 下面对上述方法进行具体描述:
根据 NFC读取到的数据得到两个部分信息。 第一部分信息为数据的特 征条件, 包含了数据的读取时间和 /或发布者信息; 第二部分信息为该数据 的内容。 利用 SHA1算法算出第一部分信息的哈希值, 将该哈希值定义为第 一类哈希值(即初级编码); 同理根据第二部分信息计算得到的第二类哈希 值(即次级编码)。
如图 2所示, 首先构建初级索引, 用于保存各个数据的初级编码; 之后 针对各个初级编码构建次级索引; 需要指出的是, 由于保存的数据量极为 庞大, 可能会同一个发布者和 /或同一读取时间存在多个数据(即初级编码 相同), 那么将这些数据的次级编码都共享一个初级编码, 如图 2所示的次 级编码 al-an都保存在与初级编码 2对应的次级索引中。
在初步构建完成初级索引以及次级索引后, 即可对目标数据的存储信 息进行处理。
如图 3所示, 当需要查询目标数据的存储信息时可进行如下步骤: 步骤 301, 首先获取用户在查找时需要输入目标数据的信息;
步骤 302, 利用 SHA1算法目标数据的初级编码以及次级编码; 步骤 303, 在初级索引中进行二分查找;
步骤 304, 对二分查找的结果进行判断; 若初级索引表中存在与初级编 码相同的哈希值, 进入步骤 306; 否则进入步骤 305, 查询失败;
步骤 306, 进入与初级编码对应的次级索引中, 在次级索引表的根节点 开始查询次级编码对应的第二类哈希值;
步骤 307, 判断次级编码对应的第二类哈希值是否在该根节点拥有的哈 希值的范围内; 若在范围内, 则进入步骤 308, 否则进入步骤 311 ;
步骤 308,进一步判断该节点是否拥有与初级编码相等的哈希值。若有, 则进入步骤 309, 查询成功; 若无, 则进入步骤 310, 查询失败; 步骤 311, 判断当前节点是不是二叉树的叶子节点。 若是, 则进入步骤 310, 查询失败; 若不是, 则进入步骤 312;
步骤 312, 判断次级编码对应的第二类哈希值是否大于当前节点已保存 的最大第二类哈希值。 若是则进入步骤 313, 否则进入步骤 314;
步骤 313, 判断当前节点是否有右子树。 若有则进入步骤 315; 否则进 入步骤 316, 查询失败;
步骤 315, 由于该二叉树中节点的右子树只包含大于该节点最大哈希值 的记录, 因此选择当前节点的右子树的根节点作为新的当前节点, 从其保 存的第二类哈希值中继续进行查询;
步骤 314, 判断当前节点是否有左子树。 若有则进入步骤 317; 否则进 入步骤 316, 查询失败;
步骤 317, 由于该二叉树中节点的左子树只包含小于该节点最小哈希值 的记录, 因此选择当前节点的左子树的根节点作为新的当前节点, 从其保 存的第二类哈希值中继续进行查询;
步骤 315和步骤 317后续的过程重复步骤 307至步骤 313、 步骤 307至 314 的循环, 直至查询成功或查询失败。
如图 4所示, 当需要查询目标数据的存储信息时可进行如下步骤: 步骤 401, 获取查找目标数据存储信息的指令;
步骤 402, 利用 SHA1算法算出目标数据的初级编码以及次级编码; 步骤 403, 在初级索引中进行二分查找, 若不存在与目标数据的初级编 码相同的哈希值, 进入步骤 404, 否则进入步骤 407;
步骤 404, 将目标数据的初级编码插入到初级索引中, 并新建一个与之 对应次级索引, 进入步骤 405;
步骤 405, 新建一个根节点, 将目标数据的次级编码作为该根节点的哈 希值插入次级索引表, 完成次级索引记录的添加, 进入步骤 406; 步骤 406, 由于次级索引表是一个平衡二叉树结构, 记录的添加会导致 二叉树不平衡, 因此需要在此步骤进行旋转操作。 由于旋转操作属于平衡 二叉树中的基础内容, 在本发明实施例中就不再做详细叙述; 完成旋转操 作后, 进入步骤 420, 整个添加过程结束; 引, 从该次级索引的根节点开始查询目标数据的次级编码应当插入的位置; 步骤 408, 判断目标数据的次级编码的哈希值是否在该根节点拥有的哈 希值的范围内, 即是否满足: 该节点最小哈希值 目标数据的次级编码 该节点最大哈希值; 若不在范围内, 则进入步骤 409, 否则进入步骤 414; 步骤 409, 判断此节点中是否有足够的存储空间; 假设每个节点的存储 上限为 50,即判断是否满足该节点已保存的第二类哈希值的数量 <50;若是, 则进入步骤 410, 否则进入步骤 411 ;
步骤 410, 在当前节点的哈希值中进行二分查找, 找到应当插入目标数 据的次级编码的位置, 并将该次级编码插入; 插入后该节点的所有哈希值 依然可以保持从小到大排列; 完成插入后, 进入步骤 406, 进行旋转操作, 完成整个添加过程;
步骤 411, 判断此当前节点是否有左子树, 若有左子树则进入步骤 412, 否则进入步骤 413 ;
步骤 412, 在当前节点的第二类哈希值中进行二分查找, 找到应当插入 目标数据的次级编码的位置, 并将该次级编码插入; 插入后该节点的所有 哈希值依然保持从小到大排列; 完成插入后, 该节点中拥有 51个哈希值, 而一个节点只能存储 50个哈希值, 因此需要进行置换操作, 即将节点的当 前最小哈希值中抽出; 抽出后的当前节点存储的哈希值中, 最小的哈希值 成为该节点新的门限范围的下限(即最小哈希值); 以刚才抽出的哈希值作 为新的待保存的次级编码, 以当前节点的左子树的根节点作为新的当前节 点, 重新开始插入该待保存的次级编码的过程, 进入步骤 408; 置换操作相当于在当前节点所存数的第二类哈希值已达到预设上限的 情况下, 将目标数据的次级编码插入此结点, 然后将结点中的最小第二类 哈希插入到该节点的左子树中, 之后以此类推, 并重新开始递归插入操作; 步骤 413, 在当前节点的哈希值中进行查找, 找到应当插入目标数据的 次级编码的位置, 并插入; 插入后该节点所保存的哈希值可以保持从小到 大的排列; 完成插入后, 将当前节点的最小哈希值抽出, 为当前节点新建 一个左子树节点, 成为当前节点, 将抽出的哈希值插入到当前节点中; 由 于此时的当前节点只有一个哈希值, 因此可将该当前节点的最小哈希值看 作 0; 插入操作完成后, 进入步骤 406, 进行旋转操作, 完成整个添加过程; 步骤 414, 判断目标数据的次级编码是否大于当前节点的最大哈希值; 若是则进入步骤 415, 否则进入步骤 417;
步骤 415, 判断当前节点是否存在右子树, 若存在则进入步骤 416, 否 则进入步骤 419;
步骤 416, 由于该节点的右子树只包含哈希值大于该节点最大哈希值的 记录, 因此以当前节点的右子树的根节点作为新的当前节点,进入步骤 408, 重新开始递归插入操作;
步骤 417, 判断当前节点是否存在左子树, 若存在则进入步骤 418, 否 则进入步骤 419;
在步骤 418, 由于该节点的左子树只包含哈希值小于该节点最小哈希值 的记录, 因此以当前节点的左子树的根节点作为新的当前节点, 进入步骤 408, 重新开始递归插入操作;
在步骤 419, 判断此节点中是否有足够的存储空间, 即是否满足此节点 保存的第二类哈希值数量 <50; 若是, 则进入步骤 410, 否则进入步骤 413。
当目标数据的存储信息查询成功后, 还可对删除次级索引中的存储信 息进行删除, 但是这样一来会造成次级索引无法保持平衡, 因此, 可对每 个节点都设一个平衡因子 B, 用于表示这个结点的左、 右子树的高度差, 也 就是左子树的高度减去右子树的高度的结果值。 若所有的节点上的 B值为 -1、 0、 1,则该二叉树保持平衡; 若有一个节点的 |B|>=2,则次级索引就不在 是平衡二叉树结构, 需要进行旋转操作。
综上所述,采用本发明实施例的方法对数据的存储信息进行处理时(如 进行查找或保存), 能够通过数据的特征条件在初级索引中找到次级索引, 并且由于所述次级索引采用二叉树结构, 其一个节点中的左子树只保存小 于该节点门限范围的存储信息, 右子树只保存大于该节点门限范围的存储 信息, 因此只需要判断每个节点的门限范围, 即可确定存储信息需在次级 索引中要保存的位置或者已经保存了的位置, 从而极大提高了存储信息的 处理效率以及数据的吞吐量; 此外, 具有相同特征条件的数据的存储信息 共享同一个初级索引, 可进一步加快存储信息的保存与查询时间; 此外, 对次级索引预设平衡因子, 对超出预设平衡因子的次级索引进行旋转操作, 从而维持次级索引的平衡。
如图 5所示, 本发明实施例还提供了一种数据存储信息的处理装置, 包 括:
第一建立模块, 配置为建立一初级索引, 保存数据的特征条件; 第二建立模块, 配置为针对所述初级索引的特征条件建立一次级索引, 其中所述次级索引为二叉树结构, 保存所述数据的存储信息至所述次级索 引中, 其一个节点中的左子树只保存小于该节点门限范围的存储信息, 右 子树只保存大于该节点门限范围的存储信息;
处理模块, 配置为根据所述初级索引以及所述次级索引, 对目标数据 的存储信息进行处理。
上述装置在对数据的存储信息进行处理时(如进行查找或保存), 能够 通过数据的特征条件在初级索引中找到次级索引, 并且由于所述次级索引 采用二叉树结构, 其一个节点中的左子树只保存小于该节点门限范围的存 储信息, 右子树只保存大于该节点门限范围的存储信息, 因此只需要判断 每个节点的门限范围, 即可确定存储信息需在次级索引中要保存的位置或 者已经保存了的位置, 从而极大提高了存储信息的处理效率以及数据的吞 吐量。
在本发明的上述实施例中, 所述处理模块还包括:
保存单元, 配置为根据所述初级索引中的特征条件找到所述次级索引, 将所述目标数据的存储信息保存进所述次级索引中; 和 /或
查询单元, 根据所述初级索引中的特征条件找到所述次级索引, 在所 述次级索引中查询所述目标数据的存储信息; 的第一类哈希值; 所述存储信息为根据数据的内容计算得出的第二类哈希 值; 所述门限范围为所述次级索引中, 一个节点的存储信息达到预设上限 后, 所保存的最小第二类哈希值到最大第二类哈希值;
在本发明的上述实施例中, 所述保存单元具体配置为:
计算目标数据的第一类哈希值与第二类哈希值;
判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
下面对保存单元将第二类哈希值保存至次级索引所需的步骤进行进一 步描述:
Al, 以次级索引中根节点为当前节点;
A2, 判断所述目标数据的第二类哈希值是否属于所述当前节点的门限 范围; 若属于, 则进行 A3; 若不属于则进行 A9;
A3 , 判断该当前节点的存储数量是否达到预设上限; 若未达到预设上 限, 则进行 A4; 若达到预设上限, 则进行 A6;
A4, 将所述目标数据的第二类哈希值保存至所述当前节点; 之后进行
A5;
A5 , 根据二叉树平衡特性对次级索引进行旋转, 并结束;
A6, 判断所述当前节点是否含有还有左子树; 若含有, 则以该左子树 为当前节点, 并进行 A7; 若未含有, 则进行 A8;
A7, 将所述目标数据的第二类哈希值保存至当前节点中, 将当前节点 的最小第二类哈希值提取出, 并以所述提取出的最小第二类哈希值为待保 存的第二类哈希值, 以当前节点的左子树的根节点作为新的当前节点, 重 新回到 A2, 保存所述待保存的第二类哈希值;
A8, 将所述目标数据的第二类哈希值保存至当前节点中, 在其当前节 点生成一新的左子树, 将当前节点的最小第二类哈希值提取出, 并保存至 所述新的左子树中, 以该左子树为新的当前节点; 之后回到 A5;
A9,判断所述目标数据的第二类哈希值是否大于当前节点的门限范围; 若大于, 则进行 A10; 否, 则进行 A12;
A10,判断当前节点是否有右子树;是,则以该右子树为新的当前节点, 并回到 A2; 否, 则进行 All ;
All , 判断当前节点的是否达到所述预设上限; 否, 则回到步骤 A4; 是, 则回到步骤 A8;
A12,判断当前节点是否有左子树;是,则以该做子树为新的当前节点, 并回到步骤 A2; 否, 则回到步骤 All。 下面对查询单元根据所述初级索引中的特征条件找到所述次级索引, 在所述次级索引中查询所述目标数据的存储信息的步骤进行详细描述:
B1, 获取查找目标数据存储信息的指令;
B2, 计算所述目标数据的第一类哈希值和第二类哈希值;
B3 , 在所述初级索引中进行搜索所述目标数据的第一类哈希值;
B4, 对查找的结果进行判断; 若所述初级索引中包含与所述目标数据 的第一类哈希值相等的哈希值, 则进行 B 6; 否, 则查询失败;
B6, 进入与所述目标数据的第一类哈希值对应的次级索引, 以次级索 引的根节点为当前节点, 开始查询所述目标数据的第二类哈希值;
B7,判断所述目标数据的第二哈希值是否属于当前节点的门限范围内; 若属于, 则进行 B 8; 若不属于, 则进行 B11 ;
B8, 进一步判断当前节点是否拥有与所述目标数据的第二哈希值相等 的哈希值; 若有, 则进行 B 9, 查询成功; 若无, 则进行 B10, 查询失败; B11 , 判断当前节点是不是叶子节点; 若是, 则进行 B10, 查询失败; 若不是, 则进行 B2;
B12 , 判断所述目标数据的第二哈希值是否大于当前节点的门限范围; 若大于, 是则进行 B13; 若小于, 则进行 B14;
B13 , 判断当前节点是否有右子树; 若有, 则进行 B15; 若没有, 则进 行 B16, 查询失败;
B15 ,选择当前节点的右子树的根节点作为新的当前节点;之后回到 B7 B14, 判断当前节点是否有左子树; 若有, 则进行 B17; 若没有, 回到
B16, 查询失败;
B17,选择当前节点的左子树的根节点作为新的当前节点;之后回到 B7。 当目标数据的存储信息查询成功后, 还可对删除次级索引中的存储信 息进行删除, 但是这样一来会造成次级索引无法保持平衡, 因此在本发明 的上述实施例中, 本装置还可以包括:
旋转单元, 配置为若所述次级索引中的同一节点的左子树与右子树的 高度差超出预设平衡因子的范围, 对所述次级索引进行旋转操作, 从而维 持次级索引的平衡。
显然, 上述实施例为本发明中一种数据存储信息的处理方法对应的装 置实施例, 所述数据存储信息的处理方法达到的技术效果, 本实施例的装 置也同样能够达到。
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的保 护范围。 工业实用性
本发明实施例在对数据的存储信息进行处理时 (如进行查找或保存), 能够通过数据的特征条件在初级索引中找到次级索引, 并且由于所述次级 索引采用二叉树结构, 其一个节点中的左子树只保存小于该节点门限范围 的存储信息, 右子树只保存大于该节点门限范围的存储信息, 因此只需要 判断每个节点的门限范围, 即可确定存储信息需在次级索引中要保存的位 置或者已经保存了的位置, 从而极大提高了存储信息的处理效率以及数据 的吞吐量。

Claims

权利要求书
1. 一种数据存储信息的处理方法, 所述方法包括:
建立一初级索引, 用于保存数据的特征条件;
针对所述初级索引的特征条件建立一次级索引, 用于保存所述数据的 存储信息至所述次级索引中; 其中, 所述次级索引为二叉树结构, 其一个 节点中的左子树只保存小于该节点门限范围的存储信息, 右子树只保存大 于该节点门限范围的存储信息;
根据所述初级索引以及所述次级索引, 对目标数据的存储信息进行处 理。
2. 根据权利要求 1所述的数据存储信息的处理方法, 其中, 根据所述 初级索引以及所述次级索引, 对目标数据的存储信息进行处理包括:
根据所述初级索引中的特征条件找到所述次级索引, 将所述目标数据 的存储信息保存进所述次级索引中; 和 /或
根据所述初级索引中的特征条件找到所述次级索引, 在所述次级索引 中查询所述目标数据的存储信息。
3. 根据权利要求 1或 2所述的数据存储信息的处理方法, 其中, 所述特 征条件为通过数据的读取时间和 /或发布者信息计算得出的第一类哈希值; 所述存储信息为根据数据的内容计算得出的第二类哈希值; 所述门限范围 为所述次级索引中, 一个节点的存储信息达到预设上限后, 所保存的最小 第二类哈希值到最大第二类哈希值。
4. 根据权利要求 3所述的数据存储信息的处理方法, 其中, 根据所述 初级索引中的特征条件找到所述次级索引, 将所述目标数据的存储信息保 存进所述次级索引中包括:
计算目标数据的第一类哈希值与第二类哈希值;
判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
5. 根据权利要求 4所述的数据存储信息的处理方法, 其中, 将所述目 标数据的第二类哈希值保存至该次级索引中包括:
A1 , 以次级索引中根节点为当前节点;
A2, 判断所述目标数据的第二类哈希值是否属于所述当前节点的门限 范围; 若属于, 则进行 A3; 若不属于则进行 A9;
A3 , 判断该当前节点的存储数量是否达到预设上限; 若未达到预设上 限, 则进行 A4; 若达到预设上限, 则进行 A6;
A4, 将所述目标数据的第二类哈希值保存至所述当前节点; 之后进行
A5;
A5 , 根据二叉树平衡特性对次级索引进行旋转, 并结束;
A6, 判断所述当前节点是否含有还有左子树; 若含有, 则以该左子树 为当前节点, 并进行 A7; 若未含有, 则进行 A8;
A7, 将所述目标数据的第二类哈希值保存至当前节点中, 将当前节点 的最小第二类哈希值提取出, 并以所述提取出的最小第二类哈希值为待保 存的第二类哈希值, 以当前节点的左子树的根节点作为新的当前节点, 重 新回到 A2, 保存所述待保存的第二类哈希值;
A8, 将所述目标数据的第二类哈希值保存至当前节点中, 在其当前节 点生成一新的左子树, 将当前节点的最小第二类哈希值提取出, 并保存至 所述新的左子树中, 以该左子树为新的当前节点; 之后回到 A5; A9,判断所述目标数据的第二类哈希值是否大于当前节点的门限范围; 若大于, 则进行 A10; 否, 则进行 A12;
A10,判断当前节点是否有右子树;是,则以该右子树为新的当前节点, 并回到 A2; 否, 则进行 Al l ;
Al l , 判断当前节点的是否达到所述预设上限; 否, 则回到步骤 A4; 是, 则回到步骤 A8;
A12 ,判断当前节点是否有左子树;是,则以该做子树为新的当前节点, 并回到步骤 A2; 否, 则回到步骤 Al l。
6. 根据权利要求 5所述的数据存储信息的处理方法, 其中, 根据所述 初级索引中的特征条件找到所述次级索引, 在所述次级索引中查询所述目 标数据的存储信息包括:
B1, 获取查找目标数据存储信息的指令;
B2, 计算所述目标数据的第一类哈希值和第二类哈希值;
B3, 在所述初级索引中搜索与所述目标数据的第一类哈希值相同的哈 希值;
B4, 对查找的结果进行判断; 若所述初级索引中包含与所述目标数据 的第一类哈希值相等的哈希值, 则进行 B 6; 否, 则查询失败;
B6, 进入与所述目标数据的第一类哈希值对应的次级索引, 以次级索 引的根节点为当前节点, 开始查询所述目标数据的第二类哈希值;
B7 ,判断所述目标数据的第二哈希值是否属于当前节点的门限范围内; 若属于, 则进行 B8; 若不属于, 则进行 B11 ;
B8, 进一步判断当前节点是否拥有与所述目标数据的第二哈希值相等 的哈希值; 若有, 则进行 B 9; 若无, 则进行 B10;
B9, 查询成功;
B10, 查询失败; Bl l , 判断当前节点是不是叶子节点; 若是, 则进行 B10; 若不是, 则 进行 B12;
B12 , 判断所述目标数据的第二哈希值是否大于当前节点的门限范围; 若大于, 是则进行 B13; 若小于, 则进行 B14;
B13 , 判断当前节点是否有右子树; 若有, 则进行 B15; 若没有, 则进 行 B10;
B15 ,选择当前节点的右子树的根节点作为新的当前节点;之后回到 B7 B14, 判断当前节点是否有左子树; 若有, 则进行 B17; 若没有, 回到
B10;
B17,选择当前节点的左子树的根节点作为新的当前节点;之后回到 B7。
7. 根据权利要求 1所述的数据存储信息的处理方法, 其中, 若所述次 级索引中的同一节点的左子树与右子树的高度差超出预设平衡因子的范 围, 对所述次级索引进行旋转操作。
8. 一种数据存储信息的处理装置, 所述装置包括:
第一建立模块, 配置为建立一初级索引, 保存数据的特征条件; 第二建立模块, 配置为针对所述初级索引的特征条件建立一次级索引, 其中所述次级索引为二叉树结构, 保存所述数据的存储信息至所述次级索 引中, 其一个节点中的左子树只保存小于该节点门限范围的存储信息, 右 子树只保存大于该节点门限范围的存储信息;
处理模块, 配置为根据所述初级索引以及所述次级索引, 对目标数据 的存储信息进行处理。
9. 根据权利要求 8所述的存储信息的处理装置, 其中, 所述处理模块 还包括:
保存单元, 配置为根据所述初级索引中的特征条件找到所述次级索引, 将所述目标数据的存储信息保存进所述次级索引中; 和 /或 查询单元, 根据所述初级索引中的特征条件找到所述次级索引, 在所 述次级索引中查询所述目标数据的存储信息。
10. 根据权利要求 8或 9所述的存储信息的处理装置, 其中, 所述特征 条件为通过数据的读取时间和 /或发布者信息计算得出的第一类哈希值; 所 述存储信息为根据数据的内容计算得出的第二类哈希值; 所述门限范围为 所述次级索引中, 一个节点的存储信息达到预设上限后, 所保存的最小第 二类哈希值到最大第二类哈希值。
11. 根据权利要求 10所述的存储信息的处理装置, 其中, 所述保存单 元具体配置为:
计算目标数据的第一类哈希值与第二类哈希值;
判断所述初级索引是否包含与所述目标数据的第一类哈希值相等的哈 希值;
若不包含, 则在所述初级索引中保存所述目标数据的第一类哈希值, 并建立与其对应的次级索引, 将所述目标数据的第二类哈希值保存至该次 级索引中;
若包含, 则找到所述初级索引中与其相同的第一类哈希值所对应的次 级索引, 将所述目标数据的第二类哈希值保存至该次级索引中。
12. 根据权利要求 8所述的存储信息的处理装置, 其中, 所述装置还包 括:
旋转单元, 配置为若所述次级索引中的同一节点的左子树与右子树的 高度差超出预设平衡因子的范围, 对所述次级索引进行旋转操作。
PCT/CN2013/080072 2013-01-24 2013-07-25 一种存储信息的处理方法及装置 WO2013167080A2 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310027573.9 2013-01-24
CN201310027573.9A CN103970739B (zh) 2013-01-24 2013-01-24 一种存储信息的处理方法及装置

Publications (2)

Publication Number Publication Date
WO2013167080A2 true WO2013167080A2 (zh) 2013-11-14
WO2013167080A3 WO2013167080A3 (zh) 2014-01-03

Family

ID=49551375

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/080072 WO2013167080A2 (zh) 2013-01-24 2013-07-25 一种存储信息的处理方法及装置

Country Status (2)

Country Link
CN (1) CN103970739B (zh)
WO (1) WO2013167080A2 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778948A (zh) * 2021-09-01 2021-12-10 中国人民银行清算总中心 消息持久化存储方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101039253A (zh) * 2006-03-17 2007-09-19 中兴通讯股份有限公司 一种实现三重内容可寻址存储器范围匹配的前缀扩展方法
CN101419630A (zh) * 2008-12-11 2009-04-29 中国科学院计算技术研究所 一种数据流中Top-k项的挖掘方法及系统
CN102387107A (zh) * 2010-09-01 2012-03-21 夏普株式会社 基于二叉树的联合编码方法和编码器
CN102725754A (zh) * 2011-12-26 2012-10-10 华为技术有限公司 一种索引数据处理方法及设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6567815B1 (en) * 2000-08-01 2003-05-20 International Business Machines Corporation Technique of clustering and compaction of binary trees
US20070162508A1 (en) * 2004-11-08 2007-07-12 Mazzagatti Jane C Updating information in an interlocking trees datastore

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101039253A (zh) * 2006-03-17 2007-09-19 中兴通讯股份有限公司 一种实现三重内容可寻址存储器范围匹配的前缀扩展方法
CN101419630A (zh) * 2008-12-11 2009-04-29 中国科学院计算技术研究所 一种数据流中Top-k项的挖掘方法及系统
CN102387107A (zh) * 2010-09-01 2012-03-21 夏普株式会社 基于二叉树的联合编码方法和编码器
CN102725754A (zh) * 2011-12-26 2012-10-10 华为技术有限公司 一种索引数据处理方法及设备

Also Published As

Publication number Publication date
CN103970739A (zh) 2014-08-06
CN103970739B (zh) 2017-04-26
WO2013167080A3 (zh) 2014-01-03

Similar Documents

Publication Publication Date Title
CN104699718B (zh) 用于快速引入业务数据的方法和装置
CN106874348B (zh) 文件存储和索引方法、装置及读取文件的方法
US11269902B2 (en) Time series data management method, device, and apparatus
CN104794123A (zh) 一种为半结构化数据构建NoSQL数据库索引的方法及装置
CN102870116B (zh) 内容匹配方法和装置
CN106777387B (zh) 一种基于HBase的物联网大数据存取方法
RU2585973C2 (ru) Способ и устройство управления операцией блокировки системы баз данных
CN103973810A (zh) 基于互联网协议ip盘的数据处理方法和装置
CN108399175B (zh) 一种数据存储、查询方法及其装置
CN103514236A (zh) 检索应用中基于拼音的检索条件纠错提示处理方法
WO2016043757A1 (en) Data to be backed up in a backup system
CN105095425A (zh) 一种数据库的跨库结转方法及装置
CN110232095A (zh) 一种数据同步方法、装置、存储介质和服务器
JP2012256318A (ja) 多重範囲スキャンでのnソートクエリを最適に処理する方法及び装置
CN104778252A (zh) 索引的存储方法和装置
US9836491B1 (en) Method and apparatus for hardware-implemented AVL tree updates
CN110929173A (zh) 同人识别方法、装置、设备及介质
CN102724301B (zh) 云数据库系统以及云数据读写处理方法、设备
WO2013167080A2 (zh) 一种存储信息的处理方法及装置
CN106776617B (zh) 日志文件的保存方法和装置
CN107609143B (zh) 一种分布式实时内存数据库的分片信息存储方法
CN114048206B (zh) 一种大规模集群的配置一致性校验方法、系统及装置
CN113779025B (zh) 一种区块链中分类数据检索效率的优化方法、系统及应用
CN106599326B (zh) 一种云化架构下的记录数据剔重处理方法及系统
CN103856535B (zh) 一种获取用户数据的方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13787576

Country of ref document: EP

Kind code of ref document: A2

122 Ep: pct application non-entry in european phase

Ref document number: 13787576

Country of ref document: EP

Kind code of ref document: A2