Register-based general regular matching engine step-by-step loading method and system

The step-by-step loading method and system implemented through registers solves the loading delay problem of the HNFA engine, achieves efficient regular expression matching, and is suitable for scenarios such as network filtering and intrusion detection.

CN121579101BActive Publication Date: 2026-03-27NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-27
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing general-purpose regular expression matching engines based on HNFA have performance bottlenecks when loading regular expressions, resulting in prolonged startup time, system blocking, and severely impacting matching throughput and system efficiency.

Method used

The character activation module and state transition module are implemented using registers. Data is loaded in batches according to state, and width priority sorting is used to ensure that critical states are loaded first. After the first loading cycle is completed, the matching process is started immediately, so that state loading and matching operations are executed in parallel.

Benefits of technology

It significantly reduces startup latency, improves matching response speed and throughput, reduces hardware resource requirements, and increases system utilization, making it suitable for scenarios with high real-time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579101B_ABST
    Figure CN121579101B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of register-based general regular matching engine step loading method and system.The method includes: constructing general regular matching engine, the character activation module of general regular matching engine and state transition module are all realized based on register, to support data by state batch loading.Response to the matching demand of the input text of user, determine the regular expression to be matched, the regular expression to be matched is converted into corresponding HNFA model.After the state in this model is breadth-first ordered, state data is loaded in batches to general regular matching engine, wherein, a fixed number of states are loaded in each loading cycle.After completing the first loading cycle, start regular matching process, so that the loading of the state of HNFA model and the regular matching operation of the loaded state are executed in parallel.Using the present method can improve the regular matching response rate, system high utilization and throughput.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a register-based general regular matching engine step loading method and system. BACKGROUND

[0002] Regular matching is a fundamental and key technology in the field of computer science, which is based on the core of describing, identifying and operating specific patterns in text through predefined regular expressions. This technology can efficiently complete complex tasks such as matching, searching, replacing and extracting strings, and is an important tool for automated text processing in scenarios such as network filtering, intrusion detection, and bioinformatics.

[0003] Currently, regular matching is usually based on finite state automata, which models the matching process as a transition process between automaton states. Among them, Homogeneous Non-deterministic Finite Automaton (HNFA) is a special state machine model, and all transition edges that enter the same state correspond to the same input character set, i.e. the character transition has "homomorphism" nature.

[0004] Based on the above homomorphic characteristics, HNFA can decompose the determination process of the next active state set into the intersection operation of two independent sets: one is the state set that can be activated by the current input character, and the other is the state set that can be reached by the current active state set through transition. This computing model has regular parallelism and is very suitable for hardware implementation, providing a good foundation for building an efficient and general regular matching engine.

[0005] In building a general regular matching engine, all regular expressions are usually converted into corresponding HNFA models. To achieve multi-mode compatible matching, the state capacity of the engine is usually set to the maximum number of states in all HNFAs, and the number of character activation modules is fixed at 256 to cover all ASCII characters. In actual operation, the HNFA data corresponding to each regular expression is stored in the global memory, and when the target text needs to be matched, the corresponding HNFA data is read from the memory and loaded into the matching engine, thereby realizing on-demand loading of regular expressions.

[0006] However, the existing HNFA-based general matching engine has obvious performance bottleneck: the character activation module and the state transition module are usually implemented based on block storage resources such as RAM, and when loading a regular expression, the character activation module needs to write all 256 rows of data in turn, which takes at least 256 cycles to complete the loading process. This fixed loading delay not only significantly increases the start-up delay of a single matching, but also causes system blocking in the application scenario of frequent switching between different regular expressions, which seriously restricts the overall matching throughput and system efficiency. SUMMARY

[0007] Therefore, it is necessary to provide a register-based general regular matching engine step-by-step loading method and system that can improve the response rate of regular matching, system utilization rate, and throughput.

[0008] A register-based general regular matching engine step-by-step loading method applied to a homomorphic nondeterministic finite automaton (HNFA) model, the method comprising:

[0009] Constructing a general regular matching engine, wherein the character activation module and the state transition module of the general regular matching engine are implemented based on registers to support batch loading of data by state.

[0010] In response to the matching demand of the input text of a user, determining a regular expression to be matched, and converting the regular expression to be matched into a corresponding homomorphic nondeterministic priority state machine (HNFA) model.

[0011] After performing a breadth-first ordering on the states in the HNFA model, loading the state data in batches to the general regular matching engine, wherein a fixed number of states are loaded in each loading cycle.

[0012] After completing the first loading cycle, starting the regular matching process to enable the loading of the states of the HNFA model and the regular matching operation of the loaded states to be performed in parallel.

[0013] A register-based general regular matching engine step-by-step loading system, the system comprising:

[0014] An engine state loading module for constructing a general regular matching engine that supports all regular expressions with a maximum number of HNFA states, wherein the character activation module and the state transition module of the general regular matching engine are implemented based on registers to support batch loading of data by state.

[0015] A regular expression conversion module for responding to the matching demand of the input text of a user, determining a regular expression to be matched, and converting the regular expression to be matched into a corresponding homomorphic nondeterministic priority state machine (HNFA) model.

[0016] The HNFA model state loading module is configured to load the state data to the general regular matching engine in batches after the states in the HNFA model are breadth-first sorted, wherein a fixed number of states are loaded in each loading cycle.

[0017] The regular matching module is configured to start a regular matching process after the first loading cycle is completed, so that the loading of the states of the HNFA model and the regular matching operation of the loaded states are performed in parallel.

[0018] A computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0019] The general regular matching engine is constructed, and the character activation module and the state transition module of the general regular matching engine are both implemented based on registers to support data loading in batches according to states.

[0020] In response to a matching requirement of input text of a user, a regular expression to be matched is determined, and the regular expression to be matched is converted into a corresponding homomorphic nondeterministic priority state machine (HNFA) model.

[0021] The state data is loaded to the general regular matching engine in batches after the states in the HNFA model are breadth-first sorted, wherein a fixed number of states are loaded in each loading cycle.

[0022] After the first loading cycle is completed, a regular matching process is started, so that the loading of the states of the HNFA model and the regular matching operation of the loaded states are performed in parallel.

[0023] The above-mentioned register-based general regular matching engine step-by-step loading method and system, which uses registers to implement both the character activation module and the state transition module, abandons the inefficient mode of loading all character set data by rows and instead loads in batches according to the HNFA model state, and loads a fixed number of states per cycle, greatly reducing the amount of data loaded at a time and the time consumed. At the same time, by using breadth-first ordering to ensure that key states are loaded first, the matching process is started immediately after the first loading cycle is completed, so that subsequent state loading and matching operations are executed in parallel, completely changing the serial logic of matching after full loading, and shortening the start-up delay from hundreds of cycles to a single cycle. Secondly, the step-by-step loading characteristics of registers reduce the demand for data transmission bit width, and there is no need to configure super-large capacity block storage resources, so that a medium-scale hardware platform can be adapted to achieve high-performance matching, avoiding the waste of idle hardware resources; and the design of a fixed cycle loading amount makes the allocation of hardware resources more regular and targeted, further improving resource utilization efficiency. Finally, the parallel execution mechanism makes the matching process not need to wait for all states to be loaded, and when one character is input, the loaded states have already covered the currently required activated states, ensuring that the matching continuously and efficiently advances; the high-speed read-write characteristics of registers, combined with the homomorphic advantage of the HNFA model, make state transition and activation judgment faster, ultimately significantly improving the matching response speed, reducing system blocking, and greatly improving the overall throughput. The technical goals of short delay, high response, and high utilization are achieved, and an efficient and reliable regular matching solution is provided for scenarios such as network filtering and intrusion detection that require high real-time performance. BRIEF DESCRIPTION OF DRAWINGS

[0024] Figure 1 A homomorphic nondeterministic finite state automaton model corresponding to a regular expression and a hardware implementation thereof in an embodiment;

[0025] Figure 2 A flowchart of a step-by-step loading method of a general regular matching engine based on registers in an embodiment;

[0026] Figure 3 A structural diagram of a general regular matching engine implemented based on registers in an embodiment;

[0027] Figure 4 A timing diagram of step-by-step loading and matching of a general regular matching engine in an embodiment;

[0028] Figure 5 A structural block diagram of a step-by-step loading system of a general regular matching engine based on registers in an embodiment;

[0029] Figure 6 An internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical scheme and advantages of the present application more clear, the present application is further described in detail below in combination with the drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application.

[0031] The register-based general regular matching engine step-by-step loading method provided by the present application can be applied to the hardware model as shown in Figure 1 The HNFA model corresponding to the regular expression "(ab|cd)e" and the hardware implementation schematic thereof are shown in the model, the states S0 and S1 are initial states and are in the transitionable state at the beginning of the matching; the state S4 is a termination state and indicates a successful matching when it is activated. As shown in Figure 1 The hardware implementation of the HNFA is usually divided into two core modules: the character activation module corresponds to the input character activatable state set, and the state transition module corresponds to the active state transitionable state set, and the next active state set is obtained through the "and" operation of the two. The "?" in the character activation module is the character activatable state, the "?" in the state transition module is the transitionable state in the active state set, and the "?" in the "and" operation is the current active state. If the active state set has an intersection with the reporting state set (containing the termination state), the engine outputs a matching success signal.

[0032] In one embodiment, as shown in Figure 2 A register-based general regular matching engine step-by-step loading method is provided, and the method is applied to the hardware model in Figure 1 for example, including the following steps:

[0033] Step 202, constructing a general regular matching engine, the character activation module and the state transition module of the general regular matching engine are both realized based on registers to support loading data by states in batches.

[0034] Step 204, in response to the matching requirement of the input text of the user, determining the regular expression to be matched, and converting the regular expression to be matched into a corresponding homomorphic nondeterministic priority state machine (HNFA) model.

[0035] Step 206, after the states in the HNFA model are breadth-first ordered, the state data is loaded into the general regular matching engine in batches, wherein a fixed number of states are loaded in each loading period.

[0036] Step 208, after the first loading period is completed, starting the regular matching process to make the loading of the states of the HNFA model and the regular matching operation of the loaded states executed in parallel.

[0037] In the above-mentioned register-based general regular matching engine step-by-step loading method, both the character activation module and the state transition module are implemented based on registers, abandoning the inefficient mode of loading all character set data by row and instead loading in batches according to the HNFA model state, and loading a fixed number of states per cycle, thereby greatly reducing the amount of data loaded at a time and the time consumption. At the same time, by using breadth-first ordering to ensure that key states are loaded first, the matching process is started immediately after the first loading cycle is completed, so that subsequent state loading and matching operations are performed in parallel, completely changing the serial logic of matching after full loading, and shortening the start-up delay from hundreds of cycles to a single cycle. Secondly, the step-by-step loading characteristics of registers reduce the demand for data transmission bit width, and there is no need to configure a super-large capacity block storage resource, so that a medium-scale hardware platform can be adapted to achieve high-performance matching, avoiding the waste of idle hardware resources; and the design of a fixed cycle loading amount makes the allocation of hardware resources more regular and targeted, further improving resource utilization efficiency. Finally, the parallel execution mechanism makes the matching process not need to wait for all states to be loaded, and when each character is input, the loaded states have covered the current required active states, ensuring that the matching process continuously and efficiently advances; the high-speed read-write characteristics of registers combined with the homomorphic advantage of the HNFA model make state transition and activation judgment faster, ultimately significantly improving the matching response speed, reducing system blocking, and greatly improving the overall throughput. The technical goals of short delay, high response, and high utilization are achieved, and an efficient and reliable regular matching solution is provided for scenarios such as network filtering and intrusion detection that require high real-time performance.

[0038] In one embodiment, as shown in Figure 3 a register-based general regular matching engine structure is provided. This embodiment supports a HNFA model with a maximum state number less than 32 and loads 4 states per cycle, and the specific execution steps are as follows:

[0039] S1, a general regular matching engine is constructed, and both the character activation module and the state transition module of the engine are implemented based on registers to support loading data in batches according to states.

[0040] In this embodiment, the regular matching engine is based on the HNFA model, and the next active state set is determined by calculating the logical AND operation between the set of states that can be activated by the current input character (represented by the character activation module) and the set of states that can be transferred from the current active state set (represented by the state transition module).

[0041] The character activation module of the general regular matching engine is implemented by an M*N register array, where M is the size of the character set (in this embodiment, 256, corresponding to 8-bit ASCII code), and N is the maximum number of states supported by the engine (in this embodiment, 32). Each column of the module corresponds to an HNFA state. For a specific state Sj, its corresponding column vector CharVec[:,j] represents which input characters can activate Sj. Specifically, CharVec[i,j]=1 indicates that the input character i can activate the state Sj.

[0042] The state transition module of the general regular matching engine is implemented by an N*N register array, where N is the maximum number of states supported by the engine (in this embodiment, 32). Each row of the module corresponds to an HNFA state. For a specific state Si, its corresponding row vector StateVec[i,:] represents which states can transition to Si. Specifically, StateVec[i,k]=1 indicates that the state Sk can transition to the state Si.

[0043] To implement batch loading, in the character activation module, each state corresponds to a column of register units; in the state transition module, each state corresponds to a row of register units. By writing data to the row and column register units corresponding to a specific state, the loading configuration of the state can be completed. The engine of this embodiment supports all regular expressions with a number of HNFA states less than 32, loads 4 states per cycle, and completes the loading of all states in 8 loading cycles. When performing batch loading, the character activation module writes 4 state corresponding column vector data per cycle, and the state transition module writes 4 state corresponding row vector data per cycle. Figure 3 The first loading cycle of the data loading operation on states S0 to S3 is shown in the gray area in the figure.

[0044] S2, in response to the matching requirements of the input text, determines the regular expression to be matched, and converts it into a corresponding homomorphic nondeterministic finite state automaton (HNFA) model.

[0045] The construction of the HNFA model can be implemented using known techniques in the art. The key is that the HNFA model clearly distinguishes between character transitions and null transitions, which provides a theoretical basis for separating state transition information to the character activation module and the state transition module.

[0046] S3, the states in the HNFA model are breadth-first ordered, and the state data is loaded into the regular matching engine in batches according to this order, where a fixed number of states are loaded per loading cycle.

[0047] The states in the HNFA model are sorted by a breadth-first ordering algorithm: starting from the initial state set, it is placed at the front of the ordering; then the out-edges of these states are traversed, and the first time a new state is visited, it is added to the ordering queue; this process is repeated until all states have been visited. This ordering ensures that the depth of the states is monotonically non-decreasing.

[0048] The fundamental advantage of this ordering is that for any input text, at the nth character input, only those states that are in the first m states in the breadth-first ordering can be activated (m is a function of n). Take the regular expression "(ab|cd)e" as an example, the corresponding HNFA states have been sorted in breadth-first order as shown in the table below: Figure 1

[0049] At the first character input, only the initial states S0 and S1 can be activated;

[0050] At the second character input, states S0, S1, S2, and S3 can be activated;

[0051] At the third character input, all states (S0 to S4) can be activated.

[0052] During the loading process, the first loading cycle completes the loading of states S0, S1, S2, and S3; the second loading cycle completes the loading of state S4 (after the first character input and before the second character input). For cases where the number of states is less than the maximum capacity of the engine, the remaining register units are loaded with the default value 0.

[0053] S4, after completing the first loading cycle, starts the regular matching process, so that subsequent HNFA state loading and regular matching operations based on loaded states are performed in parallel.

[0054] The key condition that must be met for parallel execution is that before the nth character is input, the set of loaded states must cover all states that can be activated when the character is input. To meet this condition and ensure the universality of the engine, for any HNFA model supported by the engine and any character input time during the matching process, the number of states that have been loaded before the character is input should not be less than the maximum number of states that can be activated when the character is input.

[0055] Formal description of the key condition: Let L(k) be the number of states that have been loaded before the kth character is input, and A(k) be the maximum number of states that can be activated when the kth character is input. This method ensures that for all k≥1, L(k)≥A(k). In the configuration of this embodiment (loading 4 states per cycle), take the regular expression "(ab|cd)e" as an example:

[0056] ​Before inputting the first character, all the states S0-S3 are loaded (L(1)=4), and the possible active states are S0 and S1 (A(1)=2), which satisfies L(1)≥A(1);

[0057] Before inputting the second character, all the five states are loaded (L(2)=8), and the possible active states are S0-S3 (A(2)=4), which satisfies L(2)≥A(2);

[0058] Before inputting the third character, all the states are loaded (L(3)=12), and all the five states are possible active states (A(3)=5), which satisfies L(3)≥A(3).

[0059] Therefore, the embodiment can realize reliable parallel execution of regular expression state loading and matching operation.

[0060] In one embodiment, a general regular matching engine supporting all regular expressions with a maximum number of HNFA states is constructed according to a homomorphism nondeterministic finite automaton (HNFA) model. An intersection between a current input character allowed active state set of a character activation module and a current active state set allowed transition state set of a state transition module is calculated by a logical AND operation to obtain a next active state set. The character activation module is configured to represent the current input character allowed active state set. The state transition module is configured to represent the current active state set allowed transition state set. The next active state set represents whether a state in the next period corresponding allowed transition state set is activated or not, and whether the regular matching is successful or not.

[0061] In one embodiment, in the character activation module, each state corresponds to a column of register units. In the state transition module, each state corresponds to a row of register units. State data of the HNFA model is written into data of the row register units and the column register units corresponding to a specific state in batches to complete loading of the specific state.

[0062] In one embodiment, the states in the HNFA model are width-first ordered to obtain a width-first ordered sequence. An initial input character has an activation possibility, and any subsequent input character only activates a local state in front of the width-first ordered sequence, and the number of the local states does not exceed the total number of states of the HNFA model, until all the state data of the activatable states are loaded into the general regular matching engine. The fixed number is the number of the local states.

[0063] In one of the embodiments, the initial state set is taken as the starting reference of the sorting and is placed at the front end of the sequence, all the out edges of the states in the HNFA model are traversed in turn in the sorted states, the first discovered unsorted state is included in the breadth-first sorting sequence, the traversal and enqueuing operations are executed in a loop until all the states in the HNFA model are sorted, and the breadth-first sorting sequence is obtained.

[0064] In one of the embodiments, after the first loading cycle is completed, the regular matching process is started, according to the preset loading and matching mechanism, before any input character enters the regular matching process, the state set loaded into the general regular matching engine needs to completely cover all the states allowed to be activated at the time of input of the current input character, and the input node of any input character satisfies that the total number of the cumulative loaded states before the input of the previous input character is not less than the maximum number of the allowed activated states at the time of input of the current input character, so that the loading of the states of the HNFA model and the regular matching operation of the loaded states are executed in parallel.

[0065] In one of the embodiments, as shown in Figure 4 , an execution timing of the step-by-step loading and matching of the general regular matching engine is provided:

[0066] Cycle 0-1: the first round of loading is performed, and the general matching engine loads the states S0-S3;

[0067] Cycle 1-2: the first round of loading is completed, the matching logic is immediately started, the first character of the input text is processed, after the matching is completed, the engine performs the second round of loading, and loads the states S4-S7, the regular loading and the regular matching are performed in parallel in the cycle unit;

[0068] Cycle 7-8: the seventh character of the input text is processed, after the matching is completed, the engine performs the last round of loading, and loads the states S28-S31;

[0069] Cycle n-n+1 (n>= 8): all the states are loaded, and the engine continues to perform the regular matching.

[0070] It should be understood that, although Figure 2 the steps in the flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, Figure 2At least one of the steps in the method can include a plurality of sub-steps or a plurality of stages, which are not necessarily executed at the same time, but can be executed at different times, and the order of execution of the sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with other steps or sub-steps or stages of other steps.

[0071] In one embodiment, as shown in FIG. 5, a register-based universal regular matching engine step loading system is provided, comprising an engine state loading module 502, a regular expression conversion module 504, an HNFA model state loading module 506, and a regular matching module 508, wherein: Figure 5

[0072] The engine state loading module 502 is configured to construct a universal regular matching engine supporting all regular expressions with a set maximum number of HNFA states, and the character activation module and the state transition module of the universal regular matching engine are both implemented based on registers to support batch loading of data by state.

[0073] The regular expression conversion module 504 is configured to determine a regular expression to be matched in response to a matching requirement of input text of a user, and convert the regular expression to be matched into a corresponding homomorphic non-deterministic priority state machine (HNFA) model.

[0074] The HNFA model state loading module 506 is configured to load state data in batches to the universal regular matching engine after performing a breadth-first sorting on the states in the HNFA model, wherein a fixed number of states are loaded in each loading cycle.

[0075] The regular matching module 508 is configured to start a regular matching process after completing the first loading cycle, so that the loading of the states of the HNFA model and the regular matching operation of the loaded states are executed in parallel.

[0076] In one embodiment, the HNFA model state loading module is further configured to take an initial state set as a sorting starting reference and at the front end of the sequence, traverse all outgoing edges of the sorted states in the HNFA model in sequence, include the first discovered unsorted state in the breadth-first sorting sequence, and cyclically execute the traversal and enqueuing operations until all states in the HNFA model are sorted to obtain a breadth-first sorting sequence. The initial input character has an activation possibility, and any subsequent input character only activates the local state at the front of the breadth-first sorting sequence, and the number of the local state does not exceed the total number of states of the HNFA model, until all the activatable states of the state data have been loaded into the universal regular matching engine. The fixed number is the number of local states.

[0077] ​Specific limitations regarding the step-by-step loading system of the register-based general regular expression matching engine can be found in the limitations of the step-by-step loading method of the register-based general regular expression matching engine mentioned above, and will not be repeated here. Each module in the aforementioned step-by-step loading system of the register-based general regular expression matching engine can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independent of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the corresponding operations of each module.

[0078] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, network interface, display screen, and input system connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When executed by the processor, the computer program implements a register-based, general-purpose regular expression matching engine step-by-step loading method. The display screen can be an LCD screen or an e-ink screen. The input system can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0079] Those skilled in the art will understand that Figure 3 , Figure 5-6 The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the computer device to which the present invention is applied. A specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0080] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to perform the following steps:

[0081] A general regular expression matching engine is constructed. The character activation module and state transition module of the general regular expression matching engine are both implemented based on registers to support loading data in batches according to state.

[0082] In response to a matching requirement of input text of a user, a regular expression to be matched is determined, and the regular expression to be matched is converted into a corresponding homomorphic non-deterministic priority state machine (HNFA) model.

[0083] After the states in the HNFA model are breadth-first ordered, the state data is loaded into a general regular matching engine in batches, wherein a fixed number of states are loaded in each loading cycle.

[0084] After the first loading cycle is completed, a regular matching process is started to enable the loading of the states of the HNFA model to be performed in parallel with the regular matching operation of the loaded states.

[0085] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0086] Any combination of the technical features of the above embodiments can be made. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.

[0087] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the application. It should be noted that for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A step-by-step loading method for a register-based general regular expression matching engine, characterized in that, The method, applied to the homomorphic nondeterministic finite state automaton (HNFA) model, includes: A general regular expression matching engine is constructed. The character activation module and state transition module of the general regular expression matching engine are both implemented based on registers to support batch loading of data according to state. Based on the homomorphic nondeterministic finite state automaton (HNFA) model, a general regular expression matching engine is constructed that supports all regular expressions below the maximum number of HNFA states. The intersection between the current input character allowed activation state set of the character activation module and the current active state set allowed transition state set of the state transition module is calculated through logical AND operation to obtain the next active state set. The character activation module is used to characterize the set of allowed activation states for the currently input character; The state transition module is used to characterize the set of states that the currently active state set can transition to; The next active state set serves as a representation of whether a state in the next cycle's allowed transition state set is active or not, and whether a regular expression match is successful or not. In response to the user's input text matching request, determine the regular expression to be matched, and transform the regular expression to be matched into the corresponding homomorphic nondeterministic precedence state machine (HNFA) model. After sorting the states in the HNFA model by width priority, the state data is loaded into the general regular expression matching engine in batches, wherein a fixed number of states are loaded in each loading cycle. The states in the HNFA model are sorted by width priority to obtain a width priority sorting sequence. The specific steps are as follows: take the initial set of states as the sorting starting point and place it at the beginning of the sequence. Iterate through all outgoing edges of the sorted states in the HNFA model. Add the first unsorted state found to the width priority sorting sequence. Repeat the traversal and enqueue operations until all states in the HNFA model are sorted to obtain a width priority sorting sequence. The initial input character has the potential to be activated. Any subsequent input character will only activate the local state at the beginning of the width-first sorting sequence, and the number of local states will not exceed the total number of states of the HNFA model, until all the activatable states of the state data have been loaded into the general regular matching engine. The fixed quantity is the number of the local states; After the first loading cycle is completed, the regular expression matching process is started so that the loading of the state of the HNFA model and the regular expression matching operation of the loaded state are executed in parallel.

2. The method according to claim 1, characterized in that, Loading state data into the general regular expression matching engine in batches includes: In the character activation module, each state corresponds to a column of register units; In the state transition module, each state corresponds to a row of register units; The state data of the HNFA model is written in batches into the data of the row register unit and the column register unit corresponding to the specific state, thereby completing the loading of the specific state.

3. The method according to claim 2, characterized in that, After the first loading cycle is completed, the regularization matching process is initiated so that the loading of the HNFA model's states and the regularization matching operation of the already loaded states are executed in parallel, including: After the first loading cycle is completed, the regular expression matching process is started. According to the preset loading and matching mechanism, before any input character enters the regular expression matching process, the set of states loaded into the general regular expression matching engine must completely cover all states that can be activated when the current input character is input. In addition, the input node of any input character satisfies that the total number of cumulative loaded states before the input of the input character is not less than the maximum number of states that can be activated when the current input character is input, so that the loading of the state of the HNFA model and the regular expression matching operation of the loaded state are executed in parallel.

4. A register-based general regular expression matching engine step-by-step loading system, characterized in that, The system includes: The engine state loading module is used to construct a general regular expression matching engine that supports all regular expressions below a set maximum number of HNFA states. Both the character activation module and the state transition module of this general regular expression matching engine are implemented based on registers to support batch loading of data according to state. The general regular expression matching engine is constructed based on a homomorphic nondeterministic finite state automaton (HNFA) model, supporting all regular expressions below a set maximum number of HNFA states. The intersection of the currently allowed active state set of the character activation module and the currently allowed transition state set of the state transition module is calculated using a logical AND operation to obtain the next active state set. The character activation module represents the currently allowed active state set of the character; the state transition module represents the currently allowed transition state set of the state transition module; and the next active state set serves as a representation of whether a state in the corresponding allowed transition state set is active or not, and whether the regular expression matching is successful or not, in the next cycle. The regular expression conversion module is used to respond to the user's input text matching requirements, determine the regular expression to be matched, and convert the regular expression to be matched into the corresponding homomorphic nondeterministic first state machine (HNFA) model. The HNFA model state loading module is used to perform width-first sorting on the states in the HNFA model and then load the state data into the general regular expression matching engine in batches. Each loading cycle loads a fixed number of states. It is also used to use an initial state set as the starting point for sorting and place it at the beginning of the sequence. It then iterates through all outgoing edges of the sorted states in the HNFA model, adding the first unsorted state to the width-first sorting sequence. This traversal and enqueueing operation is repeated until all states in the HNFA model are sorted, resulting in a width-first sorted sequence. The initial input character has activation potential; subsequent input characters only activate the first local states in the width-first sorted sequence, and the number of these local states does not exceed the total number of states in the HNFA model, until all activatable states of the state data have been loaded into the general regular expression matching engine. The fixed quantity is the number of the local states; The regular expression matching module is used to start the regular expression matching process after the first loading cycle is completed, so that the loading of the state of the HNFA model and the regular expression matching operation of the loaded state are executed in parallel.

Citation Information

Patent Citations

  • Regular expression matching equipment and method on basis of deterministic finite automaton

    CN102521356A

  • Regular expression matching engine and method based on FPGA and electronic equipment

    CN115981726A