CN110543494A - Method for constructing reachable graph based on cache table - Google Patents

Method for constructing reachable graph based on cache table Download PDF

Info

Publication number
CN110543494A
CN110543494A CN201910762401.3A CN201910762401A CN110543494A CN 110543494 A CN110543494 A CN 110543494A CN 201910762401 A CN201910762401 A CN 201910762401A CN 110543494 A CN110543494 A CN 110543494A
Authority
CN
China
Prior art keywords
cache table
root node
graph
constructing
entries
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.)
Granted
Application number
CN201910762401.3A
Other languages
Chinese (zh)
Other versions
CN110543494B (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.)
Hunan Linqi Network Technology Co Ltd
Original Assignee
Hunan Linqi Network Technology 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 Hunan Linqi Network Technology Co Ltd filed Critical Hunan Linqi Network Technology Co Ltd
Priority to CN201910762401.3A priority Critical patent/CN110543494B/en
Publication of CN110543494A publication Critical patent/CN110543494A/en
Application granted granted Critical
Publication of CN110543494B publication Critical patent/CN110543494B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • 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/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention relates to a method for constructing a reachability graph based on a cache table, which comprises the following steps: step one, constructing a cache table: establishing a relation cache table in a graph database or a memory; step two, constructing a reachable graph by using a cache table; and step three, updating the cache table. The method is suitable for the scene of constructing the reachable tree of the node in the graph by using the relational database storage graph, and a large amount of reachable tree construction requirements based on the same graph exist.

Description

method for constructing reachable graph based on cache table
Technical Field
the invention relates to the technical field of reachable graph construction, in particular to a method for constructing a reachable graph based on a cache table.
background
At present, big data are more and more widely used, and a reachability graph is expected to be constructed based on the big data, but the traditional relational database is based on records and cannot rapidly construct the reachability graph; in practice, only a few nodes are accessed for many times, so the invention increases the efficiency of generating the reachable graph by adding a cache table in the graph database or the memory when constructing the database.
the conventional node relationship table is as follows:
Serial number starting point Terminal point
1 A B
2 A C
3 B C
4 C D
5 F E
6 F G
Based on the data structure, when a reachable graph taking a node A as a root is constructed by the traditional method, firstly, a row with the value of a starting point column of a node relation table equal to A is inquired, and the node B, the node C and the node A are inquired to be reachable; continuously inquiring the row with the initial point column of B or C in the node relation table, and inquiring that the node D can be reached by the node C; and continuously inquiring the initial point column in the node relation table as a node D row, wherein no new reachable node is searched, and the algorithm is ended.
according to the above process, constructing the reachable tree with the node A as the root requires at least N database queries (where N is the number of nodes of the reachable tree).
disclosure of Invention
Aiming at the defects of the prior art, the invention provides a method for constructing a reachable graph based on a cache table, which is suitable for a scene of constructing the reachable tree of the nodes in the graph by using a relational database storage graph and has a large number of reachable tree construction requirements based on the same graph.
the technical scheme adopted by the invention for solving the technical problems is as follows: the method for constructing the reachability graph based on the cache table comprises the following steps:
step one, constructing a cache table: establishing a relation cache table in a graph database or a memory;
Step two, constructing a reachable graph by using a cache table;
And step three, updating the cache table.
in a preferred embodiment of the method for constructing a reachability graph based on a cache table provided by the present invention, the method includes that the table is composed of a header and a table body, the table body includes a plurality of rows of entries, the number of rows of entries is a constant C, and the header sequentially includes from left to right:
a table body, wherein the table body comprises a plurality of rows of entries, and the number of the entries is stored in the rows of the entries in the sequence number row of the table body;
a root node name storing the name of the root node in a plurality of rows of entries of a root node name column in the table body;
the names of the child nodes are stored in a plurality of rows of entries of corresponding child node name columns in the table body, and the number of the child nodes is not more than L;
A plurality of child node hierarchies, wherein the hierarchy number of the child node is stored in a corresponding child node hierarchy column in a table body, and the hierarchy of each child node is the number of layers between the child node and the root node;
And the last access time, namely the time of using the row entry data to construct the reachable graph last time, including year, month, day, hour, minute and second, is stored in the last access time column in the table body.
in a preferred embodiment of the method for constructing a reachability graph based on a cache table of the present invention, each of the child node names and the child node hierarchies are sequentially arranged adjacent to each other.
in a preferred embodiment of the method for constructing a reachability graph based on a cache table provided in the present invention, in the second step, when constructing the reachability graph by using the root node, the root node name column in the cache table is firstly queried, which includes the following steps:
case a: the root node appears in the root node name column of the cache table, and the root node name in the cache table is taken out to be an entry of the root node, wherein the entry of the row contains all information of the reachable graph taking the root node as the root;
Case b: and traversing the cache table step by step according to the original access mode and returning the obtained reachable graph.
in a preferred embodiment of the method for constructing a reachability graph based on a cache table provided by the present invention, in the third step, when constructing the reachability graph by using a root node, a name column of the root node in the cache table is first queried, which includes the following situations that the cache table needs to be updated:
case a: if the root node appears in the root node name column of the cache table, only the last access time of the row of entries of which the root node name is the root node in the cache table needs to be updated is the current time;
Case b: if the root node does not appear in the root node name column of the cache table, the number of child nodes of the reachable graph with the root node as the root and the depth of H, which is obtained by inquiring the cache table, does not exceed L, and the number of entries in the cache table is less than C, the information of the reachable graph is filled into the empty row entries in the cache table;
case c: and if the number of the child nodes of the reachable graph which takes the root node as the root and has the depth of H obtained by inquiring the cache table does not exceed L and the number of the entries in the cache table is equal to C, deleting the entry with the earliest last access time in the cache table, and filling the information of the reachable graph into the deleted entry in the cache table.
compared with the prior art, the method for constructing the reachability graph based on the cache table has the advantages that: the constructed cache table can be used as a database cache table based on a database and used as a memory cache table based on a memory, and the efficiency of generating the reachable graph is improved by adding one cache table when the database is constructed;
When the cache table is built in the database, the root node is used for building the reachable graph, the query frequency of the database is 1 time under the condition of hitting the cache table, and the query frequency of the database is +1 time under the condition of not hitting the cache table;
when the cache table is built in the memory, the root node is used for building the reachable graph, under the condition of hitting the cache table, the database query frequency is 0, the memory table query frequency is 1, and under the condition of not hitting the cache table, the database query frequency is 1 in the traditional method plus the memory table query;
the method is suitable for the scene of constructing the reachable tree of the node in the graph by using the relational database storage graph, and a large amount of reachable tree construction requirements based on the same graph exist.
drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without inventive efforts, wherein:
FIG. 1 is a block diagram of a cache table according to a preferred embodiment of the present invention;
FIG. 2 is a block diagram of the root A architecture of the preferred embodiment of FIG. 1;
FIG. 3 is a block diagram of the embodiment of FIG. 1, with B as the root;
FIG. 4 is a block diagram of the embodiment of FIG. 1, which is a reachable diagram implemented with C as the root.
Detailed Description
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.
the method for constructing the reachability graph based on the cache table comprises the following steps:
Step S1, constructing a cache table: establishing a relation cache table in a graph database or a memory;
specifically, the cache table is composed of a header and a table body, the table body includes a plurality of rows of entries, the number of rows of entries is a constant C, and the header sequentially includes from left to right:
the serial number, the number of entries is stored in a plurality of rows of entries in the serial number column of the table body;
A root node name storing the name of the root node in a plurality of rows of entries of a root node name column in the table body;
The method comprises the following steps that names of child nodes are stored in a plurality of rows of entries of corresponding child node name columns in a table body, the number of the child nodes is not more than L, and L in the embodiment is the maximum number of the child nodes of a reachable graph supported by a preset cache table;
The hierarchy number of the child node is stored in a corresponding child node hierarchy column in a table body, the hierarchy of each child node is the number of layers between the child node and the root node, and the name of each child node and the hierarchy of the child node are sequentially arranged adjacently;
and the last access time, namely the time of using the row entry data to construct the reachable graph last time, including year, month, day, hour, minute and second, is stored in the last access time column in the table body.
step S2, constructing a reachability graph by using a cache table;
Specifically, when constructing the reachability graph by using the root node, the root node name column in the cache table is firstly queried, which includes the following cases:
case a: the root node appears in the root node name column of the cache table, and the root node name in the cache table is taken out to be an entry of the root node, wherein the entry of the row contains all information of the reachable graph taking the root node as the root;
case b: and traversing the cache table step by step according to the original access mode and returning the obtained reachable graph.
Step S3, the cache table is updated.
Specifically, when the reachability graph is constructed by the root node, the root node name column in the cache table is firstly queried, including the following situations that the cache table needs to be updated:
case a: if the root node appears in the root node name column of the cache table, only the last access time of the row of entries of which the root node name is the root node in the cache table needs to be updated is the current time;
Case b: if the root node does not appear in the root node name column of the cache table, the number of child nodes of the reachable graph with the root node as the root and the depth of H, which is obtained by inquiring the cache table, does not exceed L, and the number of entries in the cache table is less than C, the information of the reachable graph is filled into the empty row entries in the cache table;
case c: and if the number of the child nodes of the reachable graph which takes the root node as the root and has the depth of H obtained by inquiring the cache table does not exceed L and the number of the entries in the cache table is equal to C, deleting the entry with the earliest last access time in the cache table, and filling the information of the reachable graph into the deleted entry in the cache table.
in this embodiment, the following cache table is constructed according to the above method:
to further supplement the description, the present embodiment creates a cache table as shown in fig. 1:
When A is taken as a root node to construct a reachable graph, firstly traversing a root node name column, wherein an entry with the sequence number of 1 comprises all information of the reachable graph taking A as the root, and the constructed reachable graph is shown in FIG. 2;
when B is used as a root node to construct a reachable graph, firstly traversing a root node name column, wherein an entry with the sequence number of 2 contains all information of the reachable graph using B as the root, and the constructed reachable graph is shown in FIG. 3;
when a reachable graph is constructed by taking C as a root node, firstly traversing a root node name column, wherein an entry with a sequence number of 3 contains all information of the reachable graph taking C as the root, and the constructed reachable graph is shown in FIG. 4;
and by analogy, constructing a reachable graph of all nodes.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by the present specification, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (5)

1. a method for constructing a reachability graph based on a cache table is characterized in that: the method comprises the following steps:
step one, constructing a cache table: establishing a relation cache table in a graph database or a memory;
Step two, constructing a reachable graph by using a cache table;
and step three, updating the cache table.
2. the method for constructing a reachability graph based on a cache table of claim 1, wherein: the cache table is composed of a header and a table body, the table body comprises a plurality of rows of entries, the number of rows of the entries is a constant C, and the header sequentially comprises from left to right:
the serial number, the number of entries is stored in a plurality of rows of entries in the serial number column of the table body;
A root node name storing the name of the root node in a plurality of rows of entries of a root node name column in the table body;
the names of the child nodes are stored in a plurality of rows of entries of corresponding child node name columns in the table body, and the number of the child nodes is not more than L;
a plurality of child node hierarchies, wherein the hierarchy number of the child node is stored in a corresponding child node hierarchy column in a table body, and the hierarchy of each child node is the number of layers between the child node and the root node;
And the last access time, namely the time of using the row entry data to construct the reachable graph last time, including year, month, day, hour, minute and second, is stored in the last access time column in the table body.
3. The method for constructing a reachability graph based on a cache table of claim 2, wherein: and each child node name is sequentially arranged adjacent to a child node hierarchy.
4. the method for constructing a reachability graph based on a cache table of claim 1, wherein: in the second step, when the reachability graph is constructed by the root node, the root node name column in the cache table is firstly queried, which includes the following conditions:
case a: the root node appears in the root node name column of the cache table, and the root node name in the cache table is taken out to be an entry of the root node, wherein the entry of the row contains all information of the reachable graph taking the root node as the root;
case b: and traversing the cache table step by step according to the original access mode and returning the obtained reachable graph.
5. The method for constructing a reachability graph based on a cache table of claim 1, wherein: in the third step, when the reachability graph is constructed by the root node, the root node name column in the cache table is firstly queried, including the following conditions that the cache table needs to be updated:
case a: if the root node appears in the root node name column of the cache table, only the last access time of the row of entries of which the root node name is the root node in the cache table needs to be updated is the current time;
case b: if the root node does not appear in the root node name column of the cache table, the number of child nodes of the reachable graph with the root node as the root and the depth of H, which is obtained by inquiring the cache table, does not exceed L, and the number of entries in the cache table is less than C, the information of the reachable graph is filled into the empty row entries in the cache table;
case c: and if the number of the child nodes of the reachable graph which takes the root node as the root and has the depth of H obtained by inquiring the cache table does not exceed L and the number of the entries in the cache table is equal to C, deleting the entry with the earliest last access time in the cache table, and filling the information of the reachable graph into the deleted entry in the cache table.
CN201910762401.3A 2019-08-19 2019-08-19 Method for constructing reachable graph based on cache table Active CN110543494B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910762401.3A CN110543494B (en) 2019-08-19 2019-08-19 Method for constructing reachable graph based on cache table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910762401.3A CN110543494B (en) 2019-08-19 2019-08-19 Method for constructing reachable graph based on cache table

Publications (2)

Publication Number Publication Date
CN110543494A true CN110543494A (en) 2019-12-06
CN110543494B CN110543494B (en) 2023-03-24

Family

ID=68711542

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910762401.3A Active CN110543494B (en) 2019-08-19 2019-08-19 Method for constructing reachable graph based on cache table

Country Status (1)

Country Link
CN (1) CN110543494B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103748982B (en) * 2009-05-31 2011-04-27 北京理工大学 The method of calibration in the misuse detection system attack knowledge storehouse based on Petri pessimistic concurrency control
CN104484478A (en) * 2014-12-31 2015-04-01 中国农业银行股份有限公司 Correlation clustered data slimming method and system
CN107679107A (en) * 2017-09-13 2018-02-09 全球能源互联网研究院有限公司 A kind of grid equipment accessibility querying method and system based on chart database
CN109947796A (en) * 2019-04-12 2019-06-28 北京工业大学 A kind of caching method of distributed data base system inquiry intermediate result set

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103748982B (en) * 2009-05-31 2011-04-27 北京理工大学 The method of calibration in the misuse detection system attack knowledge storehouse based on Petri pessimistic concurrency control
CN104484478A (en) * 2014-12-31 2015-04-01 中国农业银行股份有限公司 Correlation clustered data slimming method and system
CN107679107A (en) * 2017-09-13 2018-02-09 全球能源互联网研究院有限公司 A kind of grid equipment accessibility querying method and system based on chart database
CN109947796A (en) * 2019-04-12 2019-06-28 北京工业大学 A kind of caching method of distributed data base system inquiry intermediate result set

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
小爪哇海: "可达性分析算法(根搜索算法GCRoots)", 《HTTPS://WWW.JIANSHU.COM/P/B79FE594EED3》 *

Also Published As

Publication number Publication date
CN110543494B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
CN111782742B (en) Large-scale geographic space data oriented storage and retrieval method and system thereof
CN110413611B (en) Data storage and query method and device
CN102521334B (en) Data storage and query method based on classification characteristics and balanced binary tree
CN109471905B (en) Block chain indexing method supporting time range and attribute range compound query
CN102722566B (en) Method for inquiring potential friends in social network
WO2020034757A1 (en) Data processing method and device, storage medium, and electronic device
CN110825733B (en) Multi-sampling-stream-oriented time series data management method and system
CN108197313B (en) Dictionary indexing method for realizing space optimization through 16-bit Trie tree
CN103051543A (en) Route prefix processing, lookup, adding and deleting method
CN103365991A (en) Method for realizing dictionary memory management of Trie tree based on one-dimensional linear space
CN111639075A (en) Non-relational database vector data management method based on flattened R tree
CN110069500A (en) A kind of non-relational database dynamic hybrid index method
CN110597805B (en) Memory index structure processing method
US20140324875A1 (en) Index for fast batch updates of large data tables
CN113486034B (en) Historical version backtracking method for vector map layer and pattern spot
CN113468080B (en) Caching method, system and related device for full-flash metadata
CN110543494B (en) Method for constructing reachable graph based on cache table
CN109885570A (en) A kind of multi-Dimensional Range querying method of secondary index combination hash table
CN107562762A (en) Data directory construction method and device
CN116821127A (en) Method for realizing hash index of kv stored distributed database
CN113626433B (en) Data storage method based on two-layer ART tree
CN111159175B (en) Incomplete database Skyline query method based on index
CN115221361A (en) Method for storing and encoding graph data based on attribute graph model
CN111190545B (en) Method for carrying out LPM rule compression storage on trie structure based on software implementation
CN110083603B (en) Method and system for realizing node path query based on adjacency list

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