Data screening method, device and product

By building a filter tree for query objects, the data filtering problem of not using data sets stored by existing database software is solved, and the data filtering process is simplified and development efficiency is improved.

CN120448386AActive Publication Date: 2025-08-08XIANGYANG QIUJI WIN SOFTWARE TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510548764.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2025-08-08
Estimated Expiration
2045-04-28

AI Technical Summary

Technical Problem

In the prior art, for data sets that do not use existing database software, a simple data filtering method is lacking, resulting in the need to manually write screening codes and waste human resources.

Method used

By defining instances of query objects, a filter tree is built, and the field structure of the query objects is organized into a tree structure to realize data filtering and avoid additional writing of query code.

Benefits of technology

The data screening process is simplified, development efficiency is improved, and duplicate waste of human resources is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448386A_ABST
    Figure CN120448386A_ABST
Patent Text Reader

Abstract

The invention discloses a data screening method and device and a product, and relates to the technical field of data processing. The method comprises the following steps: constructing a corresponding screening tree based on an obtained instance of a query object; and screening the data set corresponding to the query object through the corresponding screening tree to obtain a screened subset. According to the method, the corresponding screening tree is constructed based on the instance of the query object, each field of the query object is constructed as one or one group of screening nodes in the screening tree, the screening nodes are used for executing logical operation on the elements in the data set to obtain the judgment result, and therefore the elements are screened based on the screening tree. Data screening can be realized through the screening tree constructed based on the instance of the query object, and corresponding query codes do not need to be customized, so that repeated waste of artificial resources is avoided, and the data screening process is simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data screening method, device and product. Background Art

[0002] Data filtering is a fundamental step in data querying. It refers to the process of selecting data (elements) that meet specific criteria from a large amount of data to meet business needs. For example, during data development, elements of the same type are often stored in a data set. Qualified elements are then filtered from the data set based on specific conditions to meet the corresponding business needs.

[0003] In current technology, for data sets that are not stored using existing database software, it is necessary to manually write data filtering code based on business needs to implement the filtering of the data set.

[0004] It can be seen from this that in the current technology, for data sets that are not stored using existing database software, there is a lack of a universal and simple method to implement data set screening. Summary of the Invention

[0005] Based on the above problems, the present application provides a data screening method, device and product. By defining specific query objects, data screening can be achieved without the need to write additional corresponding query codes, avoiding the repeated waste of manual resources and simplifying the data screening process.

[0006] The embodiments of this application disclose the following technical solutions:

[0007] In a first aspect, the present application provides a data screening method, comprising:

[0008] Based on the obtained query object instance, a corresponding filter tree is constructed; the fields defined in the query object include at least first-category fields and second-category fields; the first-category fields are used to construct a filter node; the second-category fields are used to construct a group of filter nodes, the group of filter nodes including a parent node and multiple child nodes; the filter nodes are used to perform logical operations on elements in the data set to obtain judgment results; the filter nodes are organized into a tree structure based on the field structure of the query object, which is called a filter tree;

[0009] The data set corresponding to the query object is filtered through the corresponding filtering tree to obtain a filtered subset.

[0010] Optionally, the first type of field is a field whose name ends with a preset atomic predicate, and the second type of field is a field whose name ends with a preset composite predicate.

[0011] Optionally, constructing a corresponding filter tree based on the obtained query object instance includes:

[0012] According to the instance of the query object, a branch node of the tree structure is constructed as a root node of the screening tree; the branch node includes a logical operator and multiple child nodes; the logical operator is used to perform a logical operation on the judgment results returned by the multiple child nodes to obtain the judgment result of the branch node;

[0013] The fields of the instance of the query object are traversed, and the assigned fields are constructed as child nodes of the branch node.

[0014] Optionally, constructing the assigned field as a child node of the branch node includes:

[0015] Determining a classification of the assigned field based on the name of the assigned field;

[0016] For the first type of fields that have been assigned values, construct a corresponding leaf node of the tree structure; the leaf node includes a predicate logic for judging the element; the predicate logic is constructed according to the field name and the assigned value;

[0017] For the second-category fields that have been assigned values, construct the corresponding branch nodes of the tree structure, and recursively construct the child nodes of the branch nodes according to the assignments of the second-category fields that have been assigned values, until all the assigned fields are constructed; the logical operator of the branch node is set according to the composite predicate in the name of the second-category field.

[0018] Optionally, constructing a corresponding filter tree based on the obtained query object instance includes:

[0019] Obtaining a corresponding filtering tree template according to the type of the obtained query object; wherein the leaf nodes in the filtering tree template include predicate logic containing variables, and the branch nodes in the filtering tree template do not include child nodes; wherein the variables are determined according to the values assigned to the first category of fields, and the child nodes of the branch nodes are determined according to the values assigned to the second category of fields;

[0020] Based on the instance of the query object and the corresponding filtering tree template, a corresponding filtering tree is constructed.

[0021] Optionally, obtaining a corresponding filter tree template according to the type of the obtained query object includes:

[0022] Based on the type of the query object obtained, obtain the corresponding filter tree template from the context;

[0023] When the corresponding filtering tree template is not obtained, a corresponding filtering tree template is constructed according to the type of the query object, and the type of the query object and the filtering tree template and their mapping relationship are stored in the context.

[0024] Optionally, constructing a corresponding screening tree template according to the type of the query object includes:

[0025] According to the type of the query object, construct a branch node of the tree structure as the root node of the screening tree template, and traverse all fields defined in the query object;

[0026] For the first type of fields, constructing a leaf node in the screening tree template; wherein the leaf node in the screening tree template includes predicate logic containing variables; the variables are determined according to the values assigned to the first type of fields;

[0027] For the second category of fields, a branch node in the filtering tree template is constructed, and the filtering tree template is continued to be constructed according to the type of the second category of fields, and the type of the second category of fields and the filtering tree template and their mapping relationship are stored in the context until filtering tree templates are constructed for all known types of the second category of fields.

[0028] Optionally, constructing a corresponding filtering tree based on the instance of the query object and the corresponding filtering tree template includes:

[0029] According to the instance of the query object, construct a branch node of the tree structure as a root node of the screening tree;

[0030] Traversing the fields in the instance of the query object, adding the nodes in the filter tree template corresponding to the assigned fields as child nodes of the branch node;

[0031] For the assigned first-category field, add the leaf node corresponding to the assigned first-category field in the screening tree template as a child node of the branch node, and set the variable to the assigned value of the assigned first-category field;

[0032] For the second-category fields that have been assigned values, add the branch nodes corresponding to the second-category fields that have been assigned values in the filtering tree template as child nodes of the branch nodes; and recursively construct the child nodes of the branch nodes corresponding to the second-category fields that have been assigned values according to the values assigned to the second-category fields.

[0033] Optionally, filtering the data set corresponding to the query object through the corresponding filtering tree to obtain a filtered subset includes:

[0034] Traversing all elements of the data set corresponding to the query object;

[0035] Use the root node of the filter tree to judge each traversed element, obtain a judgment result, and add the element with the true judgment result to the filter result set;

[0036] After the traversal is completed, the filtered result set is output as the filtered subset.

[0037] In a second aspect, the present application provides a data screening device, comprising:

[0038] A construction module is configured to construct a corresponding filter tree based on the obtained query object instance; the fields defined in the query object include at least a first-category field and a second-category field; the first-category field is used to construct a filter node; the second-category field is used to construct a group of filter nodes, each of which includes a parent node and multiple child nodes; the filter nodes are used to perform logical operations on elements in the data set to obtain a judgment result; the filter nodes are organized into a tree structure based on the field structure of the query object, referred to as a filter tree;

[0039] The screening module is used to screen the data set corresponding to the query object through the corresponding screening tree to obtain a screening subset.

[0040] In a third aspect, the present application provides a data screening product, comprising: a processor and a memory, wherein the processor and the memory are coupled;

[0041] The memory is used to store computer program instructions;

[0042] The processor is used to execute the computer program instructions stored in the memory to implement the data screening method described in any one of the first aspects above.

[0043] Compared with the existing technology, the present application has the following beneficial effects: In the present application, data screening can be achieved by constructing a screening tree based on the instance of the query object, and there is no need to customize the corresponding query code, which avoids the repeated waste of manual resources and simplifies the data screening process. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 A flowchart of a data screening method provided in an embodiment of the present application;

[0046] Figure 2 A flowchart of a method for constructing a screening tree provided in an embodiment of the present application;

[0047] Figure 3 A flowchart of another method for constructing a screening tree provided in an embodiment of the present application;

[0048] Figure 4 A flowchart of a method for constructing a screening tree template provided in an embodiment of the present application;

[0049] Figure 5 This is a diagram illustrating an example structure of a screening tree template provided in an embodiment of the present application;

[0050] Figure 6 A flowchart of a method for screening a data set provided in an embodiment of the present application;

[0051] Figure 7 This is an example diagram of assigning values to an instance of the query object UserQuery provided in an embodiment of the present application;

[0052] Figure 8 A structural example diagram of a screening tree and a screening tree template provided in an embodiment of the application;

[0053] Figure 9 A schematic diagram of the structure of a data screening device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In current technology, for data sets stored using existing database software, data screening can be completed using the database query language corresponding to the database software; for data sets not stored using existing database software (for example, data structures such as sets or lists in memory), it is necessary to manually write corresponding code based on the element type of each data set and the requirements of the data query to implement data screening.

[0055] The present application provides a data screening method, including: constructing a corresponding screening tree based on the instance of the query object obtained; filtering the data set corresponding to the query object through the screening tree to obtain a screening subset. In the present application, a corresponding screening tree is constructed based on the instance of the query object, and the fields of the query object are constructed as screening nodes in the screening tree. The screening nodes are used to perform logical operations on the elements in the data set to obtain judgment results, thereby filtering the elements based on the screening tree. Data screening can be achieved by constructing a screening tree based on the instance of the query object, and there is no need to write additional corresponding screening data code, which improves development efficiency and simplifies the data screening process.

[0056] Furthermore, there's a correspondence between query objects and element types: one query object applies only to collections of one element type. For collections of the same element type, a corresponding query object instance must be constructed and assigned values. Different filtering requirements can be met by assigning different values to the query object instance. Although different types of element collections correspond to different query objects, the process of constructing the corresponding filtering tree based on the query object instance remains the same, further simplifying the data filtering process.

[0057] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0058] Example 1:

[0059] The following combination Figures 1-8 , a data screening method provided in an embodiment of the present application is introduced in detail.

[0060] It should be noted that the data screening method provided in the embodiments of the present application is a data screening method for general terminal devices, that is, the method is applied to general terminal devices. General terminal devices include: mobile computing terminals, wearable terminals, smart home terminals, and embedded system devices.

[0061] like Figure 1 As shown, a data screening method provided in an embodiment of the present application includes the following steps:

[0062] S101: Construct a corresponding screening tree based on the acquired query object instance.

[0063] The query object is pre-defined based on the attributes of the elements in the data set and business requirements. That is, the technicians define the corresponding query object based on the attributes of the elements in the data set and the query requirements to filter the data set.

[0064] Furthermore, the type of an element in a data set is a collection of attributes. For example, when the element type is user type, its attribute set generally includes: ID, age, name, occupation, etc. Furthermore, in computer programming, the element type is a structure or class, and the element contains the specific data corresponding to each attribute. Specifically, for procedural programming languages (such as C), the element type is a structure (struct), and the element is a structure variable; for object-oriented programming languages (such as C++, Java, Python), the element type is a class (class), and the element is an instance of the class (instance).

[0065] The fields defined in the query object include at least first-category fields and second-category fields. First-category fields are used to construct a filter node, while second-category fields are used to construct a group of filter nodes. A group of filter nodes consists of a parent node and multiple child nodes. The filter nodes are organized into a tree structure based on the query object's field structure, called a filter tree. The filter nodes are used to perform logical operations on elements in the data set to obtain judgment results.

[0066] Specifically, the first type of field is one whose name ends with a preset atomic predicate, and the second type of field is one whose name ends with a preset compound predicate. Atomic predicates are the simplest logical statements and cannot be further decomposed into smaller logical parts. Compound predicates are composed of one or more atomic predicates or other compound predicates combined using logical element operators (such as AND and OR).

[0067] Specifically, a filter tree is a tree structure constructed based on instances of query objects. Each node in the filter tree is a filter node, which is used to perform logical operations on elements in a data set to obtain a judgment result. Tree structures are an important data structure in computer science, used to represent data with hierarchical relationships.

[0068] The instance of the query object is created by a computer according to the definition of the query object and is obtained by assigning values according to the obtained query parameters.

[0069] For ease of understanding, the following Figure 2-Figure 5 , respectively introduces in detail the two methods of constructing the screening tree provided in the embodiments of this application.

[0070] First combine Figure 2 , a method for constructing a screening tree provided in an embodiment of the present application is introduced in detail.

[0071] like Figure 2 As shown, a method for constructing a screening tree provided in an embodiment of the present application includes the following steps:

[0072] S210: Construct branch nodes of a tree structure according to instances of the query object as root nodes of a screening tree.

[0073] A branch node is a node in a tree structure that contains multiple child nodes.

[0074] Specifically, a branch node includes a logical operator and multiple child nodes. The branch node is used to apply the logical operator to the judgment results returned by the multiple child nodes included in the branch node to perform a logical operation to obtain the judgment result of the branch node. Logical operators include: AND, OR, NOT, XOR, etc.

[0075] Furthermore, the logical operator of the branch node that is the root node of the screening tree is AND.

[0076] It should be noted that the logical operator of the root node of the filter tree corresponding to each query object instance is AND.

[0077] S220: Traverse the fields of the instance of the query object and construct the assigned fields as child nodes of the branch node.

[0078] Specifically, the fields of the instance of the query object are traversed, and the values of the fields are obtained through reflection technology to determine the assigned fields, and the assigned fields are constructed as child nodes of the branch node.

[0079] like Figure 2 As shown, constructing the assigned fields as child nodes of the branch node specifically includes the following steps:

[0080] S221. Determine the classification of the assigned field based on the name of the assigned field.

[0081] Fields are categorized into first- and second-category fields. First-category fields are used to construct a filter node, i.e., a leaf node in a tree structure. Second-category fields are used to construct a group of filter nodes, each of which consists of a parent node and multiple child nodes. These fields are used to construct branch nodes and their child nodes in a tree structure.

[0082] Among them, the field whose name ends with a preset atomic predicate is a first-category field, and the field whose name ends with a preset composite predicate is a second-category field.

[0083] The preset atomic predicate is a predefined word or abbreviation corresponding to the atomic predicate logic. For example, the predefined abbreviation corresponding to the predicate logic "greater than" is Gt (is Greater Than); the predefined abbreviation corresponding to the predicate logic "greater than or equal to" is Ge (is Greater than or Equal to).

[0084] It should be noted that in the embodiment of the present application, preset atomic predicates and compound predicates are used to distinguish between the first category of fields and the second category of fields. In addition, new field classification applications can be added based on other characteristics of the fields, such as annotations, specific types, etc., without specific limitations.

[0085] Furthermore, for fields that cannot be categorized based on their name suffixes and other characteristics, they are defaulted to first-category fields, and the predicate suffix is a predefined word corresponding to the predicate logic "equal" (for example, "Eq"). For example, the uncategorized fields id and age are treated as equivalent to idEq and ageEq.

[0086] Specifically, fields ending with an atomic predicate are first-class fields, and fields ending with a composite predicate are second-class fields. In particular, when the end of a field name does not match the preset predicate, the field is defaulted to being a first-class field, and the corresponding atomic predicate is Eq.

[0087] The logical operators of the branch nodes are the logical operators in Boolean algebra, such as AND, OR, NOT, and XOR. Therefore, the set of preset compound predicates can be {And, Or, Not, Xor}, or variations based on the naming rules, such as {_and, _or, _not, _xor}, etc., which are not specifically limited in this application.

[0088] For example, when the name of a field ends with a preset atomic predicate such as Gt, Ge, Contain, etc., the field is a first-category field; when the name of a field ends with a compound predicate such as "Or", "And", etc., the field is a second-category field.

[0089] For the first type of fields that have been assigned values, proceed to S222.

[0090] For the second type of fields that have been assigned values, proceed to S223.

[0091] S222: Construct leaf nodes of the corresponding tree structure.

[0092] A leaf node has no child nodes and contains a predicate logic for judging an element. The predicate logic is used to execute on the screened elements to obtain a judgment result of the leaf node.

[0093] Specifically, the corresponding leaf nodes of the tree structure are constructed based on the names and values of the assigned first-category fields. That is, the attribute names and predicate names are determined based on the names of the assigned first-category fields, and the predicate logic is constructed based on the attribute names, predicate names, and the values of the assigned first-category fields, thereby obtaining the corresponding leaf nodes of the tree structure.

[0094] Among them, the name of the first type of field is defined based on the attribute predicate expression {x∈A:xP(v)}. The attribute predicate expression {x∈A:xP(v)} is a newly defined mathematical formula used to express the name of the first type of field in the present invention. Among them, A is a set of attributes of the element, x is an attribute in A, P is an atomic predicate in the preset atomic predicate set (see Table 1 for details), and v is a variable determined according to the field assignment. The predicate logic corresponding to xP(v) can be expressed as "the value of the attribute x of the element and the variable v satisfy the logical relationship P", or "$x P v". The attribute predicate expression can be abbreviated as xP as the name format of the first type of field. That is, the name format of the first type of field is "<attribute name><predicate name>".

[0095] For example, for the first type of field ageGt(30), where the attribute x is age, the predicate P is Gt, and the variable v is 30, the corresponding predicate logic can be expressed as "the value of the element's attribute age and the variable 30 satisfy the logical relationship greater than", or "$age is greater than 30".

[0096] For ease of understanding, Table 1 lists a set of preset atomic predicate sets and the corresponding predicate logic.

[0097] Table 1

[0098] Predicate name Predicate Logic Predicate name Predicate Logic Eq $x is equal to v NotLike $x does not include v Ne $x is not equal to v Like $x includes v Gt $x is greater than v NotStart $x does not start with v Ge $x is greater than or equal to v Start $x starts with v Lt $x is less than v NotEnd $x does not end with v Le $x is less than or equal to v End $x ends with v NotIn $x does not belong to v NotContain $x does not contain v In $x belongs to v Contain $x contains v Null Is $x empty?

[0099] It should be noted that the predicates in the preset atomic predicate set shown in Table 1 are an implementation form of the preset atomic predicates described above. In addition to the predicate names shown in Table 1, new atomic predicates and their corresponding predicate logic can be defined according to actual conditions. Of course, a different set of preset atomic predicate sets can also be defined according to other naming conventions, which will not be repeated here.

[0100] For example, an element contains three attributes: id, name, and age, representing the element's identifier, name, and age, respectively. Assuming that elements with an age greater than a certain value need to be filtered, the name of the first-category field defined by the attribute predicate expression is ageGt. Specifically, when the value assigned to the first-category field ageGt is 30, the steps for constructing the corresponding leaf node of the tree structure are as follows: first, based on the attribute predicate expression and Table 1, determine the predicate name P as "Gt." Then, remove the predicate name "Gt" from "ageGt" to obtain the attribute name x as "age." After obtaining the value assigned to the first-category field ageGt as 30, determine the corresponding predicate logic as "$age is greater than 30" based on Table 1. Thus, a corresponding leaf node of the tree structure is constructed for the first-category field ageGt assigned a value of 30, including the predicate logic "$age is greater than 30." When filtering specific elements, the value of the attribute age is obtained from the element and substituted into the predicate logic "$age is greater than 30." This is then executed to obtain the logical judgment result.

[0101] S223: Construct a corresponding branch node of the tree structure, and recursively construct child nodes of the branch node according to the values of the assigned second-category fields, until all assigned fields are constructed.

[0102] The corresponding branch node is used to perform corresponding logical operations on the judgment results returned by its child nodes according to the logical operator to obtain the judgment results of the branch node.

[0103] Specifically, when constructing a corresponding branch node for a second-category field that has been assigned a value, the logical operator of the branch node is determined according to the composite predicate at the end of the name of the second-category field.

[0104] Specifically, the assignment of the second-category field is used to indicate the instance of the corresponding query object, and the child node of the branch node is constructed recursively according to the assignment of the assigned second-category field, that is, recursively, according to the instance of the query object corresponding to the assignment of the assigned second-category field, a filter node corresponding to the instance of the query object corresponding to the assignment is constructed as the child node of the branch node corresponding to the assigned second-category field.

[0105] For example, assume that the query object UserQuery is defined with the fields ageGt and ageLe of the Integer type, and the field userOr of the UserQuery type. Create an instance A of UserQuery, and assign another instance B of the UserQuery query object to the second-class field userOr, and assign values to instance B, where the value of the ageGt field is 5 and the value of the ageLe field is 25. Build a branch node for instance A as the root node of the filter tree, and build a branch node of a tree structure for the field userOr. According to the composite predicate "Or" of the assigned second-class field, set the logical operator of the branch node to "OR" to build the corresponding branch node 1; when the first-class field ageGt is assigned to 5, first determine the predicate name P to be "Gt" according to the attribute predicate expression, remove the predicate name "Gt" from "ageGt" to obtain the attribute name x as "age", and after obtaining the value of the first-class field ageGt assigned to 5, determine the corresponding predicate logic to be "$age is greater than 5", so build the corresponding for the first-class field ageGt assigned to 5. Leaf node 2 includes the predicate logic "$age is greater than 5." Similarly, for the first-category field ageLe assigned a value of 25, the predicate name P is first determined to be "Le" based on the attribute predicate expression. Subtracting the predicate name "Le" from "ageLe" yields the attribute name x as "age." After obtaining the first-category field ageLe's assigned value of 25, the corresponding predicate logic is determined to be "$age is less than or equal to 25." Therefore, leaf node 3 is constructed for the first-category field ageLe assigned a value of 25, including the predicate logic "$age is less than or equal to 25." Furthermore, in instance B indicated by the assigned second-category field userOr, all assigned fields have been constructed, completing the construction of the branch node for userOr.

[0106] Furthermore, in a possible implementation, the field type of the second-category field indicates the type of the query object, that is, indicates the corresponding query object, and the value assigned to the second-category field is used to indicate an instance of the corresponding query object.

[0107] In a possible implementation, the name format of the second type of field is the element name plus a compound predicate suffix.

[0108] The above combination Figure 2 A method for constructing a filter tree corresponding to an instance of a query object is described in detail below. Figure 3-Figure 5 , we will introduce in detail another method of constructing a screening tree provided in an embodiment of the present application.

[0109] like Figure 3 As shown, another method for constructing a screening tree provided in an embodiment of the present application includes the following steps:

[0110] S310: Obtain a corresponding screening tree template according to the type of the obtained query object.

[0111] There is a one-to-one mapping relationship between the type of query object and the filter tree template.

[0112] The leaf nodes in the filter tree template include predicate logic containing variables, and the branch nodes in the filter tree template do not include child nodes. The variables are determined based on the values assigned to the first type of fields, and the child nodes of the branch nodes are determined based on the values assigned to the second type of fields.

[0113] Specifically, a filter tree template is constructed based on the query object type. The template contains leaf nodes corresponding to all first-category fields defined in the query object, and branch nodes corresponding to all second-category fields, excluding child nodes. Because the query object type doesn't include field assignments, and the variables in the predicate logic are determined based on the assignments of the first-category fields, the leaf nodes in the filter tree template include the predicate logic containing the variables. Similarly, because the child nodes of the branch nodes are determined based on the assignments of the second-category fields, the branch nodes in the filter tree template don't include child nodes.

[0114] In one possible implementation, based on the type of the query object obtained, a corresponding filter tree template is obtained from the context; when the corresponding filter tree template is not obtained, a corresponding filter tree template is constructed according to the type of the query object, and the type of the query object and the filter tree template and their mapping relationship are stored in the context, so that the next time the filter tree template corresponding to the type of the query object can be obtained in the context according to the type of the query object.

[0115] For ease of understanding, the following Figure 4 This section introduces in detail how to build the corresponding filter tree template.

[0116] S401. According to the type of the query object, a branch node of a tree structure is constructed as the root node of the filter tree template, and all fields defined in the query object are traversed.

[0117] The logical operator of the root node of the screening tree template (ie, the branch node of the constructed tree structure) is AND.

[0118] Specifically, all fields defined in the query object are traversed to determine the classification of all fields, that is, to determine first-category fields and second-category fields. Exemplarily, the classification of the fields is determined based on the names of the fields defined in the query object. Fields whose names end with a preset atomic predicate are first-category fields, and fields whose names end with a preset compound predicate are second-category fields.

[0119] For the first type of fields, proceed to S402.

[0120] For the second type of fields, proceed to S403.

[0121] S402: Construct leaf nodes in the screening tree template.

[0122] The leaf nodes in the filter tree template include predicate logic containing variables, which are determined based on the values assigned to the first-category fields. The predicate logic is expressed as "the value of the element's attribute x and the variable v satisfy the logical relationship P." The variable v is determined based on the values assigned to the first-category fields. Since all fields in the query object are unassigned, the predicate logic in the leaf nodes in the filter tree template contains variables, meaning that the variable v is empty.

[0123] For example, the query object A defines the first-class field "idGt" according to the attribute predicate expression, then the name P of the atomic predicate is determined to be "Gt" according to the attribute predicate expression, and the attribute name x is obtained as "id" by removing the name of the atomic predicate "Gt" from "idGt", and then a leaf node A in the filter tree template is constructed; the leaf node A in the filter tree template includes the predicate logic "$id is greater than #idGt" containing variables, "#idGt" is a variable, and indicates the assignment of the first-class field "idGt".

[0124] S403. Construct a branch node in the filter tree template, and continue to construct the filter tree template according to the type of the second category field, store the type of the second category field and the filter tree template and their mapping relationship in the context, until the filter tree template is constructed for all known types of the second category fields.

[0125] In the filter tree template, a branch node that is a child node does not include child nodes. That is, for the second type of field, after it is constructed as a branch node in the filter tree template, no child nodes are constructed for it. Instead, the context is checked to see if a filter tree template corresponding to that type exists. If not, a new filter tree template is constructed based on that type.

[0126] Specifically, when constructing a corresponding branch node in the filter tree template for the second type of field, the logical operator of the corresponding branch node in the filter tree template is determined according to the composite predicate at the end of the name of the second type of field.

[0127] For ease of understanding, the following Figure 5 Let’s take an example to introduce the filter tree template.

[0128] Assume that query object B defines the fields idLt, nameStart, ageGt, userAnd, and userOr.

[0129] like Figure 5The filter tree template shown is a filter tree template constructed based on the type of query object B.

[0130] A branch node 501 (the default logical operator is AND) is created as the root node of the filter tree template.

[0131] For the first type of field, the predicate name P is determined to be "Lt" according to the attribute predicate expression "idLt", and the predicate name "Lt" is removed from "idLt" to obtain the attribute name x as "id", and then the leaf node 502 of the filter tree template is constructed. The leaf node 502 includes the predicate logic "$id is less than #idLt" containing the variable (#idLt is the actual assignment of the first type of field idLt); the predicate name P is determined to be "Start" according to the attribute predicate expression "nameStart", and the predicate name "Start" is removed from "nameStart" to obtain the attribute name x as "name", and then the leaf node 502 of the filter tree template is constructed. The leaf node 503 in the filter tree template includes the predicate logic "$name starts with #nameStart" (#nameStart is the actual assignment of the first-category field nameStart) containing the variable; the predicate name P is determined to be "Gt" according to the attribute predicate expression "ageGt", and the predicate name "Gt" is removed from "ageGt" to obtain the attribute name x as "age", and then the leaf node 504 of the filter tree template is constructed, and the leaf node 504 includes the predicate logic "$age is greater than #ageGt" (#ageGt is the actual assignment of the first-category field ageGt) containing the variable.

[0132] For the second type of fields, a branch node 505 in the filter tree template is created based on the second type of field "userAnd" and the compound predicate "And", and the logical operator of the branch node 505 is the AND logical operator; a branch node 506 in the filter tree template is created based on the second type of field "userOr" and the compound predicate "Or", and the logical operator of the branch node 506 is the OR logical operator.

[0133] The above combination Figure 4 and Figure 5 , describes in detail how to create a filter tree template in the embodiment of this application, and then continues with Figure 3 , introduces another method of constructing a screening tree in an embodiment of the present application.

[0134] S320: Construct a corresponding filtering tree based on the instance of the query object and the corresponding filtering tree template.

[0135] like Figure 3 As shown, based on the instance of the query object and the corresponding filter tree template, building the corresponding filter tree specifically includes the following steps:

[0136] S321. Construct branch nodes of a tree structure according to instances of the query object as root nodes of a screening tree.

[0137] S322: traverse the fields in the instance of the query object, and add the nodes in the filter tree template corresponding to the assigned fields as child nodes of the branch node.

[0138] Specifically, for the assigned first-category field, add the node corresponding to the assigned first-category field in the filter tree template as a child node of the current branch node, and set the variable in the predicate logic to the assigned value of the assigned first-category field to obtain the leaf node corresponding to the assigned first-category field.

[0139] Exemplarily, the leaf node corresponding to "idLt" in the filtering tree template includes the predicate logic containing the variable "$id is less than #idLt", and the assigned value of "idLt" in the instance of the query object is 20, then the predicate logic of the leaf node corresponding to the assigned "idLt" is "$id is less than 20".

[0140] Specifically, for the assigned second-category fields, add the nodes corresponding to the assigned second-category fields in the filter tree template as child nodes of the current branch node, and recursively construct the child nodes of the corresponding branch nodes based on the assigned values of the second-category fields.

[0141] For example, Figure 5 As shown, a filter tree template is constructed based on the type of query object B. If the userOr field in the instance of query object B is a second-category field that has been assigned a value, a branch node 506 corresponding to userOr in the filter tree template is added as a child node of the root node of the filter tree. Based on the value assigned to the userOr field, it is determined to be another instance of query object B. Then, the filter tree template corresponding to the type of query object B is obtained again, and the child nodes of the branch node corresponding to the userOr field (i.e., the branch node 506 added to the filter tree) are recursively constructed based on the instance of query object B and the corresponding filter tree template.

[0142] The above combination Figure 2-Figure 5 , describes in detail the two methods of constructing the screening tree provided in the embodiment of the present application, and then continues with Figure 1 A data screening method provided in an embodiment of the present application is introduced.

[0143] S102: Filter the data set corresponding to the query object through the filter tree to obtain a filter subset.

[0144] There is a correspondence between the query object and the element type in the data set. For example, if query object C is predefined based on the car type, then the filter tree C constructed based on the obtained instance of query object C is used to filter the data set with the element type of car to obtain a filtered subset. In other words, the filter tree constructed using the query object instance is used to filter the data set with the element type corresponding to the query object.

[0145] The correspondence between the query object and the element type in the data set is because the x in the name format of the first-class field of the query object (i.e., the attribute predicate expression xP) comes from the element's attributes. There are several implementation methods for determining the corresponding data set for a query object instance:

[0146] The first method is to obtain the instance of the query object and the type of the element at the same time, and determine the corresponding data set based on the type of the element; the second method is to obtain the instance of the query object and the corresponding data set at the same time; the third method is to obtain the instance of the query object and obtain the corresponding data set based on the type of the element declared in the metadata of the query object; the fourth method is to obtain the instance of the query object and determine the corresponding data set based on the context of the called method.

[0147] It should be noted that, in addition to the above four methods for determining the corresponding data set for an instance of a query object, other methods can also be used to determine the corresponding data set for an instance of a query object, and this application does not make specific limitations.

[0148] It should be noted that the data screening in the embodiments of the present application is actually the screening of elements in the data set.

[0149] For ease of understanding, the following Figure 6 , a detailed introduction is given on how the embodiment of the present application filters the data set corresponding to the query object.

[0150] like Figure 6 As shown, in the embodiment of the present application, screening the data set corresponding to the query object includes the following steps:

[0151] S601: Traverse all elements of the data set corresponding to the query object.

[0152] Traversal refers to the process of accessing all elements in a data set. This means accessing each element in the data set corresponding to the query object in a specific order. The order of traversal determines the order in which the elements are accessed.

[0153] S602: Use the root node of the filter tree to judge each traversed element, obtain a judgment result, and add the elements with a true judgment result to the filter result set.

[0154] The filter result set is used to store elements that meet the filter conditions.

[0155] Specifically, the currently traversed element is input to the root node of the screening tree so that the screening tree screens the currently traversed element, and the root node of the screening tree returns the judgment result of the currently traversed element.

[0156] The judgment results can be either true or false. Elements with a true judgment result are considered to have passed the screening, meaning they meet the requirements for the instance of the query object. Elements with a false judgment result are considered to have failed the screening, meaning they do not meet the requirements for the instance of the query object. After obtaining the judgment result, elements with a true judgment result are added to the screening result set, and elements with a false judgment result are removed.

[0157] In one possible implementation, after a branch node obtains the traversed element, it passes the element to each child node for logical operations to obtain a judgment result. The branch node then performs a logical operation on the judgment results returned by each child node based on the branch node's logical operator to obtain the branch node's judgment result. The filter tree uses a method similar to a depth-first search algorithm, starting from the root node, passing the current element to each node for logical operations, ultimately returning the judgment result of the currently traversed element through the root node of the filter tree.

[0158] It should be noted that in the filter tree architecture, whether it is a branch node or a leaf node (i.e., all filter nodes), the basis for judging the currently traversed element is the built-in logic unit. That is, the filter nodes all use the same core logic program to implement their judgment function on the currently traversed element. Simply put, the filter node first receives the currently traversed element through the built-in general logic unit, and then performs the corresponding logical operation on the currently traversed element. However, the specific logical operations of different filter nodes are different, and different logical operations can be implemented.

[0159] S603: After the traversal is completed, the screening result set is output as a screening subset.

[0160] Specifically, after all elements in the data set corresponding to the query object are traversed, a screening result set including all elements with true judgment results is output as a screening subset, thereby completing the screening of the data set corresponding to the query object.

[0161] The above combination Figures 1-6 A data screening method provided by the embodiment of the present application is described in detail. For ease of understanding, the following Figure 7 and Figure 8, an example is given to introduce a data screening method provided by the Java language in an embodiment of the present application.

[0162] Assume that the UserEntity element defines a user type that contains three attributes: id, name, and age. Define a corresponding query object UserQuery for the UserEntity element. The query object UserQuery defines the idEq, nameStart, ageGt, userAnd, and userOr fields. The specific code is as follows:

[0163]

[0164]

[0165] User Figure 7 As shown in the following example, an instance of the query object UserQuery is created and assigned values. The solid line nodes represent assigned fields, and the dotted line nodes represent unassigned fields.

[0166] like Figure 8 The filter tree 800 corresponding to the instance of the query object UserQuery shown in (a) is described below with two examples of how to construct the filter tree.

[0167] The first way to construct a screening tree is: based on Figure 7The instance of the query object UserQuery shown in the figure creates a branch node 801 of a tree structure, and the logical operator of the branch node 801 is AND, which serves as the root node of the filter tree 800; all fields of the instance of the query object UserQuery are traversed, and the only assigned field is userOr read through the reflection technology. According to the field suffix "Or", it is determined that the field userOr is a second-class field that has been assigned a value, so a branch node 802 is constructed based on the assigned second-class field userOr, and the logical operator of the branch node is "OR", which serves as a child node of the branch node 801; the assignment of userOr indicates the instance of the query object UserQuery, so all fields of the instance are traversed, and the assignment of the field idEq to 4, the field userAnd and its assignment are read through the reflection technology; according to the field suffix "Eq", it is determined that the field idEq is a first-class field that has been assigned a value, so according to the field name idEq and its assignment 4, a corresponding leaf node 803 is constructed as a child node of the branch node 802, and the leaf node 803 includes the predicate logic of "$id is equal to 4"; according to the field suffix The suffix "And" is used to determine that the field userAnd is a second-class field that has been assigned a value, so a branch node 804 is created as a child node of the branch node 802 based on the second-class field userAnd that has been assigned a value, and the logical operator of the branch node 804 is AND; the assignment of userAnd indicates an instance of the query object UserQuery, so all fields of the instance are traversed, and through reflection technology, it is read that the assignment of the field nameStart is "Bra" and the assignment of the field ageGt is 5; based on the field suffix "Start", it is determined that the field nameStart is a first-class field that has been assigned a value, so based on the field nameStart and its assigned value "Bra", a corresponding leaf node 805 is constructed as a child node of the branch node 804, and the leaf node 805 includes the predicate logic "$name starts with Bra"; based on the field suffix "Gt", it is determined that the field ageGt is a first-class field that has been assigned a value, so based on the field name ageGt and its assigned value 5, a corresponding leaf node 806 is constructed as a child node of the branch node 804, and the leaf node 806 includes the predicate logic "$age is greater than 5". When all fields in the instance are traversed, that is, all assigned second-category fields are traversed, the filter tree construction process ends.

[0168] Before giving an example of the second method of constructing a screening tree, Figure 8As shown in (b), it is a filter tree template 810 corresponding to the query object UserQuery. The filter tree template 810 includes a branch node 811 as the root node of the filter tree template 810, a leaf node 812 is a leaf node corresponding to the idEq field in the filter tree template 810, a leaf node 813 is a leaf node corresponding to the nameStart field in the filter tree template 810, a leaf node 814 is a leaf node corresponding to ageGt in the filter tree template 810, a branch node 815 is a branch node corresponding to userAnd in the filter tree template 810 (the logical operator is AND), and a branch node 816 is a branch node corresponding to userOr in the filter tree template 810 (the logical operator is OR).

[0169] The first way to construct a screening tree is: Figure 7 The type of the query object UserQuery shown in FIG. 8 is used to obtain the filter tree template 810 corresponding to the query object UserQuery (eg, Figure 8 (b) in the screening tree template); based on Figure 7The instance of the query object UserQuery shown in the figure creates a branch node 801, and the logical operator of the branch node 801 is AND, which serves as the root node of the filter tree 800; all fields of the instance of the query object UserQuery are traversed, and the assigned field userOr and its assigned value are read through the reflection technology. According to the field suffix "Or", it is determined that the field userOr is a second-class field that has been assigned a value. Then, according to the assigned second-class field userOr, a branch node 816 corresponding to userOr in the filter tree template 810 is added as a branch node 802 (a child node of the root node 801); the assignment of userOr indicates that the query The instance of the object UserQuery is then traversed through all the fields of the instance. Through reflection technology, the value of the field idEq is read as 4, and the field userAnd and its assigned value are read. According to the field suffix "Eq", the field idEq is determined to be a first-class field that has been assigned a value. Based on the field name idEq and its assigned value 4, the leaf node 812 corresponding to idEq in the filter tree template 810 is added as a child node of the branch node 802, and the assigned value 4 is substituted into the variable of the predicate logic to obtain the leaf node 803. The predicate logic included in the leaf node 803 is "$id is equal to 4". According to the field suffix "And", the field userAnd is determined to be a second-class field that has been assigned a value. field, then based on the assigned second-category field userAnd, add the branch node 815 corresponding to userAnd in the filter tree template 810 as the branch node 804 (child node of the branch node 802); the assigned value of userAnd indicates the instance of the query object UserQuery, so all fields of the instance are traversed, and the assigned value of the field nameStart is read through the reflection technology to be "Bra" and the assigned value of the field ageGt is 5; according to the field suffix "Start", it is determined that the field nameStart is a first-category field that has been assigned a value, so based on the field nameStart and its assigned value "Bra", add the filter tree template Leaf node 813 corresponding to nameStart in template 810 is added as a child node of branch node 804. The value "Bra" is substituted into the variable of the predicate logic, resulting in leaf node 805. Leaf node 805 includes the predicate logic "$name starts with Bra." Based on the field suffix "Gt," field ageGt is determined to be a first-class field with a value. Based on the field name ageGt and its value 5, leaf node 814 corresponding to ageGt in filter tree template 810 is added as a child node of branch node 804. The value 5 is substituted into the variable of the predicate logic, resulting in leaf node 806. Leaf node 806 includes the predicate logic "$age is greater than 5." This completes the construction of the filter tree.

[0170] Take the element {id:2,name:"Bravo",age:12} corresponding to the element type UserEntity as an example to illustrate how to Figure 8 The filtering tree shown in (a) shows the process of judging the element.

[0171] The element is passed to branch node 801, the judgment process is executed, and the judgment result is obtained; branch node 801 needs to obtain the judgment result of the child node for logical AND operation, so branch node 801 passes the element to branch node 802, executes the judgment process, and obtains the judgment result of branch node 802 itself; branch node 802 passes the element to leaf node 803 and branch node 804, executes the judgment process, and obtains the judgment results of leaf node 803 and branch node 804 itself respectively; when leaf node 803 executes the judgment process, the value of id read from the element is 2, that is, $id=2, then the judgment result of leaf node 803 "$id equals 4" is false; branch node 804 needs to obtain the judgment result of the child node for logical AND operation, so branch node 804 passes the element to leaf node 805 and leaf node 806, executes the judgment process, and obtains the judgment results of leaf node 805 and leaf node 806 itself respectively. Judgment result; when leaf node 805 executes the judgment process, the value of the attribute name read from the element is "Bravo", that is, $name="Bravo", then the judgment result of leaf node 805 "$name starts with Bra" is true; when leaf node 806 executes the screening process, the value of the attribute age read from the element is 12, that is, $age=12, then the judgment result of leaf node 806 "$age is greater than 5" is true; therefore, the logical operation of branch node 804 is "true AND true", then the judgment result of branch node 804 itself is true; the logical operation of branch node 802 is "false OR true", then the judgment result of branch node 802 itself is true; the child node of branch node 801 is only branch node 802, since the judgment result of branch node 802 is true, the judgment result of branch node 801 is true, then the judgment result of the element is true, and it is added to the screening result set.

[0172] Furthermore, in a possible implementation, the name of the second type of field is suffixed with a composite predicate, the field type of the second type of field is an array or a collection, and the type of the element of the array or collection is any query object. For example, the second type of field is a userOr field, and its type is List<String, String> <userquery>For the userOr field, a branch node is constructed for it, and the logical operator of the branch node is "OR"; each instance in the UserQuery list corresponding to the field's assigned value is constructed as a branch node, and the logical operator of the branch node is "AND"; repeat the process of constructing the assigned fields into child nodes of the branch node for each instance until all instances are constructed.

[0173] Furthermore, in another possible implementation, the name suffix of the second type of field is a composite predicate, the field type of the second type of field is an array or a collection, and the type of the element of the array or collection is a basic data type. For example, the second type of field is the nameStartOr field, and its type is List<T> <string>For the nameStartOr field, a branch node is constructed for it, and the logical operation of the branch node is "OR". Each element in the list corresponding to the value of the nameStartOr field is constructed as a leaf node. The attribute predicate expression is determined by removing the compound predicate Or from the field name. That is, the name nameStartOr after removing Or is nameStart. Therefore, the predicate logic of each leaf node can be determined as "$name starts with v", where v is the value of each element in the list corresponding to the value of the nameStartOr field.

[0174] An embodiment of the present application provides a data screening method, comprising: constructing a corresponding screening tree based on an instance of a query object obtained; filtering the data set corresponding to the query object through the screening tree to obtain a screening subset. In an embodiment of the present application, a corresponding screening tree is constructed based on an instance of a query object, and each assigned field of the query object is constructed as one or a group of screening nodes in the screening tree. The screening node is used to perform logical operations on the elements in the data set to obtain a judgment result, thereby filtering the elements based on the screening tree. In an embodiment of the present application, data screening can be achieved by constructing a screening tree based on an instance of a query object, and there is no need to write additional corresponding query code, which avoids repeated waste of human resources and simplifies the process of data screening.

[0175] Example 2:

[0176] The following combination Figure 9 , a data screening device provided in an embodiment of the present application is introduced in detail.

[0177] like Figure 9 As shown, a data screening device provided in an embodiment of the present application includes the following modules:

[0178] Construction module 901 is used to construct a corresponding filter tree based on the obtained query object instance; the fields defined in the query object include first-category fields and second-category fields; the first-category fields are used to construct a filter node; the second-category fields are used to construct a group of filter nodes, each of which includes a parent node and multiple child nodes; the filter node is used to perform logical operations on elements in the data set to obtain a judgment result; the filter nodes are organized into a tree structure based on the structure of the query object, which is called a filter tree;

[0179] The screening module 902 is used to screen the data set corresponding to the query object through the corresponding screening tree to obtain a screening subset.

[0180] In a possible implementation, the construction module 901 includes: a first construction module and a second construction module, wherein the first construction module includes: a root node construction module and a child node construction module.

[0181] A root node construction module is used to construct branch nodes of a tree structure based on instances of the query object; wherein the branch nodes constructed based on the instances of the query object serve as the root nodes of the screening tree; the branch nodes include logical operators and multiple child nodes; the logical operators are used to perform logical operations on the judgment results returned by the multiple child nodes to obtain the judgment results of the branch nodes;

[0182] The child node construction module is used to traverse the fields of the query object instance and construct the assigned fields as child nodes of the branch node.

[0183] In one possible implementation, a child node construction module is specifically used to determine the classification of an assigned field based on the name of the assigned field; wherein, a field whose name ends with a preset composite predicate is a second-category field, and a field whose name ends with a preset atomic predicate is a first-category field; for the assigned first-category field, a corresponding leaf node of a tree structure is constructed; the leaf node includes a section of predicate logic for judging the element; the predicate logic is constructed based on the field name and the assignment; for the assigned second-category field, a corresponding branch node of a tree structure is constructed, and the child nodes of the branch node are recursively constructed based on the assignment of the assigned second-category field until all the assigned second-category fields are constructed; the logical operator of the branch node is set based on the composite predicate in the name of the second-category field.

[0184] In a possible implementation, the second building module includes: a template acquisition module and a template instantiation module.

[0185] A template acquisition module is used to acquire a corresponding filter tree template based on the type of the acquired query object; the leaf nodes in the filter tree template include predicate logic containing variables, and the branch nodes in the filter tree template do not include child nodes; wherein the variables are determined based on the assignment of the first type of fields, and the child nodes of the branch nodes are determined based on the assignment of the second type of fields;

[0186] The template instantiation module is used to build a corresponding filter tree based on the instance of the query object and the corresponding filter tree template.

[0187] In one possible implementation, the template acquisition module is specifically used to obtain the corresponding filtering tree template from the context based on the type of the query object obtained; the second construction module also includes: a template construction module, which is used to construct the corresponding filtering tree template according to the type of the query object when the corresponding filtering tree template is not obtained, and store the type of the query object and the filtering tree template and their mapping relationship in the context.

[0188] In one possible implementation, the template construction module is specifically used to construct a branch node of a tree structure according to the type of the query object, as the root node of the filter tree template, and traverse all fields defined in the query object; for the first type of field, it is constructed as a leaf node in the filter tree template; wherein the leaf node in the filter tree template includes a predicate logic containing variables; the variables are determined according to the assignment of the first type of field; for the second type of field, it is constructed as a branch node in the filter tree template, and the corresponding filter tree template is searched from the context according to the type of the second type of field; if not found, the filter tree template is continued to be constructed, and the type of the second type of field and the filter tree template are stored in the context correspondingly until the filter tree templates are constructed for all types of the second type of field.

[0189] In one possible implementation, the template instantiation module is specifically used to construct a branch node of a tree structure according to an instance of a query object as a root node of a filtering tree; traverse the fields in the instance of the query object, and add the nodes in the filtering tree template corresponding to the assigned fields as child nodes of the branch node; for the assigned first-category fields, set the variables in the leaf nodes corresponding to the assigned first-category fields to the assigned values of the assigned first-category fields; for the assigned second-category fields, recursively construct the child nodes of the branch nodes corresponding to the assigned second-category fields according to the assigned values of the second-category fields.

[0190] In one possible implementation, the filtering module 902 is specifically used to traverse all elements of the data set corresponding to the query object; use the root node of the filtering tree to judge each traversed element, obtain a judgment result, and add the elements with a true judgment result to the filtering result set; wherein, the filtering result set is used to store elements that meet the filtering conditions; after the traversal is completed, the filtering result set is output as a filtering subset.

[0191] An embodiment of the present application provides a data screening device, including: a construction module 901, which is used to construct a corresponding screening tree based on the instance of the query object obtained; a screening module 902, which is used to screen the data set corresponding to the query object through the corresponding screening tree to obtain a screening subset. In the embodiment of the present application, a corresponding screening tree is constructed based on the instance of the query object, and each field of the query object is constructed as one or a group of screening nodes in the screening tree. The screening node is used to perform logical operations on the elements in the data set to obtain a judgment result, thereby screening the elements based on the screening tree. Data screening can be achieved by constructing a screening tree based on the instance of the query object, and there is no need to write the corresponding query code separately, which avoids the repeated waste of human resources and simplifies the process of data screening.

[0192] In addition, the present application also provides a data screening product, including: a processor and a memory, the processor is coupled to the memory, the memory stores computer-executable instructions, and when the processor executes the computer-executable instructions, the data screening method in the above embodiment is implemented.

[0193] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is run on a computer, the computer is caused to execute the data screening method in the above embodiment.

[0194] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the method and device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The method and device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.

[0195] The above is merely one specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.< / string> < / userquery>

Claims

1. A data screening method, characterized in that: include: Based on the obtained query object instance, a corresponding filter tree is constructed; The fields defined in the query object include at least first-category fields and second-category fields; the first-category fields are used to construct a filter node; the second-category fields are used to construct a group of filter nodes, and the group of filter nodes includes a parent node and multiple child nodes; The screening node is used to perform logical operations on the elements in the data set to obtain a judgment result; The screening nodes are organized into a tree structure according to the field structure of the query object, which is called a screening tree; The data set corresponding to the query object is filtered through the corresponding filtering tree to obtain a filtered subset.

2. The method according to claim 1, characterized in that The first type of fields are fields whose names end with a preset atomic predicate, and the second type of fields are fields whose names end with a preset compound predicate.

3. The method according to claim 1, characterized in that The step of constructing a corresponding filter tree based on the obtained query object instance includes: According to the instance of the query object, a branch node of the tree structure is constructed as a root node of the screening tree; the branch node includes a logical operator and multiple child nodes; the logical operator is used to perform a logical operation on the judgment results returned by the multiple child nodes to obtain the judgment result of the branch node; The fields of the instance of the query object are traversed, and the assigned fields are constructed as child nodes of the branch node.

4. The method according to claim 3, characterized in that The step of constructing the assigned fields as child nodes of the branch nodes includes: Determining a classification of the assigned field based on the name of the assigned field; For the assigned first-category fields, construct corresponding leaf nodes of the tree structure; the leaf nodes include a predicate logic for judging the elements; the predicate logic is constructed according to the names and assigned values of the first-category fields; For the second-category fields that have been assigned values, construct the corresponding branch nodes of the tree structure, and recursively construct the child nodes of the branch nodes according to the assignments of the second-category fields that have been assigned values, until all the assigned fields are constructed; the logical operator of the branch node is set according to the composite predicate in the name of the second-category field.

5. The method according to claim 1, wherein The step of constructing a corresponding filter tree based on the obtained query object instance includes: Obtaining a corresponding filtering tree template according to the type of the obtained query object; wherein the leaf nodes in the filtering tree template include predicate logic containing variables, and the branch nodes in the filtering tree template do not include child nodes; wherein the variables are determined according to the values assigned to the first category of fields, and the child nodes of the branch nodes are determined according to the values assigned to the second category of fields; Based on the instance of the query object and the corresponding filtering tree template, a corresponding filtering tree is constructed.

6. The method according to claim 5, characterized in that The step of obtaining a corresponding filter tree template according to the type of the obtained query object includes: Based on the type of the query object obtained, obtain the corresponding filter tree template from the context; When the corresponding filtering tree template is not obtained, a corresponding filtering tree template is constructed according to the type of the query object, and the type of the query object and the filtering tree template and their mapping relationship are stored in the context.

7. The method according to claim 6, characterized in that The step of constructing a corresponding screening tree template according to the type of the query object includes: According to the type of the query object, construct a branch node of the tree structure as the root node of the screening tree template, and traverse all fields defined in the query object; For the first type of fields, construct leaf nodes in the screening tree template; wherein the leaf nodes in the screening tree template include predicate logic containing variables; the variables are determined according to the values assigned to the first type of fields; For the second category of fields, a branch node in the filtering tree template is constructed, and the filtering tree template is continued to be constructed according to the type of the second category of fields, and the type of the second category of fields and the filtering tree template and their mapping relationship are stored in the context until filtering tree templates are constructed for all known types of the second category of fields.

8. The method according to claim 5, characterized in that The constructing a corresponding filtering tree based on the instance of the query object and the corresponding filtering tree template includes: According to the instance of the query object, construct a branch node of the tree structure as a root node of the screening tree; Traversing the fields in the instance of the query object, adding the nodes in the filter tree template corresponding to the assigned fields as child nodes of the branch node; For the assigned first-category field, add the leaf node corresponding to the assigned first-category field in the screening tree template as a child node of the branch node, and set the variable to the assigned value of the assigned first-category field; For the second-category fields that have been assigned values, add the branch nodes corresponding to the second-category fields that have been assigned values in the filtering tree template as child nodes of the branch nodes; and recursively construct the child nodes of the branch nodes corresponding to the second-category fields that have been assigned values according to the values assigned to the second-category fields.

9. The method according to claim 1, characterized in that The filtering of the data set corresponding to the query object by the corresponding filtering tree to obtain a filtered subset includes: Traversing all elements of the data set corresponding to the query object; Use the root node of the filter tree to judge each traversed element, obtain a judgment result, and add the element with the true judgment result to the filter result set; After the traversal is completed, the filtered result set is output as the filtered subset.

10. A data screening device, characterized in that: include: A construction module, used to construct a corresponding filter tree based on the obtained query object instance; The fields defined in the query object include at least first-category fields and second-category fields; the first-category fields are used to construct a filter node; the second-category fields are used to construct a group of filter nodes, and the group of filter nodes includes a parent node and multiple child nodes; The screening node is used to perform logical operations on the elements in the data set to obtain a judgment result; The screening nodes are organized into a tree structure according to the field structure of the query object, which is called a screening tree; The screening module is used to screen the data set corresponding to the query object through the corresponding screening tree to obtain a screening subset.

11. A data screening product, characterized in that: include: a processor and a memory, the processor and the memory being coupled; The memory is used to store computer program instructions; The processor is used to execute the computer program instructions stored in the memory to implement the data screening method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Query statement generation method and device

    CN111143359A

  • Clinlin closure regular path query optimization method based on recursive index tree

    CN115062054A

  • User screening method and device, computer equipment, storage medium and product

    CN116909538A

  • Query object mapping method and device and product

    CN118227626A

  • SQL (Structured Query Language) query visual configuration method and system for screening data as required

    CN118626532A