Data access method, computer device and storage medium
By acquiring the preset attributes of the target data and utilizing the target index in the index storage area, batch access to data defined in multiple program files in embedded software is achieved, solving the problem of low data access efficiency in existing technologies and improving access speed and efficiency.
Patent Information
- Application Number
- CN202210895427.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-07-26
AI Technical Summary
In embedded software, when accessing data defined in multiple program files, existing technologies require declaration in each program file, resulting in low data access efficiency.
By obtaining the preset attributes of the target data, querying the preset index storage area, and using the target index to access the target data, batch access to data with preset attributes defined in other program files can be achieved, avoiding the need to pre-declare the data to be accessed.
It improves the efficiency of data access, reduces the number of declarations in the program file, and increases access speed and efficiency.
Smart Images

Figure CN115357928B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data processing, and in particular to a data access method, a computer device and a storage medium. BACKGROUND
[0002] In embedded software, the software code used is usually distributed in multiple program files. A user can define some data in a program file according to actual needs, and the defined data can be used in the program file. If other program files need to access the data defined by the program file, the data to be accessed needs to be declared in the other program files.
[0003] When a program file needs to access a large number of data defined by other program files, it is inevitable that the efficiency of accessing data will be reduced because the data to be accessed needs to be declared one by one in the program file.
[0004] Therefore, how to improve the efficiency of data access has become a problem to be solved. SUMMARY
[0005] The present application provides a data access method, device, computer device and storage medium. By accessing data defined by other program files according to a target index corresponding to target data, batch access of data defined by other program files and having a preset attribute can be realized without pre-declaring the data to be accessed, and the efficiency of data access is improved.
[0006] In a first aspect, the present application provides a data access method, which comprises:
[0007] obtaining a preset attribute of target data to be accessed, the target data comprising one or more initial data, the initial data being defined by each program file and stored respectively;
[0008] querying a preset index storage area according to the preset attribute to obtain a target index corresponding to the target data, the indexes in the index storage area being constructed by the program files, the indexes corresponding to the initial data one by one, each index comprising a plurality of index parameters, each index parameter being used to represent an attribute of the corresponding initial data;
[0009] accessing the target data according to the target index.
[0010] In a second aspect, the present application further provides a data access device, which comprises:
[0011] an attribute obtaining module configured to obtain a preset attribute of target data to be accessed, the target data comprising one or more initial data, the initial data being defined by each program file and stored respectively;
[0012] The index query module is configured to query a preset index storage area according to the preset attribute, and obtain a target index corresponding to the target data. The indexes in the index storage area are constructed by the program file, and each index corresponds to the initial data. Each index includes a plurality of index parameters, and each index parameter is used to represent the attribute of the corresponding initial data.
[0013] The data access module is configured to access the target data according to the target index.
[0014] In a third aspect, the present application further provides a computer device, which includes a memory and a processor.
[0015] The memory is configured to store a computer program.
[0016] The processor is configured to execute the computer program and implement the data access method as described above when executing the computer program.
[0017] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to make the processor implement the data access method as described above.
[0018] The present application discloses a data access method, device, computer device and storage medium. By obtaining a preset attribute of target data to be accessed, subsequent access to initial data with the same attribute defined by each program file can be realized according to the preset attribute. By querying a preset index storage area, a target index corresponding to the target data can be obtained, and an index with the preset attribute can be found in the index storage area. According to the target index, the target data can be accessed, and other data defined by other program files can be accessed in batches without pre-declaring the data to be accessed, thereby improving the efficiency of data access. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0020] Figure 1 is a schematic flowchart of a data access method provided by an embodiment of the present application;
[0021] Figure 2 is a schematic flowchart of a sub-step of determining a target index provided by an embodiment of the present application;
[0022] Figure 3 is a schematic flowchart of another sub-step of determining a target index provided by an embodiment of the present application;
[0023] Figure 4 is a schematic flowchart of a sub-step of constructing an index provided by an embodiment of the present application;
[0024] Figure 5 is a schematic block diagram of a data access device provided by an embodiment of the present application;
[0025] Figure 6 is a structural schematic block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0027] The flowcharts shown in the drawings are only exemplary and do not necessarily include all contents and operations / steps, nor do they necessarily need to be executed in the order described. For example, some operations / steps can be further decomposed, combined or partially merged, so the actual execution order may be changed according to the actual situation.
[0028] It should be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and the appended claims of the present application, unless otherwise clear from the context, the singular forms "a", "an" and "the" are intended to include the plural forms.
[0029] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0030] Embodiments of the present application provide a data access method, device, computer device and storage medium. The data access method can be applied to a server or a terminal, and by accessing data defined by other program files according to a target index corresponding to target data, batch access of data defined by other program files with a preset attribute can be realized without the need to declare the data to be accessed in advance, thereby improving the efficiency of data access.
[0031] The server can be a standalone server or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can be a mobile energy storage device, a household energy storage device, a smartphone, a tablet computer, a notebook computer, a desktop computer, and other electronic devices.
[0032] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following examples and features in the examples can be combined with each other without conflict.
[0033] As shown in Figure 1 The data access method includes steps S10 to S30.
[0034] Step S10, obtaining a preset attribute of target data to be accessed.
[0035] It should be noted that the data access method provided in the embodiments of the present application can be applied to the scenario of accessing data defined by other program files by a current program file. The current program file can access the data defined by other program files according to the target index corresponding to the target data with the preset attribute, realize batch access of the data defined by other program files, and does not need to declare the data to be accessed in advance in the current program file, thereby improving the efficiency of data access.
[0036] For example, when the current program file is executed, the preset attribute of the target data to be accessed in the current program file can be determined. The preset attribute of the target data can be written into the current program file in the form of code in advance. In the embodiments of the present application, the target data includes one or more initial data, and the initial data is defined by each program file and stored in the memory respectively. Each program file defines the attribute of the initial data when defining the initial data, such as data type, data name, data storage address, data size, etc. The program file can be a C program file, a C++ program file, or a program file in other programming languages, which is not limited herein.
[0037] For example, the preset attribute can include a preset data type, and can also include a preset data name, etc. For example, the preset data type can include, but is not limited to, integer, long integer, single-precision floating point, double-precision floating point, etc.
[0038] By obtaining the preset attribute of the target data to be accessed, subsequent access to the initial data defined by each program file with the preset attribute according to the preset attribute can be realized.
[0039] Step S20, querying the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data.
[0040] In the embodiment of the present application, the indexes in the index storage area are constructed by each program file, and the indexes correspond to the initial data one by one. Each index includes a plurality of index parameters, and each index parameter is used to represent the attribute of the corresponding initial data. Each index can point to the corresponding initial data. For example, when each program file defines the initial data, the index corresponding to the initial data is constructed at the same time. If the initial data has a plurality of attributes, the corresponding index has a plurality of index parameters, and the program file directly assigns the attributes of the initial data to the index parameters of the corresponding index.
[0041] For example, the target index corresponding to the target data can be obtained by querying the preset index storage area according to the preset attribute.
[0042] In the embodiment of the present application, an index storage area for storing indexes corresponding to the initial data can be created in the memory in advance. For example, the index storage area with the name DATA_SECTION can be created by the following statement: #define DATA_SECTION __attribute__((used, section (".data_section"))).
[0043] It should be noted that the indexes constructed by different program files are all stored in the same index storage area.
[0044] For example, the index parameters can include data type, pointer vector, data length, data name, and the like. The pointer vector is used to point to the access address of the initial data.
[0045] By querying the preset index storage area, the target index containing the preset attribute can be obtained, and the index corresponding to the target data in the index storage area can be found.
[0046] Step S30, accessing the target data according to the target index.
[0047] For example, after obtaining the target index corresponding to the target data, the target data can be accessed according to the index parameters in the target index. For example, the target data can be accessed in the memory according to the index parameters in the target index.
[0048] It should be noted that since the index parameters in the target index include the pointer vector pointing to the access address of the initial data, the target data can be accessed through the pointer vector. It can be understood that when the code is compiled, each initial data has an access address, and the access address is the address pointed to by the pointer vector.
[0049] By accessing the target data according to the index parameter in the target index, the data defined by other program files can be accessed in batches, and the data to be accessed does not need to be declared in advance, thereby improving the efficiency of data access.
[0050] The data access method provided by the above embodiment can obtain the preset attribute of the target data to be accessed, and subsequently access the initial data with the same attribute defined by each program file according to the preset attribute. By querying the preset index storage area, the target index corresponding to the target data is obtained, and the target data is accessed according to the target index. The data with the same attribute can be accessed in batches without the need to declare the data to be accessed in advance, thereby improving the efficiency of data access.
[0051] It should be noted that the preset attribute can be one or multiple. Therefore, in step S20, the target index can be determined by the preset data type, or the target index can be determined by the preset data name. According to actual needs, the target index can also be determined by the preset data type and the preset data name together. In the embodiments of the present application, only the manner of determining the target index will be described in detail.
[0052] Please refer to Figure 2 , Figure 2 is a schematic flow chart of a sub-step of determining the target index provided by the embodiments of the present application, and can include the following steps S201 and S202.
[0053] Step S201, poll the indexes in the index storage area to obtain the index parameter of each index.
[0054] For example, the indexes in the index storage area can be queried in sequence to obtain the index parameter corresponding to each index. For example, the data type, data name, pointer vector, and data length of each index can be obtained as the index parameter.
[0055] Step S202, determine the index including the preset data type in the index parameter as the target index.
[0056] In the embodiment, the preset attribute includes the preset data type. For example, when the preset data type is uint8_t, the index with the data type of uint8_t in the index parameter can be determined as the target index.
[0057] For example, when the preset data type is int8_t, the index with the data type of int8_t in the index parameter can be determined as the target index.
[0058] By determining the index including the preset data type in the index parameter as the target index, the target index matching the data type with the preset data type can be obtained, and subsequent batch access of target data of a specified type according to the target index can be implemented.
[0059] Referring to Figure 3 , Figure 3 is another schematic flowchart of a sub-step of determining a target index provided by the embodiment of the present application, and can specifically include the following steps S203 and S204.
[0060] Step S203, polling the indexes in the index storage area to obtain the index parameters of each index.
[0061] For example, the indexes in the index storage area can be sequentially queried to obtain the index parameters corresponding to each index.
[0062] For example, the data type, data name, pointer vector, and data length of each index can be obtained as the index parameters.
[0063] Step S204, determining the index including the preset data name in the index parameter as the target index.
[0064] In the embodiment, the preset attribute includes the preset data name. For example, when the preset data name is data1, the index with the data name data1 in the index parameter can be determined as the target index.
[0065] For example, when the preset data name is data2, the index with the data name data2 in the index parameter can be determined as the target index.
[0066] By determining the index including the preset data name in the index parameter as the target index, the target index determined according to the preset data name can be implemented, and subsequent batch access of target data of a specified data name according to the target index can be implemented.
[0067] It can be understood that in other embodiments, if the preset attribute includes the preset data name and the preset data type, the target index can also be determined according to the preset data type and the preset data name. For example, when the preset data type is uint8_t and the preset data name is data1, the index with the data type uint8_t and the data name data1 in the index parameter can be determined as the target index.
[0068] For example, when the preset data type is int8_t and the preset data name is data2, the index with the data type int8_t and the data name data2 in the index parameter can be determined as the target index.
[0069] By including the index of the preset data type and the preset data name in the index parameter, the target index is determined, so that the target index is determined according to the preset data type and the preset data name, and subsequent batch access of target data of the preset data type and the preset data name according to the target index can be implemented.
[0070] In some embodiments, before step S20, an index corresponding to the initial data also needs to be constructed. In the embodiments of the present application, how to construct the index corresponding to the initial data will be described in detail.
[0071] Please refer to Figure 4 , Figure 4 is a schematic flowchart of a sub-step of constructing an index corresponding to initial data provided by the embodiments of the present application, and can specifically include the following steps S205 and S206.
[0072] Step S205, defining each of the initial data to determine a plurality of data attributes of each of the initial data.
[0073] It should be noted that the initial data in each program file needs to be defined first before it can be used. It can be understood that the definition means allocating storage space for the initial data and specifying the data attributes of the initial data. For example, the data attributes of the initial data, such as data name, data type, pointer vector, and data length, are defined.
[0074] For example, each initial data can be defined to determine a plurality of data attributes of each initial data. For example, the data attributes of the initial data can be defined as (data_type, data_name, data_len), wherein data_type is the data type of the initial data, data_name is the data name of the initial data, data_name is the pointer vector of the initial data, and data_len is the data length of the initial data.
[0075] In the embodiments of the present application, the data type can also be represented by a serial number, wherein the serial number corresponding to the data type can be defined by the following statement:
[0076] #define DATA_TYPE_char 0 / / byte type
[0077] #define DATA_TYPE_uint8_t 1 / / unsigned 8-bit data
[0078] #define DATA_TYPE_int8_t 2 / / signed 8-bit data
[0079] #define DATA_TYPE_uint16_t 3 / / unsigned 16-bit data
[0080] #define DATA_TYPE_int16_t 4 / / unsigned 16-bit data
[0081] #define DATA_TYPE_uint32_t 5 / / unsigned 32-bit data
[0082] #define DATA_TYPE_int32_t 6 / / unsigned 32-bit data
[0083] #define DATA_TYPE_float 7 / / single-precision floating-point data.
[0084] Step S206, constructing an index corresponding to each initial data according to a plurality of data attributes of each initial data, and storing all the constructed indexes into the index storage area.
[0085] In some embodiments, constructing an index corresponding to each initial data according to a plurality of data attributes of each initial data can include: defining a plurality of index parameters of the index corresponding to each initial data, the plurality of index parameters and the plurality of data attributes of the initial data corresponding one by one; and assigning the plurality of data attributes of each initial data to the corresponding index parameters to obtain the index corresponding to each initial data.
[0086] For example, the plurality of index parameters of the index corresponding to each initial data can be defined as follows:
[0087]
[0088] Wherein, type represents the data type, p_data represents the pointer vector, len represents the data length, and name represents the data name.
[0089] For example, the plurality of data attributes of each initial data can be assigned to the corresponding index parameters to obtain the index corresponding to each initial data.
[0090] For example, when the values of the plurality of data attributes of the initial data are (uint8_t, userdata, 5), if the plurality of data attributes are assigned to the corresponding index parameters, the index corresponding to the initial data is obtained as follows:
[0091]
[0092]
[0093] According to the multiple data attributes of each initial data, an index corresponding to each initial data is constructed, and all the constructed indexes are stored in the index storage area, so as to assign the data attributes of the initial data to the index parameters of the corresponding indexes, and subsequently, the target index corresponding to the target data to be accessed can be determined by querying the index parameters in the index storage area.
[0094] It should be noted that, in the embodiments of the present application, in addition to defining each initial data first, and then constructing the corresponding index according to the multiple data attributes of each initial data, the macro definition operation can also be used to define the initial data and the index corresponding to the initial data simultaneously.
[0095] In some embodiments, before obtaining the target index corresponding to the target data according to the preset attribute by querying the preset index storage area, the method further comprises: performing a macro definition operation; wherein the macro definition operation performs the following steps: defining each initial data, and determining the multiple data attributes of each initial data; constructing the index corresponding to each initial data according to the multiple data attributes of each initial data, and storing all the constructed indexes in the index storage area.
[0096] For example, the macro definition operation is performed, and the obtained macro function is as follows:
[0097] #define REG_DATA(data_type,data_name,data_len) data_type data_name[data_len];\
[0098] const data_reg_t__data_reg_##data_name AUTO_REG_SECTION\
[0099] = {DATA_TYPE_##data_type, (void*)data_name, data_len, #data_name}.
[0100] REG_DATA(data_type,data_name,data_len) is used to define the initial data. The statement "data_type data_name[data_len]" is used to define the indexed multiple index parameters. The statement "const data_reg_t__data_reg_##data_name AUTO_REG_SECTION={DATA_TYPE_##data_type,(void*)data_name,data_len,#data_name}" is used to assign multiple data attributes of the initial data to the corresponding index parameters, and store the obtained index to the index storage area.
[0101] By performing the macro definition operation, the definition of the initial data and the construction of the index corresponding to the initial data can be completed at one time, the efficiency is improved, and when the index corresponding to the initial data needs to be constructed subsequently, the macro function can be directly replaced by the instruction in the macro definition by using the compiler.
[0102] In some embodiments, the step S30 of accessing the target data according to the target index can include: determining a target access address according to the pointer vector in the target index; and accessing the target data according to the target access address.
[0103] For example, the value corresponding to the pointer vector in the target index can be determined as the target access address. Then, the target data stored in the memory is accessed according to the target access address. The specific access method is not limited here.
[0104] By determining the target access address according to the pointer vector in the target index and accessing the target data according to the target access address, the target data can be accurately and quickly accessed, and the efficiency of data access is improved.
[0105] In some embodiments, the data access method provided by the embodiments of the present application can further include: when it is determined that any data attribute of the initial data is updated, updating the index corresponding to the initial data according to the updated data attribute.
[0106] For example, when the data name of the initial data data1 is updated, the index corresponding to the initial data data1 can be updated according to the updated data name. Here, updating the index includes updating the index parameter, for example, updating the data name in the index parameter.
[0107] For example, when the pointer vector of the initial data data2 is updated, the index corresponding to the initial data data2 can be updated according to the updated pointer vector. For example, the pointer vector in the index parameter is updated.
[0108] By updating the index corresponding to the initial data according to the updated data attribute when updating the data attribute of the initial data, it can be ensured that the data attribute of the initial data is consistent with the index parameter of the corresponding index, so that it can be avoided that the target data meeting the condition cannot be accessed due to inconsistency between the data attribute and the index parameter. At the same time, since the index is uniformly stored in the index storage area, when the data attribute of the initial data is updated, it is not necessary to update the declaration of the initial data in each program file that needs to access the initial data, but only to update the index corresponding to the initial data in the index storage area, thereby reducing the maintenance workload of the program code and reducing the risk of bug of the program.
[0109] Please refer to Figure 5 , Figure 5 is a schematic block diagram of a data access device 1000 provided by an embodiment of the present application, which is used to execute the foregoing data access method. The data access device can be configured in a server or a terminal.
[0110] As shown in Figure 5 , the data access device 1000 comprises an attribute acquisition module 1001, an index query module 1002 and a data access module 1003.
[0111] The attribute acquisition module 1001 is configured to acquire a preset attribute of target data to be accessed; the target data comprises one or more initial data, and the initial data is defined by each program file and stored respectively.
[0112] The index query module 1002 is configured to query a preset index storage area according to the preset attribute, and obtain a target index corresponding to the target data; the index in the index storage area is constructed by the program file, the index corresponds to the initial data one by one, and each index comprises a plurality of index parameters, and each index parameter is used to represent the attribute of the corresponding initial data.
[0113] The data access module 1003 is configured to access the target data according to the target index.
[0114] In some embodiments, the index query module 1002 can comprise a first polling sub-module and a first index determination module.
[0115] The first polling sub-module is configured to poll the index in the index storage area, and obtain the index parameter of each index.
[0116] The first index determination module is configured to determine the index comprising the preset data type in the index parameter as the target index.
[0117] In some embodiments, the index query module 1002 can include a second polling sub-module and a second index determining module.
[0118] The second polling sub-module is configured to poll the indexes in the index storage area and obtain index parameters of each index.
[0119] The second index determining module is configured to determine, as the target index, an index including a preset data name in the index parameters.
[0120] In some embodiments, the data access module 1003 can include an access address determining sub-module and an access sub-module.
[0121] The access address determining sub-module is configured to determine a target access address according to a pointer vector in the target index.
[0122] The access sub-module is configured to access the target data according to the target access address.
[0123] In some embodiments, the data access apparatus 1000 can further include an index updating module.
[0124] The index updating module is configured to update the index corresponding to the initial data according to an updated data attribute when determining that any data attribute of the initial data is updated.
[0125] In some embodiments, the data access apparatus 1000 can further include an initial data defining module and an index constructing module.
[0126] The initial data defining module is configured to define each of the initial data and determine a plurality of data attributes of each of the initial data.
[0127] The index constructing module is configured to construct the index corresponding to each of the initial data according to the plurality of data attributes of each of the initial data, and store all the constructed indexes to the index storage area.
[0128] In some embodiments, the index constructing module can include an index parameter defining sub-module and an assignment sub-module.
[0129] The index parameter defining sub-module is configured to define a plurality of index parameters of the index corresponding to each of the initial data, the plurality of index parameters corresponding to the plurality of data attributes of the initial data one by one.
[0130] The assignment sub-module is configured to assign the plurality of data attributes of each of the initial data to the corresponding index parameters to obtain the index corresponding to each of the initial data.
[0131] In some embodiments, the data access apparatus 1000 can further include a macro defining module.
[0132] The macro definition module is configured to perform a macro definition operation, wherein the macro definition operation comprises the following steps: defining each of the initial data and determining a plurality of data attributes of each of the initial data; constructing an index corresponding to each of the initial data according to the plurality of data attributes of each of the initial data, and storing all the constructed indexes into the index storage area.
[0133] Referring to Figure 6 , Figure 6 is a structural schematic block diagram of a computer device provided by an embodiment of the present application. As shown in Figure 6 , the computer device comprises a processor and a memory connected through a system bus, wherein the memory can comprise a storage medium and an internal memory. The storage medium can be a non-volatile storage medium or a volatile storage medium. Exemplarily, the computer device further comprises a network interface, and the computer device communicates data with other communication devices such as other computer devices or servers through the network interface.
[0134] The processor is configured to provide computing and control capabilities to support the operation of the entire computer device.
[0135] The internal memory provides an environment for the running of a computer program in the non-volatile storage medium, and the computer program is executed by the processor to enable the processor to perform any kind of data access method.
[0136] It should be understood that the processor can be a central processing unit (CPU), and the processor can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0137] In one embodiment, the processor is configured to run a computer program stored in the memory to perform the following steps:
[0138] acquire a preset attribute of target data to be accessed; the target data comprises one or more initial data, the initial data is defined by a respective program file and is stored respectively; acquire a target index corresponding to the target data according to the preset attribute by querying a preset index storage area; the index in the index storage area is constructed by the program file, the index corresponds to the initial data one by one, and each index comprises a plurality of index parameters, each index parameter is used for indicating an attribute of the corresponding initial data; and access the target data according to the target index.
[0139] In one embodiment, the preset attribute comprises a preset data type, and the index parameter comprises a data type; when implementing acquiring the target index corresponding to the target data by querying the preset index storage area according to the preset attribute, the processor is configured to implement:
[0140] polling the index in the index storage area to acquire the index parameter of each index; and determining the index comprising the preset data type in the index parameter as the target index.
[0141] In one embodiment, the preset attribute comprises a preset data name, and the index parameter comprises a data name; when implementing acquiring the target index corresponding to the target data by querying the preset index storage area according to the preset attribute, the processor is configured to implement:
[0142] polling the index in the index storage area to acquire the index parameter of each index; and determining the index comprising the preset data name in the index parameter as the target index.
[0143] In one embodiment, the index parameter comprises a pointer vector pointing to an access address of the initial data; when implementing accessing the target data according to the target index, the processor is configured to implement:
[0144] determining a target access address according to the pointer vector in the target index; and accessing the target data according to the target access address.
[0145] In one embodiment, the processor is further configured to implement:
[0146] when determining that any data attribute of the initial data is updated, updating the index corresponding to the initial data according to the updated data attribute.
[0147] In one embodiment, before implementing acquiring the target index corresponding to the target data by querying the preset index storage area according to the preset attribute, the processor is further configured to implement:
[0148] define each of the initial data, determine a plurality of data attributes of each of the initial data; construct an index corresponding to each of the initial data according to the plurality of data attributes of each of the initial data, and store all the constructed indexes to the index storage area.
[0149] In one embodiment, the processor, when implementing the construction of the index corresponding to each of the initial data according to the plurality of data attributes of each of the initial data, is configured to implement:
[0150] define a plurality of index parameters of the index corresponding to each of the initial data, the plurality of index parameters corresponding to the plurality of data attributes of the initial data one by one; and assign the plurality of data attributes of each of the initial data to the corresponding index parameters to obtain the index corresponding to each of the initial data.
[0151] In one embodiment, before the processor implements the querying of the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data, the processor is further configured to implement:
[0152] perform a macro definition operation; wherein the macro definition operation performs the following steps: define each of the initial data, determine a plurality of data attributes of each of the initial data; construct an index corresponding to each of the initial data according to the plurality of data attributes of each of the initial data, and store all the constructed indexes to the index storage area.
[0153] In an embodiment of the present application, a computer readable storage medium is also provided, which stores a computer program, the computer program including program instructions, and the processor executes the program instructions to implement any one of the data access methods provided in the embodiments of the present application.
[0154] For example, the program is loaded by the processor, and the following steps can be performed:
[0155] obtain a preset attribute of target data to be accessed; the target data includes one or more initial data, the initial data is defined by each program file and is stored respectively; query a preset index storage area according to the preset attribute to obtain a target index corresponding to the target data; the indexes in the index storage area are constructed by the program file, the indexes correspond to the initial data one by one, each of the indexes includes a plurality of index parameters, and each of the index parameters is used to represent an attribute of the corresponding initial data; and access the target data according to the target index.
[0156] The computer readable storage medium can be an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device. The computer readable storage medium can also be an external storage device of the computer device, for example, a plug-in hard disk, a smart media card (SMC), a secure digital card (SD Card), a flash card, and the like.
[0157] Further, the computer readable storage medium can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, programs required by at least one function, and the like; and the data storage area can store data created according to each program, and the like.
[0158] The above merely provides a specific implementation of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present application, and these modifications or replacements shall be encompassed within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A data access method, characterized by, The method comprises the following steps: acquiring a preset attribute of target data to be accessed; the target data comprises one or more initial data, which are defined by respective program files and stored respectively; querying a preset index storage area according to the preset attribute to obtain a target index corresponding to the target data; the indexes in the index storage area are constructed by the program files, indexes constructed by different program files are uniformly stored in the same index storage area, the indexes correspond to the initial data one by one, each index comprises a plurality of index parameters, and each index parameter is used for representing an attribute of the corresponding initial data; accessing the target data according to the target index; before the step of querying the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data, the method further comprises performing a macro definition operation; wherein the macro definition operation performs the following steps: defining each initial data to determine a plurality of data attributes of each initial data; constructing an index corresponding to each initial data according to the plurality of data attributes of each initial data, and storing all the constructed indexes into the index storage area.
2. The data access method of claim 1, wherein, the preset attribute comprises a preset data type, and the index parameter comprises a data type; the step of querying the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data comprises: polling the indexes in the index storage area to obtain the index parameters of each index; determining, as the target index, the index whose index parameter comprises the preset data type.
3. The data access method of claim 1, wherein, the preset attribute comprises a preset data name, and the index parameter comprises a data name; the step of querying the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data comprises: polling the indexes in the index storage area to obtain the index parameters of each index; determining, as the target index, the index whose index parameter comprises the preset data name.
4. The data access method of claim 1, wherein, the index parameter comprises a pointer vector pointing to an access address of the initial data; the step of accessing the target data according to the target index comprises: determining a target access address according to the pointer vector in the target index; accessing the target data according to the target access address.
5. The data access method of claim 1, wherein, the method further comprises: when determining that any data attribute of the initial data is updated, updating the index corresponding to the initial data according to the updated data attribute.
6. The data access method of claim 1, wherein, before the step of querying the preset index storage area according to the preset attribute to obtain the target index corresponding to the target data, the method further comprises: defining each initial data to determine a plurality of data attributes of each initial data; constructing an index corresponding to each initial data according to the plurality of data attributes of each initial data, and storing all the constructed indexes into the index storage area.
7. The data access method of claim 6, wherein, the step of constructing an index corresponding to each initial data according to the plurality of data attributes of each initial data comprises: defining a plurality of index parameters of the index corresponding to each initial data, the plurality of index parameters and the plurality of data attributes of the initial data correspond to each other one by one; Each of the initial data is assigned to a corresponding index parameter, and each of the initial data is assigned to a corresponding index parameter.
8. A computer device, comprising: The computer device comprises a memory and a processor. The memory is configured to store a computer program. The processor is configured to execute the computer program and implement the data access method according to any one of claims 1 to 7 when the computer program is executed.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is configured to enable the processor to implement the data access method according to any one of claims 1 to 7 when the computer program is executed by the processor.
Citation Information
Patent Citations
A data query method and system, and a storage medium
CN108984615A