Method, device, medium and computer equipment for improving risk control accuracy
By creating node classes and node variables in the risk control system of the live broadcast platform, storing and traversing node data, the problem of reducing risk control accuracy caused by incomplete logs is solved, and a higher risk control accuracy is achieved.
Patent Information
- Application Number
- CN202010683712.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-16
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2040-07-16
AI Technical Summary
In the prior art, due to incomplete acquisition of user node logs, the risk control accuracy of the live broadcast platform is reduced.
Before executing the risk control strategy, create a node class, including multiple key nodes, and create node variables for each key node, assign values and store node data. Through the preset traversal order, all child node IDs contained in the target parent node ID are determined, corresponding node data are found from the storage object, and risk control strategies are implemented based on the found node data.
Ensure the comprehensiveness of the obtained data, avoid faults during data updates, and thus improve the accuracy of risk control.
Smart Images

Figure CN113946554B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of risk control technology, and in particular, relates to a method, device, medium and computer equipment for improving risk control accuracy. Background Art
[0002] On the live broadcast platform, in order to ensure the security of the live broadcast platform, some risk control strategies need to be implemented; for example, it is necessary to conduct a unified analysis of the behavior of each user node and user data to determine whether there is some batch cheating behavior, and then determine whether the user needs to be punished.
[0003] Most existing risk control scenarios use log writing to record each node of the user, and then analyze the log through log analysis tools to analyze the user's behavior and various data.
[0004] Generally speaking, a live broadcast platform will include multiple servers, and the logs recorded by each server are different. However, due to the large number of users, the user's node logs are also in a state of constant updating. During the log update process, the obtained logs may be disconnected, and the latest version of the log cannot be obtained in time for analysis, which will affect the accuracy of risk control. Summary of the invention
[0005] In response to the problems existing in the prior art, the embodiments of the present invention provide a method, device, medium and computer equipment for improving the risk control accuracy, which are used to solve the technical problem in the prior art that the risk control accuracy of the live broadcast platform is reduced due to incomplete logs obtained from user nodes.
[0006] The present invention provides a method for improving the accuracy of risk control, characterized in that it is applied in a live broadcast platform, and the method comprises:
[0007] Before executing the risk control strategy, create a node class, which includes multiple key nodes;
[0008] For any current key node, a node variable of the current key node is established in the node class, and a value is assigned to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0009] Obtain node data of the current key node, and store the node data in a storage object of the node class, where the storage object is a map object;
[0010] When the risk control strategy needs to be executed, a target child node ID of a target key node is received, and a target parent node ID of the target child node ID is determined in the node class;
[0011] Based on a preset traversal order, traverse the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID;
[0012] Searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID;
[0013] The risk control strategy is executed based on the found node data.
[0014] Optionally, before creating the node class, the steps include:
[0015] Determine the types of all the key nodes, and store the types of the key nodes in the form of enumeration types;
[0016] Create a namespace, and create at least one static variable in the namespace; the static variable is a string of static constants;
[0017] The type of the corresponding key node is named using the at least one static variable.
[0018] Optionally, after naming the type of the corresponding key node using the at least one static variable, the method further includes:
[0019] Create a query interface;
[0020] Receive a query request, determine whether the query request carries a valid key node type, and return a null value if the query request does not carry a valid key node type;
[0021] If the query request carries a valid key node type, the corresponding static variable is returned according to the query request.
[0022] Optionally, before establishing the node variable of the current key node in the node class, the method further includes:
[0023] Create a state variable state of enumeration type;
[0024] Determine the type of the state variable, and assign a corresponding state identification value to each type of the state variable; wherein the type of the state variable includes: not started, started, and ended.
[0025] Optionally, assigning a value to the node variable includes:
[0026] Obtaining a state identification value, and assigning the state identification value to the node state variable;
[0027] The constructor is called to pass in the node type, and the node type is assigned to the node type variable;
[0028] Generate a function static atomic using the node ID in the constructor<uint32_t> num(0), id_=num++ generates a child node ID for the current key node, and assigns the child node ID to the child node ID variable; num is a static variable of the constructor, static is the variable type of num, atomic is the operation type of the static variable, and id_=num++ is the self-increment function of the child node ID;
[0029] Determine the parent node ID of the child node ID, and assign the parent node ID to the parent node ID variable;
[0030] Creating a start interface and an end interface of the current key node, using the start interface to obtain the start time of the current key node, and using the end interface to obtain the end time of the current key node;
[0031] The start time is assigned to the start time variable, and the end time is assigned to the end time variable.
[0032] Optionally, storing the node data in a storage object of the node class includes:
[0033] Obtaining the data type contained in the node data;
[0034] The data type is used as the key value, and the node data corresponding to the data type is stored as the value in the storage object SrcData.
[0035] Optionally, after searching the storage object for corresponding node data based on the target parent node ID and all child node IDs contained under the target parent node ID, the method further includes:
[0036] The node variable data of the key node is converted into a readable character string using a corresponding data conversion function.
[0037] The present invention also provides a device for improving the accuracy of risk control, the device comprising:
[0038] A creation unit, used to create a node class before executing the risk control strategy, wherein the node class includes a plurality of key nodes;
[0039] An establishing unit, for establishing a node variable of the current key node in the node class for any current key node, and assigning a value to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0040] A storage unit, used for acquiring node data of the current key node, and storing the node data in a storage object of the node class, wherein the storage object is a map object;
[0041] A determination unit, configured to receive the target child node ID of the target key node when the risk control strategy needs to be executed, and determine the target parent node ID of the target child node ID in the node class
[0042] A search unit, configured to perform a traversal based on a preset traversal order and the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID; and search for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID;
[0043] An execution unit is used to execute the risk control strategy based on the found node data.
[0044] The present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned methods is implemented.
[0045] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described methods when executing the program.
[0046] The present invention provides a method for improving the accuracy of risk control, which is applied to a live broadcast platform. The method comprises: before executing a risk control strategy, creating a node class, wherein the node class comprises a plurality of key nodes; for any current key node, establishing a node variable of the current key node in the node class, and assigning a value to the node variable; the node variable comprises: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable; obtaining node data of the current key node, and storing the node data in a storage object of the node class, wherein the storage object is a map object; when the risk control strategy needs to be executed, receiving a target child node ID of a target key node, and determining a target parent node ID of the target child node ID in the node class; traversing the target child node ID based on a preset traversal order, and performing a traversal based on the target parent node ID. Traverse the rows to determine all child node IDs contained under the target parent node ID; search for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID; execute the risk control strategy based on the node data found; in this way, the node variable of each current key node is pre-set in the node class, and in the node class, for any current key node, the association relationship between the child node ID of the current key node and the parent node ID can be pre-set; then when it is necessary to obtain the node data of a key node, the associated parent node ID is queried according to the node ID of the key node, and the node data of all child node IDs under the parent node ID are obtained in a preset traversal order, so as to ensure the comprehensiveness of the acquired data and ensure that there will be no gaps in the data update process, thereby ensuring the accuracy of risk control. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A schematic diagram of a method flow for improving the accuracy of risk control provided by an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of the structure of a device for improving the accuracy of wind control provided by an embodiment of the present invention;
[0049] Figure 3 A schematic diagram of the structure of a computer device for improving the accuracy of risk control provided by an embodiment of the present invention;
[0050] Figure 4 A schematic diagram of a computer medium structure for improving risk control accuracy provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to solve the technical problem in the prior art that the risk control accuracy of the live broadcast platform is reduced due to incomplete logs of user nodes, the present invention provides a method, device, medium and computer equipment for improving the risk control accuracy.
[0052] The technical solution of the present invention is further described in detail below through the accompanying drawings and specific embodiments.
[0053] Embodiment 1
[0054] This embodiment provides a method for improving the accuracy of risk control, which is applied to the risk control scenario of the live broadcast platform, such as Figure 1 As shown, the method includes:
[0055] S110, before executing the risk control strategy, create a node class, wherein the node class includes a plurality of key nodes;
[0056] Since there are many key nodes in the risk control scenario, and there are many data and types, before creating the node class, it also includes:
[0057] Determine the types of all key nodes and store the types of key nodes in the form of enumeration types;
[0058] Create a namespace, and create at least one static variable in the namespace; the static variable is a string of static constants;
[0059] At least one static variable is used to name the type of the corresponding key node.
[0060] Specifically, in order to save memory space, the types of key nodes are stored in the form of enumeration types, and the key nodes may include: registration nodes, login nodes, first recharge nodes, and the like.
[0061] First, define an enumeration type NodeType and use the uint16_t type for storage. Since the uint16_t type only occupies 2 bytes, it can save memory space. The storage code is implemented as follows:
[0062] enum class NodeType:uint16_t{
[0063] Register; Register node
[0064] Login; Login node
[0065] FirstCharge, the first recharge node
[0066] …
[0067] }
[0068] Here, the registration node is the first key node, and the value assigned to the registration node is 0; the login node is the second key node, and the value assigned to the login node is 1, and so on, it increases in sequence until the last stored key node is assigned a value.
[0069] When using enumeration type to store key nodes, the key node is an integer, which is not readable, so a conversion interface needs to be created to convert the enumeration type into a readable string. When creating a conversion interface, many global static variables need to be defined. In order not to pollute the variable name of the entire program, a namespace is created, and at least one static variable is created in the namespace; the global static variables in the namespace correspond to the conversion interface, and the static variables in the namespace can only be called through the call request of this conversion interface.
[0070] Here, static variables are used to name the types of the corresponding key nodes. The static variables are static constant strings, which are static and constant const types. This allows static variables to be initialized before the program starts, and these names will not change as the program runs. The specific code implementation is as follows:
[0071] namespace{
[0072] static const string kNodeRegister = "Register"; Register node
[0073] static const string kNodeLogin = "Login"; Login node
[0074] static const string kNodeFirstCharge = "FirstCharge"; first charge node
[0075] }
[0076] It can be seen from the code that static const string kNodeRegister, static conststring kNodeLogin, and static const string kNodeFirstCharge are corresponding static variables.
[0077] After at least one static variable is used to name the type of the corresponding key node, in order to ensure that the caller can accurately call the required key node, the method further includes:
[0078] Create a query interface;
[0079] Receive a query request, determine whether the query request carries a valid key node type, and return a null value if the query request does not carry a valid key node type;
[0080] If the query request carries a valid key node type, the corresponding static variable is returned according to the query request.
[0081] Here, when returning the corresponding static variable, the return value must be modified with constants const and & to prevent the returned string from being copied or modified. The specific code implementation is as follows:
[0082] const string&getNodeTypeString(NodeType type){
[0083] static const std::string kInvalidType = ""; empty string variable ""
[0084] Switch(type){
[0085] Case NodeType::Register:return kNodeRegister; if it is a registered node, return the registered node variable
[0086] Case NodeType::Login:return kNodeLogin; if it is a login node, return the login node variable
[0087] Case NodeType::FirstCharge:return kNodeFirstCharge; if it is the first charge node, return the first charge node variable}
[0088] return kInvalidType; if no corresponding node is found, the defined default variable is returned
[0089] }
[0090] In this way, if there are new key nodes in the future, the type of the key nodes can be directly added in the namespace, and each key node type exists in the namespace in text form; for example, if the type of the key node is a registration node, the text format is: Register,"Register"; the first Register is the name of the type, and the second "Register" is the corresponding string.
[0091] Then, the script parses the text to generate the above-mentioned NodeType code, kNodeRegister variable code, and getNodeTypeString query interface code; in this way, it is not necessary to modify the namespace content but only the specific code implementation to add key nodes, which reduces the workload of the staff and also improves the accuracy of the code.
[0092] After the key node type is determined, since each key node may contain multiple data, it is necessary to store the key node data. For example, for a login node, the login ID, user name, login password, etc. need to be stored.
[0093] Then, before executing the risk control strategy, create a node class KeyNode and use the node class to encapsulate data. The node class includes multiple key nodes.
[0094] S111, for any current key node, establish a node variable of the current key node in the node class, and assign a value to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0095] For any current key node, create a node variable of the current key node in the node class class KeyNode and assign a value to the node variable. Node variables include: node status variable, node type variable, child node ID variable, parent node ID variable, start time variable, and end time variable. The specific code implementation is as follows:
[0096]
[0097]
[0098] It can be seen from the above code that before the node variable of the current key node is established in the node class, it also includes:
[0099] Create a state variable state of enumeration type;
[0100] Determine the type of the state variable and assign a corresponding state identification value to each type of the state variable; wherein the types of the state variable include: not started NOT_STARTED, started STARTED and ended ENDED; then the state identification value corresponding to NOT_STARTED can be 0, the state identification value corresponding to STARTED can be 1, and the state identification value corresponding to ENDED can be 2.
[0101] After the node variable is created, you need to assign values to the node variable, including:
[0102] Obtaining a state identification value, and assigning the state identification value to the node state variable;
[0103] Calling the constructor will pass in the node type and assign the node type to the node type variable;
[0104] Generate a function static atomic using the node ID in the constructor<uint32_t> num(0), id_=num++ generates a child node ID for the current key node, and assigns the child node ID to the child node ID variable;
[0105] Determine the parent node ID of the child node ID, and assign the parent node ID to the parent node ID variable;
[0106] Create a start interface and an end interface of the current key node, use the start interface to obtain the start time of the current key node, and use the end interface to obtain the end time of the current key node;
[0107] Assign the start time to the start time variable and the end time to the end time variable.
[0108] The corresponding code implementation of the assignment process is as follows:
[0109]
[0110]
[0111] From the above code, the constructor is explicit KeyNode(NodeType type,uint32_tparentid=0), and the node ID generation function of the constructor is static atomic<uint32_t> num(0), a static variable of the num constructor, static is the variable type of num, indicating that num is a static variable; atomic is the operation type of the static variable, id_=num++ is the self-increment function of the child node ID.
[0112] Use the constructor to pass in the current key node type and provide the unique id of the parent node; since some key nodes do not require a parent node, the default value is 0, indicating that there is no parent node. Use type_=type; parent_id_=parentid; to assign the corresponding node variable. Among them, the child node ID and the parent node ID are corresponding. If a node is the parent node of another node, then the child node ID is passed to the other node. This ensures that the required data space is minimized and that the ID of each node is unique.
[0113] In this way, a static variable num is defined in the constructor. Since the static variable may be called by multiple threads at the same time, in order to ensure the calling efficiency and improve the calling performance, the static variable is of atomic operation type. Then, when multiple threads call the static variable of atomic operation type at the same time, each thread can call it at the same time without locking, thereby improving the system performance. id_=num++ Then the child node ID of each key node is incremented by this variable; for example, if the child node ID of key node A is 1, and B is the next key node of A, then the child node ID of key node B is 2. In this way, it is equivalent to that the ID of each key node is automatically assigned and increases sequentially to avoid omissions.
[0114] S112, acquiring node data of the current key node, and storing the node data in a storage object of the node class, wherein the storage object is a map object;
[0115] After assigning values to each node variable, you need to obtain the node data of the current key node and store the node data in the storage object of the node class, which is a map object. The structure of the map object is: map<DataType,SrcData> srcData_. DataType is the key value, SrcData is the corresponding value, which is the real node data, and srcData_ is a storage variable that stores any data type. In this way, node data of different data types can be stored.
[0116] Since the data types of node data include multiple types, in order to facilitate the caller to call data, when storing node data, template parameters are used for storage. This is equivalent to providing a unified interface to the outside world. The caller does not need to find out what type of data the data is before calling, and then look for the corresponding type of interface, which improves the calling efficiency. When storing, the code is implemented as follows:
[0117]
[0118] For example, when the key nodes are login nodes and registration nodes, the storage format can be:
[0119] KeyNode keynode((NodeType::Register));
[0120] int64_t data(45);
[0121] keynode.addSrc(DataType::Register,data);
[0122] Keynode.start(getCurrentTime();
[0123] String data("testdata");
[0124] keynode.addSrc(DataType::Login,data);
[0125] Here, since the present invention stores node variables and node data separately, when storing node data, it is also necessary to define it in the node class:
[0126] class KeyNode{
[0127] struct SrcData{SrcData
[0128] variant <int64_t,string,vector <string>>value_;
[0129] SrcData(T value):value_(<int64_t>(value)){}
[0130] SrcData(const std::string&value):value_(value){}
[0131] SrcData(const std::vector <std::string>&value):value_(value){}
[0132] }
[0133] Since the node data is the data in the risk control scenario, the variable type variant is used. The present invention uses three data types: the int64_t integer type can satisfy all integer types such as bool, int, uint32_t, uint64_t, etc.;
[0134] string can satisfy the string type; vector <string>It is a dynamic array that can support string arrays with variable length. Based on the above three data types, it can basically cover all types of node data.
[0135] S113, when the risk control strategy needs to be executed, receiving the target child node ID of the target key node, and determining the target parent node ID of the target child node ID in the node class;
[0136] After the node data is stored, when the risk control strategy needs to be executed, the target child node ID of the target key node or the node name of the target key node is received, and the target parent node ID of the target child node ID is determined in the node class. Among them, for any key node, since the node class contains the chain relationship between the child node ID of the node and the ID of other key nodes, forming a node tree structure, the target parent node ID of the target child node ID can be determined.
[0137] S114, based on a preset traversal order, traverse with the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID;
[0138] In order to ensure the comprehensiveness of node data, after obtaining the target parent node ID, based on the preset traversal order, traverse from top to bottom in the tree structure with the target parent node ID as the benchmark to determine all child node IDs contained under the target parent node ID; or,
[0139] Based on the target child node ID, traverse from bottom to top in the tree structure to determine all child node IDs contained under the target parent node ID.
[0140] S115, searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID;
[0141] Here, before searching for the corresponding node data from the storage object based on the target parent node ID and all the child node IDs contained under the target parent node ID, a read interface needs to be created so that the corresponding node data can be obtained using the read interface. The code implementation for creating the read interface is as follows:
[0142] template<typename T>
[0143] bool readIntSrc(DataType key,T&dest)const{
[0144] static_assert(is_integral <t>::value&&!is_same<T,bool> ::value,)
[0145] That is, the caller only needs to pass in the data type key of the required data, and the corresponding value will be returned.
[0146] When reading data, it is read through a visitor, so you need to create a visitor. The creation process is as follows:
[0147]
[0148] The reading process is as follows:
[0149]
[0150] If the corresponding node data is found, a true value is returned.
[0151] Because the visitor needs to consider different types of data when reading data, after reading the data, it needs to convert the data into the required data type. The code is as follows:
[0152]
[0153] Here, in order to prevent the caller from passing in unsupported data types and causing the program to crash, after receiving the key value, it is necessary to determine whether the data type is an abnormal type. The code is implemented as follows:
[0154] T operator()(const std::vector <std::string>&)const{
[0155] throw_exception <exception>("This type is not supported");}
[0156] If const and & are called and the current data type is determined to be an abnormal type, an exception will be thrown to prompt the caller that the call of this data type is not supported.
[0157] After searching the storage object for corresponding node data based on the target parent node ID and all child node IDs contained under the target parent node ID, the method further includes:
[0158] The corresponding data conversion function is used to convert the node variable data of the key node into a readable string. The code is implemented as follows:
[0159]
[0160] Furthermore, for a certain user, if one wants to find the node data of all key nodes of the user, one can use the read function Void savetosqlite(){sqlite->insert(id,type,start,end,parentid,srcdata);} to achieve it.
[0161] S116: Execute the risk control strategy based on the found node data.
[0162] After finding the node data of the current key node, the risk control strategy is executed based on the node data found. In this way, the search based on the tree structure ID ensures that the found data is relatively comprehensive, and there will be no data gap even after the data is updated (such as changing the login password), so the accuracy of risk control can be improved.
[0163] For example, if a user frequently logs in from a different location, receives gifts from a live streaming platform, etc., combined with data from other key nodes (such as frequently changing login passwords), it can be determined that the user is at a higher risk. The output risk result is high risk, and the user may need to be blocked.
[0164] In addition, after outputting the risk results, the version number of the node data can also be added to the risk structure for staff reference. For example, before a user changes his password, the version number of the node data obtained is 1.0, and after changing his password, the version number of the node data obtained is 2.0. When risk control is determined by node data with version number 1.0, the risk result can carry version number 1.0; when risk control is determined by node data with version number 2.0, the risk result can carry version number 2.0. This is more conducive to comparison by staff and obtaining risk results with higher credibility.
[0165] The node variables of each current key node are set in the node class in advance. In the node class, for any current key node, the association relationship between the child node ID and the parent node ID of the current key node can be set in advance; then when it is necessary to obtain the node data of a key node, the associated parent node ID is queried according to the node ID of the key node, and the node data of all child node IDs under the parent node ID are obtained in the preset traversal order. This ensures the comprehensiveness of the acquired data and ensures that there will be no gaps in the data update process, thereby ensuring the accuracy of risk control.
[0166] Based on the same inventive concept, the present invention also provides a device for improving the accuracy of risk control, see Example 2 for details.
[0167] Embodiment 2
[0168] This embodiment provides a device for improving the accuracy of risk control, such as Figure 2 As shown, the device includes: a creation unit 21, a building unit 22, a storage unit 23, a determination unit 24, a search unit 25 and an execution unit 26; wherein,
[0169] A creation unit 21, used to create a node class before executing the risk control strategy, wherein the node class includes a plurality of key nodes;
[0170] The establishing unit 22 is used to establish a node variable of the current key node in the node class for any current key node, and assign a value to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0171] A storage unit 23 is used to obtain the node data of the current key node and store the node data in a storage object of the node class, where the storage object is a map object;
[0172] The determination unit 24 is used to receive the target child node ID of the target key node when the risk control strategy needs to be executed, and determine the target parent node ID of the target child node ID in the node class.
[0173] A search unit 25 is used to perform traversal based on a preset traversal order and the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID; based on the target parent node ID and all child node IDs contained under the target parent node ID, search for corresponding node data from the storage object;
[0174] The execution unit 26 is used to execute the risk control strategy based on the found node data.
[0175] Since there are many key nodes in the risk control scenario, and there are many data and types, before creating the node class, the creation unit 21 is also used to:
[0176] Determine the types of all key nodes and store the types of key nodes in the form of enumeration types;
[0177] Create a namespace, and create at least one static variable in the namespace; the static variable is a string of static constants;
[0178] At least one static variable is used to name the type of the corresponding key node.
[0179] Specifically, in order to save memory space, the types of key nodes are stored in the form of enumeration types, and the key nodes may include: registration nodes, login nodes, first recharge nodes, and the like.
[0180] First, define an enumeration type NodeType and use the uint16_t type for storage. Since the uint16_t type only occupies 2 bytes, it can save memory space. The storage code is implemented as follows:
[0181] enum class NodeType:uint16_t{
[0182] Register; Register node
[0183] Login; Login node
[0184] FirstCharge, the first recharge node
[0185] …
[0186] }
[0187] Here, the registration node is the first key node, and the value assigned to the registration node is 0; the login node is the second key node, and the value assigned to the login node is 1, and so on, it increases in sequence until the last stored key node is assigned a value.
[0188] When using enumeration type to store key nodes, the key node is an integer, which is not readable, so a conversion interface needs to be created to convert the enumeration type into a readable string. When creating a conversion interface, many global static variables need to be defined. In order not to pollute the variable name of the entire program, a namespace is created, and at least one static variable is created in the namespace; the global static variables in the namespace correspond to the conversion interface, and the static variables in the namespace can only be called through the call request of this conversion interface.
[0189] Here, static variables are used to name the types of the corresponding key nodes. The static variables are static constant strings, which are static and constant const types. This allows static variables to be initialized before the program starts, and these names will not change as the program runs. The specific code implementation is as follows:
[0190] namespace{
[0191] static const string kNodeRegister = "Register"; Register node
[0192] static const string kNodeLogin = "Login"; Login node
[0193] static const string kNodeFirstCharge = "FirstCharge"; first charge node
[0194] }
[0195] It can be seen from the code that static const string kNodeRegister, static conststring kNodeLogin, and static const string kNodeFirstCharge are corresponding static variables.
[0196] After at least one static variable is used to name the type of the corresponding key node, in order to ensure that the caller can accurately call the required key node, the method further includes:
[0197] Create a query interface;
[0198] Receive a query request, determine whether the query request carries a valid key node type, and return a null value if the query request does not carry a valid key node type;
[0199] If the query request carries a valid key node type, the corresponding static variable is returned according to the query request.
[0200] Here, when returning the corresponding static variable, the return value must be modified with constants const and & to prevent the returned string from being copied or modified. The specific code implementation is as follows:
[0201] const string&getNodeTypeString(NodeType type){
[0202] static const std::string kInvalidType = ""; empty string variable ""
[0203] Switch(type){
[0204] Case NodeType::Register:return kNodeRegister; if it is a registered node, return the registered node variable
[0205] Case NodeType::Login:return kNodeLogin; if it is a login node, return the login node variable
[0206] Case NodeType::FirstCharge:return kNodeFirstCharge; if it is the first charge node, return the first charge node variable}
[0207] return kInvalidType; if no corresponding node is found, the defined default variable is returned
[0208] }
[0209] In this way, if there are new key nodes in the future, the type of the key nodes can be directly added in the namespace, and each key node type exists in the namespace in text form; for example, if the type of the key node is a registration node, the text format is: Register,"Register"; the first Register is the name of the type, and the second "Register" is the corresponding string.
[0210] Then, the script parses the text to generate the above-mentioned NodeType code, kNodeRegister variable code, and getNodeTypeString query interface code; in this way, it is not necessary to modify the namespace content but only the specific code implementation to add key nodes, which reduces the workload of the staff and also improves the accuracy of the code.
[0211] After the key node type is determined, since each key node may contain multiple data, it is necessary to store the key node data. For example, for a login node, the login ID, user name, login password, etc. need to be stored.
[0212] Then, before executing the risk control strategy, the creation unit 21 creates a node class KeyNode, uses the node class to encapsulate data, and the node class includes multiple key nodes.
[0213] For any current key node, the establishment unit 22 establishes a node variable of the current key node in the node class class KeyNode and assigns a value to the node variable. The node variables include: node state variable, node type variable, child node ID variable, parent node ID variable, start time variable, and end time variable. The specific code implementation is as follows:
[0214]
[0215]
[0216] It can be seen from the above code that before establishing the node variable of the current key node in the node class, the establishment unit 2 is also used to:
[0217] Create a state variable state of enumeration type;
[0218] Determine the type of the state variable and assign a corresponding state identification value to each type of the state variable; wherein the types of the state variable include: not started NOT_STARTED, started STARTED and ended ENDED; then the state identification value corresponding to NOT_STARTED can be 0, the state identification value corresponding to STARTED can be 1, and the state identification value corresponding to ENDED can be 2.
[0219] After the node variable is created, the establishment unit 22 needs to assign values to the node variable, including:
[0220] Obtaining a state identification value, and assigning the state identification value to the node state variable;
[0221] Calling the constructor will pass in the node type and assign the node type to the node type variable;
[0222] Generate a function static atomic using the node ID in the constructor<uint32_t> num(0), id_=num++ generates a child node ID for the current key node, and assigns the child node ID to the child node ID variable;
[0223] Determine the parent node ID of the child node ID, and assign the parent node ID to the parent node ID variable;
[0224] Create a start interface and an end interface of the current key node, use the start interface to obtain the start time of the current key node, and use the end interface to obtain the end time of the current key node;
[0225] Assign the start time to the start time variable and the end time to the end time variable.
[0226] The corresponding code implementation of the assignment process is as follows:
[0227]
[0228] From the above code, the constructor is explicit KeyNode(NodeType type,uint32_tparentid=0), and the node ID generation function of the constructor is static atomic<uint32_t> num(0), a static variable of the num constructor, static is the variable type of num, indicating that num is a static variable; atomic is the operation type of the static variable, id_=num++ is the self-increment function of the child node ID.
[0229] Use the constructor to pass in the current key node type and provide the unique id of the parent node; since some key nodes do not require a parent node, the default value is 0, indicating that there is no parent node. Use type_=type; parent_id_=parentid; to assign the corresponding node variable. Among them, the child node ID and the parent node ID are corresponding. If a node is the parent node of another node, then the child node ID is passed to the other node. This ensures that the required data space is minimized and that the ID of each node is unique.
[0230] In this way, a static variable num is defined in the constructor. Since the static variable may be called by multiple threads at the same time, in order to ensure the calling efficiency and improve the calling performance, the static variable is of atomic operation type. Then, when multiple threads call the static variable of atomic operation type at the same time, each thread can call it at the same time without locking, thereby improving the system performance. id_=num++ Then the child node ID of each key node is incremented by this variable; for example, if the child node ID of key node A is 1, and B is the next key node of A, then the child node ID of key node B is 2. In this way, it is equivalent to that the ID of each key node is automatically assigned and increases sequentially to avoid omissions.
[0231] After assigning values to each node variable, the storage unit 23 needs to obtain the node data of the current key node and store the node data in the storage object of the node class, which is a map object. The structure of the map object is: map<DataType,SrcData> srcData_. DataType is the key value, SrcData is the corresponding value, which is the real node data, and srcData_ is a storage variable that stores any data type. In this way, node data of different data types can be stored.
[0232] Since the data types of node data include multiple types, in order to facilitate the caller to call data, when storing node data, template parameters are used for storage. This is equivalent to providing a unified interface to the outside world. The caller does not need to find out what type of data the data is before calling, and then look for the corresponding type of interface, which improves the calling efficiency. When storing, the code is implemented as follows:
[0233]
[0234] For example, when the key nodes are login nodes and registration nodes, the storage format can be:
[0235] KeyNode keynode((NodeType::Register));
[0236] int64_t data(45);
[0237] keynode.addSrc(DataType::Register,data);
[0238] Keynode.start(getCurrentTime();
[0239] String data("testdata");
[0240] keynode.addSrc(DataType::Login,data);
[0241] Here, since the present invention stores node variables and node data separately, when storing node data, it is also necessary to define it in the node class:
[0242] class KeyNode{
[0243] struct SrcData{SrcData
[0244] variant <int64_t,string,vector <string>>value_;
[0245] SrcData(T value):value_(<int64_t>(value)){}
[0246] SrcData(const std::string&value):value_(value){}
[0247] SrcData(const std::vector <std::string>&value):value_(value){}
[0248] }
[0249] Since the node data is the data in the risk control scenario, the variable type variant is used. The present invention uses three data types: the int64_t integer type can satisfy all integer types such as bool, int, uint32_t, uint64_t, etc.;
[0250] string can satisfy the string type; vector <string>It is a dynamic array that can support string arrays with variable length. Based on the above three data types, it can basically cover all types of node data.
[0251] After the node data is stored, when the risk control strategy needs to be executed, the determination unit 24 is used to receive the target child node ID of the target key node or the node name of the target key node, and determine the target parent node ID of the target child node ID in the node class. Among them, for any key node, since the node class contains the chain relationship between the child node ID of the node and the ID of other key nodes to form a node tree structure, the target parent node ID of the target child node ID can be determined.
[0252] In order to ensure the comprehensiveness of the node data, after obtaining the target parent node ID, the search unit 25 is used to traverse from top to bottom in the tree structure based on the preset traversal order and the target parent node ID as the reference to determine all the child node IDs contained under the target parent node ID; or,
[0253] Based on the target child node ID, traverse from bottom to top in the tree structure to determine all child node IDs contained under the target parent node ID.
[0254] The search unit 25 is used to search for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID.
[0255] Here, before searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID, the creation unit 21 also needs to create a read interface so that the search unit 25 can use the read interface to obtain the corresponding node data. The code implementation for creating the read interface is as follows:
[0256] template<typename T>
[0257] bool readIntSrc(DataType key,T&dest)const{
[0258] static_assert(is_integral <t>::value&&!is_same<T,bool> ::value,)
[0259] That is, the caller only needs to pass in the data type key of the required data, and the search unit 25 will return the corresponding value.
[0260] When the search unit 25 reads data, it reads it through a visitor, so it is necessary to create a visitor. The creation process is as follows:
[0261]
[0262] The reading process is as follows:
[0263]
[0264] If the corresponding node data is found, a true value is returned.
[0265] Because the visitor needs to consider different types of data when reading data, after reading the data, it needs to convert the data into the required data type. The code is as follows:
[0266]
[0267] Here, in order to prevent the caller from passing in unsupported data types and causing the program to crash, after receiving the key value, it is necessary to determine whether the data type is an abnormal type. The code is implemented as follows:
[0268] T operator()(const std::vector <std::string>&)const{
[0269] throw_exception <exception>("This type is not supported");}
[0270] If const and & are called and the current data type is determined to be an abnormal type, an exception will be thrown to prompt the caller that the call of this data type is not supported.
[0271] After searching the storage object for corresponding node data based on the target parent node ID and all child node IDs contained under the target parent node ID, the method further includes:
[0272] The corresponding data conversion function is used to convert the node variable data of the key node into a readable string. The code is implemented as follows:
[0273]
[0274] Furthermore, for a certain user, if the search unit 25 wants to search for the node data of all key nodes of the user, it can be implemented by using the read function Void savetosqlite(){sqlite->insert(id,type,start,end,parentid,srcdata);}.
[0275] After finding the node data of the current key node, the execution unit 26 is used to execute the risk control strategy based on the node data found. In this way, the search based on the tree structure ID ensures that the found data is relatively comprehensive, and there will be no data gap even after the data is updated (such as changing the login password), thereby improving the accuracy of risk control.
[0276] For example, if a user frequently logs in from a different location, receives gifts from a live streaming platform, etc., combined with data from other key nodes (such as frequently changing login passwords), it can be determined that the user is at a higher risk. The output risk result is high risk, and the user may need to be blocked.
[0277] In addition, after outputting the risk results, the version number of the node data can also be added to the risk structure for staff reference. For example, before a user changes his password, the version number of the node data obtained is 1.0, and after changing his password, the version number of the node data obtained is 2.0. When risk control is determined by node data with version number 1.0, the risk result can carry version number 1.0; when risk control is determined by node data with version number 2.0, the risk result can carry version number 2.0. This is more conducive to comparison by staff and obtaining risk results with higher credibility.
[0278] The node variables of each current key node are set in the node class in advance. In the node class, for any current key node, the association relationship between the child node ID and the parent node ID of the current key node can be set in advance; then when it is necessary to obtain the node data of a key node, the associated parent node ID is queried according to the node ID of the key node, and the node data of all child node IDs under the parent node ID are obtained in the preset traversal order. This ensures the comprehensiveness of the acquired data and ensures that there will be no gaps in the data update process, thereby ensuring the accuracy of risk control.
[0279] Embodiment 3
[0280] This embodiment provides a computer device, such as Figure 3 As shown, it includes a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor 320. When the processor 320 executes the computer program 311, the following steps are implemented:
[0281] Before executing the risk control strategy, create a node class, which includes multiple key nodes;
[0282] For any current key node, a node variable of the current key node is established in the node class, and a value is assigned to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0283] Obtain node data of the current key node, and store the node data in a storage object of the node class, where the storage object is a map object;
[0284] When the risk control strategy needs to be executed, a target child node ID of a target key node is received, and a target parent node ID of the target child node ID is determined in the node class;
[0285] Based on a preset traversal order, traverse the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID;
[0286] Searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID;
[0287] The risk control strategy is executed based on the found node data.
[0288] In the specific implementation process, when the processor 320 executes the computer program 311, any implementation method in the first embodiment can be implemented.
[0289] Since the computer device introduced in this embodiment is a device used to implement a method for improving the accuracy of wind control in the first embodiment of this application, based on the method introduced in the first embodiment of this application, a person skilled in the art can understand the specific implementation of the computer device of this embodiment and its various variations, so how the server implements the method in the embodiment of this application is not described in detail here. As long as the device used by a person skilled in the art to implement the method in the embodiment of this application is within the scope of protection of this application.
[0290] Based on the same inventive concept, the present application provides a storage medium corresponding to the first embodiment, see the fourth embodiment for details.
[0291] Embodiment 4
[0292] This embodiment provides a computer-readable storage medium 400, such as Figure 4 As shown, a computer program 411 is stored thereon, and when the computer program 411 is executed by a processor, the following steps are implemented:
[0293] Before executing the risk control strategy, create a node class, which includes multiple key nodes;
[0294] For any current key node, a node variable of the current key node is established in the node class, and a value is assigned to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable;
[0295] Obtain node data of the current key node, and store the node data in a storage object of the node class, where the storage object is a map object;
[0296] When the risk control strategy needs to be executed, a target child node ID of a target key node is received, and a target parent node ID of the target child node ID is determined in the node class;
[0297] Based on a preset traversal order, traverse the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID;
[0298] Searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID;
[0299] The risk control strategy is executed based on the found node data.
[0300] In the specific implementation process, when the computer program 411 is executed by the processor, any implementation method in Example 1 can be implemented.
[0301] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0302] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0303] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0304] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0305] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0306] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.< / exception> < / std::string> < / t> < / string> < / std::string> < / string> < / exception> < / std::string> < / t> < / string> < / std::string> < / string>
Claims
1. A method for improving the accuracy of risk control, characterized in that: Applied in a live broadcast platform, the method includes: Before executing the risk control strategy, create a node class, which includes multiple key nodes; For any current key node, a node variable of the current key node is established in the node class, and a value is assigned to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable; Obtain node data of the current key node, and store the node data in a storage object of the node class, where the storage object is a map object; When the risk control strategy needs to be executed, a target child node ID of a target key node is received, and a target parent node ID of the target child node ID is determined in the node class; Based on a preset traversal order, traverse the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID; Searching for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID; The risk control strategy is executed based on the found node data.
2. The method according to claim 1, characterized in that Before creating the node class, include: Determine the types of all the key nodes, and store the types of the key nodes in the form of enumeration types; Create a namespace, and create at least one static variable in the namespace; the static variable is a string of static constants; The type of the corresponding key node is named using the at least one static variable.
3. The method according to claim 2, characterized in that After the type of the key node corresponding to the at least one static variable is named, the method further includes: Create a query interface; Receive a query request, determine whether the query request carries a valid key node type, and return a null value if the query request does not carry a valid key node type; If the query request carries a valid key node type, the corresponding static variable is returned according to the query request.
4. The method according to claim 1, characterized in that Before establishing the node variable of the current key node in the node class, the method further includes: Create a state variable state of enumeration type; Determine the type of the state variable, and assign a corresponding state identification value to each type of the state variable; wherein the type of the state variable includes: not started, started, and ended.
5. The method according to claim 1, characterized in that The assigning of a value to the node variable comprises: Obtaining a state identification value, and assigning the state identification value to the node state variable; The constructor is called to pass in the node type, and the node type is assigned to the node type variable; Generate a function static atomic using the node ID in the constructor<uint32_t> num(0), id_=num++ generates a child node ID for the current key node, and assigns the child node ID to the child node ID variable; num is a static variable of the constructor, static is the variable type of num, atomic is the operation type of the static variable, and id_=num++ is the self-increment function of the child node ID; Determine the parent node ID of the child node ID, and assign the parent node ID to the parent node ID variable; Creating a start interface and an end interface of the current key node, using the start interface to obtain the start time of the current key node, and using the end interface to obtain the end time of the current key node; The start time is assigned to the start time variable, and the end time is assigned to the end time variable.
6. The method according to claim 1, characterized in that The storing the node data in the storage object of the node class includes: Obtaining the data type contained in the node data; The data type is used as the key value, and the node data corresponding to the data type is stored as the value in the storage object SrcData.
7. The method according to claim 1, characterized in that After searching the storage object for corresponding node data based on the target parent node ID and all child node IDs contained under the target parent node ID, the method further includes: The node variable data of the key node is converted into a readable character string using a corresponding data conversion function.
8. A device for improving the accuracy of risk control, characterized in that: The device comprises: A creation unit, used to create a node class before executing the risk control strategy, wherein the node class includes a plurality of key nodes; An establishing unit, for establishing a node variable of the current key node in the node class for any current key node, and assigning a value to the node variable; the node variable includes: a node state variable, a node type variable, a child node ID variable, a parent node ID variable, a start time variable, and an end time variable; A storage unit, used for acquiring node data of the current key node, and storing the node data in a storage object of the node class, wherein the storage object is a map object; A determination unit is used to receive the target child node ID of the target key node when the risk control strategy needs to be executed, and determine the target parent node ID of the target child node ID in the node class. A search unit, configured to perform a traversal based on a preset traversal order and the target parent node ID as a reference to determine all child node IDs contained under the target parent node ID; and search for corresponding node data from the storage object based on the target parent node ID and all child node IDs contained under the target parent node ID; An execution unit is used to execute the risk control strategy based on the found node data.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Database query method and device, server and medium
CN110471916A
Data searching method and device of tree structure for hospital logistics operation and maintenance
CN111274242A