CN110851439A - Invitation code promotion level inquiry system based on B tree and forest - Google Patents

Invitation code promotion level inquiry system based on B tree and forest Download PDF

Info

Publication number
CN110851439A
CN110851439A CN201910623075.8A CN201910623075A CN110851439A CN 110851439 A CN110851439 A CN 110851439A CN 201910623075 A CN201910623075 A CN 201910623075A CN 110851439 A CN110851439 A CN 110851439A
Authority
CN
China
Prior art keywords
tree
forest
user
data
query
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.)
Pending
Application number
CN201910623075.8A
Other languages
Chinese (zh)
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.)
Jiangsu Yi Yi Ecological Agriculture Technology Co Ltd
Original Assignee
Jiangsu Yi Yi Ecological Agriculture 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 Jiangsu Yi Yi Ecological Agriculture Technology Co Ltd filed Critical Jiangsu Yi Yi Ecological Agriculture Technology Co Ltd
Priority to CN201910623075.8A priority Critical patent/CN110851439A/en
Publication of CN110851439A publication Critical patent/CN110851439A/en
Pending legal-status Critical Current

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/2246Trees, e.g. B+trees
    • 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/2453Query optimisation
    • 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/2457Query processing with adaptation to user needs

Landscapes

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

Abstract

The invention discloses an invitation code promotion level inquiry system based on a B tree and a forest, which comprises the following specific steps: the method comprises the following steps: and constructing all natural users as root nodes of the B tree in the forest, and performing the second step: and (3) constructing descendant nodes of the B tree, completing tree construction, and performing the third step: storing the B tree and forest data model, and the fourth step: monitoring the change of database users by the monitoring thread, dynamically updating trees and forests, and performing the fifth step: and performing related query according to the constructed B tree and the forest model. Step six: persistence of B-tree and forest data models. Through the query system, the farm game users are ranked, so that the problem of low efficiency in a massive data environment in level query is effectively solved, meanwhile, the invention provides a model based on a B tree and a forest, and self-defines tree nodes, so that the system not only can improve the efficiency of common level query, but also can realize more condition query.

Description

Invitation code promotion level inquiry system based on B tree and forest
Technical Field
The invention relates to the technical field of game user ranking, in particular to an invitation code promotion level inquiry system based on a B tree and a forest.
Background
In recent years, with the continuous development of smart phones and mobile internet, the popularization mode of the internet industry is also various, and the invitation code popularization mode based on the reward mechanism is widely applied at present. Each natural user shares the invitation code, and the successful invitation of one user to register can obtain the reward, and the more people are invited, the more the reward is, but the higher timeliness is in the reward calculation. The existing hierarchical query system is used for querying based on the invitation records of the users stored in the relational database, but for the query that the alternate invitation cannot be accurately and efficiently performed, for example, A invites B, B invites C, under the condition, both B and C belong to the users invited by A, a large number of sub-queries need to be nested in the relational database, and the query efficiency is seriously influenced.
At present, few methods for hierarchical query are used, most methods are based on traditional SQL nested sub-query, and once the user quantity is increased, the efficiency is rapidly reduced. And for alternate queries, the accuracy is not very high. How to improve the efficiency of level inquiry in game invitation is a problem which needs to be solved urgently by most level inquiry systems at present.
Patent CN106777260A discloses an index binary tree based query method and system, the method core is to establish an index table of target data for a target database according to the mapping relationship between preset query fields and the target data, the index table of the target data has a binary tree data structure; acquiring a query field input by a user; and comparing the query field input by the user with the index table of the target data to obtain and output an index result of the target data, and further extracting data information corresponding to the index result from a target database according to the obtained target index and outputting the data information.
Patent CN106777163A discloses a method and system for querying the IP address of a red and black tree, which uses the red and black tree as a core data structure to optimize the efficiency of query according to the excellent query characteristics of the red and black tree itself.
The ranking methods described above all have excellent query characteristics, whether indexing binary trees or red-black trees, by storing user data using a particular tree data structure. However, the underlying data structures used by the above two methods are binary ordering trees, which have certain advantages in query due to their ordering characteristics, but are not suitable for invitation codes to promote such hierarchical queries because: first, invitation code promotion cannot be ordered using a specific field because of the strong association between the inviter and the invited person. Secondly, the binary tree has at most two child nodes, the number of the user persons that the inviter can invite is not on line, and if the binary tree is used, the characteristic that the invitation code is popularized cannot be indicated.
The B tree forest data model used by the system adopts the B tree as a basic data structure, the natural query characteristic of the B tree is not inferior to that of a binary sequencing tree, and the B tree supports the condition of multiple descendant nodes, so that the weakness of the two patents in the aspect of hierarchical query can be solved. And the forest is used as the collection of the whole user data, so that all the user data have clear integral logic, and corresponding indexes are arranged on each node of the B-tree and the B-tree to optimize the query.
Disclosure of Invention
The invention aims to provide an invitation code promotion level inquiry system based on a B tree and a forest so as to solve the problems in the background technology.
In order to achieve the purpose, the invention provides the following technical scheme: an invitation code promotion level inquiry system based on a B tree and a forest comprises the following basic steps:
step one, constructing all natural users as root nodes of a B tree in a forest: the natural user means a user who becomes a product user by a natural registration manner, not a user invited to become a user by others. The forest is a data structure in computer science, and is used herein to represent the set of all users in a product. The B-tree is also a data structure in computer science, used here to represent the set of all non-natural users invited by each natural user;
step two, establishing descendant nodes of the B tree, and finishing tree establishment: according to the root node constructed in the step one, constructing the unnatural users invited by the root node user as B-tree nodes, and completing construction of B-tree and forest data models;
step three, storing a data model: storing the B tree and forest data model obtained according to the step three into a memory database similar to redis, and improving the query efficiency;
step four, the monitoring thread monitors the change of the database users and dynamically updates the trees and forests: in order to meet the characteristics of real-time query, monitoring the change of users in a database by adopting a monitoring thread, transmitting user information by adopting a message queue once a new user is invited, and dynamically updating a B tree and a forest data model by adopting the operation sequence of the first step and the second step;
and fifthly, performing related query according to the constructed B tree and forest model: performing query operation according to the data model obtained in the step four;
step six, persistence of the B tree and forest models: and D, according to the memory database adopted in the storage in the third step, adopting a corresponding persistence strategy, wherein the persistence strategy adopts a mode of adding logs and is updated regularly.
Preferably, in the second step, when a descendant node is constructed, the following data format is adopted as the descendant node:
pointer 1 Inviting user data Index numbering Statistical data Pointer n
Wherein the pointer 1The pointer n indicates a pointer pointing to a descendant node of the node, the basic data of the user is invited to be stored in the user data, and the index number indicates the index value of the node in the tree. The function of adding the index number is to directly convert to sequential search without traversing the tree when querying all the inviting users of the user, the time complexity is O (1), and the query efficiency is much higher than the query efficiency O (logn) of the B tree. The statistical data comprises the number of all users invited by the user, the time when the user is invited and the index numbers of all nodes under the nodes, so that some condition queries are convenient to carry out.
Preferably, when the B-tree forest data model is stored in the third step, the memory database redis is used for storage, and the problem of thread safety does not exist in a distributed environment based on single-threaded non-blocking IO, and the query performance is excellent.
Preferably, a B-tree and forest based query data model is defined, as shown in FIG. 2 in the specification:
according to the model, each natural growth user is used as a B-tree root node, and a plurality of natural users are constructed into a data forest. The specific structure of the node in the above figure is as shown in the attached figure 3 in the specification:
the directly invited user is used as a child node, and the indirectly invited user is used as a descendant node, so that the relationship between the invitation and the invited is clear at a glance, and the statistical query is very simple and efficient.
Compared with the prior art, the invention has the beneficial effects that:
the query accuracy and the query efficiency are ensured through a data model of a B tree forest; dynamically updating a data model by adopting a monitoring thread and a message queue to achieve the real-time performance of query; and a persistent mode of log addition and periodic update is adopted to ensure the recoverability of data.
Drawings
FIG. 1 is a schematic diagram of an overall flow of an invitation code promotion level query system based on a B-tree and a forest;
FIG. 2 is a diagram of a B-Tree Sensen inner data model;
fig. 3 is a data format diagram of a descendant node.
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.
Referring to fig. 1-2, the present invention provides a technical solution: an invitation code promotion level inquiry system based on a B tree and a forest comprises the following basic steps:
step one, constructing all natural users as root nodes of a B tree in a forest: the natural user means a user who becomes a product user by a natural registration manner, not a user invited to become a user by others. The forest is a data structure in computer science, and is used herein to represent the set of all users in a product. The B-tree is also a data structure in computer science, used here to represent the set of all non-natural users invited by each natural user;
step two, establishing descendant nodes of the B tree, and finishing tree establishment: according to the root node constructed in the step one, constructing the unnatural users invited by the root node user as B-tree nodes, and completing construction of B-tree and forest data models;
step three, storing a data model: storing the B tree and forest data model obtained according to the step three into a memory database similar to redis, and improving the query efficiency;
step four, the monitoring thread monitors the change of the database users and dynamically updates the trees and forests: in order to meet the characteristics of real-time query, monitoring the change of users in a database by adopting a monitoring thread, transmitting user information by adopting a message queue once a new user is invited, and dynamically updating a B tree and a forest data model by adopting the operation sequence of the first step and the second step;
and fifthly, performing related query according to the constructed B tree and forest model: performing query operation according to the data model obtained in the step four;
step six, persistence of the B tree and forest models: and D, according to the memory database adopted in the storage in the third step, adopting a corresponding persistence strategy, wherein the persistence strategy adopts a mode of adding logs and is updated regularly.
In the second step, when a descendant node is constructed, the following data format is adopted as the descendant node:
pointer 1 Inviting user data Index numbering Statistical data Pointer n
Wherein the pointer 1The pointer n indicates a pointer pointing to a descendant node of the node, the basic data of the user is invited to be stored in the user data, and the index number indicates the index value of the node in the tree. The function of adding the index number is to directly convert to sequential search without traversing the tree when querying all the inviting users of the user, the time complexity is O (1), and the query efficiency is much higher than the query efficiency O (logn) of the B tree. The statistical data comprises the number of all users invited by the user, the time when the user is invited and the index numbers of all nodes under the nodes, so that some condition queries are convenient to carry out.
And when the B-tree forest data model is stored in the step three, a memory database redis is used for storage, the problem of thread safety does not exist in a distributed environment on the basis of single-thread non-blocking IO, and the query performance is excellent.
A B-tree and forest based query data model is defined, as shown in the attached figure 2 in the specification:
according to the model, each natural growth user is used as a B-tree root node, and a plurality of natural users are constructed into a data forest. The specific structure of the node in the above figure is as shown in the attached figure 3 in the specification:
the directly invited user is used as a child node, and the indirectly invited user is used as a descendant node, so that the relationship between the invitation and the invited is clear at a glance, and the statistical query is very simple and efficient.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (4)

1. The utility model provides an invitation code promotes level inquiry system based on B tree and forest which characterized in that: the invitation code promotion level inquiry system based on the B tree and the forest comprises the following basic steps:
step one, constructing all natural users as root nodes of a B tree in a forest: the natural user means a user who becomes a product user by a natural registration manner, not a user invited to become a user by others. The forest is a data structure in computer science, and is used herein to represent the set of all users in a product. The B-tree is also a data structure in computer science, used here to represent the set of all non-natural users invited by each natural user;
step two, establishing descendant nodes of the B tree, and finishing tree establishment: according to the root node constructed in the step one, constructing the unnatural users invited by the root node user as B-tree nodes, and completing construction of B-tree and forest data models;
step three, storing a data model: storing the B tree and forest data model obtained according to the step three into a memory database similar to redis, and improving the query efficiency;
step four, the monitoring thread monitors the change of the database users and dynamically updates the trees and forests: in order to meet the characteristics of real-time query, a monitoring thread is adopted to monitor the change of users in a database, once a new user is invited, a message queue is adopted to transmit user information, and a B tree and forest data model is dynamically updated by adopting the operation sequence of the first step and the second step;
and fifthly, performing related query according to the constructed B tree and forest model: performing query operation according to the data model obtained in the step four;
step six, persistence of the B tree and forest models: and D, according to the memory database adopted in the storage in the third step, adopting a corresponding persistence strategy, wherein the persistence strategy adopts a mode of adding logs and is updated regularly.
2. The invitation code promotion level inquiry system based on the B tree and the forest as claimed in claim 1, wherein: in the second step, when a descendant node is constructed, the following data format is adopted as the descendant node:
pointer 1 Inviting user data Index numbering Statistical data Pointer n
The pointers 1 to n represent pointers pointing to descendant nodes of the nodes, the data of the invited user is the basic data of the user, and the index number represents the index value of the node in the tree. The function of adding the index number is to directly convert to sequential search without traversing the tree when querying all inviting users of the user, the time complexity is O (1), and the query efficiency is much higher than that O (logn) of the B tree. The statistical data comprises the number of all users invited by the user, the time when the user is invited and the index numbers of all nodes under the nodes, so that some condition queries are convenient to carry out.
3. The invitation code promotion level inquiry system based on the B tree and the forest as claimed in claim 1, wherein: and when the B-tree forest data model is stored in the step three, a memory database redis is used for storage, the problem of thread safety does not exist in a distributed environment based on single-thread non-blocking IO, and the query performance is excellent.
4. The invitation code promotion level inquiry system based on the B tree and the forest as claimed in claim 1, wherein: a B-tree and forest based query data model is defined, as shown in the attached figure 2 in the specification:
according to the model, each natural growth user is used as a B-tree root node, and a plurality of natural users are constructed into a data forest. The specific structure of the node in the above figure is as shown in the attached figure 3 in the specification:
the directly invited user is used as a child node, and the indirectly invited user is used as a descendant node, so that the relationship between the invitation and the invited is clear at a glance, and the statistical query is very simple and efficient.
CN201910623075.8A 2019-07-11 2019-07-11 Invitation code promotion level inquiry system based on B tree and forest Pending CN110851439A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910623075.8A CN110851439A (en) 2019-07-11 2019-07-11 Invitation code promotion level inquiry system based on B tree and forest

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910623075.8A CN110851439A (en) 2019-07-11 2019-07-11 Invitation code promotion level inquiry system based on B tree and forest

Publications (1)

Publication Number Publication Date
CN110851439A true CN110851439A (en) 2020-02-28

Family

ID=69595306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910623075.8A Pending CN110851439A (en) 2019-07-11 2019-07-11 Invitation code promotion level inquiry system based on B tree and forest

Country Status (1)

Country Link
CN (1) CN110851439A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821697A (en) * 2021-11-23 2021-12-21 杭州金线连科技有限公司 Statistical method and device for user invitation relation

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821697A (en) * 2021-11-23 2021-12-21 杭州金线连科技有限公司 Statistical method and device for user invitation relation

Similar Documents

Publication Publication Date Title
CN106227800B (en) Storage method and management system for highly-associated big data
US9798772B2 (en) Using persistent data samples and query-time statistics for query optimization
CN103412897B (en) A kind of parallel data processing method based on distributed frame
Singh et al. Indexing uncertain categorical data
Zhao et al. Modeling MongoDB with relational model
CN102270232B (en) Semantic data query system with optimized storage
CN106933833B (en) Method for quickly querying position information based on spatial index technology
CN106777163A (en) IP address institute possession querying method and system based on RBTree
CN103646032A (en) Database query method based on body and restricted natural language processing
CN108009265B (en) Spatial data indexing method in cloud computing environment
CN105843918A (en) Method for rapidly screening positions from position database
CN104391908B (en) Multiple key indexing means based on local sensitivity Hash on a kind of figure
CN106874425B (en) Storm-based real-time keyword approximate search algorithm
CN101710336A (en) Method for accelerating data processing by using relational middleware
CN106484815B (en) A kind of automatic identification optimization method based on mass data class SQL retrieval scene
CN109325029A (en) RDF data storage and querying method based on sparse matrix
CN102004798A (en) Matching method of symmetrical issuing subscription system based on plural one-dimensional index
CN114048204A (en) Beidou grid space indexing method and device based on database inverted index
CN102110158B (en) Multi-join query optimization method for database based on improved SDD-1 (System for Distributed Database) algorithm
CN110851439A (en) Invitation code promotion level inquiry system based on B tree and forest
CN114153821A (en) Electric quantity graph database construction and search method based on graph theory
CN109885570A (en) A kind of multi-Dimensional Range querying method of secondary index combination hash table
CN110297952B (en) Grid index-based parallelization high-speed railway survey data retrieval method
CN108664573A (en) A kind of quick processing system of big data and method with double-channel data library
CN114791935A (en) Method for realizing high-performance multidimensional data warehouse based on cloud object storage

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20200228

WD01 Invention patent application deemed withdrawn after publication