CN107807932B - Hierarchical data management method and system based on path enumeration - Google Patents

Hierarchical data management method and system based on path enumeration Download PDF

Info

Publication number
CN107807932B
CN107807932B CN201610812627.6A CN201610812627A CN107807932B CN 107807932 B CN107807932 B CN 107807932B CN 201610812627 A CN201610812627 A CN 201610812627A CN 107807932 B CN107807932 B CN 107807932B
Authority
CN
China
Prior art keywords
node
target
data
interface
tree
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
CN201610812627.6A
Other languages
Chinese (zh)
Other versions
CN107807932A (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.)
Tencent Technology Shenzhen Co Ltd
Tencent Cloud Computing Beijing 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 CN201610812627.6A priority Critical patent/CN107807932B/en
Publication of CN107807932A publication Critical patent/CN107807932A/en
Application granted granted Critical
Publication of CN107807932B publication Critical patent/CN107807932B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2272Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • G06F16/24566Recursive queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Landscapes

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

Abstract

The invention provides a hierarchical data management method and a hierarchical data management system based on path enumeration, wherein hierarchical data is stored in a non-relational database in a form of secondary index, and the hierarchical data is tree-structured data; in the second-level index, the first-level index is a root node of the tree, the second-level index is a target node of the tree, target data pointed by the second-level index comprises path data from the root node to the target node, and in addition, the method also comprises the step of inquiring the level data, including inquiring a higher-level node and a lower-level node of the target node. According to the invention, the hierarchical data is stored in the non-relational database in a key value storage mode of the secondary index, and the read-write efficiency is higher by using the non-relational database; and the query of the hierarchical data is realized by adopting a path enumeration recursion-free mode, so that the query efficiency is better.

Description

Hierarchical data management method and system based on path enumeration
Technical Field
The invention relates to the field of data management, in particular to a hierarchical data management method and system based on path enumeration.
Background
In the field of instant messaging, two types of instant messaging software exist, namely, an instant messaging software based on a flat architecture and an instant messaging software applied to a multi-level architecture, wherein the multi-level architecture is used for representing the superior-inferior relation between users. Because the data model of the communication software based on the flat architecture cannot process hierarchical data in a tree structure for representing a multi-level architecture, the communication software based on the flat architecture is difficult to support communication between users with upper and lower level relationships, thereby limiting the application range of the communication software.
At present, most hierarchical data are organized based on a relational database MySql, specifically, hierarchical data are organized in a manner of combining MySql and an adjacent table, MySql uses a hard disk as a memory, the read-write efficiency is low, and when the hierarchical data is read and written, SQL statement recursive query or multi-table associated query is needed, so that the system operation is complex; alternatively, the non-relational database may organize the hierarchical data by matching with the adjacency list, but the use of the adjacency list may result in an increase in the number of network interactions and an increase in the consumption of network traffic during the interaction of the hierarchical data.
Disclosure of Invention
In order to solve the technical problem, the invention provides a hierarchical data management method and system based on path enumeration. The invention is realized by the following technical scheme:
a hierarchical data management method based on path enumeration comprises the following steps:
storing hierarchical data in a non-relational database in a form of secondary indexes, wherein the hierarchical data is tree-structured data;
in the secondary indexes, a first-level index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary indexes comprise path data from the root node to the target node. The target data pointed to by the secondary index also includes a depth value representing a hierarchical position of a target node in the tree.
And querying the hierarchical data, including querying a superior node and an inferior node of the target node. And the upper node of the query target node comprises a father node and an ancestor node of the query target node. And the lower nodes of the query target node comprise child nodes and descendant nodes of the query target node.
Also included is inserting, deleting and/or migrating the hierarchical data.
A hierarchical data management system based on path enumeration, comprising:
the system comprises a secondary index building module, a path data generating module and a path data generating module, wherein the secondary index building module is used for building a secondary index of hierarchical data, the hierarchical data is tree-shaped structure data, in the secondary index, a first-level index is a root node of a tree, a second-level index is a target node of the tree, and the target data pointed by the secondary index comprises the path data from the root node to the target node;
and the database construction module is used for storing the hierarchical data in a non-relational database in a secondary index mode.
Further comprising: a data query module; the data query module comprises a superior query submodule and an inferior query submodule, wherein the superior query submodule is used for querying an superior node of a target node, and the inferior query submodule is used for querying an inferior node of the target node.
The upper-level query submodule comprises a direct upper-level query unit and all upper-level query units, the direct upper-level query unit is used for querying a father node of the target node, and all the upper-level query units are used for querying ancestor nodes of the target node.
The subordinate inquiry sub-module comprises a direct subordinate inquiry unit and all subordinate inquiry units, wherein the direct subordinate inquiry unit is used for inquiring the child nodes of the target node, and all the subordinate inquiry units are used for inquiring the descendant nodes of the target node.
Further comprising: the database operation module is used for expanding the functional logic of the database, and the functional logic comprises insertion, deletion and/or migration.
Further comprising: the interface module is used for providing an interface for operating the database, and the interface module provides an inquiry interface, an insertion interface, a deletion interface and/or a migration interface.
An instant messaging system includes the above hierarchical data management system based on path enumeration, and further includes:
the database operation module is used for expanding the functional logic of the database, and the functional logic comprises insertion, deletion and/or migration;
the interface module is used for providing an interface for operating the database, the interface module comprises an inquiry interface, an insertion interface, a deletion interface and/or a migration interface, the insertion interface is used for providing an interface for inserting the hierarchical data, the deletion interface is used for providing an interface for deleting the hierarchical data, and the migration interface is used for providing an interface for operating the hierarchical data.
Further comprising:
the system comprises an instant messaging server and at least one instant messaging client;
the instant communication client is used for sending out an operation instruction;
the instant communication server is used for receiving the operation instruction and calling the relevant interface of the interface module to realize the communication among the multi-level architectures.
The invention has the beneficial effects that:
(1) the hierarchical data is organized by using the non-relational database, the non-relational database stores and reads and writes data by adopting an internal memory or a Solid State Disk (SSD), and the storage efficiency and the data reading and writing efficiency are higher.
(2) All paths of the tree-shaped hierarchical data are recorded in an enumeration form, and the paths are organized through a secondary index, so that the hierarchical data can be queried without recursion, the query efficiency is better, and the response speed of operation instructions related to the hierarchical data is higher.
(3) In the hierarchical data management system based on path enumeration, algorithm logic and storage management related to hierarchical data management are realized in a modularized mode, so that interaction between the hierarchical data management system and other systems is simplified, and the adaptability and the portability of the hierarchical data management system are enhanced;
(4) by interacting with a hierarchical data management system based on path enumeration, an instant messaging system which originally can only support flat communication can support communication of users among multi-level architectures, and therefore the application range of flat communication software is expanded.
Drawings
FIG. 1(a) is a tree structure diagram of hierarchical data;
FIG. 1(b) is a schematic diagram of recording hierarchical data in the form of an adjacency list;
FIG. 2 is a flowchart of a hierarchical data management method based on path enumeration according to embodiment 1;
FIG. 3 is a schematic diagram of network interaction of recursive lookup of an adjacency list in embodiment 1;
FIG. 4 is a diagram showing the flow of a full-pull data layer in example 1;
FIG. 5(a) is a tree structure diagram of hierarchical data in example 1;
fig. 5(b) is a schematic diagram of a path for recording hierarchical data in an enumerated form in embodiment 1;
FIG. 6 is a schematic diagram of a hierarchical data management system based on path enumeration as provided in example 3;
FIG. 7 is a schematic view of a data query module in example 3;
fig. 8 is a schematic view of an instant messaging system provided in embodiment 4;
FIG. 9 is a timing chart of a query operation provided in embodiment 4;
fig. 10 is a timing chart of an inserting operation provided in embodiment 4;
FIG. 11 is a timing chart of a delete operation of a leaf node provided in embodiment 4;
FIG. 12 is a timing chart of a flexible delete operation of the branch provided in embodiment 4;
FIG. 13 is a timing chart of a forced delete operation of a branch provided in embodiment 4;
fig. 14 is a timing chart of the migration operation provided in embodiment 4.
Detailed description of the invention
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The method manages hierarchical data in a tree structure in a mode of matching a relational database MySql with an adjacency list in the field of supporting a communication system based on a multilevel architecture, is different from a data management mode of using a non-relational database NoSql, and has the following defects:
(1) the results of comparative analysis of the functions of the non-relational database and the relational database are shown in table 1:
TABLE 1 functional comparison of MySQL and NoSql
Functional characteristics Relational database MySql NoSql non-relational database
Length of stored data Without limitation 64kb
Complex query operations Support for Do not support
Data reading efficiency Is lower than Is higher than
Data storage mode Hard disk Memory and hard disk
Automatic backup One master and multiple slaves One master and multiple slaves
Off-site storage Support for Support for
Automatic capacity expansion Do not support Support for
The results of the analysis for table 1 are as follows:
in the field of instant messaging, the unlimited meaning of the data length of MySql is not large, but the long-distance storage and automatic capacity expansion have practical significance for the management of hierarchical data. MySql does not support automatic capacity expansion, thereby bringing hidden danger to the use of MySql in instant messaging software.
MySql supports complex query operation, so that the MySql management hierarchy data has the advantage of simplicity in development, but the MySql data reading efficiency is low, more query actions need to be executed on hierarchy data in the field of instant messaging, and obviously, the performance of software development by using NoSql is better.
The NoSql relies on the memory and the hard disk for data storage, and obviously has higher running speed compared with the MySql which relies on the hard disk.
In summary, the relational database MySql has a larger gap in performance than the non-relational database NoSql.
(2) The relational database MySql stores hierarchical data by using the adjacency list, occupies small space, has high modification efficiency but low query efficiency:
in a multi-level architecture module, many complex business logics need to be processed, such as a higher-level node and a lower-level node of a query target node, wherein the higher-level node of the query target node comprises a father node and an ancestor node of the query target node, and the lower-level node of the query target node comprises a child node and a descendant node of the query target node; both of these operations require recursive queries. As shown in fig. 1, fig. 1(a) is a tree structure diagram of hierarchical data, and fig. 1(b) is a schematic diagram of recording hierarchical data in the form of an adjacency list. Each row of MySql data records one node and one associated node, the associated nodes are a superior node and an inferior node, a recursive mode is needed when the superior node and the inferior node are queried, performance loss is caused, and the performance loss is more serious for inexperienced developers or database administrators DBA.
In summary, in order to improve the storage and management performance of the hierarchical data, it is advantageous to organize the hierarchical data by using a non-relational database.
Example 1:
as shown in fig. 2, this embodiment provides a hierarchical data management method based on path enumeration, including:
s101, storing hierarchical data in a non-relational database in a secondary index mode, wherein the hierarchical data are tree-structured data.
In the secondary indexes, a first-level index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary indexes comprise path data from the root node to the target node. The target data pointed to by the secondary index also includes a depth value representing a hierarchical position of a target node in the tree.
And S102, inquiring, inserting, deleting and/or migrating the hierarchical data.
The querying comprises querying the superior node and the inferior node of the target node.
And the upper node of the query target node comprises a father node and an ancestor node of the query target node. And the lower nodes of the query target node comprise child nodes and descendant nodes of the query target node.
In the prior art, a non-relational database is used for query, and two situations exist:
in the first case, hierarchical data is organized in a storage manner using a two-level index (keykeykeyrow) and represented by an adjacency table, and query of the hierarchical data is implemented by recursive query, as shown in fig. 3, where an average of 3 times of requests is generated in the background every 1 query request.
In the second case, the hierarchical data is organized by using a storage manner of key value pairs (KeyValue), as shown in fig. 4, in the data query operation, each operation pulls the data in full, and the network throughput is improved by 1 order of magnitude.
In order to overcome performance loss caused by querying using a non-relational database in the prior art, in this embodiment, all paths of tree-shaped hierarchical data are recorded in an enumerated form, and the paths are organized by a secondary index, so that a recursion-free query for the hierarchical data can be implemented, and thus the above-mentioned problems of increasing network interaction times and increasing network traffic are solved, where a storage manner of path enumeration is shown in fig. 5, where fig. 5(a) is a tree-shaped structure diagram of the hierarchical data, and fig. 5(b) is a schematic diagram of paths recording the hierarchical data in an enumerated form.
In the embodiment, the hierarchical data is stored based on the non-relational database, so that the read-write performance has remarkable advantages; by using path enumeration to realize recursion-free query, the problems of more network interaction times and increased network flow are solved, so that higher query efficiency is ensured.
Example 2:
the embodiment provides a hierarchical data management method based on path enumeration, which comprises the following steps:
s201, storing the hierarchical data in a non-relational database in a secondary index mode, wherein the hierarchical data are tree-structured data.
In the secondary indexes, a first-level index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary indexes comprise path data from the root node to the target node. The target data pointed to by the secondary index also includes a depth value representing a hierarchical position of a target node in the tree. For the tree structure in fig. 5(a), the specific structure of the storage in the non-relational database is shown in table 2;
TABLE 2 concrete storage Structure of Secondary indexes in non-relational database
Figure BDA0001111520560000071
Figure BDA0001111520560000081
S202, inquiring, inserting, deleting and/or migrating the hierarchical data,
the query of the hierarchical data includes querying an upper node and a lower node of a target node.
The upper node of the query target node comprises a father node and an ancestor node of the query target node, and the lower node of the query target node comprises a child node and a descendant node of the query target node.
The embodiment implements the recursion-free operation in the following specific manner with reference to table 2:
a) querying a parent node of a target node
i. Target data corresponding to a target node is taken out from a non-relational database, a first-level index (main key) corresponding to the target data is a root node of a tree where the target node is located, and a second-level index (row key) corresponding to the target data is the target node;
obtaining a depth value of the target node in the tree through the target data; in the target data, the value of the position of the depth value-1 is the parent node of the target node.
If the parent node of query 5 is found in table 2, query the row of data with a main key of 1 and a row key of 5, and if the depth value of the target data is 3, then the depth value-1 is 2, so the value of node 2 is the parent node of 5.
b) Query ancestor node of target node
i. Target data corresponding to a target node is taken out from a non-relational database, a first-level index (main key) corresponding to the target data is a root node of a tree where the target node is located, and a second-level index (row key) corresponding to the target data is the target node;
obtaining a depth value of the target node in the tree through the target data; in the target data, the values from 0 to "depth value-1" position are the ancestor nodes of the target node.
If the ancestor node of 5 is queried, in table 2, the row of data with the main key of 1 and the row key of 5 is queried, the depth value of the target data is 3, and the depth value of-1 is 2, then node 1 and node 2 are the ancestor nodes of 5.
c) Querying children of a target node
i. Target data corresponding to a target node is taken out from a non-relational database, a first-level index (main key) corresponding to the target data is a root node of a tree where the target node is located, and a second-level index (row key) corresponding to the target data is the target node;
obtaining a depth value of the target node in the tree through the target data;
and iii, searching a target second-level index (row key) under a first-level index frame corresponding to the target data, wherein the value of the target second-level index is the child node of the target node.
The target second level index points to target data having the following characteristics:
the depth value is the depth value of the target node in the book + 1;
the value of node N is the target node, where N is the depth value of the target node in the tree.
If the descendant node of query 1 is in table 2, querying the data of which the main key is 1 and the row key is 1 to obtain the depth value of 1 as 1; and filtering data with the position of the node 1 being 1 and the depth value being 2 from all data in the non-relational database to obtain two lines of data, wherein the line key of the two lines of data is the child node of 1.
d) Querying descendant nodes of a target node
i. Target data corresponding to a target node is taken out from a non-relational database, a first-level index (main key) corresponding to the target data is a root node of a tree where the target node is located, and a second-level index (row key) corresponding to the target data is the target node;
obtaining a depth value of the target node in the tree through the target data;
and iii, searching a target second-level index (row key) under a first-level index frame corresponding to the target data, wherein the value of the target second-level index is the descendant node of the target node.
The target second level index points to target data having the following characteristics:
the value of node N is the target node, where N is the depth value of the target node in the tree.
If the descendant node of query 5 is in table 2, querying the data of which the main key is 1 and the row key is 5 to obtain the depth value of 5 as 3; and filtering data with the position value of the node 3 being 5 from all data of the non-relational database to obtain three rows of data, wherein the obtained three rows of data are descendant nodes of 5.
Further, the deleting of the hierarchical data comprises leaf node deleting and branch deleting, and the branch deleting comprises flexible deleting and forced deleting.
The flexible deletion means that deletion confirmation is carried out before the data is deleted to remind that the data is deleted; the forced deletion means that a deletion request is put forward, and after the node to be deleted is read, the node is deleted directly without deletion confirmation.
The embodiment provides a hierarchical data query method based on path enumeration, which stores hierarchical data in a non-relational database, realizes various queries of a target node by adopting a path enumeration recursion-free mode, and improves the performance of a system as a whole, wherein the flow and the throughput in the query process both meet the expected low overhead.
Example 3:
as shown in fig. 6, this embodiment provides a hierarchical data management system based on path enumeration, including:
the secondary index constructing module 401 is configured to construct a secondary index of hierarchical data, where the hierarchical data is tree-structured data, a first-level index in the secondary index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary index includes path data from the root node to the target node.
A database building module 402 for storing the hierarchical data in a non-relational database in the form of a secondary index.
A data query module 403, configured to query data in the database building module, as shown in fig. 7, where the data query module includes a higher level query sub-module 4031 and a lower level query sub-module 4032, the higher level query sub-module 4031 is configured to query a higher level node of a target node, and the lower level query sub-module 4032 is configured to query a lower level node of the target node.
The upper level query submodule 4031 includes a direct upper level query unit for querying a parent node of the target node, and all upper level query units for querying an ancestor node of the target node.
The subordinate query submodule 4032 includes a direct subordinate query unit and all subordinate query units, the direct subordinate sub-query module is configured to query a child node of the target node, and all the subordinate query units are configured to query a descendant node of the target node.
Further comprising:
a database operation module 404, configured to extend functional logic of the database, where the functional logic includes insertion, deletion, and/or migration.
The interface module 405 is configured to provide an interface for operating a database, where the interface module 405 includes an inquiry interface, an insertion interface, a deletion interface, and/or a migration interface, the insertion interface is configured to provide an interface for inserting the database, the deletion interface is configured to provide an interface for deleting the database, and the migration interface is configured to provide an interface for operating the database.
The hierarchical data management system provided in this embodiment can be used to implement the hierarchical data management methods provided in embodiments 1 and 2, and algorithm logic and storage management related to hierarchical data management are implemented in a modular manner, so that interaction between the hierarchical data management system and other systems is simplified, and adaptability and portability of the hierarchical data management system are enhanced.
Example 4:
as shown in fig. 8, this embodiment provides an instant messaging system, which includes a hierarchical data management system 501, where the hierarchical data management system 501 is implemented by the hierarchical data management system based on path enumeration provided in embodiment 4, and includes a secondary index building module 5011, a database building module 5012, a data query module 5013, a database operation module 5014, and an interface module 5015;
an instant messaging server 502 and at least one instant messaging client 503;
the instant messaging client 503 is configured to issue an operation instruction;
the instant messaging server 502 is configured to receive an operation instruction, call a relevant interface of the interface module 5015, and implement communication between multiple hierarchical architectures by using the extension of the functional logic of the database operation module 5014.
Specifically, the operation instruction includes a query instruction, an insertion instruction, a deletion instruction, and a migration instruction, and the interface module 5015 includes a query interface, an insertion interface, a deletion interface, and a migration interface.
Further, as shown in fig. 9, in the timing diagram of the query operation provided in this embodiment, specifically, the timing diagram of the query descendant node, the instant messaging client 503 sends the query instruction, the instant messaging server 502 calls the query interface provided by the interface module 5015 to read the target node, and filters the descendant node of the read target node according to the filtering condition.
Further, as shown in fig. 10, in the timing chart of the inserting operation provided by this embodiment, specifically, the instant messaging client 503 issues an inserting instruction, and the instant messaging server 502 calls an inserting interface provided by the interface module 5015 to read the parent node; before the insertion action is executed according to the parameters carried in the insertion instruction, validity check is also required to be performed, such as the number validity of the inserted nodes, the hierarchical validity of the inserted nodes, and the actual existence of the nodes.
Specifically, in the instant messaging system, the deletion operation includes leaf node deletion and branch deletion, and the branch deletion includes flexible deletion and mandatory deletion.
As shown in fig. 11, which is a timing chart of a deleting operation of a leaf node, specifically, when the instant messaging client 503 issues an instruction to delete the leaf node, the instant messaging server 502 calls a deleting interface provided by the interface module 5015 to read a node to be deleted; before the deleting instruction executes the deleting action, the validity check is carried out on the leaf node to be deleted.
As shown in fig. 12, it is a timing diagram of a flexible deleting operation of a branch, specifically, the instant messaging client 503 sends a flexible deleting instruction of a branch, the instant messaging server 502 calls a deleting interface provided by the interface module 5015 to read a node to be deleted, and filters out a descendant node of the node to be deleted according to the read record; before the deletion instruction executes the deletion action, the deletion instruction returns to the instant messaging client 503 to delete confirmation information, and the confirmation information is used for reminding that all data are to be deleted.
As shown in fig. 13, it is a timing diagram of a forced deletion operation of a branch, specifically, the instant messaging client 503 sends a forced deletion instruction of a branch, the instant messaging server 502 calls a deletion interface provided by the interface module 5015 to read a node to be deleted, and filters out a subsequent node of the node to be deleted according to the read record, so as to delete the node directly.
As shown in fig. 14, in a timing chart of the migration operation, specifically, the instant messaging client 503 sends a migration instruction, the instant messaging server 502 calls the migration interface provided by the interface module 5015 to read the root node, filters out descendant nodes of the root node according to the read record, and further reads the target node; before writing in a new target node, the validity of the migrated node needs to be checked, and new data after migration needs to be assembled.
All the modules in the technical scheme of the invention can be realized by a computer terminal or other equipment. The computer terminal includes a processor and a memory. The memory is used for storing the program instructions/modules in the invention, and the processor realizes the corresponding functions of the invention by operating the program instructions/modules stored in the memory.
The technical solution of the present invention may be substantially implemented or a part of or all or part of the technical solution that contributes to the prior art may be implemented in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention.
The division of the modules/units described in the present invention is only a logical function division, and other division manners may be available in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. Some or all of the modules/units can be selected according to actual needs to achieve the purpose of implementing the scheme of the invention.
In addition, each module/unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (6)

1. A hierarchical data management method based on path enumeration is characterized by comprising the following steps:
storing hierarchical data in a non-relational database in the form of a secondary index, wherein the hierarchical data is tree-structured data, a first-level index in the secondary index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary index comprises path data from the root node to the target node and a depth value of the target node in the tree;
target data corresponding to the target node is taken out from the non-relational database;
obtaining the depth value of the target node in the tree through the target data;
taking the value of the position of subtracting 1 from the depth value in the target data as a father node of the target node, and taking the value of the position of subtracting 1 from zero to the depth value in the target data as an ancestor node of the target node;
searching a target second-level index under a first-level index frame corresponding to the target data;
and taking the value of the target second-level index as a subordinate node of the target node, wherein the subordinate node is a child node or a descendant node of the target node.
2. The hierarchical data management method based on path enumeration as claimed in claim 1, further comprising inserting, deleting and/or migrating the hierarchical data.
3. A hierarchical data management system based on path enumeration, comprising:
the secondary index building module is used for building a secondary index of the hierarchical data;
the database construction module is used for storing the hierarchical data in a non-relational database in a form of a secondary index, the hierarchical data is tree-type structure data, in the secondary index, a first-level index is a root node of a tree, a second-level index is a target node of the tree, and target data pointed by the secondary index comprises path data from the root node to the target node and a depth value of the target node in the tree;
the target data determining module is used for taking out target data corresponding to the target node from the non-relational database;
the depth value acquisition module is used for acquiring the depth value of the target node in the tree through the target data;
a parent node determining module, configured to use a value obtained by subtracting a depth value by 1 from the target data as a parent node of the target node;
an ancestor node determining module, configured to use a value from zero to a position where a depth value is subtracted by 1 in the target data as an ancestor node of the target node;
the target index searching module is used for searching a target second-level index under a first-level index frame corresponding to the target data;
a subordinate node determination module configured to use the value of the target second-level index as a subordinate node of the target node, where the subordinate node is a child node or a descendant node of the target node.
4. The hierarchical path enumeration-based data management system of claim 3, further comprising:
the database operation module is used for expanding the functional logic of the database, and the functional logic comprises insertion, deletion and/or migration.
5. The hierarchical path enumeration-based data management system of claim 4, further comprising:
the interface module is used for providing an interface for operating the database, and the interface module provides an inquiry interface, an insertion interface, a deletion interface and/or a migration interface.
6. An instant messaging system comprising the path enumeration based hierarchical data management system of claim 3, further comprising:
the database operation module is used for expanding the functional logic of the database, and the functional logic comprises insertion, deletion and/or migration;
the interface module is used for providing an interface for operating the database, and the interface module provides an inquiry interface, an insertion interface, a deletion interface and/or a migration interface;
further comprising:
the system comprises an instant messaging server and at least one instant messaging client;
the instant communication client is used for sending out an operation instruction;
the instant communication server is used for receiving the operation instruction and calling the relevant interface of the interface module to realize the communication among the multi-level architectures.
CN201610812627.6A 2016-09-08 2016-09-08 Hierarchical data management method and system based on path enumeration Active CN107807932B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610812627.6A CN107807932B (en) 2016-09-08 2016-09-08 Hierarchical data management method and system based on path enumeration

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610812627.6A CN107807932B (en) 2016-09-08 2016-09-08 Hierarchical data management method and system based on path enumeration

Publications (2)

Publication Number Publication Date
CN107807932A CN107807932A (en) 2018-03-16
CN107807932B true CN107807932B (en) 2021-11-16

Family

ID=61576233

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610812627.6A Active CN107807932B (en) 2016-09-08 2016-09-08 Hierarchical data management method and system based on path enumeration

Country Status (1)

Country Link
CN (1) CN107807932B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109062936B (en) * 2018-06-15 2023-10-31 中国平安人寿保险股份有限公司 Data query method, computer readable storage medium and terminal equipment
CN111177206B (en) * 2018-11-09 2023-07-11 盒马(中国)有限公司 Method, device and system for processing pivot table
CN110110007A (en) * 2019-04-15 2019-08-09 平安普惠企业管理有限公司 Data managing method and Related product
CN110471916B (en) * 2019-07-03 2023-05-26 平安科技(深圳)有限公司 Database query method, device, server and medium
CN112256690B (en) * 2019-07-22 2022-09-13 上海汇招信息技术有限公司 Novel tree structure method and novel tree structure updating method
US11762859B2 (en) 2020-09-28 2023-09-19 International Business Machines Corporation Database query with index leap usage
CN112948385B (en) * 2021-03-02 2024-02-13 深圳大学 Display method and device for sequence data distribution, storage medium and terminal equipment
CN113626433B (en) * 2021-08-03 2024-01-19 上海沄熹科技有限公司 Data storage method based on two-layer ART tree

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101210339B1 (en) * 2006-10-10 2012-12-18 삼성전자주식회사 Method for generating node identifier in k-nary tree
CN101840400B (en) * 2009-03-19 2012-02-01 北大方正集团有限公司 Multilevel classification retrieval method and system
CN102467521B (en) * 2010-11-08 2013-09-04 北大方正集团有限公司 Easily-extensible multi-level classification search method and system
CN103853773A (en) * 2012-12-04 2014-06-11 厦门亿联网络技术股份有限公司 Searching method of tree data structure of Mysql database
CN103279544A (en) * 2013-06-05 2013-09-04 中国电子科技集团公司第十五研究所 Method and device for storing and inquiring tree structure data in relational database
CN104239511B (en) * 2014-09-15 2016-03-30 西安交通大学 A kind of user's space file system implementation method towards MongoDB
CN104281701B (en) * 2014-10-20 2018-02-09 北京农业信息技术研究中心 Multiscale Distributed Spatial data query method and system

Also Published As

Publication number Publication date
CN107807932A (en) 2018-03-16

Similar Documents

Publication Publication Date Title
CN107807932B (en) Hierarchical data management method and system based on path enumeration
CN102426609B (en) Index generation method and index generation device based on MapReduce programming architecture
CN106484906B (en) Distributed object storage system flash-back method and device
CN104794123A (en) Method and device for establishing NoSQL database index for semi-structured data
CN103279532B (en) Many set elements duplicate removal also identifies the affiliated filtration system gathered and method thereof
CN107977396B (en) Method and device for updating data table of KeyValue database
CN104133867A (en) DOT in-fragment secondary index method and DOT in-fragment secondary index system
CN104156380A (en) Distributed memory Hash indexing method and system
CN102915278A (en) Data deduplication method
CN109542861B (en) File management method, device and system
CN104239377A (en) Platform-crossing data retrieval method and device
CN107766355B (en) Hierarchical data management method, hierarchical data management system and instant messaging system
WO2014110940A1 (en) A method, apparatus and system for storing, reading the directory index
CN104834650A (en) Method and system for generating effective query tasks
CN105260464A (en) Data storage structure conversion method and apparatus
CN104615785A (en) Data storage method and device based on TYKY cNosql
CN110888837A (en) Object storage small file merging method and device
CN106649602A (en) Way, device and server of processing business object data
CN103942301A (en) Distributed file system oriented to access and application of multiple data types
CN115840731A (en) File processing method, computing device and computer storage medium
CN109614411B (en) Data storage method, device and storage medium
WO2020024798A1 (en) Efficient storage method for time series data
CN108984626B (en) Data processing method and device and server
CN105843809B (en) Data processing method and device
KR101171551B1 (en) Event history memory device, event history tracking device, event history memory method, computer-readable recording medium recording event history memory program and computer-readable recording medium recording data structure

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20231008

Address after: 518057 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 floors

Patentee after: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd.

Patentee after: TENCENT CLOUD COMPUTING (BEIJING) Co.,Ltd.

Address before: 2, 518000, East 403 room, SEG science and Technology Park, Zhenxing Road, Shenzhen, Guangdong, Futian District

Patentee before: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd.