[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN100468402C - A data storage and query method - Google Patents

A data storage and query method Download PDF

Info

Publication number
CN100468402C
CN100468402C CNB2005101166630A CN200510116663A CN100468402C CN 100468402 C CN100468402 C CN 100468402C CN B2005101166630 A CNB2005101166630 A CN B2005101166630A CN 200510116663 A CN200510116663 A CN 200510116663A CN 100468402 C CN100468402 C CN 100468402C
Authority
CN
China
Prior art keywords
node
pointer
data
classification
split catalog
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CNB2005101166630A
Other languages
Chinese (zh)
Other versions
CN1955958A (en
Inventor
马超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CNB2005101166630A priority Critical patent/CN100468402C/en
Publication of CN1955958A publication Critical patent/CN1955958A/en
Application granted granted Critical
Publication of CN100468402C publication Critical patent/CN100468402C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

公开了一种数据存储方法,对所述数据进行至少一次分类,得到分类数据和所述分类数据的各级分类目录,将所述分类数据存储到计算机的内存空间中;采用二叉结构目录树存储所述分类数据的各级分类目录,用固定大小的内存空间存储所述目录树上的每个节点,利用递归算法分别建立与所述分类数据的各级分类目录一一对应的节点;预先在内存中生成一个映射表,并在建立每个节点的同时在预先生成的映射表中保存所述节点的节点标识与指向该节点所在内存空间的指针之间的映射关系。本发明还公开了一种数据查询方法。通过上述方法可以有效地节省内存空间,增加内存资源的使用效率,同时简化分类数据的存储以及分类目录的移动、增加以及删除操作。

Figure 200510116663

Disclosed is a data storage method, which classifies the data at least once, obtains classified data and classification directories of all levels of the classified data, stores the classified data in the memory space of a computer; adopts a binary structure directory tree Storing the classification directories at all levels of the classification data, storing each node on the directory tree with a fixed-size memory space, and using a recursive algorithm to respectively establish one-to-one corresponding nodes with the classification directories at all levels of the classification data; A mapping table is generated in the memory, and the mapping relationship between the node identifier of the node and the pointer pointing to the memory space where the node is located is saved in the pre-generated mapping table when each node is established. The invention also discloses a data query method. The above method can effectively save memory space, increase the utilization efficiency of memory resources, and simplify the storage of classified data and the operations of moving, adding and deleting classified directories.

Figure 200510116663

Description

一种数据存储及查询方法 A data storage and query method

技术领域 technical field

本发明涉及到数据的管理技术,特别涉及到一种数据存储及查询方法。The invention relates to data management technology, in particular to a data storage and query method.

背景技术 Background technique

随着目前数据信息的爆炸性增长以及计算机应用领域的不断扩大,计算机已经成为人们生活中不可或缺的数据管理工具,无论是数据采集、处理、存储以及检索等等操作均离不开计算机,因此,如何有效、快速地存储数据以及如何快速地检索出所需要的数据已成为当前数据管理所要解决的主要问题。With the explosive growth of current data information and the continuous expansion of computer applications, computers have become an indispensable data management tool in people's lives. No matter data collection, processing, storage, retrieval, etc., operations are inseparable from computers. Therefore, How to store data effectively and quickly and how to quickly retrieve the required data has become the main problem to be solved in current data management.

目前对于分类数据通常可以采用树状结构来进行存储,存储这些分类目录的树状结构又称为目录树。使用目录树存储分类数据的方法包括:首先建立一个根节点,该根节点包含至少一个一级子节点,所述一级子节点的数量根据所述分类数据经过一次分类以后得到的一级分类目录的个数而定,令每个子节点对应一个一级分类目录,记录该一级分类目录的名称或标识等信息。其中,每个一级子节点还可以进一步包含至少一个二级子节点,相应地,每个二级子节点将对应于其父节点所对应一级分类目录所包含的数据经过分类后得到的二级分类目录,记录该二级分类目录的名称等信息。如此循环下去,得到若干个n级子节点(在这里所述的n为自然数),这些n级子节点所对应的n级分类目录将不能够再进一步分类了,此时,可以将这些n级子节点称为叶子节点,这些叶子节点除了要记录所对应n级分类目录的名称或标识之外,还需要进一步存储所对应n级分类目录所包含的分类数据。At present, classification data can usually be stored in a tree structure, and the tree structure storing these classification directories is also called a directory tree. The method for using a directory tree to store classified data includes: first establishing a root node, which contains at least one first-level child node, and the number of said first-level child nodes is based on the first-level classification directory obtained after the classification data is classified once Depending on the number of , each sub-node corresponds to a first-level classification directory, and information such as the name or logo of the first-level classification directory is recorded. Wherein, each first-level child node can further include at least one second-level child node, and correspondingly, each second-level child node will correspond to the second-level data obtained after classification of the data contained in the first-level classification directory corresponding to its parent node. The first-level classification directory records information such as the name of the second-level classification directory. Going on in this way, several n-level child nodes are obtained (n described here is a natural number), and the n-level classification catalogs corresponding to these n-level child nodes will not be able to be further classified. At this time, these n-level Sub-nodes are called leaf nodes. In addition to recording the name or logo of the corresponding n-level classification directory, these leaf nodes need to further store the classification data contained in the corresponding n-level classification directory.

图1显示了一种使用上述目录树存储的商品目录。从图1可以看出,各种商品数据经过一次分类后得到若干一级分类目录,例如电脑、珠宝首饰以及手机等等目录,将对应于图1所示目录树的各个一级子节点;而每个一级分类目录所包含商品还可以进一步进行二次分类得到的若干二级分类目录,例如,电脑目录还可以进一步划分为笔记本、台式机以及办公设备等等目录,这些二级分类目录将对应于图1所示目录树的各个二级子节点。对于无法再进行分类的分类目录而言,例如IBM或DELL等目录,将对应于图1所示目录树的叶子节点,除了在上述叶子节点上存储对应分类目录的名称或标识之外,还将进一步存储其对应分类目录所包含的各种商品信息,例如IBM笔记本电脑的各个商品信息或DELL笔记本电脑的各个商品信息。Figure 1 shows a commodity catalog stored using the above catalog tree. It can be seen from Fig. 1 that after one classification of various commodity data, several first-level classification directories are obtained, such as computer, jewelry, mobile phone, etc., which will correspond to each first-level child node of the directory tree shown in Fig. 1; The commodities contained in each first-level classification catalog can be further classified into several second-level classification catalogs. For example, the computer catalog can be further divided into categories such as notebooks, desktop computers, and office equipment. Corresponding to each secondary child node of the directory tree shown in FIG. 1 . For catalogs that cannot be further classified, such as IBM or DELL, etc., they will correspond to the leaf nodes of the catalog tree shown in Figure 1. In addition to storing the name or logo of the corresponding catalog on the above leaf nodes, the It further stores various commodity information contained in its corresponding classification catalog, such as various commodity information of IBM notebook computers or various commodity information of DELL notebook computers.

通过上述树状结构可以清楚的指示出各级分类目录之间的分类关系,实现对分类数据的有效管理。然而,由于上述目录树实际上采用了多叉树的数据结构,该多叉树中每个节点所包含子节点的数目将对应于该节点所对应目录划分的子目录个数,因此,每个节点所包含子节点的数目是不确定的,或者说是不可预知的,这将导致目录树上的每个节点所需要存储空间的大小不能确定,从而造成数据存储过程中对存储空间的分配操作过于复杂。特别是在将上述存储方法应用到海量数据的管理时,例如电子商务中的商品目录管理、以及图书馆信息管理等等,由于海量数据所包含的信息量是非常巨大的,使得每个节点所包含的子节点数目过多,这将导致每个节点所存储的信息过于庞大,不但进一步增加了存储空间分配操作的复杂度,还将造成存储空间资源的浪费。The above tree structure can clearly indicate the classification relationship between the classification directories at all levels, so as to realize the effective management of the classification data. However, since the above-mentioned directory tree actually adopts the data structure of a multi-fork tree, the number of sub-nodes contained in each node in the multi-fork tree will correspond to the number of sub-directories divided by the directory corresponding to the node. Therefore, each The number of sub-nodes contained in a node is uncertain, or unpredictable, which will cause the size of the storage space required by each node on the directory tree to be uncertain, resulting in the allocation of storage space during the data storage process too complicated. Especially when the above storage method is applied to the management of massive data, such as catalog management in e-commerce, and library information management, etc., due to the huge amount of information contained in massive data, each node If the number of sub-nodes is too large, the information stored in each node will be too large, which will not only further increase the complexity of the storage space allocation operation, but also cause a waste of storage space resources.

另外,在上述由多叉树结构目录树存储的分类数据的分类关系发生变化时,例如在增加、移动或删除某个分类目录时,还需要考虑该分类目录父节点存储空间的分配以及回收等问题,使得分类目录的增加、删除以及移动操作非常复杂。In addition, when the classification relationship of the classification data stored by the multi-fork tree structure directory tree changes, for example, when adding, moving or deleting a certain classification directory, it is also necessary to consider the allocation and recovery of the storage space of the parent node of the classification directory, etc. The problem makes the addition, deletion and movement of categories very complicated.

发明内容 Contents of the invention

为了解决现有技术存在的问题,本发明提供了一种数据存储方法,可以有效地节省内存空间,同时简化分类数据的存储以及分类目录的移动、增加以及删除操作。In order to solve the problems existing in the prior art, the present invention provides a data storage method, which can effectively save memory space, and simultaneously simplify the storage of classified data and the operations of moving, adding and deleting classified directories.

本发明还提供了一种数据查询方法,可以快速的检索到需要查询的分类目录,获得该分类目录所包含的分类数据。The invention also provides a data query method, which can quickly retrieve the classification directory to be queried, and obtain the classification data contained in the classification directory.

一种数据存储方法,对所述数据进行至少一次分类,得到分类数据和所述分类数据的各级分类目录,将所述分类数据存储到计算机的内存空间中;采用二叉结构目录树存储所述分类数据的各级分类目录,用固定大小的内存空间存储所述目录树上的每个节点,所述每个节点至少包括该节点所对应分类目录的节点标识、孩子节点指针、兄弟节点指针以及数据指针;A、建立所述目录树的根节点,令该根节点的兄弟节点指针为空,数据指针为空,并建立一个新的节点,令所述根节点的孩子节点指针指向所建立的新节点,将所述新节点对应于分类数据的一个一级分类目录;B、利用递归算法分别建立与所述分类数据的各级分类目录一一对应的节点,对应每个节点,若该节点所对应的分类目录包含下一级的分类目录,则令该节点的孩子节点指针指向一个对应于本节点所对应分类目录下一级分类目录的节点,并令该节点数据指针为空,否则,令该节点孩子节点指针为空,并令该节点数据指针指向用于保存本节点所对应的分类目录所包含的分类数据的内存空间;若所述目录树中已包含对应于该节点所对应分类目录同级分类目录的所有节点,则令该节点的兄弟节点指针为空,否则,令该节点的兄弟节点指针指向一个对应于本节点所对应分类目录的同级目录且未包含在所述目录树中的节点;预先在内存中生成一个映射表,并在建立每个节点的同时在预先生成的映射表中保存所述节点的节点标识与指向该节点所在内存空间的指针之间的映射关系。A data storage method, which classifies the data at least once, obtains the classified data and classification directories of the classified data at all levels, and stores the classified data in the memory space of the computer; adopts a binary structure directory tree to store all the classified data Classification catalogs at all levels of the classification data, each node on the catalog tree is stored in a fixed-size memory space, and each node at least includes a node identifier, a child node pointer, and a brother node pointer of the classification catalog corresponding to the node And data pointer; A, set up the root node of described catalog tree, make the sibling node pointer of this root node be empty, data pointer be empty, and set up a new node, make the child node pointer of described root node point to the established A new node of the new node corresponding to a first-level classification directory of the classification data; B, using a recursive algorithm to respectively establish a node corresponding to each level of classification directory of the classification data, corresponding to each node, if the If the classification directory corresponding to the node contains the next-level classification directory, then make the child node pointer of the node point to a node corresponding to the lower-level classification directory of the corresponding classification directory of this node, and make the node data pointer empty, otherwise , make the child node pointer of the node empty, and make the node data pointer point to the memory space used to save the classification data contained in the classification directory corresponding to this node; if the directory tree already contains the corresponding If all the nodes of the category directory are at the same level as the category directory, the sibling node pointer of the node is empty; otherwise, the sibling node pointer of the node points to a directory of the same level corresponding to the category directory corresponding to this node and is not included in the Nodes in the directory tree; generate a mapping table in memory in advance, and save the mapping between the node ID of the node and the pointer to the memory space where the node is located in the pre-generated mapping table when each node is established relation.

步骤B所述利用递归算法在所述目录树中建立与所述分类数据的所有分类目录一一对应的所有节点包括以下步骤:The described step B utilizes the recursive algorithm to set up all the nodes corresponding to all classification catalogs of the classification data in the catalog tree including the following steps:

C、令新建立的节点为当前节点,并判断当前节点所对应的分类目录是否具有下一级分类目录,如果有,则设置当前节点的数据指针为空,再建立一个新的节点,令当前节点的孩子节点指针指向在本步骤建立的新节点,并设置所述新节点对应于当前节点所对应分类目录的一个下一级分类目录,然后返回本步骤C;否则,设置当前节点的孩子节点指针为空,并将当前节点的数据指针指向用于保存当前节点对应分类目录所包含的分类数据的内存空间,然后执行步骤D;C. Let the newly created node be the current node, and judge whether the classification directory corresponding to the current node has a next-level classification directory. If so, set the data pointer of the current node to be empty, and then create a new node. The child node pointer of the node points to the new node established in this step, and the new node is set to correspond to a subcategory of the category directory corresponding to the current node, and then returns to step C; otherwise, the child node of the current node is set The pointer is empty, and the data pointer of the current node points to the memory space used to save the classification data contained in the classification directory corresponding to the current node, and then step D is executed;

D:判断当前节点所对应的分类目录是否具有未加入到该目录树中的同级分类目录,如果有,则建立一个新的节点,令当前节点的兄弟节点指针指向本步骤所建立的新节点,并设置所述新节点对应于当前节点所对应分类目录的一个未加入到该目录树中的同级分类目录,然后返回步骤C;否则,返回到当前节点所对应分类目录上一级分类目录对应的节点,并判断该节点是否为根节点,如果是,则结束,否则,令该节点为当前节点,并返回本步骤D。D: judge whether the classification directory corresponding to the current node has a classification directory of the same level that has not been added to the directory tree, if so, then establish a new node, and make the sibling node pointer of the current node point to the new node established in this step , and set the new node to correspond to a category directory at the same level that is not added to the directory tree corresponding to the category directory corresponding to the current node, and then return to step C; otherwise, return to the previous category directory of the category directory corresponding to the current node Corresponding node, and judge whether this node is the root node, if yes, then end, otherwise, make this node the current node, and return to this step D.

本发明所述方法进一步包括添加分类数据到某个分类目录,具体为:The method of the present invention further includes adding classification data to a certain classification directory, specifically:

A1:根据所要添加到的分类目录在所述目录树中找到对应该分类目录的节点;A1: find the node corresponding to the classification directory in the directory tree according to the classification directory to be added;

A2:设置该节点数据指针所指向的指针数组的第一个指针元素为当前的指针元素;A2: the first pointer element of the pointer array pointed to by the node data pointer is set as the current pointer element;

A3:判断当前指针元素所指向的内存空间是否为空,如果是,则向内存申请一块固定大小的内存空间,并令该指针元素指向新申请的内存空间,然后执行A4;否则,判断当前指针元素所指向的内存空间是否已满,如果是,则设置当前指针元素为指针数组的下一个指针元素,然后返回本步骤;否则,执行步骤A4;A3: Determine whether the memory space pointed to by the current pointer element is empty, if so, apply for a fixed-size memory space from the memory, and make the pointer element point to the newly applied memory space, and then execute A4; otherwise, judge the current pointer Whether the memory space pointed to by the element is full, if yes, set the current pointer element as the next pointer element of the pointer array, and then return to this step; otherwise, execute step A4;

A4:在当前指针元素指向的内存空间中添加所要添加的分类数据信息。A4: Add the classification data information to be added in the memory space pointed to by the current pointer element.

基于本发明所述的数据存储方法,本发明还给出了一种数据查询方法,所述数据经过至少一次分类后得到的分类数据保存在计算机的内存空间中;采用二叉结构目录树存储所述数据经过至少一次分离后得到的分类数据的各级分类目录,所述目录树上的每个节点占用固定大小的内存空间,且至少包括该节点所对应分类目录的节点标识、孩子节点指针、兄弟节点指针以及数据指针;预先在内存中生成一个映射表,并在建立每个节点的同时在预先生成的映射表中保存所述节点的节点标识与指向该节点所在内存空间的指针之间的映射关系;包括:Based on the data storage method of the present invention, the present invention also provides a data query method, wherein the classified data obtained after the data is classified at least once are stored in the memory space of the computer; Each level of classification directory of classification data obtained after the data has been separated at least once, each node on the directory tree occupies a fixed size of memory space, and at least includes a node identifier of the classification directory corresponding to the node, a child node pointer, Brother node pointers and data pointers; generate a mapping table in memory in advance, and save the relationship between the node ID of the node and the pointer pointing to the memory space where the node is located in the pre-generated mapping table while establishing each node Mapping relationship; including:

a、根据所述映射表在所述目录树中找到所要查询的分类目录所对应的节点;a. Find the node corresponding to the classification directory to be queried in the directory tree according to the mapping table;

b、判断该节点的孩子节点指针是否为空,如果是,则将该节点加入到一个容器中,然后执行步骤d;否则,执行步骤c;b. Determine whether the child node pointer of the node is empty, if so, add the node into a container, and then perform step d; otherwise, perform step c;

c、通过递归算法读出该节点整个左树枝所包含所有叶子节点,并将读出的所有叶子节点依次加入到一个容器中,然后执行步骤d;c. Read all the leaf nodes contained in the entire left branch of the node through a recursive algorithm, and add all the leaf nodes read into a container in turn, and then execute step d;

d、从所述容器中依次读出叶子节点,根据所读出叶子节点数据指针指向的内存空间,获取所述内存空间中存储的所有分类数据,返回给用户。d. Read the leaf nodes sequentially from the container, obtain all classified data stored in the memory space according to the memory space pointed to by the read leaf node data pointer, and return them to the user.

本发明在建立每个节点时,令每个节点的节点标识为该节点所对应分类目录的分类标识;When the present invention establishes each node, the node identification of each node is made the classification identification of the classification directory corresponding to the node;

步骤a所述根据映射表在所述目录树中找到所述所要查询的分类目录所对应的节点包括:Finding the node corresponding to the classification directory to be queried in the directory tree according to the mapping table in step a includes:

a1、根据所要查询的分类目录的分类标识在所述映射表中找到指向其对应的节点所在内存空间的指针;a1. According to the classification identification of the classification directory to be queried, find a pointer to the memory space where the corresponding node is located in the mapping table;

a2、通过所述该指针直接定位到所述所要查询、浏览的分类目录所对应的节点。a2. Directly locate the node corresponding to the classification directory to be queried and browsed through the pointer.

由此可以看出,使用二叉目录树代替现有的多叉目录树存储分类信息可以获得以下有益效果:It can be seen from this that using a binary directory tree to replace the existing multi-fork directory tree to store classification information can obtain the following beneficial effects:

首先,由于二叉目录树每个节点的大小是固定的,并且占用的空间很小,因此,使用二叉目录树存储分类信息可以大大节约内存资源,使内存可以存储更多的分类数据,提高的内存的存储效率。First of all, since the size of each node of the binary directory tree is fixed and occupies a small space, using a binary directory tree to store classified information can greatly save memory resources, so that the memory can store more classified data and improve memory storage efficiency.

另外,由于二叉树的生成以及节点的移动、增加、删除操作算法简单、开销小,并且在某个节点被移动、增加或删除的过程中,不需要考虑其父节点存储空间的分配以及回收等问题,使得使用二叉目录树对分类数据进行管理简单易行。In addition, due to the simple operation algorithm of the generation of the binary tree and the movement, addition, and deletion of nodes, the overhead is small, and in the process of a node being moved, added, or deleted, there is no need to consider the allocation and recycling of its parent node storage space. , making it easy to manage classified data using a binary directory tree.

附图说明 Description of drawings

图1为采用现有多叉树结构目录树存储的商品目录示意图;FIG. 1 is a schematic diagram of a commodity catalog stored in an existing multi-fork tree structure catalog tree;

图2为本发明优选实施例所采用目录树中每个节点的结构示意图;Fig. 2 is the structural representation of each node in the catalog tree that the preferred embodiment of the present invention adopts;

图3为本发明优选实施例所述基于目录树的分类数据存储方法流程图;Fig. 3 is the flow chart of the classification data storage method based on directory tree described in the preferred embodiment of the present invention;

图4为采用本发明优选实施例所述目录树存储的商品目录示意图;Fig. 4 is a schematic diagram of a commodity catalog stored in a catalog tree according to a preferred embodiment of the present invention;

图5为在本发明优选实施例所述二叉目录树中查询、浏览某个分类目录所包含的分类数据的方法流程图;Fig. 5 is the flow chart of the method for querying and browsing the classification data contained in a certain classification directory in the binary directory tree described in the preferred embodiment of the present invention;

图6为在本发明优选实施例所述二叉目录树的某个分类目录中添加分类数据的方法流程图。Fig. 6 is a flowchart of a method for adding classified data in a certain classification directory of the binary directory tree according to the preferred embodiment of the present invention.

具体实施方式 Detailed ways

为使本发明的目的、技术方案及优点更加清楚明白,以下参照附图并举实施例,对本发明作进一步详细说明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and examples.

考虑到二叉树是一种被广泛用于数据查找的数据结构,其生成以及节点搜索等算法比较成熟,且收敛速度快,因此本发明的核心思想在于利用二叉树结构存储分类数据。Considering that the binary tree is a data structure widely used for data search, its generation and node search algorithms are relatively mature, and the convergence speed is fast, so the core idea of the present invention is to use the binary tree structure to store classified data.

本发明的一个优选实施例给出了用于存储分类数据的二叉树结构目录树(简称二叉目录树)中每个节点的结构,如图2所示,每个节点包含用于标识该节点所对应分类目录的节点标识(ID),一个指向该节点下一级子节点的孩子节点指针,一个指向该节点同级节点中另一个节点的兄弟节点指针以及一个指向用于保存分类数据内存空间的数据指针。A preferred embodiment of the present invention provides the structure of each node in the binary tree structure directory tree (binary directory tree for short) that is used to store classification data, as shown in Figure 2, each node contains the information used to identify the node The node identifier (ID) corresponding to the classification directory, a child node pointer pointing to the next-level child node of the node, a sibling node pointer pointing to another node in the same-level node of the node, and a pointer pointing to the memory space used to save the classification data data pointer.

本发明一个优选实施例所述使用上述二叉目录树存储分类数据的方法如图3所示,主要包括以下步骤:The method described in a preferred embodiment of the present invention uses above-mentioned binary directory tree to store classification data as shown in Figure 3, mainly comprises the following steps:

A:建立根节点,即在内存中开辟一块空间存储该根节点的节点ID、其孩子节点指针、兄弟节点指针以及数据指针,设置该根节点的节点ID为0,令其兄弟节点指针为空(NULL),数据指针也为NULL。A: Establish a root node, that is, open up a space in the memory to store the node ID of the root node, its child node pointer, sibling node pointer and data pointer, set the node ID of the root node to 0, and make its sibling node pointer empty (NULL), the data pointer is also NULL.

B:建立一个新的节点,令所述根节点的孩子节点指针指向本步骤所建立的新节点,并令所述新节点的节点ID为一个一级分类目录的分类标识。B: set up a new node, make the child node pointer of described root node point to the new node that this step is set up, and make the node ID of described new node be the classification mark of a first-level classification list.

在这里所述的分类标识是预先确定的、可以唯一标识分类数据每个分类目录的标识,例如,在本实施例中,前面描述过的商品目录中一级分类目录电脑的分类标识为1,珠宝首饰的分类标识为2,手机的分类标识为3;二级分类目录笔记本的分类标识为11,台式机的分类标识为12;三级分类目录IBM的分类标识为111,DELL的分类标识为112等等。这样,通过将当前节点的ID设置为某个分类目录的分类标识,就可以将当前节点与一个分类目录对应起来了。需要说明的是,在本发明中每个分类目录的标识可以采用任何形式,只要能够唯一标识各个分类目录即可,而不限于上述优选实施例给出的形式。在本步骤中,设置所述新节点的节点ID为一个一级分类目录的分类标识实质上是将所述新节点与一个一级分类目录对应起来。The classification identifier described here is a predetermined identifier that can uniquely identify each classification catalog of the classification data. For example, in this embodiment, the classification identifier of the first-level classification computer in the commodity catalog described above is 1, The classification logo of jewelry is 2, the classification logo of mobile phone is 3; the classification logo of notebook in the second-level classification directory is 11, and the classification logo of desktop computer is 12; the classification logo of IBM in the third-level classification directory is 111, and the classification logo of DELL is 112 and so on. In this way, by setting the ID of the current node as the classification identifier of a certain classification directory, the current node can be associated with a classification directory. It should be noted that, in the present invention, the identification of each category can be in any form, as long as each category can be uniquely identified, and is not limited to the form given in the above-mentioned preferred embodiment. In this step, setting the node ID of the new node as a classification identifier of a first-level classification directory is essentially to associate the new node with a first-level classification directory.

本步骤所述建立新节点与步骤A所述建立根节点的方法相同,即在内存中开辟一块空间存储该节点的节点ID、孩子节点指针、兄弟节点指针以及数据指针。The method of establishing a new node described in this step is the same as that of establishing a root node described in step A, that is, open up a space in memory to store the node ID, child node pointer, sibling node pointer and data pointer of the node.

在后续的步骤中,将通过递归算法创建用于存储所述分类数据的二叉目录树,具体包括:In subsequent steps, a binary directory tree for storing the classified data will be created through a recursive algorithm, specifically including:

C:令所述新节点为当前节点,判断当前节点所对应的分类目录是否具有下一级分类目录,如果有,则执行步骤D;否则,执行步骤E。C: Let the new node be the current node, judge whether the classification directory corresponding to the current node has a next-level classification directory, and if so, execute step D; otherwise, execute step E.

D:设置当前节点的数据指针为NULL,再建立一个新的节点,令当前节点的孩子节点指针指向在本步骤建立的新节点,并设置所述新节点的节点ID为当前节点所对应分类目录的下一级分类目录中一个分类目录的分类标识,即将所述新节点对应于当前节点所对应分类目录的一个下一级分类目录,然后返回步骤C。D: set the data pointer of the current node to be NULL, then set up a new node, make the child node pointer of the current node point to the new node established in this step, and set the node ID of the new node to be the corresponding classification directory of the current node The classification identifier of a classification directory in the next-level classification directory, that is, the new node corresponds to a lower-level classification directory of the classification directory corresponding to the current node, and then return to step C.

在该步骤中,若所述当前节点对应于一个n级分类目录,则所述新节点的节点ID将为该n级分类目录所包含的一个n+1级分类目录的分类标识,例如当前节点对应二级分类目录笔记本,则所述新节点的节点ID就可以为三级分类目录IBM的分类标识111或三级分类目录DELL的分类标识112。In this step, if the current node corresponds to an n-level classification directory, the node ID of the new node will be the classification identification of an n+1-level classification directory contained in the n-level classification directory, such as the current node Corresponding to the notebook of the second-level classification directory, the node ID of the new node may be the classification identification 111 of the third-level classification directory IBM or the classification identification 112 of the third-level classification directory DELL.

E:设置当前节点的孩子节点指针为NULL,并将当前节点的数据指针指向用于保存当前节点对应分类目录所包含的分类数据的内存空间,然后执行步骤F。E: set the child node pointer of the current node as NULL, and point the data pointer of the current node to the memory space for saving the classification data contained in the corresponding classification directory of the current node, and then perform step F.

本步骤所述的用于保存当前节点对应分类目录所包含的分类数据的内存空间可以是大小任意并可以动态扩展的内存空间。The memory space used for storing the classification data contained in the classification directory corresponding to the current node described in this step can be a memory space of any size and can be dynamically expanded.

在本发明的另一个优选实施例中,为了方便进行内存资源管理,在该步骤中可以进一步设置一个指针数组,并将当前节点的数据指针指向该指针数组,其中,该指针数据的每个指针元素将分别指向固定大小的内存空间,所述固定大小的内存空间将用于记录各个叶子节点所对应的分类目录所包含的分类数据。所述指针数组所包含指针元素的个数n可以根据分类数据的多少预先设定,比如设定为10个,这样每个叶子节点就可以具有10个固定大小的内存空间。但并不是在每个叶子节点创建的时候就统一为该叶子节点申请n块内存空间,而是按需分配的,当一个内存空间存满的时候,才会申请下一个内存空间,并且每次申请仅分配一块内存空间。上述采用固定大小内存空间以及按需分配的方法主要是为了提高内存分配效率,有效地避免采用大小任意的内存空间存储分类数据时所需要的对内存空间的动态扩展操作。In another preferred embodiment of the present invention, in order to facilitate memory resource management, an array of pointers can be further set in this step, and the data pointer of the current node is pointed to the array of pointers, wherein each pointer of the pointer data The elements will respectively point to a memory space of a fixed size, and the memory space of a fixed size will be used to record the classification data contained in the classification directory corresponding to each leaf node. The number n of pointer elements contained in the pointer array can be preset according to the number of classified data, for example, 10, so that each leaf node can have 10 memory spaces with a fixed size. But instead of applying for n blocks of memory space for each leaf node when it is created, it is allocated on demand. When a memory space is full, the next memory space will be applied for, and each time The application allocates only one piece of memory space. The above-mentioned method of using fixed-size memory space and on-demand allocation is mainly to improve memory allocation efficiency and effectively avoid the dynamic expansion of memory space required when storing classified data in a memory space of any size.

F:判断当前节点所对应分类目录的所有同级目录中是否具有未加入到该二叉目录树中的,如果有,则执行步骤G;否则,执行步骤H。F: Judging whether all the same-level directories of the classification directory corresponding to the current node have not added in the binary directory tree, if so, then perform step G; otherwise, perform step H.

G:建立一个新的节点,令当前节点的兄弟节点指针指向本步骤所建立的新节点,并设置所述新节点的节点ID为当前节点所对应分类目录的一个未加入该二叉目录树中的同级目录的分类标识,即将所述新节点对应于当前节点所对应分类目录的一个同级分类目录,然后返回步骤C。G: set up a new node, make the sibling node pointer of current node point to the new node that this step is set up, and the node ID of described new node is set to be that one of current node's corresponding classification directory does not add in this binary directory tree The classification identifier of the same-level directory of the current node, that is, the new node corresponds to a same-level category directory of the category directory corresponding to the current node, and then returns to step C.

在该步骤中,若所述当前节点对应于一个n级分类目录,则所述新节点的节点ID将为未加入所述二叉目录树的另一个n级分类目录的分类标识,例如当前节点对应二级分类目录笔记本,则所述新节点的节点ID就可以为未加入该二叉目录树的二级分类目录台式机的分类标识12或二级分类目录办公设备的分类标识13。In this step, if the current node corresponds to an n-level classification directory, the node ID of the new node will be the classification identifier of another n-level classification directory that has not been added to the binary directory tree, such as the current node Corresponding to the notebook of the secondary classification directory, the node ID of the new node can be the classification identification 12 of the desktop computer of the secondary classification directory or the classification identification 13 of the office equipment of the secondary classification directory that has not been added to the binary directory tree.

H:返回到当前节点所对应分类目录上一级分类目录对应的节点,并判断该节点是否为根节点,如果是,则结束;否则,执行步骤I。H: return to the node corresponding to the upper level classification directory of the corresponding classification directory of the current node, and judge whether the node is the root node, if so, then end; otherwise, perform step 1.

I:令该节点为当前节点,并返回步骤F。I: make this node the current node, and return to step F.

通过执行上述步骤A~I,用于存储分类数据的二叉目录树已经建立完成,并且所述二叉目录树的所有节点将与所述分类数据的所有分类目录一一对映。图4显示了采用上述二叉目录树存储的商品目录示意图。如图4所示,根节点的孩子节点指针将指向各种商品数据经过一次分类后得到一个一级分类目录,例如电脑目录对应的一级子节点。该一级子节点的孩子节点指针将指向该一级分类目录经过二次分类得到的一个二级分类目录例如笔记本目录对应的二级子节点;而其兄弟节点指针将指向另一个一级分类目录,例如珠宝首饰目录对应的一级子节点,如此类推。上述二叉目录树中的叶子节点,例如对应IBM或DELL等分类目录的节点的数据指针将指向一个指针数组,所述指针数组的指针元素将指向存储各个分类目录所包含商品信息的内存空间,即物理内存块。By executing the above steps A-I, the binary directory tree for storing classified data has been established, and all nodes of the binary directory tree will be in one-to-one correspondence with all classified directories of the classified data. FIG. 4 shows a schematic diagram of a commodity catalog stored in the above-mentioned binary catalog tree. As shown in Figure 4, the child node pointer of the root node will point to a first-level classification directory obtained after one classification of various commodity data, such as the first-level child node corresponding to the computer directory. The child node pointer of the first-level child node will point to a second-level classification directory obtained by secondary classification of the first-level classification directory, such as the second-level child node corresponding to the notebook directory; and its brother node pointer will point to another first-level classification directory , such as the first-level child node corresponding to the jewelry category, and so on. The leaf nodes in the above-mentioned binary directory tree, for example, the data pointers corresponding to the nodes of classification directories such as IBM or DELL will point to a pointer array, and the pointer elements of the pointer array will point to the memory space for storing the commodity information contained in each classification directory, That is, a block of physical memory.

下面将结合图5详细描述在上述二叉目录树中查询某个分类目录所包含的分类数据的方法,如图5所示,该方法主要包括以下步骤:Below in conjunction with Fig. 5, describe in detail the method for inquiring about the classification data contained in a certain classification directory in the above-mentioned binary directory tree, as shown in Fig. 5, the method mainly includes the following steps:

a1、根据所要查询或浏览的分类目录的分类标识在二叉目录树中找到所述该分类目录所对应的节点;a1. According to the classification identification of the classification directory to be queried or browsed, find the node corresponding to the classification directory in the binary directory tree;

由于每个节点的节点ID就是该节点所对应分类目录的分类标识,本步骤所述查找对应节点的方法可以是将该分类目录的ID作为索引遍历所述二叉目录树,找到所述分类目录对应的节点;Since the node ID of each node is exactly the classification identification of the corresponding classification directory of this node, the method for searching for the corresponding node described in this step can be to use the ID of the classification directory as an index to traverse the binary directory tree to find the classification directory the corresponding node;

a2、判断该节点的孩子节点指针是否为NULL,如果是,则执行a3;否则执行步骤a4;a2. Determine whether the child node pointer of the node is NULL, if yes, execute a3; otherwise, execute step a4;

a3、将该节点加入到一个容器中,然后执行步骤a5;a3. Add the node to a container, and then perform step a5;

本步骤所述的容器是一块用于暂时存放叶子节点的临时内存空间;The container described in this step is a temporary memory space for temporarily storing leaf nodes;

a4、通过递归算法读出该节点整个左树枝所包含所有叶子节点,并将读出的所有叶子节点依次加入到一个容器中,然后执行步骤a5;a4. Read all the leaf nodes contained in the entire left branch of the node through a recursive algorithm, and add all the leaf nodes read into a container in turn, and then execute step a5;

a5、从所述容器中依次读出叶子节点,根据所读出叶子节点数据指针指向的内存空间,获取所述内存空间中存储的所有分类数据,返回给用户。a5. Read the leaf nodes sequentially from the container, obtain all classified data stored in the memory space according to the memory space pointed to by the read leaf node data pointer, and return them to the user.

若上述二叉目录树的叶子节点的数据指针指向的是一个指针数组,在步骤a5还需要进一步通过该指针数组找到存储分类数据的内存空间。If the data pointer of the leaf node of the above-mentioned binary directory tree points to a pointer array, it is necessary to further find the memory space for storing classified data through the pointer array in step a5.

接下来将详细描述在上述二叉目录树中添加分类数据的方法,例如添加某个商品信息到一个分类目录的方法。Next, the method of adding classified data in the above binary directory tree will be described in detail, for example, the method of adding certain commodity information to a classified directory.

若上述二叉目录树的叶子节点的数据指针指向的是大小任意并可以动态扩展的内存空间,则首先根据所要添加到的分类目录的分类标识找到所述该分类目录所在的节点;然后将需要添加的分类数据添加到该节点数据指针所指向的内存空间中。若该内存空间已满,还需要首先通过内存动态扩展操作扩展该节点数据指针所指向的内存空间。If the data pointer of the leaf node of the above-mentioned binary directory tree points to a memory space of any size and can be dynamically expanded, then at first find the node where the classification directory is located according to the classification identification of the classification directory to be added; The added classification data is added to the memory space pointed to by the node data pointer. If the memory space is full, it is necessary to expand the memory space pointed to by the node data pointer through the memory dynamic expansion operation first.

若上述二叉目录树的叶子节点的数据指针指向的是一个指针数组,则需要执行以下步骤,如图6所示:If the data pointer of the leaf node of the above-mentioned binary directory tree points to a pointer array, the following steps need to be performed, as shown in Figure 6:

b1:根据要将分类数据添加到的分类目录的分类标识在二叉目录树中找到所述该分类目录所在的节点;b1: find the node where the classification directory is located in the binary directory tree according to the classification identification of the classification directory to which the classification data will be added;

本步骤所采用的方法与步骤a1所述的方法相同;The method adopted in this step is the same as the method described in step a1;

b2:设置该节点数据指针所指向的指针数组的第一个指针元素为当前的指针元素;b2: set the first pointer element of the pointer array pointed to by the node data pointer as the current pointer element;

b3:判断当前指针元素所指向的内存空间是否为NULL,如果是,则执行步骤b4;否则,执行步骤b6;b3: judge whether the memory space pointed to by the current pointer element is NULL, if yes, then execute step b4; otherwise, execute step b6;

b4:向内存申请一块固定大小的内存空间,并令该指针元素指向新申请的内存空间,然后执行步骤b5;b4: Apply for a memory space of a fixed size to the memory, and make the pointer element point to the newly applied memory space, and then perform step b5;

b5:在当前指针元素所指向的内存空间中添加所要添加的分类数据信息,然后结束;b5: Add the classification data information to be added in the memory space pointed to by the current pointer element, and then end;

b6:判断当前指针元素所指向的内存空间是否已满,如果是,则执行步骤b7;否则,执行步骤b5;b6: judge whether the memory space pointed to by the current pointer element is full, if yes, then execute step b7; otherwise, execute step b5;

b7:设置当前指针元素为指针数组的下一个指针元素,然后返回步骤b3。b7: Set the current pointer element as the next pointer element of the pointer array, and then return to step b3.

在该步骤中,若当前指针元素为指针数组的最后一个指针元素,并且其指向的内存空间已满,则无法在当前的目录树中添加相应的分类数据,应当返回错误信息给用户。In this step, if the current pointer element is the last pointer element of the pointer array, and the memory space it points to is full, then corresponding classification data cannot be added to the current directory tree, and an error message should be returned to the user.

从上述优选实施例可以看出,由于二叉目录树每个节点的大小是固定的,并且占用的空间很小,因此,使用二叉目录树代替多叉目录树存储分类信息可以大大节约内存资源,从而可以存储更多的分类数据,并获得较高的存储效率。另外,由于二叉树的生成以及节点的移动、增加、删除操作算法简单、开销小,并且在某个节点被移动、增加或删除的过程中,仅需要修改其父节点的指针指向,而不需要考虑其父节点存储空间的分配以及回收等问题,使得使用二叉目录树对分类数据进行管理简单易行,可以在系统正常运行的环境下指向分类目录的变更操作,而不需要停机。It can be seen from the above preferred embodiments that since the size of each node of the binary directory tree is fixed and occupies very little space, using a binary directory tree instead of a multi-fork directory tree to store classification information can greatly save memory resources , so that more classified data can be stored and higher storage efficiency can be obtained. In addition, due to the simple algorithm and low overhead of the generation of the binary tree and the movement, addition, and deletion of nodes, and in the process of moving, adding, or deleting a node, only the pointer of its parent node needs to be modified without considering The allocation and recycling of the storage space of its parent node makes it easy to manage classified data using a binary directory tree, and it is possible to point to the change operation of the classified directory under the normal operating environment of the system without downtime.

经过测试,在实际的应用中,假如有1000万件商品,共有2000个最小的分类目录,应用上述二叉目录树的方法,系统可能存在的节点,包括叶子节点和非叶子节点一共为3000个,每个节点占用的空间约为16字节(其中节点ID、孩子节点指针、兄弟节点指针以及数据指针各需4字节),并且每件商品在仅存储商品标识的情况下仅需要4字节的存储空间,那么所有的节点以及商品所需要的总的内存空间约为3000×16+10,000,000×4=40.048兆字节。完全可以全部存放在计算机内存空间中,从而可以极大地提高数据的检索效率。After testing, in an actual application, if there are 10 million items and a total of 2,000 smallest classification directories, using the above-mentioned binary directory tree method, the possible nodes in the system, including leaf nodes and non-leaf nodes, are 3,000 in total. , the space occupied by each node is about 16 bytes (the node ID, child node pointer, sibling node pointer and data pointer each need 4 bytes), and each product only needs 4 characters when only storing the product ID node storage space, then the total memory space required by all nodes and commodities is about 3000×16+10,000,000×4=40.048 megabytes. It can be completely stored in the computer memory space, which can greatly improve the retrieval efficiency of data.

在上述二叉目录树中查询、浏览某个分类目录所包含的分类数据的方法以及在二叉目录树中添加分类数据的方法中,均需要首先根据分类目录的分类标识通过遍历二叉目录树的方法找到所述该分类目录所在的节点,这种遍历操作将耗费较多的时间。In the method of querying and browsing the classification data contained in a certain classification directory in the above-mentioned binary directory tree and the method of adding classification data in the binary directory tree, it is necessary to first traverse the binary directory tree according to the classification identification of the classification directory The method to find the node where the classification directory is located, this traversal operation will consume more time.

为了方便查找各个分类目录,本发明的又一个优选实施例预先在内存中生成一个分类目录对应节点的节点ID与指向该节点所在物理内存块指针的映射表,并在执行上述步骤A~I生成所述二叉目录树的过程中,在步骤C进一步执行如下操作:在预先生成的映射表中保存步骤C所述当前节点的节点ID与指向当前节点所在内存空间的指针之间的映射关系。In order to facilitate the search for each classification directory, another preferred embodiment of the present invention pre-generates a mapping table of the node ID of the corresponding node of the classification directory and the pointer to the physical memory block where the node is located in memory, and executes the above steps A to I to generate In the process of the binary directory tree, further perform the following operations in step C: save the mapping relationship between the node ID of the current node described in step C and the pointer pointing to the memory space where the current node is located in the pre-generated mapping table.

这样,由于每个节点的节点ID就是该节点所对应分类目录的分类标识,因此,在上述二叉目录树中查询、浏览某个分类目录所包含的分类数据的方法以及在二叉目录树中添加分类数据的方法中可以首先直接根据要将分类数据添加到的分类目录的分类标识,在所述分类目录对应节点的节点ID与指向该节点所在物理内存块指针的映射表中找到指向该分类目录对应的节点所在内存空间的指针,然后通过所述指针直接定位到所述分类目录对应的节点,而无需进行二叉目录树的遍历。例如,现在有1000万件商品,分布在1000个叶子下面,这样,平均每个叶子节点下有1万件商品。如果用户需要浏览某个分类目录,这个分类目录下包含了20万件商品,通过预先保存的节点ID与指向该节点所在内存空间的指针之间的映射关系可以直接定位到该分类目录对应的节点,因此,系统需要检索的商品总数只有20W,而不需要从整个1000万件商品中过滤,并且,用户每选择查找下一级的分类目录,所需要检索的商品总数都会快速减少,从而大大地提高了节点的查找效率,进一步提高了分类数据的管理效率。In this way, since the node ID of each node is exactly the classification identifier of the corresponding classification directory of the node, the method of querying and browsing the classification data contained in a certain classification directory in the above-mentioned binary directory tree and in the binary directory tree In the method for adding classified data, at first directly according to the classification identification of the classification directory to which the classification data will be added, the node ID of the node corresponding to the classification directory and the mapping table pointing to the physical memory block pointer where the node is located can be found pointing to the classification The pointer of the memory space where the node corresponding to the directory is located, and then directly locate the node corresponding to the classification directory through the pointer, without traversing the binary directory tree. For example, there are now 10 million items distributed under 1,000 leaves, so that there are 10,000 items under each leaf node on average. If the user needs to browse a category, which contains 200,000 items, the node corresponding to the category can be directly located through the mapping relationship between the pre-saved node ID and the pointer to the memory space where the node is located. , therefore, the total number of products to be retrieved by the system is only 20W, without filtering from the entire 10 million products, and every time the user chooses to search for the next level of classification, the total number of products to be retrieved will decrease rapidly, thereby greatly The search efficiency of nodes is improved, and the management efficiency of classified data is further improved.

Claims (8)

1. a date storage method is characterized in that, comprising:
Described data are at least once classified, obtain the split catalogs at different levels of grouped data and described grouped data, described grouped data is stored in the memory headroom of computing machine;
Adopt the split catalogs at different levels of the described grouped data of y-bend structure category tree storage, store each node on the described directory tree with the memory headroom of fixed size, described each node comprise at least this node node identification, child nodes pointer, brotgher of node pointer and the data pointer of corresponding split catalog;
A, set up the root node of described directory tree, the brotgher of node pointer that makes this root node is for empty, data pointer is empty, and set up a new node, the new node that makes the child nodes pointed of described root node be set up is with the one-level split catalog of described new node corresponding to described grouped data;
B, utilize recursive algorithm to set up respectively and the split catalogs at different levels of described grouped data node one to one, for each node, if the pairing split catalog of this node comprises the split catalog of next stage, one of the child nodes pointed that then makes this node corresponding to this node the node of corresponding split catalog next stage split catalog, and make this node data pointer for empty, otherwise, make this node child nodes pointer for empty, and make this node data pointed be used to preserve the memory headroom of the grouped data that the pairing split catalog of this node comprised; If comprised all nodes in the described directory tree corresponding to corresponding split catalog peer of this node institute split catalog, the brotgher of node pointer that then makes this node is for empty, otherwise, one of the brotgher of node pointed that makes this node corresponding to this node corresponding split catalog catalogue at the same level and be not included in node in the described directory tree;
In internal memory, generate a mapping table in advance, and the mapping relations between the pointer of the node identification of when setting up each node, in the mapping table that generates in advance, preserving described node and this node place memory headroom of sensing.
2. the method for claim 1 is characterized in that, step B is described utilize recursive algorithm in described directory tree, set up with all split catalogs of described grouped data one to one all nodes may further comprise the steps:
C, make that newly-established node is a present node, and judge whether the pairing split catalog of present node has the next stage split catalog, if have, the data pointer that present node then is set is for empty, set up a new node again, the new node that the child nodes pointed that makes present node is set up in this step, and with described new node corresponding to present node a next stage split catalog of corresponding split catalog, return this step C then; Otherwise the child nodes pointer that makes present node is for empty, and the data pointer of present node is pointed to the memory headroom that is used to preserve the grouped data that the corresponding split catalog of present node comprised, execution in step D then;
D: judge whether the pairing split catalog of present node has the split catalog at the same level that does not join in this directory tree, if have, then set up a new node, the new node that makes this step of brotgher of node pointed of present node be set up, and with described new node corresponding to present node a split catalog at the same level that does not join in this directory tree of corresponding split catalog, return step C then; Otherwise, turn back to present node the pairing node of upper level split catalog of corresponding split catalog, and judge whether this node is root node, if then finish; Otherwise, make that this node is a present node, and return this step D.
3. method as claimed in claim 1 or 2, it is characterized in that, the described data pointer that makes node points to the memory headroom that is used to preserve the grouped data that the corresponding split catalog of this node comprised: make the data pointer of node point to an array of pointers, each pointer element of described pointer data will be pointed to the memory headroom of fixed size respectively, and the memory headroom of described fixed size will be used for the grouped data that the pairing split catalog of minute book node is comprised.
4. method as claimed in claim 3 is characterized in that, described method further comprises adds grouped data to certain split catalog, is specially:
A1: in described directory tree, find node that should split catalog according to the split catalog that will add to;
A2: first pointer element that this node data pointer array of pointers pointed is set is current pointer element;
A3: judge that whether current pointer element memory headroom pointed is empty, if, then to the memory headroom of a fixed size of internal memory application, and make this pointer element point to the memory headroom of new application, carry out A4 then; Otherwise, judge whether current pointer element memory headroom pointed is full, if it is the next pointer element of array of pointers that the current pointer element then is set, and returns this step then; Otherwise, execution in step A4;
A4: in the memory headroom of current pointer element directed, add the assortment data information that to add.
5. method as claimed in claim 4 is characterized in that, when setting up each node, makes the class indication of the node identification of each node by the corresponding split catalog of this node;
Steps A 1 is described to find the node at described this split catalog place to comprise according to the split catalog that will add to:
Class indication according to the split catalog that will add finds the pointer that points to its corresponding node place memory headroom in described mapping table;
Directly navigate to the node of the described split catalog correspondence that will add to by described this pointer.
6. a data enquire method is characterized in that, described data are kept in the memory headroom of computing machine through the grouped data that obtains behind at least one subseries; Adopt the at different levels split catalogs of the described data of y-bend structure category tree storage through the grouped data that obtains after the first separation at least, each node on the described directory tree takies the memory headroom of fixed size, and comprise at least this node node identification, child nodes pointer, brotgher of node pointer and the data pointer of corresponding split catalog; In internal memory, generate a mapping table in advance, and the mapping relations between the pointer of the node identification of when setting up each node, in the mapping table that generates in advance, preserving described node and this node place memory headroom of sensing; Comprise:
A, in described directory tree, find the pairing node of the split catalog that to inquire about according to described mapping table;
B, judge that whether the child nodes pointer of this node is empty, if then this node is joined in the container, then execution in step d; Otherwise, execution in step c;
C, read the whole left branch of this node by recursive algorithm and comprise all leaf nodes, and all leaf nodes that will read join in the container successively, then execution in step d;
D, read leaf node successively from described container, the memory headroom according to reading leaf node data pointer points to obtains all grouped datas of storing in the described memory headroom, returns to the user as Query Result.
7. method as claimed in claim 6 is characterized in that, when setting up each node, makes the class indication of the node identification of each node by the corresponding split catalog of this node;
Step a is described to find the pairing node of the described split catalog that will inquire about to comprise in described directory tree according to mapping table:
A1, in described mapping table, find the pointer that points to its corresponding node place memory headroom according to the class indication of the split catalog that will inquire about;
A2, directly navigate to the pairing node of the described split catalog that will inquire about, browse by described this pointer.
8. method as claimed in claim 6 is characterized in that, described container is the interim memory headroom that is used for temporarily depositing leaf node.
CNB2005101166630A 2005-10-26 2005-10-26 A data storage and query method Active CN100468402C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005101166630A CN100468402C (en) 2005-10-26 2005-10-26 A data storage and query method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005101166630A CN100468402C (en) 2005-10-26 2005-10-26 A data storage and query method

Publications (2)

Publication Number Publication Date
CN1955958A CN1955958A (en) 2007-05-02
CN100468402C true CN100468402C (en) 2009-03-11

Family

ID=38063287

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005101166630A Active CN100468402C (en) 2005-10-26 2005-10-26 A data storage and query method

Country Status (1)

Country Link
CN (1) CN100468402C (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013097115A1 (en) * 2011-12-28 2013-07-04 华为技术有限公司 File directory storage method, retrieval method and device
CN110019223A (en) * 2017-12-21 2019-07-16 天津数观科技有限公司 A method of the generation data family tree based on Data Storage Models

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101726312B (en) * 2008-10-15 2012-09-19 高德信息技术有限公司 Method and device for retrieving interest points
CN101388842B (en) 2008-10-30 2012-04-04 华为技术有限公司 Storage method and apparatus
CN102024019B (en) * 2010-11-04 2013-03-13 曙光信息产业(北京)有限公司 Suffix tree based catalog organizing method in distributed file system
CN102439598A (en) * 2011-09-15 2012-05-02 华为技术有限公司 Document template management method and system
CN102768669A (en) * 2012-04-27 2012-11-07 新奥特(北京)视频技术有限公司 Method for realizing video file classification
CN102902734A (en) * 2012-09-12 2013-01-30 北京伸得纬科技有限公司 Method and system for catalogue storage and mapping
CN103020206A (en) * 2012-12-05 2013-04-03 北京海量融通软件技术有限公司 Knowledge-network-based search result focusing system and focusing method
CN104424251B (en) 2013-08-28 2019-03-15 腾讯科技(深圳)有限公司 A kind of calculation method and system that various dimensions are split
CN104572746B (en) * 2013-10-24 2018-03-20 世纪禾光科技发展(北京)有限公司 A kind of matrix form information issue and access method and system
CN106559278B (en) * 2015-09-25 2020-09-15 中兴通讯股份有限公司 Data processing state monitoring method and device
CN105528461A (en) * 2016-01-12 2016-04-27 北京中交兴路车联网科技有限公司 Membership function based data system and method
CN105808770A (en) * 2016-03-22 2016-07-27 北京北方微电子基地设备工艺研究中心有限责任公司 File management method and device
CN106934033A (en) * 2017-03-14 2017-07-07 广东工业大学 A kind of bent plate robot data indexing means and device
CN107341207B (en) * 2017-06-23 2020-03-17 深圳市盛路物联通讯技术有限公司 Node information management method and device
CN107402977A (en) * 2017-07-03 2017-11-28 天脉聚源(北京)传媒科技有限公司 The method and apparatus for establishing video resource classification tree
CN108549676B (en) * 2018-03-30 2020-02-18 广州供电局有限公司 Display method and device of power data, computer equipment and storage medium
CN109710542B (en) * 2018-12-28 2021-03-16 北京像素软件科技股份有限公司 Full N-way tree construction method and device
CN111339042B (en) * 2020-03-26 2024-03-01 北京快映互娱传媒有限公司 Data operation processing method, system and scheduling server
CN114328797B (en) * 2021-11-09 2024-03-19 腾讯科技(深圳)有限公司 Content search method, device, electronic apparatus, storage medium, and program product
CN119938703A (en) * 2025-04-08 2025-05-06 山东建筑大学 A method for storing building construction data based on BIM

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
数据结构. 严蔚敏,吴伟民,135-138,清华大学出版社. 2002 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013097115A1 (en) * 2011-12-28 2013-07-04 华为技术有限公司 File directory storage method, retrieval method and device
CN110019223A (en) * 2017-12-21 2019-07-16 天津数观科技有限公司 A method of the generation data family tree based on Data Storage Models

Also Published As

Publication number Publication date
CN1955958A (en) 2007-05-02

Similar Documents

Publication Publication Date Title
CN100468402C (en) A data storage and query method
CN102890722B (en) Indexing method applied to time sequence historical database
CN101315628B (en) Internal memory database system and method and device for implementing internal memory data base
CN103229173B (en) Metadata management method and system
AU759360B2 (en) Database apparatus
US6208993B1 (en) Method for organizing directories
EP3103025B1 (en) Content based organization of file systems
TWI554897B (en) Mail index establishment method and system, mail search method and system
CN102298641B (en) Method for uniformly storing files and structured data based on key value bank
CN102467521B (en) Easily-extensible multi-level classification search method and system
CN101464901B (en) Object search method in object storage device
CN102332030A (en) Data storage, management and query method and system for distributed key-value storage system
CN108717457B (en) Electronic commerce platform big data processing method and system
CN109284273B (en) Massive small file query method and system adopting suffix array index
CN106970958B (en) A kind of inquiry of stream file and storage method and device
CN103282899A (en) File system data storage method and access method and device therefor
CN103942301B (en) Distributed file system oriented to access and application of multiple data types
CN103186617B (en) A kind of method and apparatus storing data
CN101526965B (en) Locating method of index nodes of disk file and device thereof
WO2014110940A1 (en) A method, apparatus and system for storing, reading the directory index
CN102609490A (en) Column-storage-oriented B+ tree index method for DWMS (data warehouse management system)
CN102968464A (en) Index-based local resource quick retrieval system and retrieval method thereof
CN103473337A (en) Massive catalogs and files oriented processing method in distributed type storage system
CN108399213A (en) A kind of clustering method and system of user oriented personal document
CN104516945A (en) Hadoop distributed file system metadata storage method based on relational data base

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: BEIJING JINGDONG SHANGKE INFORMATION TECHNOLOGY CO

Free format text: FORMER OWNER: TENGXUN SCI-TECH (SHENZHEN) CO., LTD.

Effective date: 20140425

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 518044 SHENZHEN, GUANGDONG PROVINCE TO: 100080 HAIDIAN, BEIJING

TR01 Transfer of patent right

Effective date of registration: 20140425

Address after: 100080 Beijing, Suzhou Street, No. 20, building 2, floor 2,

Patentee after: Beijing Jingdong Shangke Information Technology Co., Ltd.

Address before: Shenzhen Futian District City, Guangdong province 518044 Zhenxing Road, SEG Science Park 2 East Room 403

Patentee before: Tencent Technology (Shenzhen) Co., Ltd.