CN112860634A - Rapid defect checking method based on balanced binary tree - Google Patents
Rapid defect checking method based on balanced binary tree Download PDFInfo
- Publication number
- CN112860634A CN112860634A CN202110192467.0A CN202110192467A CN112860634A CN 112860634 A CN112860634 A CN 112860634A CN 202110192467 A CN202110192467 A CN 202110192467A CN 112860634 A CN112860634 A CN 112860634A
- Authority
- CN
- China
- Prior art keywords
- bit
- query
- fragments
- bits
- array
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/14—Details of searching files based on file metadata
- G06F16/148—File search processing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Library & Information Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a quick defect checking method based on a balanced binary tree, which comprises the following steps: s1, constructing a 64-bit shaping Array, wherein each bit represents a fragment, for example, 512 fragments exist, the first 64 bits of the Array can represent fragments with the number of 0-63, the second 64 bits of the Array can represent fragments with the number of 64-127, and the like; s2, when a fragment is received, calculating the position of the fragment in the array and setting the corresponding bit as 1; and S3, performing AND operation on all leaf nodes pairwise through a balanced binary tree rule, and constructing father nodes of the leaf nodes until a root node is constructed. The invention has the beneficial effects that: by balancing the binary tree and fast miss-searching for bit partitions(number of N files or message fragments, M number of missing files or fragments) complexAnd under the performance of complexity, which fragments are missing can be quickly found.
Description
Technical Field
The invention relates to the technical field of network data, in particular to a rapid defect checking method based on a balanced binary tree.
Background
In a large-scale network data transmission scene, a receiving end needs to check whether received data is complete, while sending data generally adopts a fragmentation and concurrent sending mode, which can cause that the data received by the receiving end is not continuous and complete, and the receiving end needs to check whether each fragmentation arrives at the time in a traversal mode.
Disclosure of Invention
The invention aims to provide a quick defect-checking method based on a balanced binary tree to solve the problems in the background technology.
In order to achieve the purpose, the invention provides the following technical scheme: a quick defect checking method based on a balanced binary tree comprises the following steps:
s1, constructing a 64-bit shaping Array, wherein each bit represents a fragment, for example, 512 fragments exist, the first 64 bits of the Array can represent fragments with the number of 0-63, the second 64 bits of the Array can represent fragments with the number of 64-127, and the like;
s2, when a fragment is received, calculating the position of the fragment in the array and setting the corresponding bit as 1;
s3, performing AND operation on all leaf nodes pairwise through a balanced binary tree rule, and constructing father nodes of the leaf nodes till a root node is constructed;
and S4, after the root node is constructed, which leaf nodes are missing can be inquired downwards from the root node.
Preferably, each node in the step S1 only displays the last 8 bits of the 64 bits, and the first 56 bits are default 1.
Preferably, the query process in step S4 is as follows: if the root node is Uint64full (each bit of a 64-bit integer is 1), all fragments are received, the data is complete, the query efficiency is 0(1), otherwise, whether the left sub-tree is Uint64full is queried, then the right sub-tree is queried, the leaf node 3 can be rapidly queried to be missing through four query processes (query 1, query 2, query 3 and query 4), because each node is represented by 64 bits, although the leaf node 3 is determined to be missing, which bit is 0 is not determined, and the query is optimized again in order to not traverse 64 times.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flowchart of the defect checking of the balanced binary tree of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention are clearly and completely described below, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all 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, the fast defect checking method based on the balanced binary tree of the present invention includes the following steps:
s1, constructing a 64-bit shaping Array, wherein each bit represents a fragment, for example, 512 fragments exist, the first 64 bits of the Array can represent fragments with the number of 0-63, the second 64 bits of the Array can represent fragments with the number of 64-127, and the like;
s2, when a fragment is received, calculating the position of the fragment in the array and setting the corresponding bit as 1;
s3, performing AND operation on all leaf nodes pairwise through a balanced binary tree rule, and constructing father nodes of the leaf nodes till a root node is constructed;
and S4, after the root node is constructed, which leaf nodes are missing can be inquired downwards from the root node.
For convenience of viewing in step S1, each node in fig. 1 only displays the last 8 of 64 bits, and the first 56 bits are default 1.
The query process in step S4 is: if the root node is Uint64full (each bit of a 64-bit integer is 1), it indicates that all fragments have been received, the data is complete, the query efficiency is 0(1), otherwise, it queries whether the left sub-tree is Uint64full, then queries the right sub-tree, and it can quickly query that the leaf node 3 is missing through the four processes of the query in fig. 1 (query 1, query 2, query 3, and query 4), because each node is represented by 64 bits, it is not determined which bit is 0 although it is determined that the leaf node 3 is missing, and in order to not traverse 64 times, the query will be optimized again.
The first embodiment is as follows:
s1, constructing a 64-bit shaping Array, wherein each bit represents a fragment, for example, 512 fragments exist, the first 64 bits of the Array can represent fragments with the number of 0-63, the second 64 bits of the Array can represent fragments with the number of 64-127, and the like;
s2, after receiving a fragment, calculating the position of the fragment in the array, and setting the corresponding bit as 1, wherein the calculation formula is as follows:
Arrindex=Splitno/64
Bitindex=Splitno%64
Array[Arrindex]=Array[Arrindex]|(1<<Bitindex)
s3, performing AND operation on all leaf nodes pairwise through a balanced binary tree rule, and constructing father nodes of the leaf nodes till a root node is constructed;
and S4, after the root node is constructed, which leaf nodes are missing can be inquired downwards from the root node.
For convenience of viewing in step S1, each node in fig. 1 only displays the last 8 of 64 bits, and the first 56 bits are default 1.
The query process in step S4 is: if the root node is Uint64full (each bit of a 64-bit integer is 1), it indicates that all fragments have been received, the data is complete, the query efficiency is 0(1), otherwise, it queries whether the left sub-tree is Uint64full, then queries the right sub-tree, and it can quickly query that the leaf node 3 is missing through the four processes of the query in fig. 1 (query 1, query 2, query 3, and query 4), because each node is represented by 64 bits, it is not determined which bit is 0 although it is determined that the leaf node 3 is missing, and in order to not traverse 64 times, the query will be optimized again.
The missing index mapping table of the present invention is:
the above chart is: a lookup table of 0 to 65535 is constructed, and each table entry contains an index VALUE of which bit is 0, for example, KEY is 0, if all bits are 0, its VALUE is (0, 1, 2 … 15), KEY is 65534, if only the last bit is 0, its VALUE is (0), and it can know a 16-bit integer and which bits are missing by fast missing position lookup.
In step S4, it is found that there is a missing leaf node 3, but it is not known which bit is missing, the leaf node is divided into 4 integers of 16 bits, the 4 integers of 16 bits are found by querying the missing index mapping table, and the first three are found to be complete, the fourth integer value is 65533, and the missing position is: (1).
And then through the formula:
Missingindex=64*(Leafindex-1)+16*(Splitindex-1)+Mapindex
the loss position was calculated to be 64 x (3-1) +16 x (4-1) +1 ═ 177, i.e. the data loss with fragment number 177.
Firstly, mapping N fragments into 64-bit arrays to generate N/64 leaf nodes, then constructing a balanced binary tree, when a missing position is queried, quickly finding out the missing leaf nodes through binary tree search, then dividing 64-bit integers into 4 16-bit integers through a quick missing mapping table, and carrying out key value query with the efficiency of 0(1), so that the query efficiency is the efficiency of querying the leaf child nodes by the balanced binary tree: 0(LogN/64), therefore, if it is necessary to check whether one piece of data is complete, it is only necessary to determine whether the root node is the maximum value of 64-bit shaping, and it is not necessary to traverse all the fragments.
The above description is only an embodiment of the present invention, and is not intended to limit the present invention. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims (3)
1. A quick defect checking method based on a balanced binary tree is characterized in that: the method comprises the following steps:
s1, constructing a 64-bit shaping Array, wherein each bit represents a fragment, for example, 512 fragments exist, the first 64 bits of the Array can represent fragments with the number of 0-63, the second 64 bits of the Array can represent fragments with the number of 64-127, and the like;
s2, when a fragment is received, calculating the position of the fragment in the array and setting the corresponding bit as 1;
s3, performing AND operation on all leaf nodes pairwise through a balanced binary tree rule, and constructing father nodes of the leaf nodes till a root node is constructed;
and S4, after the root node is constructed, which leaf nodes are missing can be inquired downwards from the root node.
2. The balanced binary tree-based fast defect checking method according to claim 1, wherein: in step S1, each node only displays the last 8 of the 64 bits, and the first 56 bits are default 1.
3. The balanced binary tree-based fast defect checking method according to claim 1, wherein: the query process in step S4 is as follows: if the root node is Uint64full (each bit of a 64-bit integer is 1), all fragments are received, the data is complete, the query efficiency is 0(1), otherwise, whether the left sub-tree is Uint64full is queried, then the right sub-tree is queried, the leaf node 3 can be rapidly queried to be missing through four query processes (query 1, query 2, query 3 and query 4), because each node is represented by 64 bits, although the leaf node 3 is determined to be missing, which bit is 0 is not determined, and the query is optimized again in order to not traverse 64 times.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110192467.0A CN112860634A (en) | 2021-02-20 | 2021-02-20 | Rapid defect checking method based on balanced binary tree |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110192467.0A CN112860634A (en) | 2021-02-20 | 2021-02-20 | Rapid defect checking method based on balanced binary tree |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112860634A true CN112860634A (en) | 2021-05-28 |
Family
ID=75989797
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110192467.0A Pending CN112860634A (en) | 2021-02-20 | 2021-02-20 | Rapid defect checking method based on balanced binary tree |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112860634A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113760937A (en) * | 2021-09-17 | 2021-12-07 | 恒生电子股份有限公司 | Data defect checking method and device, electronic equipment and storage medium |
-
2021
- 2021-02-20 CN CN202110192467.0A patent/CN112860634A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113760937A (en) * | 2021-09-17 | 2021-12-07 | 恒生电子股份有限公司 | Data defect checking method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101901248B (en) | Method and device for creating and updating Bloom filter and searching elements | |
CN101594319B (en) | Entry lookup method and entry lookup device | |
CN101694672B (en) | Distributed safe retrieval system | |
CN107862026B (en) | Data storage method and device, data query method and device, and electronic equipment | |
CN109766389B (en) | Block chain light client verification query method based on bitmap index | |
CN103077208B (en) | URL(uniform resource locator) matched processing method and device | |
CN108460030B (en) | Set element judgment method based on improved bloom filter | |
WO2010066115A1 (en) | Method and system for lowering time complexity in short sequences assembly | |
CN101286935A (en) | Route searching method based on IP address scope | |
CN105515997B (en) | The higher efficiency range matching process of zero scope expansion is realized based on BF_TCAM | |
CN108197313B (en) | Dictionary indexing method for realizing space optimization through 16-bit Trie tree | |
CN102045412B (en) | Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix | |
CN112860634A (en) | Rapid defect checking method based on balanced binary tree | |
WO2012166190A1 (en) | Compression match enumeration | |
CN108241709B (en) | Data integration method, device and system | |
CN114884877A (en) | IPv6 route searching method combining hash table and HOT | |
CN108153907B (en) | Dictionary storage management method for realizing space optimization through 16-bit Trie tree | |
CN110995876B (en) | Method and device for storing and searching IP | |
CN105227468A (en) | One searches device, lookup method and collocation method | |
CN113986931B (en) | Report paging method and device, storage medium and computing equipment | |
CN104301182A (en) | Method and device for inquiring slow website access abnormal information | |
US10516613B1 (en) | Network device storage of incremental prefix trees | |
Lin et al. | A multi-index hybrid trie for lookup and updates | |
TW200933406A (en) | Data item interval indentifier lookup method and system | |
CN116126928A (en) | Information searching system based on variable fingerprint cuckoo filter |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210528 |