CN116662615A - A Fast Search Method for Non-matrix Data - Google Patents
A Fast Search Method for Non-matrix Data Download PDFInfo
- Publication number
- CN116662615A CN116662615A CN202310645039.8A CN202310645039A CN116662615A CN 116662615 A CN116662615 A CN 116662615A CN 202310645039 A CN202310645039 A CN 202310645039A CN 116662615 A CN116662615 A CN 116662615A
- Authority
- CN
- China
- Prior art keywords
- search
- matrix data
- address data
- searched
- data
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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/9017—Indexing; Data structures therefor; Storage structures using directory or table look-up
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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/903—Querying
- G06F16/90335—Query processing
- G06F16/90344—Query processing by using string matching techniques
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy 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)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Indexing, Searching, Synchronizing, And The Amount Of Synchronization Travel Of Record Carriers (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机软件技术领域,尤其涉及一种非矩阵数据快速查找的方法。The invention relates to the technical field of computer software, in particular to a method for fast searching of non-matrix data.
背景技术Background technique
当今世界,已经无法脱离计算机来运行,使用计算机就涉及到大量的算法和查找。在面对巨大的数据面前,计算机的查找效率就显得尤为重要,快速查找中使用较多的二分查找在面对不是矩阵数据的情况下就显得尤为笨重,失去了二分查找的本质。那就不得不去选择其他的一些低效的查找方式来代替。In today's world, it is impossible to operate without a computer, and using a computer involves a large number of algorithms and searches. In the face of huge data, the search efficiency of the computer is particularly important. Binary search, which is often used in quick search, is particularly cumbersome when faced with non-matrix data, and loses the essence of binary search. Then you have to choose some other inefficient search methods instead.
因此,现有技术存在缺陷,需要改进。Therefore, there are defects in the prior art and need to be improved.
发明内容Contents of the invention
本发明的目的是克服现有技术的不足,提供一种非矩阵数据快速查找的方法。The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method for fast searching of non-matrix data.
本发明的技术方案如下:提供一种非矩阵数据快速查找的方法,包括如下步骤:The technical scheme of the present invention is as follows: provide a kind of method for quick search of non-matrix data, comprise the steps:
步骤1:根据所需查找的非矩阵数据生成一张非矩阵数据的行头地址数据表;Step 1: Generate a row header address data table of non-matrix data according to the non-matrix data to be searched;
步骤2:输入需要查找定位的字符串,开始进行查找;Step 2: Enter the character string that needs to be searched and located, and start to search;
步骤3:定位到辅助行头地址数据表的中间地址数据;Step 3: locate the intermediate address data of the auxiliary row header address data table;
步骤4:跳转到中间地址数据后,判断是否为当前需要查找的字符串;Step 4: After jumping to the intermediate address data, judge whether it is the string that needs to be searched currently;
步骤5:如果步骤4中所跳转的中间地址数据不是所需查找的字符串,则对地址数据表进行二分匹配查找,并定位到新的待匹配地址数据,判断是否为当前需要查找的字符串;如果不是,则重复执行步骤5;Step 5: If the intermediate address data jumped in step 4 is not the character string to be searched, perform a binary matching search on the address data table, locate the new address data to be matched, and judge whether it is the character that needs to be searched currently string; if not, repeat step 5;
步骤6:如果步骤4或步骤5中所跳转的中间地址数据为所查找的字符串,对结果进行输出,程序结束。Step 6: If the jumping intermediate address data in step 4 or step 5 is the searched character string, output the result and the program ends.
进一步地,所述二分匹配查找的具体步骤包括:Further, the specific steps of the binary matching search include:
使用两个寄存器组来分别存储当前查询的表项地址和步长;Use two register groups to store the address and step size of the current query respectively;
使用当前表项地址去查找表中读取表项进行比较;Use the address of the current entry to read the entry in the lookup table for comparison;
根据比较结果和查找表生成方式确定下一二分匹配的方向,并在判断不为所需查找的字符串时完成下一跳操作。Determine the direction of the next binary match according to the comparison result and the way the lookup table is generated, and complete the next hop operation when it is judged that it is not the desired string.
采用上述方案,本发明根据非矩阵数据建立一个映射表,将映射表的辅助行地址数据与非矩阵数据表的地址数据进行关联,当用户输入一个字符串时,开始在映射表内进行快速查找。对映射表进行二分查找的操作,将输入的字符串与映射表中间位置记录的关键字进行比较,如果两者相同,则查找成功;否则从中间位置将表分成前后两个子表,如果中间位置记录的关键字大于查找关键字,则进一步查找前一子表,否则进一步查找后一子表。重复以上过程,直到找到满足条件的记录,使查找成功,或直到子表不存在为止,此时查找不成功。通过映射表的方式,将非矩阵数据以矩阵数据的型式进行列表,从而提高二分法的查找效率,实现非矩阵数据的快速查找定位。Using the above scheme, the present invention establishes a mapping table according to the non-matrix data, associates the auxiliary row address data of the mapping table with the address data of the non-matrix data table, and starts to quickly search in the mapping table when the user inputs a character string . Perform a binary search operation on the mapping table, compare the input string with the key recorded in the middle of the mapping table, if the two are the same, the search is successful; otherwise divide the table into two sub-tables from the middle position, if the middle position If the recorded key is greater than the search key, the previous sub-table is further searched; otherwise, the latter sub-table is further searched. Repeat the above process until a record meeting the condition is found, making the search successful, or until the child table does not exist, at this time the search is unsuccessful. Through the mapping table, the non-matrix data is listed in the form of matrix data, thereby improving the search efficiency of the dichotomy and realizing the fast search and positioning of non-matrix data.
附图说明Description of drawings
图1为本发明的流程示意框图。Fig. 1 is a schematic block diagram of the process of the present invention.
图2为非矩阵数据与映射表示意图。Fig. 2 is a schematic diagram of non-matrix data and mapping table.
具体实施方式Detailed ways
以下结合附图和具体实施例,对本发明进行详细说明。The present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments.
请参阅图1,本发明提供一种非矩阵数据快速查找的方法,包括如下步骤:Please refer to Fig. 1, the present invention provides a kind of method for quick search of non-matrix data, comprises the following steps:
步骤1:根据所需查找的非矩阵数据生成一张非矩阵数据的行头地址数据表。Step 1: Generate a row header address data table of non-matrix data according to the non-matrix data to be searched.
非矩阵数据表如下:The non-matrix data table is as follows:
DS<Const=AAAAAAAAAAAAAAAAAA>,DD<ID=0x00000001>;DS<Const=AAAAAAAAAAAAAAAAAA>,DD<ID=0x00000001>;
DS<Const=BBB>,DD<ID=0x00000002>;DS<Const=BBB>,DD<ID=0x00000002>;
DS<Const=CCCC>,DD<ID=0x00000003>;DS<Const=CCCC>,DD<ID=0x00000003>;
DS<Const=D>,DD<ID=0x00000004>DS<Const=D>,DD<ID=0x00000004>
映射表范例如下:An example of a mapping table is as follows:
DD<ID=0x00000000>;/////此值为对应数据表的头地址DD<ID=0x00000000>;/////This value is the head address of the corresponding data table
DD<ID=0x00000016>;/////此值为对应数据表的头地址DD<ID=0x00000016>;/////This value is the head address of the corresponding data table
DD<ID=0x0000001D>;dd<ID=0x0000001D>;
DD<ID=0x00000025>DD<ID=0x00000025>
步骤2:输入需要查找定位的字符串,开始进行查找。Step 2: Enter the character string that needs to be searched and located, and start searching.
步骤3:定位到辅助行头地址数据表的中间地址数据。Step 3: Locate to the middle address data of the auxiliary row head address data table.
步骤4:跳转到中间地址数据后,判断是否为当前需要查找的字符串。Step 4: After jumping to the intermediate address data, judge whether it is the character string that needs to be searched currently.
步骤5:如果步骤4中所跳转的中间地址数据不是所需查找的字符串,则对地址数据表进行二分匹配查找,并定位到新的待匹配地址数据,判断是否为当前需要查找的字符串;如果不是,则重复执行步骤5。Step 5: If the intermediate address data jumped in step 4 is not the character string to be searched, perform a binary matching search on the address data table, locate the new address data to be matched, and judge whether it is the character that needs to be searched currently string; if not, repeat step 5.
步骤6:如果步骤4或步骤5中所跳转的中间地址数据为所查找的字符串,对结果进行输出,程序结束。Step 6: If the jumping intermediate address data in step 4 or step 5 is the searched character string, output the result and the program ends.
所述二分匹配查找的具体步骤包括:The specific steps of the binary matching search include:
使用两个寄存器组来分别存储当前查询的表项地址和步长;Use two register groups to store the address and step size of the current query respectively;
使用当前表项地址去查找表中读取表项进行比较;Use the address of the current entry to read the entry in the lookup table for comparison;
根据比较结果和查找表生成方式确定下一二分匹配的方向,并在判断不为所需查找的字符串时完成下一跳操作。Determine the direction of the next binary match according to the comparison result and the way the lookup table is generated, and complete the next hop operation when it is judged that it is not the desired string.
如图2所示,当传入字符串ARC177,首先在Addr_Check_Map表中进行二分查找,第一步定位到第五个Index,对应的地址为0x0000002A,使用0x0000002A地址在Addr_Check表中查找到字符串BCMFA2,发现与传入字符串不匹配,且比传入字符串ASCII大,所以继续进行向上的二分查找,检索到第二个Index,对应地址为0x0000000A,使用0x0000000A地址在Addr_Check表中查找到字符串ARC177,发现与传入字符串完全匹配,所以此时识别成功,获取数据表中对应Type数据。As shown in Figure 2, when the string ARC177 is passed in, a binary search is first performed in the Addr_Check_Map table, the first step is to locate the fifth Index, the corresponding address is 0x0000002A, and the string BCMFA2 is found in the Addr_Check table using the address 0x0000002A , it is found that it does not match the incoming string, and it is larger than the incoming string in ASCII, so continue the upward binary search, retrieve the second Index, the corresponding address is 0x0000000A, use the address 0x0000000A to find the string in the Addr_Check table ARC177, it is found that it exactly matches the incoming string, so the recognition is successful at this time, and the corresponding Type data in the data table is obtained.
传统的二分查找在面对不是矩阵数据的情况时,无法快速的进行查找,实际操作下显得尤为繁杂、笨重,失去了二分查找的本质。本发明通过新建一张地址映射表来实现二分查找,以最小的代价实现了最大的查找效率。When the traditional binary search is not faced with matrix data, it cannot quickly search, and it is particularly complicated and cumbersome in actual operation, losing the essence of binary search. The present invention realizes the binary search by creating an address mapping table, and realizes the maximum search efficiency at the minimum cost.
综上所述,本发明根据非矩阵数据建立一个映射表,将映射表的辅助行地址数据与非矩阵数据表的地址数据进行关联,当用户输入一个字符串时,开始在映射表内进行快速查找。对映射表进行二分查找的操作,将输入的字符串与映射表中间位置记录的关键字进行比较,如果两者相同,则查找成功;否则从中间位置将表分成前后两个子表,如果中间位置记录的关键字大于查找关键字,则进一步查找前一子表,否则进一步查找后一子表。重复以上过程,直到找到满足条件的记录,使查找成功,或直到子表不存在为止,此时查找不成功。通过映射表的方式,将非矩阵数据以矩阵数据的型式进行列表,从而提高二分法的查找效率,实现非矩阵数据的快速查找定位。In summary, the present invention establishes a mapping table based on non-matrix data, and associates the auxiliary row address data of the mapping table with the address data of the non-matrix data table. find. Perform a binary search operation on the mapping table, compare the input string with the key recorded in the middle of the mapping table, if the two are the same, the search is successful; otherwise divide the table into two sub-tables from the middle position, if the middle position If the recorded key is greater than the search key, the previous sub-table is further searched; otherwise, the latter sub-table is further searched. Repeat the above process until a record meeting the condition is found, making the search successful, or until the child table does not exist, at this time the search is unsuccessful. Through the mapping table, the non-matrix data is listed in the form of matrix data, thereby improving the search efficiency of the dichotomy and realizing the fast search and positioning of non-matrix data.
以上仅为本发明的较佳实施例而已,并不用于限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention. Inside.
Claims (2)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310645039.8A CN116662615A (en) | 2023-06-01 | 2023-06-01 | A Fast Search Method for Non-matrix Data |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310645039.8A CN116662615A (en) | 2023-06-01 | 2023-06-01 | A Fast Search Method for Non-matrix Data |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116662615A true CN116662615A (en) | 2023-08-29 |
Family
ID=87716716
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310645039.8A Pending CN116662615A (en) | 2023-06-01 | 2023-06-01 | A Fast Search Method for Non-matrix Data |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116662615A (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030217046A1 (en) * | 2002-05-16 | 2003-11-20 | Kuo-Hua Yuan | Method of a data range search with plural pre-set rules |
| CN105827530A (en) * | 2016-03-11 | 2016-08-03 | 中国互联网络信息中心 | IP binary searching method and apparatus with compatibility with IPV4/IPV6 |
| CN114615195A (en) * | 2022-02-25 | 2022-06-10 | 阳光凯讯(北京)科技有限公司 | Ethernet quintuple fast matching search method and device for FPGA |
| CN114896145A (en) * | 2022-04-27 | 2022-08-12 | 北京轩宇信息技术有限公司 | Lazy symbolization method and system for complex type input variables for symbolic execution |
-
2023
- 2023-06-01 CN CN202310645039.8A patent/CN116662615A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030217046A1 (en) * | 2002-05-16 | 2003-11-20 | Kuo-Hua Yuan | Method of a data range search with plural pre-set rules |
| CN105827530A (en) * | 2016-03-11 | 2016-08-03 | 中国互联网络信息中心 | IP binary searching method and apparatus with compatibility with IPV4/IPV6 |
| CN114615195A (en) * | 2022-02-25 | 2022-06-10 | 阳光凯讯(北京)科技有限公司 | Ethernet quintuple fast matching search method and device for FPGA |
| CN114896145A (en) * | 2022-04-27 | 2022-08-12 | 北京轩宇信息技术有限公司 | Lazy symbolization method and system for complex type input variables for symbolic execution |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN102867040B (en) | Chinese search engine mixed speech-oriented query error correction method and system | |
| CN100565515C (en) | A kind of Chinese auto-answer method and system | |
| CN106980656B (en) | A kind of searching method based on two-value code dictionary tree | |
| US20100325136A1 (en) | Error tolerant autocompletion | |
| CN108846016B (en) | A Search Algorithm for Chinese Word Segmentation | |
| CN103092860B (en) | Search Hints information generating method and device | |
| CN111868710A (en) | Random Extraction Forest Index Structure for Searching Large-Scale Unstructured Data | |
| CN112131218B (en) | Hash look-up table method, device, equipment and storage medium for gene comparison | |
| US20220005546A1 (en) | Non-redundant gene set clustering method and system, and electronic device | |
| CN106959962A (en) | A kind of multi-pattern match method and apparatus | |
| US7222129B2 (en) | Database retrieval apparatus, retrieval method, storage medium, and program | |
| CN105404677A (en) | Tree structure based retrieval method | |
| CN111966654A (en) | Mixed filter based on Trie dictionary tree | |
| CN112269784B (en) | Hash table device based on hardware realization and inserting, inquiring and deleting method | |
| CN111625544B (en) | Method and system for inverted indexing based On character string segmentation On SQL On HBase | |
| CN100527134C (en) | Method and system for multi-mode search | |
| CN112015856A (en) | A method of pinyin retrieval based on Elasticsearch in IPTV | |
| CN108920483A (en) | Character string fast matching method based on Suffix array clustering | |
| CN116662615A (en) | A Fast Search Method for Non-matrix Data | |
| CN111459938A (en) | Table item processing method, table look-up method and system | |
| CN110795617A (en) | A kind of error correction method of search word and related device | |
| CN100483409C (en) | Word data searching method | |
| CN113343034A (en) | IP searching method, system and storage medium | |
| TWI807661B (en) | Method and device for identifying industry proper nouns from text | |
| CN113065419B (en) | Pattern matching algorithm and system based on flow high-frequency content |
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 |