Summary of the invention
This application provides a kind of date storage method, data query method, apparatus and storage medium, can solve with existing
Efficiency data query lower problem when some date storage method storage tree form data structures.The application provides following technical side
Case:
In a first aspect, providing a kind of date storage method, which comprises
Obtain the destination node in tree form data structure;
The M of the root node is generated when the destination node is root node1Inherit coding, the M in position1For positive integer;
The succession coding of the child node, the i-stage child node are generated when the destination node is i-stage child node
Succession coding include (i-1)-th grade of node succession coding, and the digit of the succession coding of the i-stage child node is Mi-1+
mi, the Mi-1For the digit of the succession coding of (i-1)-th grade of node, miFor the newly-increased number of encoding bits of the i-stage child node;
The i is the integer greater than 1;
It stores the destination node and inherits the corresponding relationship between coding, different target node corresponds to different successions and compiles
Code.
Optionally, the newly-increased number of encoding bits between not at the same level are identical, described when the destination node is i-stage child node
Generate the succession coding of the child node, comprising:
Obtain the value of the newly-increased number of encoding bits;
The newly-increased coding with the newly-increased number of encoding bits is generated according to the value of the newly-increased number of encoding bits;
Obtain the succession coding of the father node of the i-stage child node;
The succession coding of the father node of the i-stage child node is spliced with the newly-increased coding, obtains i-stage
The succession of node encodes, and the succession coding of the i-stage child node is different from the succession of the other child nodes of i-stage coding.
Optionally, the corresponding relationship between the storage destination node and succession coding, comprising:
Determine the succession coding mapped database of the destination node;
Corresponding relationship between the destination node and the succession coding is stored to the database.
Optionally, the succession of the determination destination node encodes mapped database, comprising:
Remainder, the first data that remainder result is indicated are carried out to default value using the succession coding of the destination node
Library is determined as the succession coding mapped database of the destination node;Alternatively,
Remainder is carried out to default value using preceding n of the succession coding of the destination node, remainder result is indicated
Second database is determined as the succession coding mapped database of the destination node, and the n is positive integer;Alternatively,
Remainder is carried out to default value using the preceding position n ' of the affiliated father node of the destination node, remainder result is indicated
Third database is determined as the succession coding mapped database of the destination node, and the n ' is positive integer.
Optionally, described that the destination node is stored to remainder result and referred to the corresponding relationship inherited between coding
After the database shown, further includes:
Obtain the succession coding of the destination node;
The destination node is searched in the succession coding mapped database of the destination node;
Corresponding processing operation is executed to the destination node, the processing operation includes modification operation or deletion behaviour
Make.
Optionally, the method also includes:
Obtain the quantity of the child node of the destination node;
Store the corresponding relationship between the destination node and the child node quantity.
Optionally, the method also includes:
Obtain the data mode of the destination node;
The corresponding relationship between the destination node and the data mode is stored, the data mode is used to indicate described
Whether destination node is deleted.
Optionally, the method also includes:
The hierarchical identification of level where obtaining the destination node;
The corresponding relationship between the destination node and the hierarchical identification is stored, the hierarchical identification of different levels is different.
Second aspect provides a kind of data query method, which comprises
The data query requirements to tree form data structure are obtained, the data query requirements include belonging to child node to be checked
Root node and the child node to be checked series;
Obtain the succession coding of the root node;
Obtain the corresponding target digit for inheriting coding of series of the child node to be checked;
It is the target digit and packet in node and the digit for inheriting lookup succession coding in the corresponding relationship between encoding
Include the child node of the succession coding of the root node;
Wherein, the node and the corresponding relationship inherited between coding include the corresponding M of the root node1Position, which is inherited, compiles
Code, the corresponding M of j-th stage child nodej-1+mjInherit coding in position;The succession coding of the j-th stage child node includes -1 grade of node of jth
Succession coding, the Mj-1For the digit of the succession coding of -1 grade of node of the jth, mjFor the newly-increased of the j-th stage child node
Number of encoding bits;The j is the integer greater than 1;The M1For positive integer.
Optionally, the newly-increased number of encoding bits between not at the same level are identical, the series pair for obtaining the child node to be checked
The target digit for the succession coding answered, comprising:
Obtain the value of the newly-increased number of encoding bits;
Calculate the values of the newly-increased number of encoding bits multiplied by after j-1 with M1Sum, obtain the target digit.
Optionally, the method also includes:
The target tier mark of level where obtaining the child node to be checked;
Searching in corresponding relationship between pre-stored node and hierarchical identification has target tier mark
Node.The third aspect, provides a kind of data storage device, and described device includes:
Node obtains module, for obtaining the destination node in tree form data structure;
Generation module is encoded, for generating the M of the root node when the destination node is root node1Position, which is inherited, compiles
Code, the M1For positive integer;
The coding generation module is also used to generate the child node when the destination node is i-stage child node
Coding is inherited, the succession coding of the i-stage child node includes the succession coding of (i-1)-th grade of node, and the i-stage child node
Succession coding digit be Mi-1+mi, the Mi-1For the digit of the succession coding of (i-1)-th grade of node, miIt is described i-th
The newly-increased number of encoding bits of grade child node;The i is the integer greater than 1;
Data memory module, for storing the destination node and inheriting the corresponding relationship between coding, different target section
The corresponding different succession coding of point.
Fourth aspect, provides a kind of data query device, and described device includes:
Demand obtains module, for obtaining the data query requirements to tree form data structure, the data query requirements packet
Include the series of root node belonging to child node to be checked and the child node to be checked;
Coding obtains module, and the succession for obtaining the root node encodes;
Digit obtains module, the corresponding target digit for inheriting coding of the series for obtaining the child node to be checked;
Querying node module, the digit for searching succession coding in the corresponding relationship between node and succession coding are
The child node of the target digit and the succession coding including the root node;
Wherein, the node and the corresponding relationship inherited between coding include the corresponding M of the root node1Position, which is inherited, compiles
Code, the corresponding M of j-th stage child nodej-1+mjInherit coding in position;The succession coding of the j-th stage child node includes -1 grade of node of jth
Succession coding, the Mj-1For the digit of the succession coding of -1 grade of node of the jth, mjFor the newly-increased of the j-th stage child node
Number of encoding bits;The j is the integer greater than 1;The M1For positive integer.
5th aspect, provides a kind of data storage device, described device includes processor and memory;In the memory
It is stored with program, described program is loaded as the processor and executed to realize date storage method described in first aspect.
6th aspect, provides a kind of data query device, described device includes processor and memory;In the memory
It is stored with program, described program is loaded as the processor and executed to realize data query method described in second aspect.
7th aspect, provides a kind of computer readable storage medium, program, described program is stored in the storage medium
It is loaded as the processor and is executed to realize data storage device described in first aspect;Alternatively, realizing described in second aspect
Data query method.
The beneficial effects of the present application are as follows: by obtaining the destination node in tree form data structure;It is root in destination node
The M of root node is generated when node1Inherit coding in position;The succession coding of child node is generated when destination node is i-stage child node,
Succession coding of the succession coding of i-stage child node including (i-1)-th grade of node, and the digit of the succession coding of i-stage child node
For Mi-1+mi, Mi-1For the digit of the succession coding of (i-1)-th grade of node, miFor the newly-increased number of encoding bits of i-stage child node;Store mesh
It marks node and inherits the corresponding relationship between coding;When can solve with existing date storage method storage tree form data structure
The lower problem of efficiency data query;Due to the succession of the succession coding and child node of the root node by child node to be checked
The digit of coding, so that it may all child nodes for meeting query requirement are inquired, it is thus possible to improve efficiency data query.
Above description is only the general introduction of technical scheme, in order to better understand the technological means of the application,
And can be implemented in accordance with the contents of the specification, with the preferred embodiment of the application and cooperate attached drawing below detailed description is as follows.
Specific embodiment
With reference to the accompanying drawings and examples, the specific embodiment of the application is described in further detail.Implement below
Example is not limited to scope of the present application for illustrating the application.
Optionally, the application is illustrated so that the executing subject of each embodiment is electronic equipment as an example, the electronic equipment
It can be the equipment that server or terminal etc. have data-handling capacity.Wherein, terminal can be computer, mobile phone, plate
Computer, wearable device etc., the present embodiment do not limit the type of terminal.
Fig. 1 is the flow chart for the date storage method that the application one embodiment provides.This method includes at least following several
A step:
Step 101, the destination node in tree form data structure is obtained.
Tree form data structure is used to simulate the data acquisition system with tree property.Tree form data structure has following special
Point:
Each node has zero or more child node, which is the father node of child node;
The node for not having father node is root node;
Each non-root node has and only one father node;
Other than root node, each child node can be divided into multiple disjoint subtrees.
Wherein, node refers to the data element in tree form data structure.
With reference to tree form data structure shown in Fig. 2, wherein node where " Jiangsu " is root node, the root node includes " south
Child node where capital " and " Suzhou " two child nodes, " Suzhou " includes " the aunt Red Region ", " Wuzhong District " and " industrial park " three sons
Child node where node, " industrial park " includes " lake Du Shu Gao Jiaoqu " and " Hu Dong " two child nodes, " lake Du Shu Gao Jiaoqu "
Place child node includes " moon gulf " and " Hyde Park " two child nodes.
Destination node is the data to be stored element in tree form data structure.Destination node can be root node or can also
To be the child node in addition to root node, step 102 is executed when destination node is root node;It is except root node in destination node
Except child node when execute step 103.
Step 102, the M of root node is generated when destination node is root node1Inherit coding in position.
M1For positive integer.The succession of root node is encoded for uniquely identifying the root node.Optionally, in the application, after
Holding coding can be indicated by number and/or letter, wherein number can be the decimal system, binary system etc., the present embodiment not to after
The representation for holding coding limits.M1Value can guarantee that all root nodes corresponding succession coding is different.Such as: M1's
Value is 8, and inherit coding is indicated by ten's digit, then the succession coding of root node can be 00000000-99999999
In any number, the quantity of root node is up to 100000000, at this point it is possible to guarantee that the corresponding succession of all root nodes is compiled
Code is different.
In one example, electronic equipment generates the M of root node according to the storage order of root node1Inherit coding in position.Its
In, the storage order the forward, inherit coding it is smaller, storage order more rearward then inherit coding it is bigger.Such as: it is suitable for storing
The root node that sequence is first, succession are encoded to 00000000;The root node for being second for storage order, succession are encoded to
00000001;It is the root node of third for storage order, succession is encoded to 00000002.
In another example, electronic equipment generates the M of root node at random1Coding is inherited in position, and different root node after
It is different to hold coding.
Certainly, electronic equipment can also generate the M of root node otherwise1Coding is inherited in position, and the present embodiment is not right
The generating mode for inheriting coding limits.
Step 103, destination node be i-stage child node when generate child node succession coding, i-stage child node after
The succession coding that coding includes (i-1)-th grade of node is held, and the digit of the succession coding of i-stage child node is Mi-1+mi, Mi-1It is
The digit of the succession coding of i-1 grades of nodes, miFor the newly-increased number of encoding bits of i-stage child node.
I is the integer greater than 1.The series of node is used to indicate depth of the node in tree form data structure, series and depth
Correlation is spent, i.e., the bigger depth of series is deeper, the smaller depth of series is more shallow.In the present embodiment, the 1st grade of node is root section
Point, the child node ... that the 2nd grade of child node is the child node of the root node, 3rd level child node is the 2nd grade of child node are so followed
Ring.
In the present embodiment, the succession coding of every grade of child node is that the succession coding of superior node and newly-increased coding splicing obtain
's.Optionally, the succession coding of superior node is located at before newly-increased coding;Alternatively, can also be located at after newly-increased coding, this reality
Example is applied not limit the stitching position of the succession coding of superior node.It is located in the present embodiment with the succession coding of superior node
It is illustrated for before newly-increased coding.
In one example, the newly-increased number of encoding bits between not at the same level are identical, raw when destination node is i-stage child node
It is encoded at the succession of child node, comprising: obtain the value of newly-increased number of encoding bits;It is generated to have according to the value of newly-increased number of encoding bits and be increased newly
The newly-increased coding of number of encoding bits;Obtain the succession coding of the father node of i-stage child node;By the father node of i-stage child node
Coding and newly-increased coding splicing are inherited, the succession coding of i-stage child node is obtained.Wherein, i-stage child node succession coding with
The succession of the other child nodes of i-stage encodes different.
Wherein, newly-increased number of encoding bits can be with M1It is identical;Alternatively, can also be with M1It is different.
In one example, electronic equipment generates the m of the i-stage child node according to the storage order of i-stage child nodeiPosition
Newly-increased coding.Wherein, the newly-increased coding in the more forward then position of storage order is smaller, and it is bigger that storage order more then increases coding newly rearward.Than
Such as: the i-stage child node for being first for storage order, it is newly-increased to be encoded to 00000000;It is second for storage order
I-stage child node, it is newly-increased to be encoded to 00000001;It is the i-stage child node of third for storage order, succession is encoded to
00000002。
In another example, electronic equipment generates the m of i-stage child node at randomiThe newly-increased coding in position, and different child nodes
Newly-increased coding it is different.
Certainly, electronic equipment can also generate the m of i-stage child node otherwiseiThe newly-increased coding in position, the present embodiment
The generating mode of newly-increased coding is not limited.
Step 104, store destination node and inherit coding between corresponding relationship, different target node correspond to it is different after
Hold coding.
Optionally, electronic equipment can first store destination node in the database, then after generating the destination node
Store the corresponding succession coding of the destination node;Alternatively, the succession that can also first generate destination node encodes again in the database
Store destination node succession coding corresponding with the destination node.
With reference to destination node shown in Fig. 3 and inherit the corresponding relationship between coding, wherein other than root node, each
Node includes the succession coding of father node.
Optionally, electronic equipment can also obtain the quantity of the child node of destination node;Store destination node and child node
Corresponding relationship between quantity.When the quantity of the child node of destination node increases, which is increase accordingly.With reference to figure
Corresponding relationship between destination node shown in 4 and succession coding, the child node of destination node " lake Du Shu Gao Jiaoqu " increase
" member of Imperial Academy garden ", then the quantity of the child node of destination node " lake Du Shu Gao Jiaoqu " adds 1.
Optionally, electronic equipment can also obtain the data mode of destination node;Store destination node and data mode it
Between corresponding relationship, which is used to indicate whether destination node is deleted.Schematically, data mode passes through 0 and 1 table
Show, when destination node is deleted, data mode is 0, and when destination node is not deleted, data mode is 1.With reference to shown in Fig. 5
Destination node and inherit coding between corresponding relationship, destination node " moon gulf " be deleted when, " moon gulf " is corresponding
Data mode becomes 0 from 1.
It should be added that being encoded in order to avoid electronic equipment generates identical succession to different nodes, electronics
After equipment deletes destination node, the quantity of the child node of the affiliated father node of the destination node is not changed.Such as: in Fig. 5, mesh
When mark node " moon gulf " is deleted, the quantity of the child node of father node belonging to " moon gulf " " lake Du Shu Gao Jiaoqu " is kept not
Become.
Optionally, electronic equipment can store the corresponding relationship between destination node and succession coding to same data
Library;Alternatively, also can store at most a database.
In one example, by destination node and the corresponding relationship storage at most number between coding is inherited in electronic equipment
When according to library, electronic equipment determines the succession coding mapped database of destination node;By destination node and inherit between coding
Corresponding relationship store to database.
Wherein, electronic equipment determines that the succession coding mapped database of destination node includes but is not limited to following several
At least one of mode:
The first: carrying out remainder, first that remainder result is indicated to default value using the succession coding of destination node
Database is determined as the succession coding mapped database of destination node.
Schematically, in the application, default value is the quantity for storing the database of data to be stored.Certainly, present count
Value is also possible to the value of the quantity less than database.
With reference to Fig. 5, it is assumed that the quantity of database is 3, and the succession coding of destination node is to the knot obtained after 3 progress remainders
Fruit may be 0,1,2, wherein 0 referred database 501,1 referred database 502,2 referred databases 503, if destination node
Succession coding is 0 to the result obtained after 3 progress remainders, then stores the corresponding relationship between destination node and succession coding
To database 501;If the succession coding of destination node is 1 to obtained result after 3 progress remainders, by destination node with after
The corresponding relationship held between coding is stored to database 502;If the succession coding of destination node obtains 3 progress remainders later
As a result it is 2, then stores the corresponding relationship between destination node and succession coding to database 503.
Second: remainder being carried out to default value using preceding n of the succession coding of destination node, remainder result is indicated
The second database be determined as destination node succession coding mapped database.
N is positive integer.Wherein, n can be with M1It is equal;Alternatively, being also possible to be greater than M1Numerical value;Alternatively, can also be small
In M1Numerical value.Schematically, n is 16.
Wherein, the second database remainder result indicated is determined as the succession coding mapped database of destination node
Identical as process shown in fig. 5, details are not described herein for the present embodiment.
The third: carrying out remainder to default value using the preceding position n ' of the affiliated father node of destination node, remainder result referred to
The third database shown is determined as the succession coding mapped database of destination node.
N ' is positive integer.Wherein, n ' can be equal with n;Alternatively, can also be with n etc..Schematically, n ' is 16.
Wherein, the succession that the third database that remainder result indicates is determined as destination node is encoded into mapped database
Identical as process shown in fig. 5, details are not described herein for the present embodiment.
Optionally, after corresponding relationship of the electronic equipment between storage destination node and succession coding, it may be necessary to right
Destination node is handled.
If electronic equipment requires to look up destination node, the succession coding of destination node is obtained;In the succession of destination node
Destination node is searched in coding mapped database.
If electronic equipment needs to modify destination node, the succession coding of destination node is obtained;In the succession of destination node
Destination node is searched in coding mapped database;Corresponding processing operation, the processing operation packet are executed to the destination node
Include modification operation.Such as: it is " garden " by the name modifications of destination node " industrial park ".
If electronic equipment needs delete target node, the succession coding of destination node is obtained;In the succession of destination node
Destination node is searched in coding mapped database;Corresponding processing operation, the processing operation packet are executed to the destination node
Include delete operation.Such as: by the data mode of destination node from 1 be revised as 0 operation.
Wherein, the succession of destination node encodes the method for determination of mapped database and stores destination node and inherit volume
Code between corresponding relationship when mapping database mode it is identical.
Optionally, the hierarchical identification of level where electronic equipment can also obtain destination node;And store destination node with
The hierarchical identification of corresponding relationship between the hierarchical identification, different levels is different.
Hierarchical identification is used to indicate the feature that each node of same level has jointly, such as: the 5th grade of section in Fig. 3
The common trait of point " moon gulf " and " Hyde Park " is residential area, then hierarchical identification can be residential area, and/or be used to indicate
The character string of residential area, the present embodiment do not limit the set-up mode of hierarchical identification.In this way, user is searching same level
When node, each node can be searched by searching for hierarchical identification, improve the search efficiency of node.
In conclusion date storage method provided in this embodiment, by obtaining the destination node in tree form data structure;
The M of root node is generated when destination node is root node1Inherit coding in position;Son is generated when destination node is i-stage child node
The succession of node encodes, and the succession coding of i-stage child node is encoded including the succession of (i-1)-th grade of node, and i-stage child node
The digit for inheriting coding is Mi-1+mi, Mi-1For the digit of the succession coding of (i-1)-th grade of node, miFor the newly-increased of i-stage child node
Number of encoding bits;It stores destination node and inherits the corresponding relationship between coding;It can solve and deposited with existing date storage method
Efficiency data query lower problem when storing up tree form data structure;Since the succession of the root node by child node to be checked is compiled
The digit of code and the succession coding of child node, so that it may all child nodes for meeting query requirement are inquired, it is thus possible to improve
Efficiency data query.
Such as: tree form data structure shown in FIG. 1 is referred to, user needs to inquire all residential areas in Jiangsu Province.According to
When existing date storage method storage tree form data structure, the Node_id that electronic equipment needs to first pass through Jiangsu Province finds river
The Node_id in all cities that Su Sheng includes;All areas that each city includes are found out by the Node_id in each city again
Node_id;The Node_id in all streets that each area includes is found out by the Node_id in each area again;Finally by every
The Node_ide in street finds out all residential areas that every street includes.At this point, electronic equipment needs to be implemented 4 lookups behaviour
Make.
And provide through this embodiment date storage method storage tree form data structure when, electronic equipment only needs to obtain
To the digit of the succession coding of the succession coding and residential area in Jiangsu Province, Jiangsu Province can be found by executing one query operation
All residential areas.
In addition, only need to obtain the succession coding of father node when increasing child node, the succession coding based on the father node
The succession for generating the child node is encoded and is stored;It can be tree-like to avoid the storage of the left and right value code Design based on binary tree
When data structure, need to modify the left and right value of each node, the lower problem of the increased efficiency of node;Due to not needing to execute modification
The operation of left and right value, it is thus possible to improve increasing the efficiency of node in the database.
In addition, the quantity of the child node by storage destination node, allows user intuitively to understand the son of destination node
Node situation improves the efficiency of the quantity of the child node of user's acquisition destination node.
In addition, by the data mode of storage destination node, so that after destination node is deleted, it is only necessary to by the data
Status modifier is that instruction destination node has been deleted;When destination node adds again, it is only necessary to be revised as the data mode
Instruction destination node is not deleted, and electronic equipment is without executing the behaviour for deleting data and adding data to same destination node repeatedly
Make, save device resource, improves data manipulation efficiency.
In addition, encoding mapped number by storing the corresponding relationship between destination node and succession coding to the succession
It, can be with the pressure of sharing data library storing data according to library.In addition, when inquiring or handling data, electronic equipment is to corresponding
Data base querying data, since the average data in multiple databases are reduced.It is thus possible to improve electronic equipment searches data
Efficiency.
Based on the above embodiment, Fig. 6 is the flow chart for the data query method that the application one embodiment provides.This method
Including at least following steps:
Step 601, the data query requirements to tree form data structure are obtained, which includes sub- section to be checked
The series of root node and child node to be checked belonging to point.
Step 602, the succession coding of root node is obtained.
Optionally, the succession coding of root node can be electronic equipment in root node and inherit the corresponding relationship between coding
In inquire;Alternatively, being also possible to user's input, the present embodiment is not limited the acquisition modes of the succession coding of root node
It is fixed.
Step 603, the corresponding target digit for inheriting coding of series of child node to be checked is obtained.
Electronic equipment determines the target digit of succession coding according to the create-rule of the succession coding of child node.
In one example, the create-rule of the succession coding of child node is the newly-increased number of encoding bits phase between not at the same level
Together.At this point, the corresponding target digit for inheriting coding of the series for obtaining child node to be checked, comprising: obtain newly-increased number of encoding bits
Value;Calculate the values of newly-increased number of encoding bits multiplied by after j-1 with M1Sum, obtain target digit.
Step 604, node and inherit coding between corresponding relationship in search inherit coding digit be target digit,
And the child node of the succession coding including root node.
Wherein, node and the corresponding relationship inherited between coding include the corresponding M of root node1Inherit coding, j-th stage in position
The corresponding M of nodej-1+mjInherit coding in position;The succession coding of j-th stage child node includes that the succession of -1 grade of node of jth encodes, Mj-1
For the digit of the succession coding of -1 grade of node of jth, mjFor the newly-increased number of encoding bits of j-th stage child node;J is the integer greater than 1;M1
For positive integer.
Such as: with reference to destination node shown in Fig. 3 and the corresponding relationship between coding is inherited, user needs to inquire Jiangsu Province
All residential areas.The succession in the Jiangsu Province that electronic equipment is got is encoded to 00000000, and residential area is the 5th grade of son section
Point, it is assumed that the value of newly-increased number of encoding bits is 8, then target digit is 8+4 × 8=40, searched in Fig. 3 preceding 8 be 00000000,
The succession that digit is 40 encodes, these inherit the corresponding child node " moon gulf " of coding and " Hyde Park " is that user needs to look into
Ask all residential areas in Jiangsu Province.
Optionally, in order to improve the accuracy that electronic equipment searches child node, electronic equipment can also obtain son to be checked
The target tier mark of level where node;Searching in corresponding relationship between pre-stored node and hierarchical identification has
The node of target tier mark;And searching the digit inherited and encoded in the corresponding relationship between node and succession coding is target
The union of two kinds of lookup results, is determined as final lookup result by the child node of digit and the succession coding including root node.
Such as: with reference to destination node shown in Fig. 3 and the corresponding relationship between coding is inherited, user needs to inquire Jiangsu Province
All residential areas.The succession in the Jiangsu Province that electronic equipment is got is encoded to 00000000, and residential area is the 5th grade of son section
Point, it is assumed that the value of newly-increased number of encoding bits is 8, then target digit is 8+4 × 8=40, searched in Fig. 3 preceding 8 be 00000000,
The succession that digit is 40 encodes, these, which are inherited, encodes corresponding child node " moon gulf " and " Hyde Park ";Target tier is identified as
" residential area ", electronic equipment is searched in the corresponding relationship between pre-stored node and hierarchical identification has target tier mark
Know the node of " residential area ", child node " moon gulf " and " Hyde Park " are all inhabitations that user needs to inquire Jiangsu Province
Area.
In conclusion data query method provided in this embodiment, by obtaining the data query to tree form data structure
Demand, data query requirements include the series of root node belonging to child node to be checked and child node to be checked;Obtain root node
Succession coding;Obtain the corresponding target digit for inheriting coding of series of child node to be checked;In node and inherit coding
Between corresponding relationship in search inherit coding digit be target digit and including root node succession coding child node;Its
In, node and the corresponding relationship inherited between coding include the corresponding M of root node1It is corresponding that coding, j-th stage child node are inherited in position
Mj-1+mjInherit coding in position;The succession coding of j-th stage child node includes that the succession of -1 grade of node of jth encodes, Mj-1It is -1 grade of jth
The digit of the succession coding of node, mjFor the newly-increased number of encoding bits of j-th stage child node;It can solve with existing data storage side
Efficiency data query lower problem when method stores tree form data structure;Due to root node by child node to be checked after
Hold the digit of the succession coding of coding and child node, so that it may all child nodes for meeting query requirement are inquired, it therefore, can be with
Improve efficiency data query.
In addition, combining the mesh of child node to be checked by the digit of the succession coding of root node, the succession coding of child node
Hierarchical identification is marked to inquire child node, the accuracy of inquiry child node can be improved.
Fig. 7 is the block diagram for the data storage device that the application one embodiment provides.The device includes at least following
Module: node obtains module 710, coding generation module 720 and data memory module 730.
Node obtains module 710, for obtaining the destination node in tree form data structure;
Generation module 720 is encoded, for generating the M of the root node when the destination node is root node1It inherits position
Coding, the M1For positive integer;
The coding generation module 720 is also used to generate the child node when the destination node is i-stage child node
Succession coding, the succession coding of the i-stage child node includes the succession coding of (i-1)-th grade of node, and the i-stage section
The digit of the succession coding of point is Mi-1+mi, the Mi-1For the digit of the succession coding of (i-1)-th grade of node, miIt is described
The newly-increased number of encoding bits of i grades of child nodes;The i is the integer greater than 1;
Data memory module 730, for storing the destination node and inheriting the corresponding relationship between coding, different target
Node corresponds to different succession codings.
Correlative detail refers to above method embodiment.
It should be understood that the data storage device provided in above-described embodiment is when carrying out data storage, only with above-mentioned
The division progress of each functional module can according to need and for example, in practical application by above-mentioned function distribution by different
Functional module is completed, i.e., the internal structure of data storage device is divided into different functional modules, described above to complete
All or part of function.In addition, data storage device provided by the above embodiment and date storage method embodiment belong to together
One design, specific implementation process are detailed in embodiment of the method, and which is not described herein again.
Fig. 8 is the block diagram for the data query device that the application one embodiment provides.The device includes at least following
Module: demand obtains module 810, coding obtains module 820, digit obtains module 830 and querying node module 840.
Demand obtains module 810, for obtaining the data query requirements to tree form data structure, the data query requirements
Series including root node belonging to child node to be checked and the child node to be checked;
Coding obtains module 820, and the succession for obtaining the root node encodes;
Digit obtains module 830, the corresponding target position for inheriting coding of the series for obtaining the child node to be checked
Number;
Querying node module 840, for searching the position for inheriting coding in the corresponding relationship between node and succession coding
Number is the child node of the target digit and the succession coding including the root node;
Wherein, the node and the corresponding relationship inherited between coding include the corresponding M of the root node1Position, which is inherited, compiles
Code, the corresponding M of j-th stage child nodej-1+mjInherit coding in position;The succession coding of the j-th stage child node includes -1 grade of node of jth
Succession coding, the Mj-1For the digit of the succession coding of -1 grade of node of the jth, mjFor the newly-increased of the j-th stage child node
Number of encoding bits;The j is the integer greater than 1;The M1For positive integer.
Correlative detail refers to above method embodiment.
It should be understood that the data query device provided in above-described embodiment is when carrying out data query, only with above-mentioned
The division progress of each functional module can according to need and for example, in practical application by above-mentioned function distribution by different
Functional module is completed, i.e., the internal structure of data query device is divided into different functional modules, described above to complete
All or part of function.In addition, data query device provided by the above embodiment and data query embodiment of the method belong to together
One design, specific implementation process are detailed in embodiment of the method, and which is not described herein again.
Fig. 9 is the block diagram for the electronic equipment that the application one embodiment provides, which may include Fig. 7 offer
Data storage device;And/or the data query device that Fig. 8 is provided, the electronic equipment can be smart phone, tablet computer, pen
Remember this computer, desktop computer or server.Electronic equipment be also possible to referred to as user equipment, portable terminal, laptop terminal,
Terminal console, controlling terminal etc., the present embodiment is not construed as limiting this.The electronic equipment includes at least processor 901 and memory
902。
Processor 901 may include one or more processing cores, such as: 4 core processors, 8 core processors etc..Place
Reason device 901 can use DSP (Digital Signal Processing, Digital Signal Processing), FPGA (Field-
Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, may be programmed
Logic array) at least one of example, in hardware realize.Processor 901 also may include primary processor and coprocessor, master
Processor is the processor for being handled data in the awake state, also referred to as CPU (Central Processing
Unit, central processing unit);Coprocessor is the low power processor for being handled data in the standby state.?
In some embodiments, processor 901 can be integrated with GPU (Graphics Processing Unit, image processor),
GPU is used to be responsible for the rendering and drafting of content to be shown needed for display screen.In some embodiments, processor 901 can also be wrapped
AI (Artificial Intelligence, artificial intelligence) processor is included, the AI processor is for handling related machine learning
Calculating operation.
Memory 902 may include one or more computer readable storage mediums, which can
To be non-transient.Memory 902 may also include high-speed random access memory and nonvolatile memory, such as one
Or multiple disk storage equipments, flash memory device.In some embodiments, the non-transient computer in memory 902 can
Storage medium is read for storing at least one instruction, at least one instruction performed by processor 901 for realizing this Shen
Please in embodiment of the method provide date storage method;Or data query method.
In some embodiments, electronic equipment is also optional includes: peripheral device interface and at least one peripheral equipment.Place
Managing can be connected between device 901, memory 902 and peripheral device interface by bus or signal wire.Each peripheral equipment can be with
It is connected by bus, signal wire or circuit board with peripheral device interface.Schematically, peripheral equipment includes but is not limited to: radio frequency
Circuit, touch display screen, voicefrequency circuit and power supply etc..
Certainly, electronic equipment can also include less or more component, and the present embodiment is not construed as limiting this.
Optionally, the application is also provided with a kind of computer readable storage medium, in the computer readable storage medium
It is stored with program, described program is loaded by processor and executed the date storage method to realize above method embodiment;Or
Data query method.
Optionally, the application is also provided with a kind of computer product, which includes computer-readable storage medium
Matter is stored with program in the computer readable storage medium, and described program is loaded by processor and executed to realize above-mentioned side
The date storage method of method embodiment;Or data query method.
Each technical characteristic of embodiment described above can be combined arbitrarily, for simplicity of description, not to above-mentioned reality
It applies all possible combination of each technical characteristic in example to be all described, as long as however, the combination of these technical characteristics is not deposited
In contradiction, all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously
It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art
It says, without departing from the concept of this application, various modifications and improvements can be made, these belong to the protection of the application
Range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.