Method and system for mutual indexing of lookup table fields
By automatically detecting the reference relationship in the configuration table, the problem of low detection efficiency of configuration table index relationship in game development is solved, efficient configuration table management is realized, manual errors are reduced, and project progress is improved.
Patent Information
- Application Number
- CN202311208565.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2025-03-21
AI Technical Summary
In game development, the index relationship detection efficiency of fields in the configuration table is low, configuration errors are prone to occur, and manual detection and modification efficiency is low.
Provides a method and system for finding table fields to index each other. By automatically detecting the reference relationship in the configuration table, avoiding manual filling of reference relationships, and using script file cache and regular expressions to extract referenced table names and field names.
It realizes automatic detection of configuration table index relationships, saves time, reduces the probability of errors, improves the processing efficiency of adding, deleting and modifying configuration tables, and speeds up project progress.
Smart Images

Figure CN119668667A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer communication, and in particular to a method and system for searching mutual indexes of table fields. Background Art
[0002] In game development, it is often necessary to configure data in a field in a configuration table. The configuration data is indexed to the configuration data of a field in another configuration table. The configuration is nested based on the two identical configuration data. If a field in another configuration table that needs to be indexed does not have the same configuration data, a configuration error will occur. If you manually detect whether there is an index configuration error or wait for the program to run and an error occurs when reading the corresponding configuration data of the corresponding field in the index configuration table, the efficiency of modifying the index configuration error is relatively low. Tools are usually used to detect whether there is an index configuration error. To use tools to detect index configuration, you need to know which field of which table the current configuration data of the current field of the current table corresponds to. The commonly used method is to add a type configuration of the configuration field in the configuration table. The type configuration corresponds to a field in other configuration tables. This is labor-intensive, error-prone, and troublesome to modify. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides a method and system for looking up mutual indexes of table fields, which can automatically detect the reference relationship when it is necessary to detect the index of other configuration tables in the configuration table, avoiding adding fields to manually fill in the reference relationship.
[0004] The present invention is implemented by the following technical solutions:
[0005] A method for finding mutual indexes of table fields, the method comprising the following steps:
[0006] Step S1, read all script files and cache them;
[0007] Step S2, read the table name and field name of the table to be indexed;
[0008] Step S3, traverse all script files in step S1, search and record the script file that references the table name read in step S2;
[0009] Step S4, for the script file recorded in step S3, search line by line whether there is a field name obtained in step S2, and if so, read the table name and field name referenced by the obtained field name;
[0010] Step S5, repeating steps S2 to S4, traversing and detecting the table names and field names of all indexes;
[0011] Step S6: If the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
[0012] Preferably, the step S1 is further specified as follows: reading all script files according to the program script project path, and using the .NET file reading and writing library to read all lines of scripts in all script files and cache them.
[0013] Preferably, the step S4 is further specifically as follows: reading the referenced table name in the following manner:
[0014] Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of the "="; for the string outside the "()" in the obtained string, split it using "." as a delimiter to obtain the string on the left side of the ".", which is the table name.
[0015] Preferably, the step S4 is further specifically: reading the referenced field name in the following manner:
[0016] The string in “()” is extracted from the obtained string using a regular expression, and is split using “,” as a delimiter, so that the string on the left side of “,” is the parameter name of the indexed table.
[0017] A system for looking up table fields that index each other, the system comprising a reading module A, a reading module B, a lookup module A, a lookup module B, a repeat module, and a detection module;
[0018] Read module A, read all script files and cache them;
[0019] Read module B, read the table name and field name of the table to be indexed;
[0020] Search module A, traverses all script files in step S1, searches for and records the script file that references the table name read in step S2;
[0021] Search module B, for the script file recorded in step S3, searches line by line whether there is a field name obtained in step S2, and if so, reads the table name and field name referenced by the obtained field name;
[0022] The repeat module, the repeat read module B, the search module A, and the search module B traverse and detect the table names and field names of all indexes;
[0023] In the detection module, if the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
[0024] Preferably, the reading module A is further specifically configured to: read all script files according to the program script project path, and use the .NET file reading and writing library to read all lines of scripts and cache the contents in all script files.
[0025] Preferably, the search module B is further specifically: reading the referenced table name in the following manner:
[0026] Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of the "="; for the string outside the "()" in the obtained string, split it using "." as a delimiter to obtain the string on the left side of the ".", which is the table name.
[0027] Preferably, the search module B is further specifically: reading the referenced field name in the following manner:
[0028] The string in “()” is extracted from the obtained string using a regular expression, and is split using “,” as a delimiter, so that the string on the left side of “,” is the parameter name of the indexed table.
[0029] Beneficial effects of the present invention:
[0030] The present invention provides a method and system for looking up mutual indexes of table fields, which can automatically detect the reference relationship when it is necessary to detect the indexes of other configuration tables in the configuration table, avoid adding fields to manually fill in the reference relationship, save time and reduce the error probability compared to manually filling in the reference relationship, and can use tools to handle the addition, deletion and modification of the configuration table, thereby speeding up the project progress. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic flow chart of the method of the present invention.
[0032] Figure 2 It is a system principle block diagram of the present invention.
[0033] Figure 3 This is an example of the Goods field in the c_shop_goods table. DETAILED DESCRIPTION
[0034] The present invention will be further described below in conjunction with the accompanying drawings.
[0035] See also Figure 1 , Figure 3 The present invention provides a method for looking up table fields for mutual indexing, the method comprising the following steps:
[0036] Step S1, read all script files and cache them;
[0037] Step S2, read the table name and field name of the table to be indexed;
[0038] Step S3, traverse all script files in step S1, search and record the script file that references the table name read in step S2;
[0039] Step S4, for the script file recorded in step S3, search line by line whether there is a field name obtained in step S2, and if so, read the table name and field name referenced by the obtained field name;
[0040] Step S5, repeating steps S2 to S4, traversing and detecting the table names and field names of all indexes;
[0041] Step S6: If the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
[0042] The present invention will be further described below in conjunction with a specific embodiment:
[0043] The present invention provides a method for looking up table fields to index each other.
[0044] 1. Read all script files and cache them;
[0045] 1.1. Read all script files according to the program script project path, and use the .NET file reading and writing library to read all lines of scripts and cache the contents of all script files.
[0046] Read all script files according to the program script project path, and use the .NET file reading and writing library (such as File) to read all lines of scripts in all script files and cache them (use the existing technology DirectoryInfo to read the folder where the script of the current game project is located, and use the GetFiles function to pass the script format in its parameter, which can be a .lua string, to read all scripts).
[0047] 2. Read the table name and field name of the table to be indexed;
[0048] Read the table name and field name of the index to be detected.
[0049]
[0050]
[0051]
[0052]
[0053] 3. Traverse all script files in step 1, find and record the script file that references the table name read in step S2.
[0054] Traverse all script contents cached in step 1 to find out whether there is a reference to the table name to be indexed in step 2. If there is a reference to the table name, record these scripts. Take the Goods field of the c_shop_goods.csv table as an example; Figure 3 shown.
[0055] 4. For the script file recorded in step 3, check line by line whether there is a field name obtained in step S2. If there is, read the table name and field name referenced by the obtained field name;
[0056] 4.1. Read the referenced table name in the following way:
[0057] Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of the "="; split the string outside the "()" in the obtained string using "." as a delimiter to obtain the string on the left side of the ".", which is the table name;
[0058] 4.2. Read the referenced field name in the following way:
[0059] The string in “()” is extracted from the obtained string using a regular expression, and is split using “,” as a delimiter, so that the string on the left side of “,” is the parameter name of the indexed table.
[0060] For the scripts recorded in step 3, check line by line whether there is a field name obtained in step 2. If so, read the reference table and field name for the obtained field name, such as the Goods field of the c_shop_goods table in the example. Figure 3 As shown;
[0061] (1) Search for the configuration table name in the code line where the obtained field name appears (use '=' as a delimiter to split the string. The next string after the split is ItemLoader.GetConfig("itemId", shopgoods.Goods). Then use '.' to split the string. The first string is the name of the indexed configuration table);
[0062] (2) Extract parameters from the function that obtains index configuration data (use regular expression string to extract the content inside (), split it by ","). The first half is the parameter name of the index table.
[0063] Here are two of the lines of code:
[0064] local shopgoods=shopGoodsLoader.GetConfig("Goods",100001);
[0065] local itemConfig=shopgoods.GetConfig("ItemId",shopgoods.Goods).
[0066] It should be noted that the code function for reading configuration index data in the code is a function used by the business code to read configuration data as a parameter, such as the GetConfig function in the above code line.
[0067] 5. Repeat steps S2 to S4 to traverse and detect the table names and field names of all indexes;
[0068] In this way, all index tables and field names of the field are recorded. Steps 2 to 4 are repeated to traverse all fields of all tables, and the values of the fields of all index tables of the fields of all tables are detected.
[0069] 6. If the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface will display the field configuration value of the index empty reference;
[0070] If the value of the field of the detected table does not exist in the corresponding field of the index table, it can be exposed in the display interface.
[0071] Please continue reading Figure 2 ,The present invention also provides a system for mutual indexing of fields in a lookup table, the system comprising a reading module A, a reading module B, a lookup module A, a lookup module B, a repeat module, and a detection module;
[0072] Read module A, read all script files and cache them;
[0073] Read module B, read the table name and field name of the table to be indexed;
[0074] Search module A, traverses all script files in step S1, searches for and records the script file that references the table name read in step S2;
[0075] Search module B, for the script file recorded in step S3, searches line by line whether there is a field name obtained in step S2, and if so, reads the table name and field name referenced by the obtained field name;
[0076] The repeat module, the repeat read module B, the search module A, and the search module B traverse and detect the table names and field names of all indexes;
[0077] In the detection module, if the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
[0078] The reading module A is further specifically configured to read all script files according to the program script project path, and use the .NET file reading and writing library to read all lines of scripts and cache the contents in all script files.
[0079] The search module B is further specifically configured to read the referenced table name in the following manner:
[0080] Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of the "="; for the string outside the "()" in the obtained string, split it using "." as a delimiter to obtain the string on the left side of the ".", which is the table name.
[0081] The search module B is further specifically configured to read the referenced field name in the following manner:
[0082] The string in “()” is extracted from the obtained string using a regular expression, and is split using “,” as a delimiter, so that the string on the left side of “,” is the parameter name of the indexed table.
[0083] In summary, the present invention can automatically detect the reference relationship when it is necessary to detect the index of other configuration tables in the configuration table, avoiding adding fields to manually fill in the reference relationship. Compared with manually filling in the reference relationship, it can save time and reduce the probability of errors. When adding, deleting and modifying the configuration table, the tool can be used for processing, which speeds up the project progress.
[0084] The above description is only a preferred embodiment of the present invention and should not be construed as limiting the present application. All equivalent changes and modifications made within the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for finding mutual indexes of table fields, characterized in that: The method comprises the following steps: Step S1, read all script files and cache them; Step S2, read the table name and field name of the table to be indexed; Step S3, traverse all script files in step S1, search and record the script file that references the table name read in step S2; Step S4, for the script file recorded in step S3, search line by line whether there is a field name obtained in step S2, and if so, read the table name and field name referenced by the obtained field name; Step S5, repeating steps S2 to S4, traversing and detecting the table names and field names of all indexes; Step S6: If the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
2. A method for mutual indexing of lookup table fields according to claim 1, characterized in that: The step S1 is further specifically as follows: reading all script files according to the program script project path, and using the .NET file reading and writing library to read all lines of scripts in all script files and cache them.
3. A method for mutual indexing of fields in a lookup table according to claim 1, characterized in that: The step S4 is further specifically as follows: reading the referenced table name in the following manner: Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of "="; for the string outside "()" in the obtained string, split it using ".." as a delimiter to obtain the string on the left side of "..", which is the table name.
4. A method for mutual indexing of fields in a lookup table according to claim 3, characterized in that: The step S4 is further specifically as follows: reading the referenced field name in the following manner: Use a regular expression to extract the string in "()" from the obtained string, split it using "," as a delimiter, and obtain the string on the left side of "," which is the parameter name of the indexed table.
5. A system for indexing each other in a lookup table, characterized in that: The system includes a reading module A, a reading module B, a searching module A, a searching module B, a repeating module, and a detecting module; Read module A, read all script files and cache them; Read module B, read the table name and field name of the table to be indexed; Search module A, traverses all script files in step S1, searches for and records the script file that references the table name read in step S2; Search module B, for the script file recorded in step S3, searches line by line whether there is a field name obtained in step S2, and if so, reads the table name and field name referenced by the obtained field name; The repeat module, the repeat read module B, the search module A, and the search module B traverse and detect the table names and field names of all indexes; In the detection module, if the corresponding field of the indexed table does not have the value of the corresponding field of the detected table, the display interface displays the field configuration value of the index empty reference.
6. A system for mutual indexing of lookup table fields according to claim 5, characterized in that: The reading module A is further specifically configured to read all script files according to the program script project path, and use the .NET file reading and writing library to read all lines of scripts and cache the contents in all script files.
7. A system for mutual indexing of lookup table fields according to claim 5, characterized in that: The search module B is further specifically configured to read the referenced table name in the following manner: Search for the configuration table name in the code line where the acquired field name appears, split it using the "=" in the code line as a delimiter to obtain the string on the right side of "="; for the string outside "()" in the obtained string, split it using ".." as a delimiter to obtain the string on the left side of "..", which is the table name.
8. A system for mutual indexing of lookup table fields according to claim 7, characterized in that: The search module B is further specifically configured to read the referenced field name in the following manner: Use a regular expression to extract the string in "()" from the obtained string, split it using "," as a delimiter, and obtain the string on the left side of "," which is the parameter name of the indexed table.