Data access method and device in virtual machine, electronic equipment and medium

By resolving the issue of accessing data in the virtual machine from within C++, the code consistency problem was solved, and technical means were implemented to improve code development efficiency.

CN115408003BActive Publication Date: 2025-12-05WUHAN DOUYU NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110586422.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-27
Publication Date
2025-12-05
Estimated Expiration
2041-05-27

AI Technical Summary

Technical Problem

Accessing object data in the virtual machine in C++ presents problems of poor code consistency and increased difficulty in code development.

Method used

By using methods of predefined virtual machine iterator classes, virtual machine utility template classes, and C++ iterator classes, the collection object to be accessed in the virtual machine is obtained, the data identifier and value are stored, and they are concatenated into the target data to be accessed in key-value pair format, and then accessed using the C++ iterator class.

Benefits of technology

It improves code consistency, reduces the difficulty of code development, and thus improves code development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115408003B_ABST
    Figure CN115408003B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data access method and device in a virtual machine, electronic equipment and a medium. The method comprises: obtaining a to-be-accessed collection object in the virtual machine; obtaining a virtual iterator of the to-be-accessed collection object through a constructor method of a virtual machine iterator class, storing a data identifier of to-be-accessed data included in the virtual iterator to an identifier storage space through a data storage method, and storing a data value corresponding to the data identifier to a value storage space; obtaining the data identifier from the identifier storage space and the data value corresponding to the data identifier from the value storage space through a data construction method, splicing the data identifier and the data value into a target to-be-accessed data in the format of a key-value pair, and storing the target to-be-accessed data to a storage space; and determining the target to-be-accessed data from the storage space through a data determination method, and accessing the target to-be-accessed data through a data access method, thereby reducing the difficulty of code development and improving the efficiency of code development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data access method, apparatus, electronic device and medium in a virtual machine. Background Technology

[0002] A virtual machine is a computer system that is simulated by software, possessing full hardware system functionality and running in a completely isolated environment. Virtual machine technology allows one or more virtual computers to be simulated on a single physical computer.

[0003] In existing technologies, accessing data of objects in the virtual machine from C++ typically requires retrieving the object's data in C++ according to the virtual machine's syntax rules. However, accessing object data in the virtual machine from C++ using the virtual machine's syntax rules suffers from poor code consistency and increases the difficulty of code development, thus reducing development efficiency. Summary of the Invention

[0004] This invention provides a data access method, apparatus, electronic device, and medium in a virtual machine to improve code consistency and reduce the difficulty of code development, thereby improving code development efficiency.

[0005] In a first aspect, embodiments of the present invention provide a data access method in a virtual machine, the method comprising:

[0006] Retrieve the collection object to be accessed in the virtual machine;

[0007] The virtual iterator of the collection object to be accessed is obtained by the constructor method of the predefined virtual machine iterator class. The data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object by the predefined data storage method of the virtual machine iterator class, and the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object.

[0008] Using a predefined virtual machine tool template class data construction method, the data identifier is obtained from the identifier storage space, the data value corresponding to the data identifier is obtained from the value storage space, and the data identifier of the data to be accessed and the data value corresponding to the data identifier are concatenated into a key-value pair format corresponding to the target data to be accessed. The target data to be accessed is then stored in the storage space corresponding to the predefined target collection object to be accessed.

[0009] The target data to be accessed is determined from the storage space corresponding to the target collection object by using the data determination method of the predefined C++ iterator class, and the target data to be accessed is accessed by using the data access method of the predefined C++ iterator base class.

[0010] Secondly, embodiments of the present invention also provide a data access device in a virtual machine, the device comprising:

[0011] The module for obtaining the collection object to be accessed is used to obtain the collection object to be accessed in the virtual machine;

[0012] The data identification and data value storage module is used to obtain the virtual iterator of the collection object to be accessed through the constructor method of the predefined virtual machine iterator class, and to store the data identification of the data to be accessed included in the virtual iterator to the identification storage space corresponding to the predefined identification storage object through the predefined data storage method of the virtual machine iterator class, and to store the data value corresponding to the data identification to the value storage space corresponding to the predefined value storage object.

[0013] The target data storage module is used to obtain the data identifier from the identifier storage space and the data value corresponding to the data identifier from the value storage space through the data construction method of the predefined virtual machine tool template class, and to concatenate the data identifier of the data to be accessed and the data value corresponding to the data identifier into the target data to be accessed in the format of key-value pairs, and to store the target data to be accessed in the storage space corresponding to the predefined target collection object.

[0014] The target data access module is used to determine the target data to be accessed from the storage space corresponding to the target collection object by using the data determination method of the predefined C++ iterator class, and to access the target data to be accessed by using the data access method of the predefined C++ iterator base class.

[0015] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising:

[0016] One or more processors;

[0017] Storage device for storing one or more programs;

[0018] When the program is executed by the processor, the processor implements a data access method in a virtual machine as provided in any embodiment of the present invention.

[0019] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a data access method in a virtual machine as provided in any embodiment of the present invention.

[0020] The technical solution of this embodiment obtains the collection object to be accessed in the virtual machine. A virtual iterator for the collection object is obtained through the constructor method of a predefined virtual machine iterator class. Then, through the predefined data storage method of the virtual machine iterator class, the data identifiers of the data to be accessed included in the virtual iterator are stored in the identifier storage space corresponding to a predefined identifier storage object, and the data values ​​corresponding to the data identifiers are stored in the value storage space corresponding to a predefined value storage object.

[0021] Using the data construction method of a predefined virtual machine tool template class, a data identifier is obtained from the identifier storage space, and the data value corresponding to the data identifier is obtained from the value storage space. The data identifier of the data to be accessed and the data value corresponding to the data identifier are concatenated into a key-value pair format corresponding to the target data to be accessed, and the target data to be accessed is stored in the storage space corresponding to the predefined target collection object to be accessed.

[0022] By using a predefined C++ iterator class to determine the data, the target data to be accessed is determined from the storage space corresponding to the target collection object. The target data is then accessed using the predefined C++ iterator base class's data access method. This solves the technical problem of poor code consistency and increased code development difficulty in existing technologies for accessing data of objects in the virtual machine in C++. It achieves the technical effect of improving code consistency while reducing code development difficulty, thereby improving code development efficiency. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of exemplary embodiments of the present invention, the accompanying drawings used in describing the embodiments are briefly introduced below. Obviously, the accompanying drawings described are only a portion of the drawings of the embodiments to be described in this invention, and not all of the drawings. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort.

[0024] Figure 1 This is a schematic diagram of a data access method in a virtual machine provided in Embodiment 1 of the present invention;

[0025] Figure 2 This is a schematic diagram of a data access method in a virtual machine provided in Embodiment 2 of the present invention;

[0026] Figure 3This is a schematic diagram of a data access method in a virtual machine provided in Embodiment 3 of the present invention;

[0027] Figure 4 This is a schematic diagram of a data access device module in a virtual machine provided in Embodiment 4 of the present invention;

[0028] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Detailed Implementation

[0029] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0030] Example 1

[0031] Figure 1 This is a schematic diagram of a data access method in a virtual machine provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation where data in a collection object in a virtual machine is accessed through C++ iteration. This method can be executed by a data access device in the virtual machine, which can be implemented by software and / or hardware. The data access device in the virtual machine can be integrated into an electronic device such as a computer or server.

[0032] like Figure 1 As shown, the method in this embodiment includes:

[0033] S110. Obtain the collection object to be accessed in the virtual machine.

[0034] The collection object to be accessed can be a pre-defined collection object. The type of the collection object to be accessed can be the vmap type from the virtual machine's data types. For example, if the type of the collection object to be accessed is vmap, the key type of the data in the collection object to be accessed is vstring, and the value type of the data in the collection object to be accessed is vstring, then the pre-defined collection object to be accessed is vmap.<vstring,vstring> `vmaptest` refers to the collection object to be accessed. Specifically, the type of the collection object to be accessed in the virtual machine is predefined as `vmap`, and the data types of the keys and values ​​in the collection object are pre-set. When it is detected that the type of the collection object is `vmap`, the data type of the keys in the collection object is the pre-set data type of the keys in the collection object, and the data type of the values ​​in the collection object is the pre-set data type of the values ​​in the collection object, the collection object is used as the collection object to be accessed, i.e., the collection object to be accessed in the virtual machine is retrieved.

[0035] S120. Obtain the virtual iterator of the collection object to be accessed through the constructor method of the predefined virtual machine iterator class.

[0036] The virtual machine iterator class can be a predefined class used to access data in a collection object of type `vmap` within the virtual machine. The virtual machine iterator class can be defined using the `class` keyword. For example, the virtual machine iterator class might be named `VMapIterator`, defined using the `class VMapIterator{}` keyword. The iterator class within the virtual machine can include one, two, or more methods.

[0037] The advantage of a predefined virtual machine iterator class is that it encapsulates the constructor method that obtains the iterator of the collection object to be accessed, thus facilitating later code maintenance and improving code readability. The advantage of obtaining the virtual iterator of the collection object through the constructor method of the virtual machine iterator class is that it allows for faster retrieval of the virtual iterator, thereby improving code execution efficiency. The constructor method of the virtual machine iterator class can be a predefined constructor method used to obtain the virtual iterator of the collection object to be accessed in the virtual machine. The input parameter of the constructor method of the virtual machine iterator class can be, that is, the formal parameter of the constructor method of the virtual machine iterator class can be the collection object to be accessed of type `vmap`. For example, if the formal parameter of the constructor method of the virtual machine iterator class is `VMap map`, then the constructor method of the virtual machine iterator class is `VMapIterator(VMap map)`.

[0038] In this implementation, the constructor method name is the same as the class name, and the constructor method can be used to instantiate objects. The constructor method is automatically called when a class instantiates an object. Therefore, in this embodiment, the virtual iterator of the collection object to be accessed in the virtual machine is obtained through the constructor method of the virtual machine iterator class. The advantage of this approach is that it can automatically obtain the virtual iterator of the collection object to be accessed, improving code execution efficiency.

[0039] The virtual iterator can be used to traverse the data to be accessed in the collection object. The relationship between the collection object to be accessed and the virtual iterator can be that the collection object to be accessed contains the virtual iterator.

[0040] The virtual iterator for obtaining the collection object to be accessed can be a predefined virtual machine iterator method. When it is detected that the formal parameter of the virtual machine iterator class constructor has received the corresponding actual parameter—that is, when it is detected that the formal parameter of the virtual machine iterator class constructor has received the collection object to be accessed from the virtual machine—the predefined virtual machine iterator method can be called through the collection object to obtain the virtual iterator of the collection object. For example, the predefined virtual machine iterator method could be `iterator()`, and the predefined virtual machine iterator method that can be called through the collection object could be `map.iterator()`, meaning the virtual iterator of the collection object to be accessed can be obtained through `map.iterator()`.

[0041] To reduce code complexity and improve its logical consistency, a variable can be predefined to store the virtual iterator of the collection object to be accessed in the virtual machine. To improve code reusability, this variable can be made a member variable of the virtual machine iterator class. When the virtual iterator of the collection object is retrieved, it is assigned to the predefined variable used to store iterators.

[0042] The variable defining the virtual iterator for storing the accessed collection objects can be based on an iterator (Iterator) of generic type VMap.Entry. For example, the iterator of generic type VMap.Entry can be an Iterator.<VMap.Entry> Based on an iterator with the generic type VMap.Entry, a variable Iterator is defined to store a virtual iterator for the collection objects to be accessed.<VMap.Entry> iter is the variable used to store the virtual iterator of the collection object to be accessed.

[0043] The process of assigning the virtual iterator of the acquired collection object to a predefined variable for storing virtual iterators of the acquired collection object can be understood as storing the virtual iterator of the acquired collection object into the storage space corresponding to the predefined variable for storing virtual iterators of the acquired collection object.

[0044] For example, if the predefined variable for storing the virtual iterator of the collection object to be accessed is called iter, then the virtual iterator of the collection object to be accessed can be assigned to the predefined variable for storing the virtual iterator of the collection object to be accessed, which can be iter = map.iterator().

[0045] Specifically, a virtual machine iterator class is predefined. Within this class, a constructor is predefined that takes a collection object of type `vmap` as its input parameter. The virtual machine's iterator method is also predefined. A variable is predefined to store the virtual iterator of the collection object to be accessed within the virtual machine. When the location of the collection object to be accessed within the virtual machine is determined, this collection object can be passed as the actual parameter to the input parameter of the predefined constructor in the virtual machine iterator class. In other words, the collection object to be accessed within the virtual machine can be passed as the actual parameter to the formal parameter of the predefined constructor in the virtual machine iterator class.

[0046] Specifically, when it's detected that the formal parameter of the constructor has received the actual parameter—that is, when it's detected that the formal parameter of the constructor has received the collection object to be accessed—a predefined virtual machine iterator method can be called through the collection object. When the virtual machine iterator method call completes, the virtual iterator of the collection object to be accessed can be determined. Once the virtual iterator of the collection object to be accessed is determined, it can be stored in the storage space corresponding to the predefined variable used to store the virtual iterator of the collection object to be accessed in the virtual machine; that is, the virtual iterator of the collection object to be accessed can be obtained.

[0047] For example, the virtual machine iterator class is `class VMapIterator{}`. Within the virtual machine iterator class, a variable `class VMapIterator{Iterator}` is defined to store the virtual iterator for the collection objects to be accessed in the virtual machine.<VMap.Entry> The virtual machine iterator class defines a constructor that takes a collection object of type `vmap` as its input parameter: `class VMapIterator{VMapIterator(VMap map){}}`. Within this constructor, the virtual iterator of the collection object is obtained using `VMapIterator(VMap map){iter=map.iterator()}`. Therefore, obtaining the virtual iterator of the collection object through the predefined virtual machine iterator class constructor can be done as follows:

[0048] class VMapIterator{Iterator<VMap.Entry> iter;VMapIterator(VMap map){iter=map.iterator();}}.

[0049] S130. Using the predefined data storage method of the virtual machine iterator class, the data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object, and the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object.

[0050] The data to be accessed can be data stored in a virtual iterator of the collection object to be accessed within the virtual machine. The number of data items to be accessed in the virtual iterator can be one, two, or more. A single piece of data to be accessed can include a data identifier and a data value. The data identifier can be understood as the key of the data to be accessed, and the data value can be understood as the data value of the data to be accessed. The correspondence between the data to be accessed and the data identifier can be one-to-one; a one-to-one correspondence can exist between the data identifier and the data value of a single piece of data to be accessed.

[0051] In this system, the identifier storage object can be a predefined object, such as an Object Key. The identifier storage space can be the storage space corresponding to the identifier storage object, and can be used to store the data identifier of the data to be accessed. The correspondence between the identifier storage object and the identifier storage space can be pre-established. Similarly, the value storage object can be a predefined object, such as an Object value. The value storage space can be the storage space corresponding to the value storage object, and can be used to store the data value of the data to be accessed. The correspondence between the value storage object and the value storage space can also be pre-established.

[0052] The data storage method can be a predefined method used to store the data identifier of the data to be accessed included in the virtual iterator, as well as the data value corresponding to the data identifier. The data storage method can be encapsulated in the virtual machine iterator class; that is, the virtual machine iterator class can include a data storage method. For example, the data storage method could be `Next()`. The advantage of encapsulating the data storage method in the virtual machine iterator class is that it enhances code readability and reduces code complexity.

[0053] Optionally, before storing the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to the predefined identifier storage object, and storing the data value corresponding to the data identifier to the value storage space corresponding to the predefined value storage object through the predefined data storage method of the virtual iterator class, it is also possible to determine whether the virtual iterator includes the data to be accessed. If yes, the predefined data access method of the virtual iterator class is called to determine the data identifier of the data to be accessed included in the virtual iterator and the data value corresponding to the data identifier; if no, a prompt message is displayed to indicate that the virtual iterator does not include the data to be accessed.

[0054] The data access methods of the virtual machine iterator class can be predefined methods used to determine the data identifier of the data to be accessed included in the virtual iterator, and the data value corresponding to the data identifier. The prompt message can be used to indicate that the virtual iterator does not include the data to be accessed. In this example, the form in which the prompt message is displayed is not limited; for example, the prompt message can be displayed as a pop-up window.

[0055] Specifically, data access methods are predefined in the virtual machine iterator class. When the virtual iterator of the collection object to be accessed is detected as having been acquired, it can be determined whether the virtual iterator contains the data to be accessed. If the virtual iterator contains the data to be accessed, the data access methods defined in the virtual machine iterator class can be called; that is, the data access methods defined in the virtual machine iterator class can be executed. When the execution of the data access methods defined in the virtual machine iterator class is detected as complete, the data identifier of the data to be accessed included in the virtual iterator, as well as the data value corresponding to the data identifier, can be determined. If the virtual iterator does not contain the data to be accessed, a prompt message indicating that the virtual iterator does not contain the data to be accessed will be displayed. Specifically, data storage methods are predefined in the virtual machine iterator class. An identifier storage object is predefined, and an identifier storage space is pre-created in memory. The correspondence between the identifier storage object and the identifier storage space is pre-established. A value storage object is predefined, and a value storage space is pre-created in memory. The correspondence between the value storage object and the value storage space is pre-established. When a virtual iterator contains data to be accessed, the data identifier of the data to be accessed included in the virtual iterator, as well as the data value corresponding to the data identifier, can be determined.

[0056] Specifically, upon detecting the data identifier of the data to be accessed and determining the corresponding data value, the data storage method defined in the virtual machine iterator class can be called to assign the data identifier of the data to be accessed to a predefined identifier storage object. When the value of the identifier storage object is detected to be the data identifier of the data to be accessed, the value of the identifier storage object can be stored in the identifier storage space corresponding to the identifier storage object. Simultaneously, the data value corresponding to the data identifier is assigned to a predefined value storage object. When the value of the storage object is detected to be the data value corresponding to the data identifier, the data value can be stored in the value storage space corresponding to the value storage object.

[0057] S140. Using the data construction method of the predefined virtual machine tool template class, obtain the data identifier from the identifier storage space, obtain the data value corresponding to the data identifier from the value storage space, and concatenate the data identifier of the data to be accessed and the data value corresponding to the data identifier into the target data to be accessed in the format of key-value pairs. Store the target data to be accessed in the storage space corresponding to the predefined target collection object to be accessed.

[0058] The virtual machine tool template class can be a predefined class used to implement data construction functionality. For example, the virtual machine tool template class can be a template.<typename K,typename V> struct MapUtils{}. The benefits of pre-defining virtual machine utility template classes are: reduced code coupling, improved code reusability, easier code management, and reduced code complexity.

[0059] The data construction method can be a predefined method used to construct the target collection object to be accessed. Concatenation can be understood as data combination. The concatenation format can be a key-value pair format. The target data to be accessed can be key-value pair data to be accessed. The target collection object to be accessed can be a predefined object used to store the target data to be accessed. Specifically, the target data to be accessed, which concatenates the data identifier of the data to be accessed and the data value corresponding to the data identifier into a key-value pair format, can be a predefined data concatenation method (e.g., std::make_pair()). By calling the predefined data concatenation method, the data identifier of the data to be accessed and the data value corresponding to the data identifier are concatenated in key-value pair format.

[0060] Optionally, obtaining the data identifier from the identifier storage space through the data construction method of the predefined virtual machine tool template class includes: in the data construction method of the predefined virtual machine tool template class, determining the field identifier corresponding to the data identifier of the data to be accessed by calling the system's object identifier determination method, which takes the field name corresponding to the identifier storage object as the input parameter; and determining the data identifier by calling the system's data value determination method, which takes the field identifier corresponding to the data identifier as the input parameter.

[0061] The system's object identifier determination method can be GetFieldID(). The input parameters for object identifier determination can include: the class name, the variable name, and the variable type. The system's data value determination method, which uses the field identifier corresponding to the data identifier as the input parameter, can be a predefined method used to determine the data identifier of the data to be accessed. In this embodiment, the input parameters for the object identifier determination method can include: the class name, the field name corresponding to the identifier storage object, and the type name of the identifier storage object. For example, the system's object identifier determination method is GetFieldID(jcls,"key","Object"), where jcls can be the class name, "key" can be the field name corresponding to the identifier storage object, and "Object" can be the type name of the identifier storage object.

[0062] To facilitate obtaining the data identifier of the data to be accessed, a variable can be predefined to store the data identifier. Once the data identifier of the data to be accessed is determined, it can be assigned to the predefined variable. For example, `jfieldID kid = GetFieldID(jcls,"key","Object")`, where `kid` is the variable storing the data identifier.

[0063] Optionally, obtaining the data value corresponding to the data identifier from the value storage space includes: determining the field identifier corresponding to the data value of the data to be accessed by calling the system's object identifier determination method, which takes the field name corresponding to the value storage object as the input parameter; and determining the data value corresponding to the data identifier by calling the system's data value determination method, which takes the field identifier corresponding to the data value as the input parameter.

[0064] The system's object identifier determination method, which uses the field name corresponding to the value storage object as the input parameter, can be a predefined method used to determine the data value corresponding to the data identifier. In this embodiment, the input parameters of the object identifier determination method may include: the class name, the field name corresponding to the value storage object, and the type name of the value storage object. For example, the system's object identifier determination method is GetFieldID(jcls,"value","Object"), where jcls can be the class name, "value" can be the field name corresponding to the value storage object, and "Object" can be the type name of the identifier storage object.

[0065] To facilitate retrieving the data value corresponding to the data identifier of the data to be accessed, a variable can be predefined to store the data value. Once the data value of the data to be accessed is determined, it can be assigned to the predefined variable. For example, `jfieldID vid = GetFieldID(jcls,"value","Object")`, where `vid` is the variable storing the data identifier.

[0066] To facilitate retrieving the value of a data identifier, a method can be predefined that takes the variable storing the data identifier as its input parameter, such as `GetObjectField(kid)`. Similarly, to facilitate retrieving the data value, a method can be predefined that takes the variable storing the data value as its input parameter, such as `GetObjectField(vid)`. To improve code readability and reduce code complexity, variables for storing data identifier values ​​(e.g., `Object k`) and variables for storing data values ​​(e.g., `Object v`) can be predefined. For example, `Object k = GetObjectField(kid)`; `Object v = GetObjectField(vid)`.

[0067] Specifically, a virtual machine tool template class is predefined. Within this template class, data construction methods are predefined. A system data value determination method is predefined, using the field identifier corresponding to the data identifier as the input parameter. A system object identifier determination method is predefined, using the field name corresponding to the value storage object as the input parameter. A data concatenation method is predefined. A value retrieval method is predefined, using the variable storing the data identifier as the input parameter. A value retrieval method is predefined, using the variable storing the data value as the input parameter. Variables storing data values ​​and variables storing data identifiers are predefined. A target collection object to be accessed is predefined. When the data identifier of the data to be accessed and the corresponding data value are stored, the predefined system data value determination method, using the field identifier corresponding to the data identifier as the input parameter, can be called within the data construction method to determine the data identifier of the data to be accessed.

[0068] Specifically, once the data identifier is determined, it is assigned to a predefined variable that stores the data identifier. Calling the predefined system object identifier determination method, which takes the field name corresponding to the value storage object as its input parameter, can determine the data value corresponding to the data identifier of the data to be accessed. Once the data value corresponding to the data identifier is determined, it is assigned to a predefined variable that stores the data value.

[0069] Specifically, when the value of the variable storing the data identifier is the data identifier, a predefined value retrieval method that takes the variable storing the data identifier as its input parameter can be called to obtain the value of the data identifier of the data to be accessed. When the value of the variable storing the data value is the data value, a predefined value retrieval method that takes the variable storing the data value as its input parameter can be called to obtain the data value corresponding to the data identifier. Upon detecting that the value of the data identifier of the data to be accessed and the corresponding data value have been retrieved, a predefined data concatenation method can be called to concatenate the value of the data identifier of the data to be accessed and the corresponding data value into a key-value pair format corresponding to the target data to be accessed. Upon detecting that the data concatenation is complete, the target data to be accessed can be stored in the storage space corresponding to the predefined target collection object to be accessed.

[0070] S150. Using the data determination method of a predefined C++ iterator class, determine the target data to be accessed from the storage space corresponding to the target collection object to be accessed.

[0071] In this context, the C++ iterator class can be a predefined template class. For example, `template`.<typename K,typename V> The data determination method can be a predefined method in a C++ iterator class, used to determine the target data to be accessed. For example, the data determination method could be `struct CMapIterator:public Iterator`.<K,V> {}.

[0072] Specifically, a predefined C++ iterator class predefines a data determination method. When the target data to be accessed is detected to be stored in the storage space corresponding to the target collection object, the data determination method of the predefined C++ iterator class can be called. In other words, the data determination method of the predefined C++ iterator class can be executed to determine the target data to be accessed from the storage space corresponding to the target collection object.

[0073] S160. Access the target data using the data access methods of the predefined C++ iterator base class.

[0074] The C++ iterator base class can be a predefined template class, used to implement the functionality of accessing target data. Template classes are a mechanism for generating functions and classes based on parameter types. Therefore, defining the C++ iterator base class as a template class is because by using templates, only one class needs to be designed to handle multiple data types, instead of creating separate classes for each type. In this embodiment of the invention, defining the C++ iterator base class as a template class has the advantages of improving code reusability, reducing the workload of software developers, and lowering the error rate of the code.

[0075] For example, the base class for C++ iterators is template.<typename T,typename V> The class `ItBase{}`. The C++ access method can be a predefined method used to access the target data. For example, the C++ access method is `ItBase&operator++(){}`.

[0076] Specifically, a base class for C++ iterators is predefined, and data access methods are predefined within this base class. When the target data to be accessed is determined to be available, the predefined data access methods of the base class can be called. In other words, the predefined data access methods of the base class can be executed to access the target data. For example, the data access methods could be:

[0077] ItBase&operator++(){

[0078] data_ = utils_->Next();

[0079] const V*operator->()const{return&data_;}

[0080] In this context, by calling utils_->Next(), the target data to be accessed can be determined, and by using const V*operator->()const{return&data_;}, the target data to be accessed can be obtained.

[0081] The technical solution of this embodiment obtains the collection object to be accessed in the virtual machine. A virtual iterator for the collection object is obtained through the constructor method of a predefined virtual machine iterator class. Then, through the predefined data storage method of the virtual machine iterator class, the data identifiers of the data to be accessed included in the virtual iterator are stored in the identifier storage space corresponding to a predefined identifier storage object, and the data values ​​corresponding to the data identifiers are stored in the value storage space corresponding to a predefined value storage object.

[0082] Using the data construction method of a predefined virtual machine tool template class, a data identifier is obtained from the identifier storage space, and the data value corresponding to the data identifier is obtained from the value storage space. The data identifier of the data to be accessed and the data value corresponding to the data identifier are concatenated into a key-value pair format corresponding to the target data to be accessed, and the target data to be accessed is stored in the storage space corresponding to the predefined target collection object to be accessed.

[0083] By using a predefined C++ iterator class to determine the data, the target data to be accessed is determined from the storage space corresponding to the target collection object. The target data is then accessed using the predefined C++ iterator base class's data access method. This solves the technical problem of poor code consistency and increased code development difficulty in existing technologies for accessing data of objects in the virtual machine in C++. It achieves the technical effect of improving code consistency while reducing code development difficulty, thereby improving code development efficiency.

[0084] Example 2

[0085] Figure 2 This is a schematic flowchart of a data access method in a virtual machine according to Embodiment 2 of the present invention. Optionally, based on the foregoing embodiments, the step of storing the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to a predefined identifier storage object, and storing the data value corresponding to the data identifier to the value storage space corresponding to a predefined value storage object, through a predefined data storage method of the virtual machine iterator class, includes: in the predefined data storage method of the virtual machine iterator class, calling a predefined data element acquisition method through the virtual iterator of the collection object to be accessed to determine the data to be accessed included in the virtual iterator; calling a predefined data identifier storage method through the data to be accessed to store the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to the predefined identifier storage object; and calling a predefined data value storage method through the data to be accessed to store the data value corresponding to the data identifier to the value storage space corresponding to the predefined value storage object.

[0086] Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here.

[0087] like Figure 2 As shown, the method in this embodiment may specifically include:

[0088] S210. Obtain the collection object to be accessed in the virtual machine.

[0089] S220. Obtain the virtual iterator of the collection object to be accessed through the constructor method of the predefined virtual machine iterator class.

[0090] S230. In the predefined data storage method of the virtual machine iterator class, the predefined data element retrieval method is called through the virtual iterator of the collection object to be accessed to determine the data to be accessed included in the virtual iterator.

[0091] The data element retrieval method can be a predefined method that can be used to retrieve the data to be accessed from the virtual iterator of the collection object to be accessed.

[0092] Specifically, a method for retrieving data elements is predefined. When the virtual iterator of the collection object to be accessed is detected as having been retrieved, the predefined data element retrieval method can be called through the virtual iterator; that is, the predefined data element retrieval method can be executed. Upon detection that the data element retrieval method has completed execution, the data to be accessed included in the virtual iterator can be determined.

[0093] Optionally, to improve code reusability, in the predefined data storage method of the virtual machine iterator class, the predefined data access method of the virtual machine iterator class is repeatedly called through the virtual iterator of the collection object to be accessed, to determine the data to be accessed included in the virtual iterator. For example, Map.Entry entry = iter.next().

[0094] S240. By calling the predefined data identifier storage method through the data to be accessed, the data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object.

[0095] The data identifier storage method can be `getKey()`, which can be used to determine the data identifier of the data to be accessed. The identifier storage object can be a predefined object, such as `key`. The identifier storage space can be a pre-created storage space in memory, used to store the data identifier of the data to be accessed. The correspondence between the identifier storage object and the identifier storage space can be pre-established.

[0096] Specifically, a data identifier storage method, an identifier storage object, and an identifier storage space are predefined. A correspondence between the identifier storage object and the identifier storage space is pre-established. When it is detected that the data to be accessed included in the virtual iterator has been determined, the predefined data identifier storage method can be called through the data to be accessed; that is, the data identifier storage method is executed. When it is detected that the data identifier storage method has been executed, the data identifier of the data to be accessed included in the virtual iterator can be stored in the identifier storage space corresponding to the predefined identifier storage object.

[0097] For example, the predefined data identifier storage method is getKey(), and the data to be accessed can be entry. If the data identifier storage method entry.getKey() is called through the data to be accessed, then the data identifier of the data to be accessed included in the virtual iterator can be stored in the identifier storage space corresponding to the identifier storage object as key = entry.getKey().

[0098] S250: By calling a predefined data value storage method through the data to be accessed, the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object.

[0099] The data value storage method can be `getValue()`, which can be used to determine the data value corresponding to the data identifier. The value storage object can be a predefined object, such as `Value`. The value storage space can be a pre-created storage space in memory, used to store the data value corresponding to the data identifier of the data to be accessed. The correspondence between the value storage object and the value storage space can be pre-established.

[0100] Specifically, a data value storage method, a value storage object, and a value storage space are predefined. A correspondence between the value storage object and the value storage space is pre-established. When it is detected that the data to be accessed included in the virtual iterator has been determined, or when it is detected that the data identifier of the data to be accessed has been stored in the identifier storage space, the predefined data value storage method can be called through the data to be accessed; that is, the data value storage method can be executed. When it is detected that the data value storage method has been executed, the data value corresponding to the data identifier can be stored in the value storage space corresponding to the predefined value storage object.

[0101] For example, a predefined data value storage method is getValue(). Calling the predefined data value storage method with the data to be accessed can be entry.getValue(). Storing the data value corresponding to the data identifier into the value storage space corresponding to the predefined value storage object can be key = entry.getKey().

[0102] S260. Using the data construction method of the predefined virtual machine tool template class, obtain the data identifier from the identifier storage space, obtain the data value corresponding to the data identifier from the value storage space, and concatenate the data identifier of the data to be accessed and the data value corresponding to the data identifier into the target data to be accessed in the format of key-value pairs, and store the target data to be accessed in the storage space corresponding to the predefined target collection object to be accessed.

[0103] S270. Using the data determination method of a predefined C++ iterator class, determine the target data to be accessed from the storage space corresponding to the target collection object to be accessed.

[0104] S280. Access the target data by using the data access methods of the predefined C++ iterator base class.

[0105] The technical solution of this embodiment, by calling a predefined data element retrieval method through the virtual iterator of the collection object to be accessed in a predefined data storage method of the virtual machine iterator class, determines the data to be accessed included in the virtual iterator. Then, by calling a predefined data identifier storage method through the data to be accessed, the data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object. Finally, by calling a predefined data value storage method through the data to be accessed, the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object. This further optimizes the steps of storing the data identifier of the data to be accessed included in the virtual iterator in the identifier storage space corresponding to the predefined identifier storage object, and storing the data value corresponding to the data identifier in the value storage space corresponding to the predefined value storage object, through the predefined data storage method of the virtual machine iterator class. This achieves the technical effect of improving code readability and reusability, and facilitating later code maintenance.

[0106] Example 3

[0107] Figure 3This is a schematic diagram of a data access method in a virtual machine provided in Embodiment 3 of the present invention. Based on the foregoing embodiments, optionally, the step of determining the target data to be accessed from the storage space corresponding to the target collection object through a predefined C++ iterator class data determination method includes: in the C++ iterator class data determination method, calling a predefined C++ basic iteration template class object element iterator acquisition method to obtain the iterator of the current element in the target collection object, and using the iterator of the current element as the target iterator; determining whether the target iterator is an empty iterator, obtaining the determination result, and determining the target data to be accessed based on the determination result.

[0108] Optionally, determining the target data to be accessed based on the judgment result includes: when the judgment result is that the target iterator is not an empty iterator, returning to the operation of calling the object element iterator acquisition method of the predefined C++ basic iteration template class to obtain the iterator of the adjacent element of the current element; taking the iterator of the adjacent element of the current element as the target iterator, and performing a judgment on whether the target iterator is an empty iterator to obtain the judgment result, and determining the target data to be accessed based on the judgment result.

[0109] Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here.

[0110] like Figure 3 As shown, the method in this embodiment may specifically include:

[0111] S310. Obtain the collection object to be accessed in the virtual machine.

[0112] S320. Obtain the virtual iterator of the collection object to be accessed through the constructor method of the predefined virtual machine iterator class.

[0113] S330. Using the predefined data storage method of the virtual machine iterator class, the data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object, and the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object.

[0114] S340. Using the data construction method of the predefined virtual machine tool template class, obtain the data identifier from the identifier storage space, obtain the data value corresponding to the data identifier from the value storage space, and concatenate the data identifier of the data to be accessed and the data value corresponding to the data identifier into the target data to be accessed in the format of key-value pairs. Store the target data to be accessed in the storage space corresponding to the predefined target collection object to be accessed.

[0115] S350. By calling the object element iterator acquisition method of the predefined C++ basic iteration template class in the data determination method of the C++ iterator class, the iterator of the current element in the target collection object to be accessed is obtained, and the iterator of the current element is used as the target iterator.

[0116] The method for retrieving the object element iterator can be a predefined method used to obtain the iterator of the current element of the target collection object to be accessed. The current element can be understood as the element to be accessed. The target collection object to be accessed can include one or more elements. The correspondence between elements and iterators can be one-to-one, meaning that one element can contain one iterator. The target iterator can be understood as the iterator to be accessed.

[0117] Specifically, a data determination method is predefined in the C++ iterator class. When it is detected that the target data to be accessed is stored in the memory space corresponding to the target collection object, the predefined data determination method in the C++ iterator class can be called; that is, the data determination method can be executed. When it is detected that the data determination method has completed execution, the iterator of the current element in the target collection object can be obtained. When it is detected that the iterator of the current element in the target collection object has been obtained, the iterator of the current element can be used as the target iterator.

[0118] S360. Determine whether the target iterator is an empty iterator, obtain the determination result, and determine the target data to be accessed based on the determination result.

[0119] An empty iterator can be understood as an iterator that does not contain data. The result of the judgment can be used to determine whether the target iterator is an empty iterator. The result can include the following two cases: the target iterator is an empty iterator, and the target iterator is not an empty iterator.

[0120] Specifically, upon obtaining the target iterator, or after determining the target iterator, it can be checked whether the target iterator is empty. Once the check for an empty target iterator is complete, the result can be obtained. Based on this result, the target data to be accessed can be determined.

[0121] Optionally, determining the target data to be accessed based on the judgment result includes: when the judgment result is that the target iterator is not an empty iterator, returning to the operation of calling the object element iterator acquisition method of the predefined C++ basic iteration template class to obtain the iterator of the adjacent element of the current element; taking the iterator of the adjacent element of the current element as the target iterator, and performing a judgment on whether the target iterator is an empty iterator to obtain the judgment result, and determining the target data to be accessed based on the judgment result.

[0122] Specifically, when the determination result indicates that the target iterator is not an empty iterator, the operation of calling the object element iterator retrieval method of the predefined C++ basic iteration template class can be performed to retrieve the iterators of the adjacent elements of the current element. Once the iterators of the adjacent elements of the current element have been retrieved, these iterators can be used as the target iterator, and a determination of whether the target iterator is empty can be performed. Based on the determination result, the operation of determining the target data to be accessed can be performed.

[0123] S370. Access the target data by using the data access methods of the predefined C++ iterator base class.

[0124] The technical solution of this embodiment, by calling the object element iterator acquisition method of a predefined C++ basic iteration template class in the data determination method of the C++ iterator class, obtains the iterator of the current element in the target collection object to be accessed, and uses the iterator of the current element as the target iterator. By determining whether the target iterator is an empty iterator, a judgment result is obtained, and the target data to be accessed is determined based on the judgment result. This achieves the technical effect of reducing code complexity and reducing the difficulty of code development by using the data determination method of the predefined C++ iterator class to determine the target data to be accessed from the storage space corresponding to the target collection object.

[0125] Example 4

[0126] Figure 4 This is a schematic diagram of a data access device module in a virtual machine according to Embodiment 4 of the present invention. The present invention provides a data access device in a virtual machine, which includes: a collection object acquisition module 410 to be accessed, a data identifier and data value storage module 420, a target data storage module 430 to be accessed, and a target data access module 440 to be accessed.

[0127] The system includes: a collection object acquisition module 410, used to acquire the collection object to be accessed in the virtual machine; a data identifier and data value storage module 420, used to acquire the virtual iterator of the collection object to be accessed through a predefined virtual machine iterator class constructor, and to store the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to the predefined identifier storage object through a predefined data storage method of the virtual machine iterator class, and to store the data value corresponding to the data identifier to the value storage space corresponding to the predefined value storage object; and a target data storage module 430, used to acquire the data identifier of the collection object to be accessed through a predefined virtual machine tool template class data construction method. The system retrieves the data identifier from the identifier storage space, retrieves the data value corresponding to the data identifier from the value storage space, and concatenates the data identifier of the data to be accessed and the data value corresponding to the data identifier into a key-value pair format corresponding to the target data to be accessed. The target data to be accessed is then stored in the storage space corresponding to a predefined target data to be accessed collection object. The target data to be accessed module 440 is used to determine the target data to be accessed from the storage space corresponding to the target data to be accessed collection object using a predefined data determination method of a C++ iterator class, and access the target data to be accessed using a predefined data access method of a C++ iterator base class.

[0128] The technical solution of this embodiment obtains the collection object to be accessed in the virtual machine through the collection object acquisition module. The data identifier and data value storage module calls the constructor method of a predefined virtual machine iterator class to obtain a virtual iterator for the collection object to be accessed. Using the predefined data storage method of the virtual machine iterator class, the data identifiers of the data to be accessed included in the virtual iterator are stored in the identifier storage space corresponding to a predefined identifier storage object, and the data values ​​corresponding to the data identifiers are stored in the value storage space corresponding to a predefined value storage object.

[0129] The target data storage module calls the data construction method of the predefined virtual machine tool template class to obtain the data identifier from the identifier storage space, obtain the data value corresponding to the data identifier from the value storage space, and concatenate the data identifier of the data to be accessed and the data value corresponding to the data identifier into the target data to be accessed in the format of key-value pairs. The target data to be accessed is then stored in the storage space corresponding to the predefined target collection object to be accessed.

[0130] By calling the data determination method of a predefined C++ iterator class through the target data access module, the target data to be accessed is determined from the storage space corresponding to the target collection object. The target data is then accessed through the data access method of the predefined C++ iterator base class. This solves the technical problem of poor code consistency and increased code development difficulty in the existing technology of accessing data of objects in the virtual machine in C++. It achieves the technical effect of improving code consistency and reducing code development difficulty, thereby improving code development efficiency.

[0131] Optionally, before storing the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to the predefined identifier storage object, and storing the data value corresponding to the data identifier to the value storage space corresponding to the predefined value storage object, through the predefined data storage method of the virtual machine iterator class, the device further includes: a data to be accessed determination module, used to determine whether the virtual iterator includes data to be accessed; if so, it calls the predefined data access method of the virtual machine iterator class to determine the data identifier of the data to be accessed included in the virtual iterator and the data value corresponding to the data identifier; if not, it displays a prompt message indicating that the virtual iterator does not include data to be accessed.

[0132] Optionally, the data identifier and data value storage module 420 is used to, in the predefined data storage method of the virtual machine iterator class, call a predefined data element acquisition method through the virtual iterator of the collection object to be accessed to determine the data to be accessed included in the virtual iterator; call a predefined data identifier storage method through the data to be accessed to store the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to the predefined identifier storage object; and call a predefined data value storage method through the data to be accessed to store the data value corresponding to the data identifier to the value storage space corresponding to the predefined value storage object.

[0133] Optionally, the target data storage module 430 is used in the data construction method of the predefined virtual machine tool template class to determine the field identifier corresponding to the data identifier of the data to be accessed by calling the system's object identifier determination method with the field name corresponding to the identifier storage object as the input parameter; and to determine the data identifier by calling the system's data value determination method with the field identifier corresponding to the data identifier as the input parameter.

[0134] Optionally, the target data storage module 430 is used to determine the field identifier corresponding to the data value of the data to be accessed by calling the system's object identifier determination method with the field name corresponding to the value storage object as the input parameter; and to determine the data value corresponding to the data identifier by calling the system's data value determination method with the field identifier corresponding to the data value as the input parameter.

[0135] The target data access module 440 is used to obtain the iterator of the current element in the target collection object by calling the object element iterator acquisition method of the predefined C++ basic iteration template class in the data determination method of the C++ iterator class, and using the iterator of the current element as the target iterator; determine whether the target iterator is an empty iterator, obtain the judgment result, and determine the target data to be accessed based on the judgment result.

[0136] The target data access module 440 is used to, when the judgment result is that the target iterator is not an empty iterator, return to the operation of calling the object element iterator acquisition method of the predefined C++ basic iteration template class to obtain the iterator of the adjacent element of the current element; take the iterator of the adjacent element of the current element as the target iterator, and perform the operation of judging whether the target iterator is an empty iterator to obtain the judgment result, and determine the target data to be accessed based on the judgment result.

[0137] The above-described apparatus can execute the data access method in a virtual machine provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the data access method in a virtual machine.

[0138] It is worth noting that the various units and modules included in the data access device in the virtual machine are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of the present invention.

[0139] Example 5

[0140] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram is shown of an exemplary electronic device 12 suitable for implementing any embodiment of the present invention. Figure 5 The electronic device 12 shown is merely an example and should not be construed as limiting the functionality or scope of the embodiments of the present invention. Device 12 is typically an electronic device that processes configuration information.

[0141] like Figure 5As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, memory 28, and bus 18 connecting different components (including memory 28 and processing unit 16).

[0142] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MCA) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0143] Electronic device 12 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0144] Memory 28 may include computer device readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 5(Not shown, commonly referred to as a "hard disk drive"). Although not shown in the figures, disk drives for reading and writing to removable non-volatile disks (e.g., "floppy disks") and optical disc drives for reading and writing to removable non-volatile optical discs (e.g., Compact Disc-Read Only Memory (CD-ROM), Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product 40 having a set of program modules 42 configured to perform the functions of the various embodiments of the present invention. Program product 40 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods of the embodiments described in the present invention.

[0145] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, mouse, camera, etc., and monitor), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., Local Area Network (LAN), Wide Area Network (WAN) and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) devices, tape drives, and data backup storage devices.

[0146] Processor 16 executes various functional applications and data processing by running programs stored in memory 28, such as implementing the data access method in a virtual machine provided in the above embodiments of the present invention, the method comprising:

[0147] The process involves: obtaining the collection object to be accessed in the virtual machine; obtaining a virtual iterator for the collection object using a predefined virtual machine iterator class constructor; storing the data identifier of the data to be accessed included in the virtual iterator to the identifier storage space corresponding to a predefined identifier storage object using a predefined data storage method of the virtual machine iterator class; storing the data value corresponding to the data identifier to the value storage space corresponding to a predefined value storage object using a predefined value storage method of the virtual machine utility template class; obtaining the data identifier from the identifier storage space and the data value corresponding to the data identifier from the value storage space using a predefined data construction method of the virtual machine utility template class; concatenating the data identifier of the data to be accessed and the data value corresponding to the data identifier into a key-value pair format for the target data to be accessed; storing the target data to be accessed in the storage space corresponding to the predefined target collection object; determining the target data to be accessed from the storage space corresponding to the target collection object using a predefined C++ iterator class data determination method; and accessing the target data to be accessed using a predefined C++ iterator base class data access method.

[0148] Of course, those skilled in the art will understand that the processor can also implement the data access method in the virtual machine provided in any embodiment of the present invention.

[0149] Example 5

[0150] Embodiment 5 of the present invention also provides a computer-readable storage medium storing a computer program thereon, characterized in that, when the program is executed by a processor, for example, the data access method in the virtual machine provided in the above embodiments of the present invention, the method includes:

[0151] Retrieve the collection object to be accessed in the virtual machine;

[0152] The virtual iterator of the collection object to be accessed is obtained by the constructor method of the predefined virtual machine iterator class. The data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the predefined identifier storage object by the predefined data storage method of the virtual machine iterator class, and the data value corresponding to the data identifier is stored in the value storage space corresponding to the predefined value storage object.

[0153] Using a predefined virtual machine tool template class data construction method, the data identifier is obtained from the identifier storage space, the data value corresponding to the data identifier is obtained from the value storage space, and the data identifier of the data to be accessed and the data value corresponding to the data identifier are concatenated into a key-value pair format corresponding to the target data to be accessed. The target data to be accessed is then stored in the storage space corresponding to the predefined target collection object to be accessed.

[0154] The target data to be accessed is determined from the storage space corresponding to the target collection object by using the data determination method of the predefined C++ iterator class, and the target data to be accessed is accessed by using the data access method of the predefined C++ iterator base class.

[0155] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0156] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0157] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0158] Computer program code for performing the operations of embodiments of the present invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0159] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A method of data access in a virtual machine, characterized by, The method comprises the following steps: acquiring a to-be-accessed collection object in a virtual machine; acquiring a virtual iterator of the to-be-accessed collection object through a predefined constructor method of a virtual machine iterator class, storing a data identifier of to-be-accessed data included in the virtual iterator into an identifier storage space corresponding to a predefined identifier storage object through a predefined data storage method of the virtual machine iterator class, and storing a data value corresponding to the data identifier into a value storage space corresponding to a predefined value storage object; acquiring the data identifier from the identifier storage space and the data value corresponding to the data identifier from the value storage space through a data construction method of a predefined virtual machine tool template class, and splicing the data identifier of the to-be-accessed data and the data value corresponding to the data identifier into a target to-be-accessed data in a key-value pair format, and storing the target to-be-accessed data into a storage space corresponding to a predefined target to-be-accessed collection object; determining the target to-be-accessed data from the storage space corresponding to the target to-be-accessed collection object through a data determination method of a predefined C++ iterator class, and accessing the target to-be-accessed data through a data access method of a predefined C++ iterator base class.

2. The method of claim 1, wherein, Before storing the data identifier of to-be-accessed data included in the virtual iterator into the identifier storage space corresponding to the predefined identifier storage object and storing the data value corresponding to the data identifier into the value storage space corresponding to the predefined value storage object through the predefined data storage method of the virtual machine iterator class, the method further comprises the following steps: determining whether to-be-accessed data is included in the virtual iterator, and if yes, calling a predefined data access method of the virtual machine iterator class to determine the data identifier of to-be-accessed data included in the virtual iterator and the data value corresponding to the data identifier; if no, displaying prompt information for prompting that to-be-accessed data is not included in the virtual iterator.

3. The method of claim 1, wherein, The step of storing the data identifier of to-be-accessed data included in the virtual iterator into the identifier storage space corresponding to the predefined identifier storage object and storing the data value corresponding to the data identifier into the value storage space corresponding to the predefined value storage object through the predefined data storage method of the virtual machine iterator class comprises the following steps: in the predefined data storage method of the virtual machine iterator class, calling a predefined data element acquisition method through the virtual iterator of the to-be-accessed collection object to determine to-be-accessed data included in the virtual iterator; storing the data identifier of to-be-accessed data included in the virtual iterator into the identifier storage space corresponding to the predefined identifier storage object through a predefined data identifier storage method of the to-be-accessed data; storing the data value corresponding to the data identifier into the value storage space corresponding to the predefined value storage object through a predefined data value storage method of the to-be-accessed data.

4. The method of claim 1, wherein, The data construction method through the pre-defined virtual machine tool template class, obtains the data identifier from the identifier storage space, and includes: In the data construction method of the pre-defined virtual machine tool template class, the data identifier of the data to be accessed is determined by calling the object identifier determination method of the system with the field name corresponding to the identifier storage object as an entry parameter; The data identifier is determined by calling the data value determination method of the system with the field identifier corresponding to the data identifier as an entry parameter.

5. The method of claim 4, wherein, The data value corresponding to the data identifier is obtained from the value storage space, and includes: The field identifier corresponding to the data value of the data to be accessed is determined by calling the object identifier determination method of the system with the field name corresponding to the value storage object as an entry parameter; The data value corresponding to the data identifier is determined by calling the data value determination method of the system with the field identifier corresponding to the data value as an entry parameter.

6. The method of claim 1, wherein, The data determination method through the pre-defined C++ iterator class, determines the target data to be accessed from the storage space corresponding to the target collection object to be accessed, and includes: In the data determination method of the C++ iterator class, the object element iterator acquisition method of the pre-defined C++ basic iteration template class is called to acquire the iterator of the current element in the target collection object to be accessed, and the iterator of the current element is used as a target iterator; It is judged whether the target iterator is a null iterator, and a judgment result is obtained, and the target data to be accessed is determined according to the judgment result.

7. The method of claim 6, wherein, The target data to be accessed is determined according to the judgment result, including: When the judgment result is that the target iterator is not a null iterator, the operation of calling the object element iterator acquisition method of the pre-defined C++ basic iteration template class is returned to acquire the iterator of the adjacent element of the current element; The adjacent element of the current element is used as a target iterator, and it is judged whether the target iterator is a null iterator, and a judgment result is obtained, and the target data to be accessed is determined according to the judgment result.

8. A data access apparatus in a virtual machine, characterized by comprising: It includes: The collection object to be accessed is acquired, and the collection object to be accessed in the virtual machine is acquired; The data identifier and the data value storage module are used to acquire the virtual iterator of the collection object to be accessed through the construction method of the pre-defined virtual machine iterator class, and the data identifier of the data to be accessed included in the virtual iterator is stored in the identifier storage space corresponding to the pre-defined identifier storage object through the pre-defined data storage method of the virtual machine iterator class, and the data value corresponding to the data identifier is stored in the value storage space corresponding to the pre-defined value storage object; The target data to be accessed storage module is configured to obtain the data identifier from the identifier storage space and the data value corresponding to the data identifier from the value storage space by using a data construction method of a predefined virtual machine tool template class, splice the data identifier of the data to be accessed and the data value corresponding to the data identifier into a target data to be accessed in a key-value pair format, and store the target data to be accessed in a storage space corresponding to a predefined target data to be accessed collection object; The target data to be accessed access module is configured to determine the target data to be accessed from the storage space corresponding to the target data to be accessed collection object by using a data determination method of a predefined C++ iterator class, and access the target data to be accessed by using a data access method of a predefined C++ iterator base class.

9. An electronic device, comprising: The electronic device includes: one or more processors; a storage device for storing one or more programs; When the program is executed by the processor, the processor implements a data access method in a virtual machine as claimed in any one of claims 1-7.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement a data access method in a virtual machine as claimed in any one of claims 1-7.

Citation Information

Patent Citations

  • Object access method, device and equipment and storage medium

    CN111290746A

  • Function verification method based on LLVM and related device

    CN112668004A