Data filtering method, data filtering device, equipment, medium, product
By generating filtering contexts and constructing data filtering chains, and dynamically loading hard filtering, soft filtering, and custom filtering components, the problem of universality and scalability of data filtering methods in existing technologies is solved, and flexible data filtering strategies and efficient decoupling of business logic are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINGDONG TECH HLDG CO LTD
- Filing Date
- 2026-02-14
- Publication Date
- 2026-06-02
AI Technical Summary
Existing data filtering methods are difficult to guarantee universality and scalability. The filtering logic is highly coupled with business code, resulting in high code duplication. Modifying filtering rules requires changes to core business logic, and the execution order between different filtering rules is difficult to adjust flexibly.
A filtering context is generated by parsing the data filtering request parameters, and a data filtering chain is constructed, which includes multiple filtering components arranged in execution order. Hard filtering, soft filtering and custom filtering components are dynamically loaded and combined using the filter chain builder, and the filtering process is controlled according to the filtering type identifier and mode.
It decouples data filtering logic from business code, improves the flexibility and scalability of data filtering, supports the dynamic combination and order adjustment of multiple components, reduces development costs, and improves code maintainability and testability.
Smart Images

Figure CN122132136A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer software technology and data processing technology, and more specifically, to a data filtering method, data filtering device, equipment, medium, and product. Background Technology
[0002] As internet application systems become increasingly complex and software iterations accelerate, data filtering, a common requirement in internet application systems, has its implementation methods impacting system development efficiency and maintainability.
[0003] In one example, data filtering for different scenarios can employ methods such as hard-coded parsing, strategy-based approaches, and configuration-based methods. However, none of these methods can effectively guarantee the universality and scalability of data filtering. Summary of the Invention
[0004] In view of this, the present disclosure provides a data filtering method, a data filtering device, an equipment, a medium, and a product.
[0005] According to one aspect of this disclosure, a data filtering method is provided, comprising: in response to receiving a data filtering request, parsing a request parameter in the data filtering request to obtain a filtering context; constructing a data filtering chain for the data filtering request based on the filtering context, wherein the data filtering chain includes a plurality of filtering components arranged in an execution order; and sequentially using the plurality of filtering components to filter the filtering context in the execution order to obtain a data filtering result.
[0006] According to embodiments of this disclosure, the filtering context includes a filtering type identifier; the construction of a data filtering chain for the data filtering request based on the filtering context includes: determining the filtering component type for the data filtering request based on the filtering type identifier; and adding filtering components belonging to the filtering component type to the data filtering chain by calling the corresponding filtering interface through the filtering chain builder according to the filtering component type.
[0007] According to embodiments of this disclosure, the filtering component type includes one of the following: hard filtering type, soft filtering type, and custom filtering type; the filtering component of the hard filtering type is used to perform fixed filtering operations, the filtering component of the soft filtering type is used to perform optional filtering operations, and the filtering component of the custom filtering type is used to perform business-specific filtering operations.
[0008] According to embodiments of this disclosure, the filter type identifier includes a first control identifier indicating whether a hard filter type is used, a second control identifier indicating whether a soft filter type is used, and a third control identifier indicating whether a custom filter type is used. Determining the filter component type for the data filtering request based on the filter type identifier includes: determining that the filter component type includes a hard filter type in response to the first control identifier being a target value; determining that the filter component type includes a soft filter type in response to the second control identifier being the target value; and determining that the filter component type includes a custom filter type in response to the third control identifier being the target value.
[0009] According to embodiments of this disclosure, the filtering context further includes a filtering mode identifier; when the filtering context is filtered sequentially using multiple filtering components in the above execution order, the process includes: if the filtering mode identifier represents a fine-grained filtering mode, in response to the failure of a fixed filtering operation of a hard filtering type filtering component, interrupting the data filtering process and returning a prompt message; and if the filtering mode identifier represents a coarse-grained filtering mode, in response to the failure of a fixed filtering operation of a hard filtering type filtering component, continuing to call the next filtering component to perform the filtering operation.
[0010] According to embodiments of this disclosure, for a filter component of a custom filter type, the above-mentioned method of adding a filter component of the filter component type to the data filter chain by calling the corresponding filter interface through the filter chain builder includes: dynamically loading the filter component of the custom filter type corresponding to the filter component name in response to receiving one or more filter component names; and adding the filter component of the custom filter type to the data filter chain.
[0011] According to embodiments of this disclosure, the execution priority among the plurality of filtering components includes: the execution priority of a filtering component belonging to the hard filtering type is higher than the execution priority of a filtering component belonging to the soft filtering type, and the execution priority of a filtering component belonging to the soft filtering type is higher than the execution priority of a filtering component belonging to the custom filtering type.
[0012] According to embodiments of this disclosure, the filtering context is obtained by encapsulating the structured data parsed from the request parameters using a parameter parser. The filtering context is used to provide a perception method to control the continuation or interruption of the filtering process based on the filtering component type of the currently executing filtering component. The above-mentioned filtering process, which sequentially uses multiple filtering components to filter the filtering context in the above-mentioned execution order to obtain the data filtering result, includes: passing the filtering context in the above-mentioned data filtering chain so that multiple filtering components can sequentially perform filtering operations on the filtering context to obtain the data filtering result.
[0013] According to another aspect of this disclosure, a data filtering apparatus is provided, comprising: a parameter parsing module, configured to, in response to receiving a data filtering request, parse request parameters in the data filtering request to obtain a filtering context; a filter chain construction module, configured to, based on the filtering context, construct a data filtering chain for the data filtering request by calling a filtering interface, wherein the data filtering chain includes multiple filtering components arranged in execution order; and a data filtering module, configured to, in the execution order, sequentially use the multiple filtering components to filter the filtering context to obtain a data filtering result.
[0014] According to another aspect of this disclosure, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more instructions, wherein, when executed by the one or more processors, the one or more processors cause the one or more processors to perform the method as described in this disclosure.
[0015] According to another aspect of this disclosure, a computer-readable storage medium is provided having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the methods described in this disclosure.
[0016] According to another aspect of this disclosure, a computer program product is provided, which includes computer-executable instructions that, when executed, are used to perform the methods described in this disclosure. Attached Figure Description
[0017] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0018] Figure 1 This illustration schematically shows a system architecture to which data filtering methods can be applied according to embodiments of the present disclosure;
[0019] Figure 2 A flowchart illustrating a data filtering method according to an embodiment of the present disclosure is shown schematically.
[0020] Figure 3 The illustration shows an example schematic diagram of a framework for implementing a data filtering method according to an embodiment of the present disclosure;
[0021] Figure 4 An example schematic diagram of a filtering component type according to an embodiment of the present disclosure is shown;
[0022] Figure 5 This illustration schematically shows an example diagram of a data filter chain construction process according to an embodiment of the present disclosure;
[0023] Figure 6 The illustration shows an example schematic diagram of a framework for implementing a data filtering method according to another embodiment of the present disclosure;
[0024] Figure 7 A block diagram of a data filtering apparatus according to an embodiment of the present disclosure is schematically shown; and
[0025] Figure 8 A block diagram of an electronic device suitable for implementing a data filtering method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation
[0026] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0027] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0028] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0029] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0030] In the technical solution of this invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.
[0031] Hard-coded parsing refers to writing branching logic directly in the business logic based on user request parameters. For example, in an order processing system, different data filtering code is written for different user age groups. However, this approach leads to deep coupling between the filtering logic and the business logic, resulting in high code duplication, and requiring modifications to the core business logic for every change in requirements.
[0032] The strategy pattern-based approach involves encapsulating different filtering logic into independent strategies using design patterns. For example, different data filtering strategies can be selected based on user type (such as regular users and VIP users). However, while this approach decouples the data to some extent, the execution order of filtering rules is fixed, making it impossible to dynamically adjust the strategy combination based on request parameters, thus limiting scalability.
[0033] The configuration-based approach refers to developing a separate configuration-based filtering system that filters data based on configuration conditions. For example, filtering conditions such as user age range and region can be configured through a user interface. However, this approach requires the separate development of a configuration management system, resulting in high development costs, and the configuration system itself remains coupled with the business system.
[0034] In summary, all of the above data acquisition methods require customized development for different user scenarios. The filtering logic is highly coupled with the business code, resulting in high code duplication. Furthermore, modifying the filtering rules requires changes to the core business logic, and the execution order between different filtering rules is difficult to adjust flexibly, making it impossible to dynamically combine different filtering strategies. As a result, the versatility and scalability are weak, and the development cost is high.
[0035] Therefore, this disclosure provides a data filtering method, data filtering device, equipment, medium, and product, which can be applied to the fields of computer software technology and data processing technology. The data filtering method includes: in response to receiving a data filtering request, parsing the request parameters in the data filtering request to obtain a filtering context; based on the filtering context, constructing a data filtering chain for the data filtering request, wherein the data filtering chain includes multiple filtering components arranged in execution order; and sequentially using the multiple filtering components to filter the filtering context in execution order to obtain a data filtering result.
[0036] Figure 1 The illustration schematically depicts a system architecture to which a data filtering method can be applied according to embodiments of the present disclosure. It should be noted that... Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.
[0037] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between different devices.
[0038] It should be noted that the data filtering method provided in this embodiment can generally be executed by the server 105. Accordingly, the data filtering device provided in this embodiment can generally be set in the server 105.
[0039] Alternatively, the data filtering method provided in this embodiment of the present disclosure can also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103. Correspondingly, the data filtering device provided in this embodiment of the present disclosure can also be disposed in the first terminal device 101, the second terminal device 102, or the third terminal device 103.
[0040] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0041] It should be noted that the sequence numbers of the operations in the following methods are for descriptive purposes only and should not be considered as indicating the execution order of the operations. Unless explicitly stated otherwise, the method does not need to be executed in the exact order shown.
[0042] Figure 2 A flowchart illustrating a data filtering method according to an embodiment of the present disclosure is shown schematically.
[0043] like Figure 2 As shown, the data filtering method 200 includes operations S210 to S230.
[0044] In operation S210, in response to receiving a data filtering request, the filtering context is obtained by parsing the request parameters in the data filtering request.
[0045] In operation S220, a data filtering chain for the data filtering request is constructed based on the filtering context, wherein the data filtering chain includes multiple filtering components arranged in execution order.
[0046] In operation S230, multiple filtering components are used sequentially to filter the filtering context in the order of execution to obtain the data filtering result.
[0047] A data filtering request is a request initiated by a user or system to filter or process specific data. Request parameters are the set of data carried in the data filtering request that describes the filtering conditions. For example, in an e-commerce order system, a data filtering request could filter out order data for users aged 18 and older whose address is in City A; the corresponding request parameters could be {"age:18", "address:City A"}.
[0048] In response to a received data filtering request, a filtering context object containing data and configuration can be constructed by parsing the parameters in the request, thus providing a unified input for subsequent filtering. A filtering context is an object that encapsulates the data and configuration required for filtering. In one embodiment, the filtering context may include the business data to be filtered, structured filtering parameters, a filtering mode identifier, and optional metadata such as request ID, timestamp, and tenant identifier.
[0049] The specific parsing method can be configured according to actual business needs and is not limited here. For example, a parameter parser can be used to convert request parameters into entity objects, Maps, or JSON; alternatively, annotation-driven parsing can be used; alternatively, a template engine can be used to dynamically generate filtering context.
[0050] After obtaining the filtering context, a data filtering chain can be dynamically constructed based on the configuration within that context. A data filtering chain is a chain-like structure composed of multiple filtering components arranged sequentially to execute filtering operations. A filtering component is an independent unit that implements specific filtering logic. For example, an "age filtering component" might check whether the age field in the data meets the required range, while a "sensitive word filtering component" might detect and replace sensitive content. In user data filtering, the data filtering chain may include null value validation, sensitive information masking, and business-defined filtering, executed in a specific order. The execution order refers to the order in which each filtering component is called within the data filtering chain, and can be determined by priority values.
[0051] The specific method for constructing the data filtering chain can be configured according to actual business needs and is not limited here. For example, the builder pattern and Service Provider Interface (SPI) can be used to dynamically load and sort filtering components; alternatively, a dependency injection framework can be used to manage the data filtering chain; alternatively, the structure of the data filtering chain can be defined through Extensible Markup Language (XML) or YAML configuration files.
[0052] After obtaining the data filtering chain, you can iterate through each filtering component in the chain and execute the filtering logic sequentially to obtain the data filtering result. The data filtering result refers to the final data after processing by the data filtering chain. For example, given an original order list as input, the output after filtering would only contain a list of completed orders.
[0053] In the embodiments of this disclosure, a filtering context is generated by parsing request parameters, ensuring unified input and configurable management of the filtering process; a data filtering chain is constructed based on the filtering context, and each filtering component in the data filtering chain is executed sequentially, ensuring the modularity and testability of the filtering process; and, since it can support the dynamic combination and order adjustment of multiple filtering components, it avoids the technical problem in related technologies that it is difficult to effectively guarantee the universality and scalability of data filtering, realizes the decoupling of filtering logic and business code, and improves the flexibility and scalability of data filtering.
[0054] The following is for reference. Figures 3-6 The data filtering method 200 according to an embodiment of the present invention will be further described.
[0055] Figure 3 The illustration shows an example schematic diagram of a framework for implementing a data filtering method according to an embodiment of the present disclosure.
[0056] like Figure 3As shown, in embodiment 300 of the framework for implementing the data filtering method, the framework may include a core layer 310, a service layer 320, and an extension layer 330.
[0057] The core layer 310 can be used to define the basic filtering interface and abstract implementation, the service layer 320 can be used to provide the filtering service entry and configuration management, and the extension layer 330 can be used to support dynamic loading and custom filtering implementation.
[0058] According to embodiments of this disclosure, the filter component type includes one of the following: hard filter type, soft filter type, and custom filter type.
[0059] Figure 4 An example schematic diagram of a filtering component type according to an embodiment of the present disclosure is shown.
[0060] like Figure 4 As shown, in embodiment 400 of the filter component type, the filter component type includes one of the following: hard filter type, soft filter type, and custom filter type.
[0061] Hard filter components are used to perform fixed filtering operations, soft filter components are used to perform optional filtering operations, and custom filter components are used to perform business-specific filtering operations.
[0062] Hard filtering refers to filtering operations that must be performed and cannot be skipped, and can involve core verification aspects of data security and integrity. For example, a null value validation filter is a type of hard filtering; if a required field is detected to be empty, the filtering process is immediately terminated.
[0063] Soft filtering refers to optional and degradeable filtering operations, which can be used for data optimization or non-critical processing. For example, data masking filters are soft filters; even if masking fails, it will not affect the main business processes, only logging errors.
[0064] Custom filter types refer to filter operations customized according to specific business needs. For example, in an e-commerce system, a filter specifically designed to verify the special discount eligibility of VIP users is a custom filter.
[0065] In the embodiments of this disclosure, by establishing a multi-layered filtering component type system, hard filtering types ensure the mandatory execution of core filtering operations, guaranteeing the baseline security and integrity of data processing; soft filtering types provide optional filtering capabilities, supporting data optimization processing while maintaining process flexibility; and custom filtering types endow specific business scenarios with extended capabilities to meet personalized filtering needs. This type division enables filtering strategies to be dynamically combined according to actual needs, realizing refined management and flexible configuration of data filtering logic, and improving the adaptability and scalability of data filtering.
[0066] According to embodiments of this disclosure, the execution priority among multiple filtering components includes: the execution priority of a filtering component belonging to the hard filtering type is higher than the execution priority of a filtering component belonging to the soft filtering type, and the execution priority of a filtering component belonging to the soft filtering type is higher than the execution priority of a filtering component belonging to the custom filtering type.
[0067] Execution priority refers to the order in which multiple filtering components are scheduled for execution in a data filtering chain. Hard filtering components are those that must be executed and have priority. Soft filtering components are those that can be executed optionally and have a lower execution order than hard filtering. Custom filtering components are business-specific components, offering the most flexible execution order but the lowest priority.
[0068] During data filtering, the execution order of each filtering component can be determined by a numerical order value (such as an order value), with smaller values indicating higher priority. For hard filtering components, the numerical order value can be between the first and second thresholds; for soft filtering components, it can be between the third and fourth thresholds; and for custom filtering components, it can be greater than or equal to the fifth threshold.
[0069] For example, the first threshold can be 0, the second threshold can be 99, that is, the numerical sequence value of the filter component of the hard filter type can be between 0 and 99; the third threshold can be 100, the fourth threshold can be 199, that is, the numerical sequence value of the filter component of the soft filter type can be between 100 and 199; the fifth threshold can be 200+, that is, the numerical sequence value of the filter component of the custom filter type can be greater than or equal to 200+.
[0070] For example, taking a hard filter type component including a null pointer check component as an example, its order value can be set to 10 to ensure that it is executed before other filters. Taking a soft filter type component including a data format normalization component as an example, its order value can be set to 110, and it is executed after the hard filter type components. Taking a custom filter type component including a user behavior analysis filter component as an example, its order value can be set to 250.
[0071] In the embodiments of this disclosure, by establishing a hierarchical priority system for the execution of filtering components, the hard filtering components are executed first to ensure the baseline protection of data security and integrity, and can promptly intercept invalid or dangerous data to avoid unnecessary subsequent processing overhead; the soft filtering components are executed second-most to optimize data processing while ensuring the completion of core verification, balancing processing efficiency and functional integrity; the custom filtering components execute business-specific logic last, ensuring that personalized needs are realized on a secure and reliable data basis. This priority arrangement improves filtering efficiency and realizes the optimization of the data filtering process and the rational allocation of resources.
[0072] According to an embodiment of this disclosure, the filtering context includes a filtering type identifier; operation S220 may include the following operations: determining the filtering component type for the data filtering request based on the filtering type identifier; and adding the filtering component belonging to the filtering component type to the data filtering chain by calling the corresponding filtering interface through the filtering chain builder according to the filtering component type.
[0073] A filtering context is a container object that encapsulates the data and configuration information required during the filtering process. For example, in a user data filtering scenario, the filtering context might contain a list of user information to be filtered, a dictionary of filtering parameters, and a filter type identifier.
[0074] The filter type identifier identifies the category of filter components that need to be executed, providing a basis for constructing subsequent filter chains. The filter type identifier is a flag used to distinguish different filter component types; it can be an enumeration value or a string constant. For example, "HARD_FILTER" represents a hard filter type, "SOFT_FILTER" represents a soft filter type, and "CUSTOM_FILTER" represents a custom filter type. For instance, when the filter type identifier is "HARD_FILTER," it indicates that hard filter components such as null value validation and data format validation need to be loaded.
[0075] The specific method for determining the filter component type can be configured according to actual business needs and is not limited here. For example, the filter type identifier can be parsed through the FilterConfig configuration class, and the filter component type can be determined by enumeration matching; alternatively, the filter type identifier can be parsed using a rule engine, supporting complex multi-condition combination judgments; alternatively, a dedicated state processor can be created for each filter type identifier.
[0076] After determining the filter component type, the corresponding filter interface method can be called through the filter chain constructor, and the concrete implementation of the filter component can be added to the component collection of the data filter chain to complete the assembly of the data filter chain. The filter chain constructor is a utility class used to dynamically construct the filter chain, which can be implemented using the builder pattern. The filter interface is a standard method interface that defines filtering operations. For example, the DataFilter interface declares the doFilter method, and each filter component can implement this interface.
[0077] The specific method of invocation can be configured according to actual business needs and is not limited here. For example, the builder pattern can be used to explicitly specify the activation of each type of filter component through chained invocation; alternatively, the factory method pattern can be used to automatically create the corresponding filter interface caller based on the filter type identifier; alternatively, the command pattern can be used to encapsulate the filter interface call into a rollbackable command object.
[0078] In the embodiments of this disclosure, by precisely controlling the filter type identifier and flexibly utilizing the filter chain builder, the required filter component types can be accurately identified based on the filter type explicitly identified in the filter context, ensuring a precise match between the filter strategy and business requirements. A standardized component registration mechanism is established by calling the corresponding filter interface through the filter chain builder, guaranteeing the consistency and replaceability of filtering capabilities. By adding the identified filter components to the data filter chain according to their type, a complete filter execution pipeline is formed. This mechanism enhances the adaptability and flexibility of filtering, enabling the filter strategy to be dynamically adjusted according to specific business scenarios and data processing needs. This ensures the stability of the core filtering logic while supporting personalized extensions for specific business requirements, effectively reducing the coupling between filter components, improving code maintainability and testability, and realizing the dynamic and intelligent construction of the data filter chain.
[0079] According to embodiments of this disclosure, the filter type identifier includes a first control identifier for indicating whether a hard filter type is used, a second control identifier for indicating whether a soft filter type is used, and a third control identifier for indicating whether a custom filter type is used.
[0080] According to embodiments of this disclosure, determining the filter component type for a data filtering request based on a filter type identifier may include the following operations: in response to a first control identifier being a target value, determining that the filter component type includes a hard filter type; in response to a second control identifier being a target value, determining that the filter component type includes a soft filter type; and in response to a third control identifier being a target value, determining that the filter component type includes a custom filter type.
[0081] The target value refers to the specific value that triggers the activation of the corresponding filter type. For example, in a Boolean control flag, the target value can be "true"; in a numeric control flag, the target value can be "1".
[0082] When the first control flag is the target value, the hard filter type can be included in the component type set for this filtering. The first control flag is a flag used to control whether the hard filter type is enabled. Taking the first control flag as "requireHardFilter" as an example, in the Boolean control flag, when its value is "true", it means that the hard filter type filter component needs to be enabled; alternatively, in the numeric control flag, when its value is "1", it means that the hard filter type filter component needs to be enabled.
[0083] When the second control flag is the target value, the soft filter type can be included in the component type set for this filtering. The second control flag is a flag used to control whether the soft filter type is enabled. Taking the second control flag as "enableSoftFilter" as an example, in a Boolean control flag, a value of "true" indicates that the soft filter type filter component needs to be enabled; alternatively, in a numeric control flag, a value of "1" indicates that the soft filter type filter component needs to be enabled.
[0084] When the third control flag is the target value, the custom filter type can be included in the component type set for this filter. The third control flag is a flag used to control whether the custom filter type is enabled. Taking the third control flag as "useCustomFilter" as an example, in the Boolean control flag, when its value is "true", it means that the filter component of the custom filter type needs to be enabled; alternatively, in the numeric control flag, when its value is "1", it means that the filter component of the custom filter type needs to be enabled.
[0085] The filter chain constructor enables the dynamic construction of the data filter chain. The filter chain constructor provides Boolean variables for hard filtering, soft filtering, and custom filtering, and provides methods to assign the relevant variables to true (that is, after calling the method, it will be set to hard filtering, soft filtering, or custom filtering. When using the custom filtering method, the custom filter name of string type must be passed and specified by the user).
[0086] Additionally, the filter chain constructor also provides a List <string>The `customFilterNames` collection stores custom filter DataFilters, which are set by the user when using the constructor by calling custom methods. Additionally, the filter chain constructor provides a `build()` method. Based on the methods called during constructor creation, it assigns a `true` value to the Boolean variables for hard filtering, soft filtering, and custom filtering. If a Boolean variable is true, it's assumed the user needs the current type of filtering and determines whether to add the current filter to the `FilterChain`. This is dynamically loaded via `ServiceLoader`, and the filter type is determined by the `FilterType` enumeration, which provides three types of enumeration values: hard filtering, soft filtering, and custom filtering.
[0087] In the embodiments of this disclosure, an independent and controllable filter type identification system is established. Specifically, the first control identifier ensures that hard filter types are accurately enabled when needed, providing reliable protection for core data security; the second control identifier enables precise control over soft filter types, providing data processing optimization capabilities while ensuring system stability; and the third control identifier provides a dedicated channel for specific business needs, supporting flexible expansion of personalized filtering scenarios. This separate identification control mechanism allows the three filter types to be enabled independently or used in any combination, enhancing the adaptability and configurability of filtering strategies and realizing fine-grained configuration and flexible combination of data filtering strategies.
[0088] According to embodiments of this disclosure, for a filter component of a custom filter type, the filter component belonging to the filter component type is added to the data filter chain by calling the corresponding filter interface through the filter chain builder. This can include the following operations: in response to receiving one or more filter component names, dynamically loading the filter component of the custom filter type corresponding to the filter component name; and adding the filter component of the custom filter type to the data filter chain.
[0089] When the user-specified filter component name is obtained, the corresponding custom filter component implementation class can be found and instantiated in real time. The filter component name is a unique string that identifies the filter component of a custom filter type. In one embodiment, the filter component name can be a class name, a business semantic name, or an annotation declaration value, etc. Dynamic loading refers to the process of instantiating and registering filter components in real time as needed at runtime. For example, when VIP price filtering is found during configuration parsing, the corresponding class is immediately loaded from the classpath and an instance is created.
[0090] The method for obtaining filter component names can be configured according to actual business needs and is not limited here. For example, an annotation-based declarative approach can be used, that is, intercepting annotations marked on business methods through Aspect-Oriented Programming (AOP) and automatically extracting the filter name and injecting it into the constructor before the method is called; alternatively, an event subscription approach based on a configuration center can be used, that is, storing the list of custom filter names in the configuration center, with the filter chain constructor listening for configuration change events, and automatically refreshing the filter component names when the configuration is updated.
[0091] When using a custom filtering method, you need to pass the custom filter name as a String. If it is a custom type enumeration, you need to check whether the request parameter Map contains the custom filter name, and filter based on the returned Boolean type.
[0092] The specific search method can be configured according to actual business needs and is not limited here. For example, the Java SPI mechanism can be used to configure the mapping relationship between the filter component name and the implementation class in the METAINF / services directory and dynamically load them using ServiceLoader; alternatively, the Spring framework's ApplicationContext can be used to retrieve the registered filter component instance by name using the getBean(componentName) method.
[0093] After obtaining a filter component of a custom filter type corresponding to the filter component name, the dynamically loaded custom filter component instance can be added to the data filter chain being built, becoming part of the chained processing.
[0094] The specific method of adding filters can be configured according to actual business needs and is not limited here. For example, you can call the addFilter() method of FilterChain to add dynamically loaded DataFilter instances to the internal filterList collection; alternatively, you can use the chain-of-responsibility pattern to assemble multiple custom filter components into a chain using the setNext() method.
[0095] In the embodiments of this disclosure, a name-driven dynamic loading mechanism is used to dynamically load new business filtering requirements based on the names of filtering components. This allows new business filtering requirements to be integrated into the system with simple configuration, without modifying the core filtering framework. By adding the loaded custom components to the filtering chain, business-specific logic can be seamlessly integrated into the standard processing flow. This mechanism effectively supports differentiated filtering requirements under a multi-tenant architecture. Different business lines can independently develop and maintain their own filtering components, which can be dynamically enabled at appropriate times through name identification. This achieves flexible registration and hot-swapping of custom filtering components, improving the scalability and adaptability of data filtering.
[0096] Figure 5 The illustration shows an example schematic diagram of a data filter chain construction process according to an embodiment of the present disclosure.
[0097] like Figure 5 As shown, in embodiment 500 of the data filtering chain construction process, the type of filtering component used for the data filtering request is determined based on the filtering type identifier 501 included in the filtering context 510.
[0098] For example, the filter type identifier 501 may include a first control identifier 520 for indicating whether a hard filter type is used, a second control identifier 530 for indicating whether a soft filter type is used, and a third control identifier 540 for indicating whether a custom filter type is used.
[0099] For the first control identifier 520, operation S510 can be performed. In operation S510, is the first control identifier a target value? If so, it can be determined that the filter component type includes hard filter type 550.
[0100] For the second control identifier 530, operation S520 can be performed. In operation S520, is the second control identifier a target value? If so, it can be determined that the filter component type includes soft filter type 560.
[0101] For the second control identifier 540, operation S530 can be performed. In operation S530, is the third control identifier a target value? If so, it can be determined that the filter component type includes custom filter type 570.
[0102] Based on hard filter type 550, soft filter type 560, and custom filter type 570, the corresponding filter interface is called through the filter chain builder to add filter components belonging to the filter component type to the data filter chain 580. This enables dynamic filter chain construction, supports dynamic adjustment of filter combinations at runtime, and allows changes to the filter strategy without recompiling.
[0103] According to embodiments of this disclosure, the filtering context further includes a filtering mode identifier; operation S230 may include the following operations: when the filtering mode identifier represents a fine-grained filtering mode, in response to the failure of a fixed filtering operation of a filtering component of the hard filtering type, the data filtering process is interrupted and a prompt message is returned; when the filtering mode identifier represents a coarse-grained filtering mode, in response to the failure of a fixed filtering operation of a filtering component of the hard filtering type, the next filtering component is called to perform the filtering operation.
[0104] The filter mode identifier is a configuration parameter used to control the stringency of the filtration process. The filter mode identifier can represent a fine-grained filtration mode or a coarse-grained filtration mode.
[0105] Fine-grained filtering mode, also known as strict processing mode, immediately terminates the process if any critical filtering fails. For example, in bank transaction data filtering, once account balance verification fails, all subsequent filtering operations are immediately stopped. For instance, taking the filtering mode identifier "strictMode" as an example, in a Boolean control identifier, a value of "true" indicates fine-grained filtering mode; alternatively, in a numeric control identifier, a value of "1" indicates fine-grained filtering mode.
[0106] In strict mode, any failure of the hard filtering component will immediately terminate the filtering chain and return detailed error information. For example, in user registration data filtering, if password strength verification fails in fine-grained mode, an error message "password does not meet security requirements" will be returned immediately, and subsequent operations such as email format verification will not be performed.
[0107] Coarse-grained filtering mode, also known as a lenient processing mode, continues subsequent operations even if critical filtering fails. For example, in data statistical analysis scenarios, even if the format validation of a certain field fails, filtering of other fields continues to collect more error information. For instance, taking the filtering mode identifier "strictMode" as an example, in the Boolean control identifier, a value of "false" indicates coarse-grained filtering mode; alternatively, in the numeric control identifier, a value of "0" indicates coarse-grained filtering mode.
[0108] In the lenient mode, even if the hard filtering component fails, subsequent filtering components will continue to execute, completing as many processing steps as possible. For example, during data migration, in coarse-grained mode, even if the data type conversion of a certain field fails, the cleaning and conversion operations of other fields will continue, and finally all error information will be summarized.
[0109] In the embodiments of this disclosure, a dual control mechanism of filtering mode identification is introduced. The fine-grained filtering mode provides immediate failure protection for scenarios with stringent data quality requirements, ensuring that any critical data issues can be immediately detected and addressed, effectively preventing the spread of erroneous data within the system. The coarse-grained filtering mode provides fault-tolerant support for data exploration and batch processing scenarios, maximizing the collection of processing results and error information by continuing to execute subsequent filtering operations. This dual-mode design expands the applicability of the filtering framework, meeting the data accuracy requirements of critical businesses such as finance and trading, while also adapting to scenarios requiring comprehensive data quality assessment, achieving an intelligent balance between accuracy and robustness in the data filtering process.
[0110] According to embodiments of this disclosure, the filtering context is obtained by encapsulating the structured data parsed from the request parameters using a parameter parser. The filtering context is used to provide a perception method to control the continuation or interruption of the filtering process based on the filtering component type of the currently executing filtering component. Operation S230 may include the following operation: passing the filtering context in the data filtering chain so that multiple filtering components can sequentially perform filtering operations on the filtering context to obtain data filtering results.
[0111] In response to a received data filtering request, a parameter parser can be used to convert the raw request parameters into standard structured data that is easy for the program to process. A parameter parser is a component that converts raw request parameters into structured data. Structured data refers to data organization with a defined format and type. For example, structured data can be WildJSON objects, Java entity class instances, or KeyValue mapping tables.
[0112] The specific parsing method can be configured according to actual business needs and is not limited here. For example, the ParameterParser interface can be implemented to convert parameters according to parameter type mapping rules; alternatively, annotation-driven parsing can be used, that is, annotations can be used to automatically bind parameters to object properties; alternatively, the template method pattern can be used to define a standard process for parameter parsing, allowing subclasses to override specific steps.
[0113] The filter context object can provide awareness methods that determine the flow direction based on the current filter component type and configuration. A awareness method is a logical method that makes flow control decisions based on the current filter state. The awareness method can return a boolean value indicating whether to continue the process, depending on the type of filter component being executed and the strict mode setting. For example, in fine-grained filtering mode, when the hard filter component fails validation, the awareness method returns false, indicating that the process should be immediately aborted.
[0114] By allowing the same filtering context to flow between different filtering components in the data filtering chain, state consistency can be maintained. For example, in a data filtering chain used for order processing, the same FilterContext object sequentially passes through the filtering component used for price validation, the filtering component used for inventory check, the filtering component used for risk control verification, and so on.
[0115] In this process, each filtering component in the data filtering chain processes the data in the data context sequentially, ultimately producing the data filtering result. For example, user data undergoes null value validation, sensitive information de-identification, and business rule filtering in sequence, outputting a data set that meets the requirements.
[0116] The specific transmission method can be configured according to actual business needs and is not limited here. For example, the doFilter method can be called sequentially by looping through the DataFilter list in FilterChain; alternatively, a pipeline filter component pattern can be used, with each filter component processing data as an independent pipeline stage.
[0117] The filter context object (FilterContext) provides a filtering control method that returns a Boolean value. The getType method is called through the DataFilter parameter to determine the filter type (e.g., whether it is a custom type enumeration). If it is a custom type enumeration, the logic of checking whether the request parameter Map contains a custom filter name is applied, and filtering is performed based on the returned Boolean type.
[0118] In the embodiments of this disclosure, through standardized processing by the parameter parser and intelligent encapsulation of the filtering context, the parameter parser converts diverse request parameters into structured data, eliminating the impact of data source differences on the filtering process. The filtering context, acting as a data carrier and process controller, implements intelligent process decisions based on filtering type and operating mode through a perception method. Passing the context within the filtering chain ensures the consistency and continuity of the processing states of each filtering component. This approach enhances the adaptability and robustness of filtering, supporting input in various data formats and meeting the needs of complex filtering scenarios. Simultaneously, centralized process control reduces the coupling between components, establishing a unified data filtering entry point and process control mechanism, thereby improving the flexibility and maintainability of the filtering process.
[0119] Figure 6 The illustration shows an example schematic diagram of a framework for implementing a data filtering method according to another embodiment of the present disclosure.
[0120] like Figure 6 As shown, in embodiment 600 of the framework for implementing the data filtering method, the framework may include a core layer 620, a service layer 630, and an extension layer 640.
[0121] The core layer 620 can be used to define the basic filtering interface and abstract implementation. Specifically, in response to receiving a data filtering request 610, the request parameters in the data filtering request 610 are parsed using the parameter parser 621 to obtain the filtering context 622.
[0122] The service layer 630 can be used to provide a filtering service entry point and configuration management. Specifically, the filtering service entry point 631 can be a unified call endpoint exposed by the framework to business systems, internally encapsulating standardized filtering processing templates. The filter type enumeration 632 can be used to enumerate and describe filter types. The filter configuration class 633 can provide user-defined configuration capabilities, including multiple control flags for identifying whether hard filtering types, soft filtering types, and custom filtering types are enabled, as well as filtering mode flags (such as strict mode / non-strict mode).
[0123] The filter service entry point 631, DataFilterService, provides the filterData() method, which is implemented internally according to a template. It provides users with directly accessible abstract methods such as buildFilterConfig(). Users can implement DataFilter according to their own business filtering requirements, and then write the implementation class of the service entry point DataFilterService, override the buildFilterConfig() method, and specify the construction of FilterConfig objects. Users can flexibly combine filtering configurations, specify the filtering types and custom filtering implementation classes required by the user.
[0124] The core layer 620 can determine the type of filter component used for the data filtering request 610 based on the filter type identifier in the filtering context 622, and add the filter component belonging to the filter component type to the data filtering chain 625 by calling the corresponding filtering interface 623 through the filter chain builder 624. The data filtering chain 625 includes multiple filter components arranged in execution order. For example, the multiple filter components may include a filter component 626 of hard filtering type, a filter component 627 of soft filtering type, and a filter component 628 of custom filtering type.
[0125] For example, you can sort the filters using the `getOrder()` method of `DataFilter`, and add the current filtering operation to the `filterList` of the `FilterChain` by calling the `addFilter()` method of the filter chain. The `addFilter()` method in the filter chain adds all the filtering capabilities in the system (i.e., implementation classes of the filtering interfaces) through a `List`. <DataFilter <t>The filterList stores the filters and provides the option to execute each filter operation sequentially according to the execution order set when the filter chain is constructed (by looping through the previous filterList, the doFilter() method of the interface implementation class is executed in turn).
[0126] The extension layer 640 can be used to support dynamic loading and custom filter implementations. Specifically, the custom filter definition annotation 641 provides declarative extension capabilities. Business systems can automatically register components by annotating the filter components 628 of the custom filter type with this annotation. Dynamic filter loading 642 can be implemented based on the SPI mechanism. At runtime, the framework scans and discovers all implementation classes of the filter interface 621 through the service loader.
[0127] The core layer 620 can sequentially use multiple filtering components to filter the filtering context 622 according to the execution order of multiple filtering components in the data filtering chain 625, and obtain the data filtering result 650.
[0128] The data filtering method disclosed herein provides an abstract data filtering model through a lightweight JAR package. It uses a chain of responsibility to parse input parameter fields, construct filtering interface logic, filter chains, and filtering contexts, encapsulates the data entities required by the business, understands user intent, and provides templates for hard filtering (such as source filtering), soft filtering (such as conditional filtering), and business-defined filtering for businesses that need to perform filtering. This provides a general field parsing and processing flow that performs data transformation, user intent analysis, and filtering model creation based on the input parameter data provided by the user, realizing data filtering needs in different scenarios without affecting the business.
[0129] Furthermore, the data filtering method provided in this disclosure decouples the filtering logic through the chain of responsibility pattern, abstracting it into independent filtering components. Business code only needs to call a unified filtering service entry point, achieving modular encapsulation of the filtering logic while maintaining physical isolation between the business code and the filtering rules. Moreover, by employing the builder pattern and dynamic configuration, the filtering strategy can be dynamically adjusted based on user request parameters. FilterChainBuilder supports building the filtering chain at runtime, and, in conjunction with FilterConfig, enables strategy customization during the request process, thereby dynamically changing the filtering strategy.
[0130] The above are merely exemplary embodiments, but are not limited thereto. Other data filtering methods known in the art may also be included, as long as they can decouple the filtering logic from the business code and improve the flexibility and scalability of data filtering.
[0131] Figure 7 A block diagram of a data filtering apparatus according to an embodiment of the present disclosure is shown schematically.
[0132] like Figure 7 As shown, the data filtering device 700 may include a parameter parsing module 710, a filter chain construction module 720, and a data filtering module 730.
[0133] The parameter parsing module 710 is used to respond to a received data filtering request by parsing the request parameters in the data filtering request to obtain the filtering context.
[0134] The filter chain building module 720 is used to build a data filter chain for data filtering requests based on the filtering context by calling the filtering interface. The data filter chain includes multiple filtering components arranged in execution order.
[0135] The data filtering module 730 is used to filter the filtering context sequentially using multiple filtering components according to the execution order to obtain the data filtering result.
[0136] According to embodiments of this disclosure, the filtering context includes a filter type identifier; the filter chain construction module 720 may include a determination submodule and a construction submodule.
[0137] The determination submodule is used to determine the type of filtering component used for the data filtering request based on the filtering type identifier.
[0138] The construction submodule is used to add filter components of the same type to the data filter chain by calling the corresponding filter interface through the filter chain constructor, based on the filter component type.
[0139] According to embodiments of this disclosure, the filtering component type includes one of the following: hard filtering type, soft filtering type, and custom filtering type; the filtering component of the hard filtering type is used to perform fixed filtering operations, the filtering component of the soft filtering type is used to perform optional filtering operations, and the filtering component of the custom filtering type is used to perform business-specific filtering operations.
[0140] According to embodiments of this disclosure, the filter type identifier includes a first control identifier for indicating whether a hard filter type is used, a second control identifier for indicating whether a soft filter type is used, and a third control identifier for indicating whether a custom filter type is used; the determination submodule may include a first determination unit and a second determination unit.
[0141] The first determining unit is configured to determine, in response to a first control identifier being a target value, the filter component type, including a hard filter type.
[0142] The second determining unit is used to determine the filter component type, including soft filter type, in response to the second control identifier being a target value.
[0143] The third determining unit is used to determine the filter component type, including the custom filter type, in response to the third control identifier being a target value.
[0144] According to embodiments of this disclosure, the filtering context further includes a filtering mode identifier; the data filtering module 730 may include a first filtering submodule and a second filtering submodule.
[0145] The first filtering submodule is used to interrupt the data filtering process and return a prompt message in response to the failure of the fixed filtering operation of the filtering component of the hard filtering type when the filtering mode identifier represents a fine-grained filtering mode.
[0146] The second filtering submodule is used to continue calling the next filtering component to perform the filtering operation when the filtering mode identifier represents a coarse-grained filtering mode, in response to the failure of the fixed filtering operation of the filtering component of the hard filtering type.
[0147] According to embodiments of this disclosure, for a filter component of a custom filter type, the construction submodule may include a loading unit and an adding unit.
[0148] The loading unit is used to dynamically load a filter component of a custom filter type corresponding to the filter component name in response to receiving one or more filter component names.
[0149] Add a unit to add filter components of a custom filter type to the data filter chain.
[0150] According to embodiments of this disclosure, the execution priority among multiple filtering components includes: the execution priority of a filtering component belonging to the hard filtering type is higher than the execution priority of a filtering component belonging to the soft filtering type, and the execution priority of a filtering component belonging to the soft filtering type is higher than the execution priority of a filtering component belonging to the custom filtering type.
[0151] According to embodiments of this disclosure, the filtering context is obtained by encapsulating the structured data parsed from the request parameters using a parameter parser. The filtering context is used to provide a perception method to control the continuation or interruption of the filtering process based on the filtering component type of the filtering component being executed. The data filtering module 730 may include a third filtering submodule.
[0152] The third filtering submodule is used to pass the filtering context in the data filtering chain so that multiple filtering components can sequentially perform filtering operations on the filtering context to obtain the data filtering results.
[0153] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as a Field-Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a System-on-Chip, a System-on-a-Substrate, a System-on-Package, an Application-Specific Integrated Circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.
[0154] It should be noted that the data filtering device part in the embodiments of this disclosure corresponds to the data filtering method part in the embodiments of this disclosure. For a detailed description of the data filtering device part, please refer to the data filtering method part, which will not be repeated here.
[0155] Figure 8 A block diagram of an electronic device suitable for implementing a data filtering method according to an embodiment of the present disclosure is shown schematically. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0156] like Figure 8 As shown, a computer electronic device 800 according to an embodiment of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 809 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0157] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804.
[0158] According to embodiments of this disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the input / output (I / O) interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0159] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the data filtering method according to the embodiments of this disclosure.
[0160] In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0161] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods provided in the embodiments of this disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the data filtering methods provided in the embodiments of this disclosure.
[0162] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0163] According to embodiments of this disclosure, program code for executing computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages.
[0164] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. It should also be noted that in some alternative implementations, the functions indicated in the boxes may occur in a different order than those shown in the drawings.
[0165] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.< / t> < / string>
Claims
1. A data filtering method, comprising: In response to receiving a data filtering request, the filtering context is obtained by parsing the request parameters in the data filtering request; Based on the filtering context, a data filtering chain is constructed for the data filtering request, wherein the data filtering chain includes multiple filtering components arranged in execution order; as well as According to the execution order, the filtering context is filtered sequentially using multiple filtering components to obtain the data filtering result.
2. The method according to claim 1, wherein, The filtering context includes a filter type identifier; The step of constructing a data filtering chain for the data filtering request based on the filtering context includes: Based on the filter type identifier, determine the type of filter component used for the data filtering request; and Based on the filter component type, the corresponding filter interface is called through the filter chain builder to add the filter component belonging to the filter component type to the data filter chain.
3. The method according to claim 2, wherein, The filter component types include one of the following: hard filter type, soft filter type, and custom filter type; The hard filter type filter component is used to perform fixed filtering operations, the soft filter type filter component is used to perform optional filtering operations, and the custom filter type filter component is used to perform business-specific filtering operations.
4. The method according to claim 2, wherein, The filter type identifier includes a first control identifier for indicating whether a hard filter type is used, a second control identifier for indicating whether a soft filter type is used, and a third control identifier for indicating whether a custom filter type is used. The step of determining the type of filtering component used for the data filtering request based on the filtering type identifier includes: In response to the first control identifier being a target value, it is determined that the filter component type includes a hard filter type; In response to the second control identifier being the target value, it is determined that the filter component type includes a soft filter type; and In response to the third control identifier being the target value, it is determined that the filter component type includes a custom filter type.
5. The method according to claim 2, wherein, The filtering context also includes a filtering mode identifier; When the filtering context is filtered sequentially using multiple filtering components according to the execution order, the process includes: When the filter mode identifier represents a fine-grained filter mode, in response to the failure of the fixed filter operation of the filter component of the hard filter type, the data filter process is interrupted and a prompt message is returned. as well as When the filter mode identifier represents a coarse-grained filter mode, in response to the failure of the fixed filter operation of the filter component of the hard filter type, the next filter component is called to perform the filter operation.
6. The method according to claim 2, wherein, For filter components with custom filter types, The step of adding filter components of the same type to the data filter chain by calling the corresponding filter interface through the filter chain constructor includes: In response to receiving one or more filter component names, dynamically load the filter component of the custom filter type corresponding to the filter component name; and Add the filter component of the custom filter type to the data filter chain.
7. The method according to claim 3, wherein, The execution priority among the multiple filtering components includes: Filtering components that are hard filters have a higher execution priority than those that are soft filters, and those that are soft filters have a higher execution priority than those that are custom filters.
8. The method according to any one of claims 1 to 7, wherein, The filtering context is obtained by encapsulating the structured data parsed from the request parameters using a parameter parser. The filtering context is used to provide a perception method to control the continuation or interruption of the filtering process based on the filtering component type of the filtering component being executed. The step of sequentially using multiple filtering components to filter the filtering context according to the execution order to obtain data filtering results includes: The filtering context is passed through the data filtering chain so that multiple filtering components can sequentially perform filtering operations on the filtering context to obtain the data filtering result.
9. A data filtering device, comprising: The parameter parsing module is used to respond to a received data filtering request by parsing the request parameters in the data filtering request to obtain the filtering context; A filter chain construction module is used to construct a data filter chain for the data filtering request based on the filtering context by calling a filtering interface, wherein the data filter chain includes multiple filtering components arranged in execution order; as well as The data filtering module is used to sequentially filter the filtering context using multiple filtering components according to the execution order to obtain the data filtering result.
10. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 8.