A method and apparatus for generating an XML file
By storing query results to local disks and using query IDs to retrieve data from cloud servers, the method addresses memory overflow issues in XML file generation, ensuring efficient data processing and file creation.
Patent Information
- Application Number
- CN202411368133.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2044-09-29
AI Technical Summary
There is a problem of memory overflow in the process of generating XML files, especially when the data volume is large, the existing technology is difficult to effectively solve.
By storing the query results to the local disk and using the cloud server, the distribution server obtains the query content from the cloud based on the query ID and generates XML files based on the data structure information to avoid directly transmitting large data to the distribution server and causing memory overflow.
It effectively solves the memory overflow problem, ensures the stability and efficiency of the process of generating XML files, and reduces the network transmission volume and the load pressure of distributed servers.
Smart Images

Figure CN119336257B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular, to a method and device for generating an XML file. Background Art
[0002] In the enterprise communication scenario, generally, the Extensible Markup Language (XML) is used as a communication message for data transmission.
[0003] Currently, generally based on the Java language, data is obtained from a data source and stored in a cache, and then the obtained data is spliced. If the amount of data required to generate an XML file is large, there will be a problem of memory overflow during the process of obtaining data and splicing data.
[0004] In summary, how to solve the problem of memory overflow during the process of generating an XML file is a technical problem that needs to be solved urgently at present. Summary of the Invention
[0005] A method and device for generating an XML file provided by an embodiment of the present invention are used to solve the problem of memory overflow in the prior art during the process of generating an XML file.
[0006] In a first aspect, a method for generating an XML file provided by an embodiment of the present invention includes: a distribution server sending a plurality of target query requests to a distributed server; any one of the target query requests being used to obtain a query result including at least one query content; the query result being obtained by the distributed server from a target data source and stored in a local disk; for any one of the target query requests, the distribution server receiving query information sent by the distributed server; the query information being obtained through the query result of the target query request; the query information including a query ID of at least one query content in the query result and data structure information for the query result; any one of the query IDs being generated by a cloud server based on any one of the query contents sent by the distributed server; the data structure information for the query result being generated by the distributed server and used to represent the subordination relationship between the query result and at least one query content; for any one of the target query requests, the distribution server obtaining the query content corresponding to at least one query ID from the cloud server according to the at least one query ID corresponding to the query result of the target query request; the distribution server generating a query object according to the query content corresponding to at least one query ID and the data structure information of the query result; the distribution server generating an XML file corresponding to the plurality of target query requests according to the plurality of query objects corresponding to the plurality of target query requests.
[0007] In the above technical solution, since the amount of data to be queried is large, when the distributed server obtains the query result from the target data source, the query result will be stored on the local disk, so as to avoid the problem of memory overflow during the process of obtaining the query result. Since the amount of data in the query result is large, in order to prevent the distributed server from directly sending the query result to the distribution server and causing memory overflow of the distribution server, the distributed server stores at least one query content in the query result on the cloud server. In this way, the distribution server will obtain the query content from the cloud server through the query ID, and then restore the query result with the data structure according to the data structure information and the query content, and generate an XML file according to the query result.
[0008] Optionally, the distribution server sends multiple target query requests to the distributed server, including: the distribution server receives multiple query requests; any query request includes query identity information and query content information; the distribution server classifies the multiple query requests according to the query identity information in any query request to obtain multiple query request groups; each query request group corresponds to one query identity information; for any query request group, the distribution server divides the multiple query requests in the query request group into individual query requests and common query requests according to the query content information of the multiple query requests in the query request group; and determines the individual query requests and common query requests corresponding to each query request group as multiple target query requests.
[0009] Optionally, the query result of any target query request is determined in the following manner: the distributed server obtains the query result corresponding to the target query request from the target data source; the query result includes at least one query content with the same query identity information; the distributed server traverses the query result to determine the data structure information of the query result and splits the query result into at least one query content and stores them separately in the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk; the distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
[0010] Optionally, the query ID is determined in the following manner: the distributed server sends multiple serialized query contents on the local disk to the cloud server; the cloud server generates a query ID corresponding to each serialized query content and sends it to the distributed server.
[0011] Optionally, before generating a query object based on the query content corresponding to at least one query ID and the data structure information of the query result, the distribution server further includes: the distribution server deserializes the serialized query content obtained from the cloud server according to at least one query ID to obtain at least one query content and stores it in the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it on the local disk; the distribution server clears the cache array and continues to obtain query content until all query content is stored on the local disk.
[0012] Optionally, generating a query object by the distribution server according to the query content corresponding to at least one query ID and the data structure information of the query result includes: the distribution server obtains each serialized query content corresponding to the query result from the local disk and performs deserialization processing; according to the data structure information of the query result, generates a query object from multiple deserialized query contents.
[0013] Optionally, generating an XML file corresponding to multiple target query requests by the distribution server according to multiple query objects corresponding to the multiple target query requests includes: the distribution server assigns any query object to an external object, and the external object is set with annotation information; the distribution server creates XML nodes for each query object and / or each external object to generate an XML file corresponding to the multiple target query requests.
[0014] In a second aspect, a method for generating an XML file provided by an embodiment of the present invention includes: a distributed server receives multiple target query requests sent by a distribution server; the distributed server obtains query results of the target query requests from a target data source according to the multiple target query requests; the distributed server traverses the query results, determines the data structure information of the query results, and stores the query results on the local disk; the query results include at least one query content; the data structure information is used to characterize the membership relationship between the query results and at least one query content; the distributed server sends the query results to the cloud server; the distributed server receives a query ID sent by the cloud server; any query ID is generated by the cloud server based on any query content sent by the distributed server; the distributed server determines query information according to the query ID of at least one query content in the query results and the data structure information of the query results and sends it to the distribution server; the query information is used for the distribution server to obtain the query content corresponding to at least one query ID from the cloud server and generate an XML file according to the query content.
[0015] Optionally, the distributed server obtains the query results of the target query requests from the target data source according to multiple target query requests, including: the distributed server obtains the query results corresponding to the target query requests from the target data source; the query results include at least one query content with the same query identity information; the distributed server traverses the query results, determines the data structure information of the query results, and splits the query results into at least one query content and stores them separately in the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk; the distributed server clears the cache array and continues to obtain the query results until the query results are stored on the local disk.
[0016] In a third aspect, an apparatus for generating an XML file provided by an embodiment of the present invention includes: a sending unit configured to send multiple target query requests to a distributed server; any one of the target query requests is used to obtain a query result including at least one query content; the query result is obtained by the distributed server from the target data source and stored on the local disk; a first processing unit configured to, for any one of the target query requests, receive the query information sent by the distributed server; the query information is obtained from the query result of the target query request; the query information includes the query ID of at least one query content in the query result and the data structure information for the query result; any one of the query IDs is generated by the cloud server based on any one of the query contents sent by the distributed server; the data structure information for the query result is generated by the distributed server and is used to represent the subordination relationship between the query result and at least one query content; for any one of the target query requests, obtain the query content corresponding to at least one query ID from the cloud server according to the at least one query ID corresponding to the query result of the target query request; generate a query object according to the query content corresponding to at least one query ID and the data structure information of the query result; generate an XML file corresponding to multiple target query requests according to multiple query objects corresponding to multiple target query requests.
[0017] Optionally, the sending unit is specifically configured to: receive multiple query requests; any one of the query requests includes query identity information and query content information; classify the multiple query requests according to the query identity information in any one of the query requests to obtain multiple query request groups; each query request group corresponds to one query identity information; for any one of the query request groups, divide the multiple query requests in the query request group into individual query requests and common query requests according to the query content information of the multiple query requests in the query request group; determine the individual query requests and common query requests corresponding to each query request group as multiple target query requests.
[0018] Optionally, the query result of any target query request is determined as follows: The distributed server obtains the query result corresponding to the target query request from the target data source; the query result includes at least one query content with the same query identity information; the distributed server traverses the query result, determines the data structure information of the query result, and splits the query result into at least one query content and stores them separately into the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk; the distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
[0019] Optionally, the query ID is determined as follows: The distributed server sends multiple serialized query contents on the local disk to the cloud server; the cloud server generates a query ID corresponding to each serialized query content and sends it to the distributed server.
[0020] Optionally, the first processing unit is further configured to: The distribution server deserializes the serialized query content obtained from the cloud server according to at least one query ID to obtain at least one query content and stores it into the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it on the local disk; the distribution server clears the cache array and continues to obtain the query content until all the query content is stored on the local disk.
[0021] Optionally, the first processing unit is specifically configured to: Obtain each serialized query content corresponding to the query result from the local disk and perform deserialization processing; according to the data structure information of the query result, generate query objects from multiple deserialized query contents.
[0022] Fourthly, an apparatus for generating an XML file provided by an embodiment of the present invention includes: an obtaining unit configured to obtain, according to a plurality of target query requests, query results of the target query requests from a target data source; traverse the query results to determine data structure information of the query results, and store the query results to a local disk; the query results include at least one query content; the data structure information is used to represent a subordination relationship between the query results and the at least one query content; a second processing unit configured to send the query results to a cloud server; receive a query ID sent by the cloud server; any query ID is generated by the cloud server based on any query content sent by a distributed server; determine query information according to the query IDs of at least one query content in the query results and the data structure information of the query results, and send the query information to a distribution server; the query information is used for the distribution server to obtain query content corresponding to at least one query ID from the cloud server, and generate an XML file according to the query content.
[0023] Optionally, the obtaining unit is specifically configured to: obtain query results corresponding to the target query requests from the target data source; the query results include at least one query content having the same query identity information; traverse the query results to determine the data structure information of the query results and split the query results into at least one query content and store them separately to a cache array defined in a LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, perform serialization processing on the query content in the cache array and then store it to the local disk; empty the cache array and continue to obtain query results until the query results are stored to the local disk.
[0024] Fifthly, an embodiment of the present application further provides a computing device, including: a memory configured to store a program; a processor configured to call the program stored in the memory and execute a method for generating an XML file as described in the first aspect according to the obtained program.
[0025] Sixthly, an embodiment of the present application further provides a computer-readable non-volatile storage medium, including a computer-readable program, when the computer reads and executes the computer-readable program, causing the computer to execute a method for generating an XML file as described in the first aspect.
[0026] Seventhly, an embodiment of the present application provides a computer program product, the computer program product includes a computer program stored on a computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a computer device, causing the computer device to execute the steps of the method for generating an XML file as described in the first aspect above. Description of the Drawings
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the attached drawings required for description in the embodiments. Obviously, the attached drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other attached drawings can be obtained based on these attached drawings.
[0028] Figure 1 It is a flowchart of a method for generating an XML file provided by an embodiment of the present invention;
[0029] Figure 2 It is a flowchart of a method for screening query requests provided by an embodiment of the present invention;
[0030] Figure 3 It is a flowchart of a method for obtaining query results provided by an embodiment of the present invention;
[0031] Figure 4 It is a flowchart of a method for uploading query content to a cloud server provided by an embodiment of the present invention;
[0032] Figure 5 It is a flowchart of a method for obtaining query content from a cloud server provided by an embodiment of the present invention;
[0033] Figure 6 It is a flowchart of a method for generating a query object provided by an embodiment of the present invention;
[0034] Figure 7 It is a flowchart of a method for generating an XML file provided by an embodiment of the present invention;
[0035] Figure 8 It is a schematic structural diagram of a device for generating an XML file provided by an embodiment of the present invention;
[0036] Figure 9 It is a schematic structural diagram of a device for generating an XML file provided by an embodiment of the present invention;
[0037] Figure 10 It is a schematic structural diagram of a computing device provided by an embodiment of the present invention. Detailed implementation manners
[0038] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the attached drawings. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0039] Such as Figure 1As shown in the figure, it is a flowchart of a method for generating an XML file provided by an embodiment of the present invention. The method includes the following steps:
[0040] Step 101, the distribution server sends multiple target query requests to the distributed server.
[0041] In an embodiment of the present invention, any target query request is used to obtain a query result including at least one query content. Since the number of query results required to generate the XML file is large, directly storing them in the cache will cause a memory overflow problem. Therefore, the distributed server obtains the query result from the target data source and stores it on the local disk. In this way, it is possible to ensure that the memory does not overflow during the process of the distributed server obtaining the query result. The target data source can be a database, a data folder, or other data sources, which is not limited here.
[0042] Step 102, for any target query request, the distribution server receives the query information sent by the distributed server.
[0043] In an embodiment of the present invention, the distributed server obtains multiple pieces of query information according to multiple target query requests. The query information includes the query ID of at least one query content in the query result and the data structure information for the query result. Any query ID is generated by the cloud server based on any query content sent by the distributed server. The data structure information for the query result is generated by the distributed server and is used to represent the subordination relationship between the query result and at least one query content.
[0044] Step 103, for any target query request, the distribution server obtains the query content corresponding to at least one query ID from the cloud server according to at least one query ID corresponding to the query result of the target query request.
[0045] In an embodiment of the present invention, in order to generate an XML file subsequently, the distribution server can obtain the query content corresponding to the query ID from the cloud server according to the query ID sent by the distributed server to the distribution server.
[0046] Step 104, the distribution server generates a query object according to the query content corresponding to at least one query ID and the data structure information of the query result.
[0047] In an embodiment of the present invention, since there is a subordination relationship between multiple query contents and the query result, and there is also a data structure in the internal data of the query content, the distribution server needs to generate a query object with a data structure according to the query content and the data structure information of the query result.
[0048] Step 105: The distribution server generates XML files corresponding to multiple target query requests based on multiple query objects corresponding to the multiple target query requests.
[0049] In the embodiment of the present invention, after the distribution server obtains multiple query objects, XML files corresponding to multiple target query requests can be generated according to the multiple query objects.
[0050] It can be seen from the above steps 101 to 105 that since the amount of data to be queried is large, when the distributed server obtains the query result from the target data source, the query result will be stored on the local disk, so as to realize the problem that the memory does not overflow during the process of obtaining the query result. Since the amount of data in the query result is large, in order to prevent the problem that the distributed server directly sends the query result to the distribution server and causes the memory of the distribution server to overflow, the distributed server stores at least one query content in the query result in the cloud server. In this way, the distribution server will obtain the query content from the cloud server through the query ID, and then restore the query result with the data structure according to the data structure information and the query content, and generate an XML file according to the query result.
[0051] Since the amount of data to be queried is large and there is a lot of content to be queried in the query request, before the distribution server sends the query request to the distributed server, it is necessary to first perform resource integration on the query request and screen out some duplicate query contents, which can reduce the distribution workload of the distribution server and the network transmission volume between the subsequent distribution server and the distributed server, and reduce the load pressure on the distributed server.
[0052] Such as Figure 2 shown, is a flowchart of a method for screening query requests provided by an embodiment of the present invention. The method includes the following steps:
[0053] Step 201: The distribution server receives multiple query requests.
[0054] In the embodiment of the present invention, the distribution server receives multiple query requests. Since the number of query requests is large, it is necessary to screen out duplicate query requests to reduce the distribution workload of the distribution server.
[0055] Step 202: The distribution server classifies the multiple query requests according to the query identity information in any one of the query requests to obtain multiple query request groups.
[0056] In the embodiments of the present invention, the queried identity information includes an account number, a card number, and an identification number, and may also be other information for proving identity information, which is not limited herein. First, according to the queried identity information, multiple query requests are classified, and the query information with the same queried identity information is divided into one group to obtain multiple query request groups. For example, the distribution server receives multiple query requests, namely query request A, query request B, and query request C. Among them, the account information of query request A is account number 1, the account information of query request B is account number 2, and the account information of query request C is account number 1. Since the queried identity information of query request A and query request C is both account number 1, query request A and query request C are grouped into the same query request group. Any one of the query request groups corresponds to the same object; each query request group corresponds to a queried identity information;
[0057] Step 203, for any one of the query request groups, the distribution server divides the multiple query requests in the query request group into individual query requests and common query requests according to the query content information of the multiple query requests in the query request group.
[0058] In the embodiments of the present invention, the query content information includes customer information, account information, financial management information, transaction details and other information, and may also be other information representing content, which is not limited herein. After classifying the multiple query requests, for any one of the query requests in the same query request group, a bitmap vector string is generated according to the query content information, where 0 indicates not to query and 1 indicates to query. For example, if the account information of query request A, query request B, and query request C is all account number 1, that is to say, these three query requests are grouped into one category. The bitmap vector strings of these three query requests can be viewed through Table 1:
[0059]
[0060] Among them, the bitmap vector string of query request A is 11010, the bitmap vector string of query request B is 11110, and the bitmap vector string of query request C is 10110. By taking the intersection of the bitmap vector strings of these three query requests, that is, 11010 ∩ 11110 ∩ 10110 = 10010. According to the result of the intersection, it can be seen that these three query requests all need to query customer information and transaction details. That is to say, the common query content information is customer information and transaction details. Among them, the individual query content information of query request A is account information, the individual query content information of query request B is account information and financial management information, and the individual query content information of query request C is customer information and financial management information. Therefore, by splitting multiple target query requests of the same query request group into common query content information and individual query content information, that is, splitting the content to be queried into the content of common query and the content of individual query, and by determining the content of common query, the number of queries for customer information and transaction details is reduced from 3 times to 1 time, thus reducing the number of queries.
[0061] Step 204: Determine the individual query requests and common query requests corresponding to each query request group as multiple target query requests.
[0062] In the embodiment of the present invention, for any query request group, the target query requests of the query request group include individual query requests and common query requests. The query identity information of any one of the target query requests is the same. One query request group corresponds to one target query request.
[0063] It can be seen from the above steps 201 to 204 that by determining the content of common query, duplicate query content information is screened out, thereby reducing the number of queries, and further reducing the data transmission volume, saving the subsequent storage space and resource consumption of the distributed server.
[0064] In the embodiment of the present invention, the distribution server screens out some duplicate query content, determines the target query requests, and then sends the target query requests to the distributed server. The distributed server obtains the query results corresponding to the target query requests from the target data source according to the target query requests.
[0065] In a possible scenario, if the XML document is generated by splicing nodes based on the Java language, ArrayList is a commonly used LIST in Java, which internally uses a cached array to store elements, and the cached array can be Object[] elementData. The query result is obtained from the target data source through a query request and stored in the array Object[] elementData. Specifically, through the add(E e) method of ArrayList, this method first expands the cached array elementData by increasing it by 1, and then stores the query result in the cached array elementData. If the number of elements stored in ArrayList is very large, then the cached array elementData will be very large, which may cause an out-of-memory error.
[0066] An embodiment of the present invention provides a method for obtaining a query result to solve the problem of out-of-memory error caused during the process of obtaining the query result corresponding to the target query request from the target data source.
[0067] As Figure 3 shown, it is a flowchart of a method for obtaining a query result provided by an embodiment of the present invention, and the method includes the following steps:
[0068] Step 301, the distributed server obtains the query result corresponding to the target query request from the target data source.
[0069] In an embodiment of the present invention, the distributed server obtains the query result corresponding to the target query request from the target data source according to the target query request.
[0070] Step 302, the distributed server traverses the query result, determines the data structure information of the query result, and splits the query result into at least one query content and stores them separately in the cached array defined in the LIST interface.
[0071] In the embodiments of the present invention, since there is a subordination relationship between at least one query content in the query result and the query result, and the internal data of the query content also has a data structure relationship. For example, the query result includes customer information, financial management information, transaction details, freezing information, and account information. Since the data volume of any query result is large, if the query result is directly stored in the cache, it will directly cause the problem of out-of-memory. Therefore, since the target query request includes a separate query request and a common query request, the distributed server obtains at least one query content in the query result according to the target query request, then traverses the entire query result to determine the data structure information of the query result, and splits the query result into at least one query content, and then stores them separately in the cache array defined in the LIST interface. The capacity limit of the cached data can be dynamically adjusted, which can not only take into account the storage file efficiency but also avoid the entire system crashing due to out-of-memory.
[0072] Step 303, when the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk.
[0073] In the embodiments of the present invention, since the cache array has a set length, when the cached data reaches the capacity limit, the distributed server will perform JSON serialization processing on the query content in the cache array to obtain a JSON string, and store the JSON string on the local disk, so as to ensure that there is no out-of-memory problem during the process of obtaining the query result. For example, in a custom LIST collection class, rewrite the underlying core logic and assign the call to the add(E e) method. add(E e) is a method of the standard interface LIST. If the data volume of the query result is particularly large, if tens of millions of data volumes are continuously called add(E e), then the memory of Java will definitely overflow. Define a cache array in LIST. When add(E e) is called, e is temporarily placed in the cache array. When the data in the cache array reaches the cache value, such as 1000, create a temporary file on the local disk, loop through the object list in the cache array, serialize the query content in the cache array and store it in the temporary file on the local disk. When add(E e) is called again, the cache array is reinitialized and stored starting from 1.
[0074] Step 304, the distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
[0075] In the embodiments of the present invention, since the query content in the cache array has been stored on the local disk, to prevent the problem of out-of-memory, the distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
[0076] As can be seen from the above steps 301 to 304, by storing the query results in the local disk, the problem of memory overflow can be prevented, and the preset threshold can be dynamically adjusted, so as to ensure both the efficiency of storing query results and avoid the problem of memory overflow.
[0077] Optionally, since any target query request includes a common query request and a separate query request, any common query request or any separate query request is used to request the corresponding query content from the target data source. Therefore, any query result is composed of at least one query content, and any query result has data structure information, which is used to characterize the subordination relationship between the query result and at least one query content, as well as the internal data structure relationship of any query content. The distribution server needs to generate an XML file based on the query content and the data structure information of the query result. Therefore, the query result needs to be sent to the distribution server.
[0078] Optionally, if the query result is saved as personal information Customer, where the personal information Customer includes a list of transaction details <traninfo>, Financial Information List <fininfo>, where the transaction details List <traninfo>TranInfo object containing 10 million and a List of financial management information <fininfo>An object containing 20 million; Since a custom RemoteFileStreamList is used, there will be no out-of-memory error during the add() operation in the storage process. In order to return the query result Customer to the distribution server, it needs to be serialized to generate a result message, such as a JSON string. However, if the object Customer is directly serialized, the transaction details List will be directly included <traninfo>10 million TranInfo objects (assuming the object contains 10 fields), wealth management information List <fininfo>If all 20 million FinInfo objects (assuming each object contains 10 fields) are serialized into JSON strings, there is a risk of out-of-memory due to their extremely large data volume (10 million * 10 + 20 million * 10 = 300 million fields).
[0079] In a possible scenario, the distributed server sends the JSON string of at least one query content of the query result and the data structure information of the query result to the distribution server. The distribution server deserializes the JSON string and stores it in the cache array. When the cache array reaches its limit, the distribution server stores the query content on the local disk, then clears the cache array and continues to obtain query content until all query content is stored on the local disk. Then, the distribution server generates a query object based on the data structure information and the query content, facilitating the subsequent generation of an XML file based on the query object.
[0080] In another possible scenario, the present invention introduces a cloud server. The distributed server uploads the query content to the cloud server and sends the data structure information to the distribution server. In this way, the distribution server obtains the query content from the cloud server and then determines the query object based on the query content and the data structure information.
[0081] Therefore, an embodiment of the present invention provides a method flowchart for uploading query content to a cloud server. The method includes the following steps:
[0082] As Figure 4 shown, it is a method flowchart for uploading query content to a cloud server provided by an embodiment of the present invention. The method includes the following steps:
[0083] Step 401, the distributed server sends multiple serialized query contents in the local disk to the cloud server.
[0084] In an embodiment of the present invention, the distributed server sends multiple serialized query contents in the local disk to the cloud server, which facilitates the subsequent distribution server to obtain the query content from the cloud server.
[0085] Step 402, the cloud server generates a query ID corresponding to each serialized query content and sends it to the distributed server.
[0086] In an embodiment of the present invention, for any serialized query content, the cloud server generates a corresponding query ID and a corresponding check value, and then sends the query ID and the check value to the distributed server. When the distributed server receives the query ID and the check value, the distributed server clears the temporary files in the local disk. The query ID is used by the subsequent distribution server to obtain the corresponding serialized query content from the cloud server, and the check value is the MD5 value used to verify the integrity of the serialized query content.
[0087] As can be seen from the above steps 401 to 402, by uploading the query content to the cloud server, the distributed server will not directly send the query result to the distribution server, resulting in a memory overflow problem. If the distributed server performs JSON serialization on the query ID and the check value and sends the serialized query ID and check value to the distribution server, the distribution server can sequentially obtain the query content from the cloud server according to the query ID.
[0088] In an embodiment of the present invention, the distributed server performs JSON serialization on the query ID and the check value, and sends the serialized query ID and check value to the distribution server. Specifically, the distributed server customizes a RemoteFileStreamListAdapter, inherits from the TypeAdapter of GSON, and calls write(JSONWriter out, RemoteFileStreamList<?> value) during serialization. The write method only serializes the data structure information of the query ID, the check value, and the query result and sends it to the distribution server, so that the transaction details List will not be serialized. <traninfo>, Financial Information List <fininfo>All the data in it is serialized, so as to ensure that the distribution server will not have a memory overflow problem.
[0089] The following describes how the distribution server obtains the query content from the cloud server and how to avoid memory overflow during the process of obtaining the query content.
[0090] As Figure 5 shown, it is a flowchart of a method for obtaining query content from a cloud server provided by an embodiment of the present invention. The method includes the following steps:
[0091] Step 501, the distribution server deserializes the serialized query content obtained from the cloud server according to at least one query ID, obtains at least one query content, and stores it in the cache array defined in the LIST interface.
[0092] In an embodiment of the present invention, the distribution server receives the serialized query ID and the serialized check value sent by the distributed server, and performs deserialization processing to obtain the query ID and the check value. Then, the distribution server obtains the serialized query content from the cloud server according to the query ID, and performs deserialization processing to obtain at least one query content, and stores it in the cache array defined in the LIST interface. For example, in the read(JsonReader in) deserialization method of the custom RemoteFileStreamListAdapter, the read method stores the fildId value and the fileHash value of JSON as the attribute fields fildId and fileHash of the object RemoteFileStreamList respectively, and then the read method returns the object RemoteFileStreamList <e>. Thus, the Customer object is restored, along with its List of property transaction details <traninfo>, Financial Information List <fininfo>When initializing the RemoteFileStreamList, the distribution server calls the cloud file server according to the fildId value and the fileHash value to obtain the result file queried by the distributed server, and at the same time saves it as a temporary file tempRemote.json on the local disk.
[0093] Step 502, when the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it on the local disk.
[0094] In the embodiment of the present invention, in order to prevent the memory of the distribution server from overflowing, when the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it in a temporary file on the local disk.
[0095] Step 503, the distribution server clears the cache array and continues to obtain the query content until all the query content is stored on the local disk.
[0096] In the embodiment of the present invention, the distribution server clears the cache array, that is, initializes the cache array, and then continues to obtain the query content from the cloud server according to the query ID until all the query content is stored in the temporary file on the local disk.
[0097] It can be seen from the above steps 501 to 503 that by setting the cache array, the memory does not overflow during the process of the distribution server obtaining the query content.
[0098] After the distribution server stores the query content on the local disk, the distribution server generates a query object according to the data structure information of the query content and the query result.
[0099] As Figure 6 shown, it is a flowchart of the method for generating a query object provided by the embodiment of the present invention, and the method includes the following steps:
[0100] Step 601, the distribution server obtains each serialized query content corresponding to the query result from the local disk and performs deserialization processing.
[0101] In the embodiment of the present invention, since the query content obtained by the distribution server is JSON-serialized, the distribution server first needs to obtain each serialized query content corresponding to the query result from the temporary file on the local disk and perform deserialization processing. For example, the distribution server calls the custom RemoteFileStreamList traversal method next(), which implements the standard interface Iterator. Each time the next() method is called, only one JSON string of data is taken out from the temporary file and deserialized.
[0102] Step 602: Generate query objects from multiple deserialized query contents according to the data structure information of the query results.
[0103] In the embodiment of the present invention, since the query object has a data structure, query objects can be generated from the deserialized query contents according to the data structure information of the query results. The internal data of the query contents in the query object has a data structure, and there is a subordination relationship between the query contents and the query results. Therefore, the distribution server performs deserialization processing on the serialized data structure information, and then generates query objects from multiple deserialized query contents according to the data structure information of the query results.
[0104] It can be seen from the above steps 601 to 602 that the distribution server can restore the query results, that is, the query objects, according to the data structure information and the query contents corresponding to the query results.
[0105] As Figure 7 shown, it is a flowchart of a method for generating an XML file provided by an embodiment of the present invention. The method includes the following steps:
[0106] Step 701: The distribution server assigns any query object to an external object, and the external object is provided with annotation information.
[0107] In the embodiment of the present invention, the distribution server assigns annotation information to any query object. In this way, since the object is annotated, it is convenient to splice multiple query objects with annotation information later to obtain an XML file. For example, assign the returned query object E to the external object T, and call the add(T t) method of the custom FileStreamList collection class. The add(T t) method is an addition method of the standard interface List. The external object T will be defined as different objects T according to different external access parties. For example, for the same account information, the object defined by access party A is Ta, and the annotation of the account is: @XmlElement(name = "ACCT_NO"), while the object defined by access party B is Tb, and the annotation of the account is: @XmlElement(name = "accountNo"), and different XML tags <ACCT_NO> can be generated according to different annotations. <accountno>In this way, different access parties only need to define different object Ts and annotation tags, and can easily expand the generation function of large XML files.
[0108] Step 702: The distribution server creates XML nodes for each query object and / or each external object to generate XML files corresponding to multiple target query requests.
[0109] In the embodiment of the present invention, when the distribution server calls add(T t) of FileStreamList to reach the set cache value, it performs JSON serialization on the object T in its memory and persists it in the XML folder on the local disk, and at the same time clears the memory object.
[0110] It can be seen from the above steps 701 to 702 that by using the annotation method, the structure of the XML file is intuitively reflected by the attributes of the object, and the hierarchical relationship between the parent and child nodes of the XML is reflected by the collection of objects, so that the query objects can be quickly and simply spliced according to the annotation information to obtain the XML file.
[0111] Based on the same technical concept, the embodiment of the present application provides a device for generating an XML file, as Figure 8 shown. The device 800 includes: a sending unit 801 for sending multiple target query requests to the distributed server; any target query request is used to obtain a query result including at least one query content; the query result is obtained by the distributed server from the target data source and stored on the local disk; a first processing unit 802 for, for any target query request, receiving the query information sent by the distributed server; the query information is obtained from the query result of the target query request; the query information includes the query ID of at least one query content in the query result and the data structure information for the query result; any query ID is generated by the cloud server based on any query content sent by the distributed server; the data structure information for the query result is generated by the distributed server and is used to characterize the subordination relationship between the query result and at least one query content; for any target query request, obtaining the query content corresponding to at least one query ID from the cloud server according to the at least one query ID corresponding to the query result of the target query request; generating a query object according to the query content corresponding to at least one query ID and the data structure information of the query result; and generating XML files corresponding to multiple target query requests according to the multiple query objects corresponding to the multiple target query requests.
[0112] Optionally, the sending unit 801 is specifically configured to: receive multiple query requests; any query request includes query identity information and query content information; classify the multiple query requests according to the query identity information in any query request to obtain multiple query request groups; each query request group corresponds to one query identity information; for any query request group, divide the multiple query requests in the query request group into individual query requests and common query requests according to the query content information of the multiple query requests in the query request group; and determine the individual query requests and common query requests corresponding to each query request group as multiple target query requests.
[0113] Optionally, the query result of any target query request is determined in the following manner: the distributed server obtains the query result corresponding to the target query request from the target data source; the query result includes at least one query content with the same query identity information; the distributed server traverses the query result to determine the data structure information of the query result and split the query result into at least one query content and store them separately in the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk; the distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
[0114] Optionally, the query ID is determined in the following manner: the distributed server sends multiple serialized query contents on the local disk to the cloud server; the cloud server generates a query ID corresponding to each serialized query content and sends it to the distributed server.
[0115] Optionally, the first processing unit 802 is further configured to: the distribution server deserializes the serialized query contents obtained from the cloud server according to at least one query ID to obtain at least one query content and stores them in the cache array defined in the LIST interface; the cache array has a set length; when the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it on the local disk; the distribution server clears the cache array and continues to obtain the query content until all the query contents are stored on the local disk.
[0116] Optionally, the first processing unit 802 is specifically configured to: obtain each serialized query content corresponding to the query result from the local disk and perform deserialization processing; generate query objects from the multiple deserialized query contents according to the data structure information of the query result.
[0117] Based on the same technical concept, an embodiment of the present application provides a device for generating an XML file, such as Figure 9 As shown in the figure, the device 900 includes: an acquisition unit 901 configured to obtain query results of target query requests from a target data source according to multiple target query requests; traverse the query results, determine data structure information of the query results, and store the query results on a local disk; the query results include at least one query content; the data structure information is used to represent the subordination relationship between the query results and at least one query content;
[0118] A second processing unit 902 is configured to send the query results to a cloud server; receive a query ID sent by the cloud server; any query ID is generated by the cloud server based on any query content sent by a distributed server; determine query information according to the query ID of at least one query content in the query results and the data structure information of the query results, and send the query information to a distribution server; the query information is used for the distribution server to obtain query content corresponding to at least one query ID from the cloud server and generate an XML file according to the query content.
[0119] Optionally, the acquisition unit 901 is specifically configured to: obtain query results corresponding to a target query request from a target data source; the query results include at least one query content having the same query identity information; traverse the query results, determine the data structure information of the query results, and split the query results into at least one query content and store them in a cache array defined in a LIST interface respectively; the cache array has a set length; when the cache array reaches the capacity limit, perform serialization processing on the query content in the cache array and then store it on a local disk; clear the cache array and continue to obtain the query results until the query results are stored on the local disk.
[0120] Based on the same technical concept, an embodiment of the present application provides a computing device, such as Figure 10 As shown in the figure, it includes at least one processor 1001 and a memory 1002 connected to at least one processor. In the embodiment of the present application, the specific connection medium between the processor 1001 and the memory 1002 is not limited. Figure 10 Taking the example that the processor 1001 and the memory 1002 are connected by a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0121] In the embodiment of the present application, the memory 1002 stores instructions executable by at least one processor 1001. By executing the instructions stored in the memory 1002, at least one processor 1001 can execute the steps of generating the XML file described above.
[0122] Among them, the processor 1001 is the control center of the computing device. It can connect various parts of the computing device through various interfaces and circuits, and process the generated XML file by running or executing the instructions stored in the memory 1002 and calling the data stored in the memory 1002.
[0123] Optionally, the processor 1001 may include one or more processing units. The processor 1001 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may also be integrated into the processor 1001. In some embodiments, the processor 1001 and the memory 1002 may be implemented on the same chip. In some embodiments, they may also be separately implemented on independent chips.
[0124] The processor 1001 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit (ASIC), a field programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, which can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application may be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0125] The memory 1002, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The memory 1002 can include at least one type of storage medium. For example, it can include flash memory, hard disks, multimedia cards, card-type memories, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memories, magnetic disks, optical disks, and so on. The memory 1002 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer device, but is not limited thereto. The memory 1002 in the embodiments of the present application can also be a circuit or any other device capable of implementing a storage function, for storing program instructions and / or data.
[0126] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium storing a computer program executable by a computer device. When the program runs on the computer device, it causes the computer device to execute the steps of the above method for generating an XML file.
[0127] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0128] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices generate for implementing the flow Figure 1 One or more processes and / or blocks Figure 1 Apparatus for the functions specified in one or more blocks
[0129] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to work in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction apparatus that implements the functions in the process Figure 1 One or more processes and / or blocks Figure 1 The functions specified in one or more blocks
[0130] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus, such that a series of operational steps are performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions in the process Figure 1 One or more processes and / or blocks Figure 1 The steps of the functions specified in one or more blocks
[0131] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these modifications and variations< / accountno> < / fininfo> < / traninfo> < / e> < / fininfo> < / traninfo> < / fininfo> < / traninfo> < / fininfo> < / traninfo> < / fininfo> < / traninfo>
Claims
1. A method for generating an Extensible Markup Language (XML) file, characterized in that Including: The distribution server sends multiple target query requests to the distributed server; Any one of the target query requests is used to obtain a query result including at least one query content; The query result is obtained by the distributed server from the target data source and stored on the local disk; For any one of the target query requests, the distribution server receives the query information sent by the distributed server; The query information is obtained from the query result of the target query request; The query information includes the query ID of at least one query content in the query result and the data structure information for the query result; any query ID is generated by the cloud server based on any query content sent by the distributed server; The data structure information for the query result is generated by the distributed server and is used to characterize the subordination relationship between the query result and the at least one query content; For any one of the target query requests, the distribution server obtains the query content corresponding to the at least one query ID from the cloud server according to the at least one query ID corresponding to the query result of the target query request; The distribution server generates a query object according to the query content corresponding to the at least one query ID and the data structure information of the query result; The distribution server generates an XML file corresponding to the multiple target query requests according to the multiple query objects corresponding to the multiple target query requests.
2. The method according to claim 1, wherein The distribution server sends multiple target query requests to the distributed server, including: The distribution server receives multiple query requests; any one of the query requests includes query identity information and query content information; The distribution server classifies the multiple query requests according to the query identity information in any one of the query requests, and obtains multiple query request groups; each query request group corresponds to one query identity information; For any one of the query request groups, the distribution server divides the multiple query requests in the query request group into individual query requests and common query requests according to the query content information of the multiple query requests in the query request group; The individual query requests and common query requests corresponding to each query request group are determined as multiple target query requests.
3. The method according to claim 1, characterized in that, The query result of any one of the target query requests is determined by the following method: The distributed server obtains the query result corresponding to the target query request from the target data source; the query result includes at least one query content with the same query identity information; The distributed server traverses the query result, determines the data structure information of the query result and splits the query result into at least one query content and stores them separately in the cache array defined in the LIST interface; the cache array has a set length; When the cache array reaches the capacity limit, the distributed server serializes the query content in the cache array and stores it on the local disk; The distributed server clears the cache array and continues to obtain the query result until the query result is stored on the local disk.
4. The method according to claim 3, characterized in that, The query ID is determined by the following method: The distributed server sends multiple serialized query contents in the local disk to the cloud server; The cloud server generates a query ID corresponding to each serialized query content and sends it to the distributed server.
5. The method according to claim 1, characterized in that Before the distribution server generates a query object according to the query content corresponding to the at least one query ID and the data structure information of the query result, it further includes: The distribution server deserializes the serialized query content obtained from the cloud server according to the at least one query ID to obtain at least one query content and stores it in the cache array defined in the LIST interface; the cache array has a set length; When the cache array reaches the capacity limit, the distribution server serializes the content in the cache array and stores it in the local disk; The distribution server clears the cache array and continues to obtain query contents until all query contents are stored in the local disk.
6. The method according to claim 5, wherein The distribution server generates a query object according to the query content corresponding to the at least one query ID and the data structure information of the query result, including: The distribution server obtains each serialized query content corresponding to the query result from the local disk and performs deserialization processing; According to the data structure information of the query result, multiple deserialized query contents are generated into a query object.
7. The method according to claim 6, wherein The distribution server generates an XML file corresponding to the multiple target query requests according to the multiple query objects corresponding to the multiple target query requests, including: The distribution server assigns any query object to an external object, and the external object is provided with annotation information; The distribution server creates XML nodes for each query object and / or each external object to generate an XML file corresponding to the multiple target query requests.
8. A method for generating an XML file, characterized in that, It includes: The distributed server receives multiple target query requests sent by the distribution server; The distributed server obtains the query result of the target query request from the target data source according to the multiple target query requests; The distributed server traverses the query result, determines the data structure information of the query result, and stores the query result in the local disk; The query result includes at least one query content; The data structure information is used to represent the subordination relationship between the query result and the at least one query content; The distributed server sends the query result to the cloud server; The distributed server receives the query ID sent by the cloud server; any query ID is generated by the cloud server based on any query content sent by the distributed server; The distributed server determines query information according to the query ID of at least one query content in the query result and the data structure information of the query result and sends it to the distribution server; The query information is used for the distribution server to obtain the query content corresponding to at least one query ID from the cloud server and generate an XML file according to the query content.
9. An apparatus for generating an XML file, characterized in that, It includes: The sending unit is used to send multiple target query requests to the distributed server; Any target query request is used to obtain a query result including at least one query content; The query result is obtained by the distributed server from the target data source and stored on the local disk; The first processing unit is used to receive query information sent by the distributed server for any target query request; The query information is obtained from the query result of the target query request; The query information includes the query ID of at least one query content in the query result and the data structure information for the query result; any query ID is generated by the cloud server based on any query content sent by the distributed server; The data structure information for the query result is generated by the distributed server and is used to represent the membership relationship between the query result and the at least one query content; For any target query request, obtain the query content corresponding to the at least one query ID from the cloud server according to the at least one query ID corresponding to the query result of the target query request; Generate a query object according to the query content corresponding to the at least one query ID and the data structure information of the query result; Generate an XML file corresponding to the multiple target query requests according to the multiple query objects corresponding to the multiple target query requests.
10. An apparatus for generating an XML file, characterized in that, Comprising: The obtaining unit is used to obtain the query result of the target query request from the target data source according to the multiple target query requests; Traverse the query result, determine the data structure information of the query result, and store the query result on the local disk; The query result includes at least one query content; The data structure information is used to represent the membership relationship between the query result and the at least one query content; The second processing unit is used to send the query result to the cloud server; Receive the query ID sent by the cloud server; any query ID is generated by the cloud server based on any query content sent by the distributed server; Determine the query information according to the query ID of at least one query content in the query result and the data structure information of the query result, and send it to the distribution server; The query information is used for the distribution server to obtain the query content corresponding to at least one query ID from the cloud server and generate an XML file according to the query content.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program, and when the program runs on a computer, it causes the computer to implement the method according to any one of claims 1 to 7.
12. A computing device, characterized in that, Comprising: A memory for storing a computer program; A processor for calling the computer program stored in the memory and executing the steps according to any one of claims 1 to 7 as obtained by the program.
13. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the steps of the method according to claim 1 are implemented.
Citation Information
Patent Citations
System and method for data propagation tracking of application system
CN111966718A
Data query method and device, equipment and storage medium
CN113760986A