A method and device for reading data
By first separating and filtering and then deserializing during data reading, the problem of intensive deserialization resulting in reduced server carrying capacity is solved, and the effect of reducing CPU occupancy and improving server carrying capacity is achieved.
Patent Information
- Application Number
- CN201910551474.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-24
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2039-06-24
AI Technical Summary
Intensive deserialization operations will lead to a reduction in the carrying capacity of the server, resulting in the deterioration of key system indicators such as CPU occupancy, TPS and TP99.
First read the target string data from the data source, separate the floor string data of each floor to the same array, and then filter and deserialize the floor string data in the string array.
It reduces the density of deserialization operations, reduces CPU usage, improves the carrying capacity of the server, and does not need to change the upstream data storage logic and downstream client display logic.
Smart Images

Figure CN112131287B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for reading data. Background Art
[0002] In order to meet cross-platform requirements (it needs to be easily readable by web pages, apps, various app embedded mini-programs, etc.), promotional activities and stores are generally organized in JSON data format with stores as the dimension. Therefore, after the JSON object is serialized into a string, the string is stored as a string content in the cache or database field. In the string content, it is organized as a string with floors as the dimension.
[0003] When each mobile terminal reads a string of JSON data from a data source, it is necessary to first deserialize the entire string data into an object format (such as JSON.stringify of nodejs) through the JSON interface of each mobile terminal, and then perform filtering operations according to business needs. Finally, the filtered JSON object is serialized into string data and sent to the client.
[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0005] Deserialization is a CPU (computer central processing unit) intensive operation. Intensive deserialization operations on large JSON data will bring greater performance pressure to the server's CPU, thereby reducing the server's carrying capacity and causing key system indicators such as CPU occupancy, TPS (the number of transactions processed by the server per second), and TP99 (the minimum time required to meet 99% of network requests) to deteriorate. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a method and device for reading data to solve the technical problem that intensive deserialization operations may lead to reduced server carrying capacity.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for reading data is provided, comprising:
[0008] Read the target string data from the data source;
[0009] Separating the target character string data, and adding the floor character string data of each floor into the same array, thereby generating a character string array; wherein the target character string data includes the floor character string data;
[0010] The floor character string data in the character string array is filtered, and the filtered floor character string data is deserialized into object data.
[0011] Optionally, read the target string data from the data source, including:
[0012] Read stored string data from the data source;
[0013] Extracting target string data from the stored string data according to the start string index and the end string index of the target string data;
[0014] The stored character string data includes the target character string data and auxiliary information.
[0015] Optionally, the target character string data is separated, and the floor character string data of each floor is added to the same array, thereby generating a character string array, including:
[0016] Using the first attribute name in each floor character string as a separator, the target character string data is separated to obtain the floor character string data of each floor;
[0017] Add the floor string data of each floor to the same array in sequence to generate a string array;
[0018] Among them, one array element in the string array represents a floor string data.
[0019] Optionally, filtering the floor character string data in the character string array includes:
[0020] The floor character string data in the character string array is filtered based on a preset maximum number of floors and / or at least one floor identifier.
[0021] Optionally, after deserializing the filtered floor string data into object data, the method further includes:
[0022] Filtering the object data based on business requirements;
[0023] The filtered object data is serialized into sent string data, and the sent string data is sent to the client.
[0024] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for reading data, comprising:
[0025] The interception module is used to read the target string data from the data source;
[0026] A separation module, used to separate the target string data, and add the floor string data of each floor into the same array, so as to generate a string array; wherein the target string data includes the floor string data;
[0027] The deserialization module is used to filter the floor string data in the string array and deserialize the filtered floor string data into object data.
[0028] Optionally, the interception module is further used for:
[0029] Read stored string data from the data source;
[0030] Extracting target string data from the stored string data according to the start string index and the end string index of the target string data;
[0031] The stored character string data includes the target character string data and auxiliary information.
[0032] Optionally, the separation module is further used for:
[0033] Using the first attribute name in each floor character string as a separator, the target character string data is separated to obtain the floor character string data of each floor;
[0034] Add the floor string data of each floor to the same array in sequence to generate a string array;
[0035] Among them, one array element in the string array represents a floor string data.
[0036] Optionally, filtering the floor character string data in the character string array includes:
[0037] The floor character string data in the character string array is filtered based on a preset maximum number of floors and / or at least one floor identifier.
[0038] Optionally, a serialization module is further included, which is used to deserialize the filtered floor string data into object data, filter the object data based on business needs, and serialize the filtered object data into sent string data, and send the sent string data to the client.
[0039] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:
[0040] one or more processors;
[0041] a storage device for storing one or more programs,
[0042] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0043] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0044] One embodiment of the above invention has the following advantages or beneficial effects: because the target string data is first read from the data source, then the target string data is separated and filtered, and finally the filtered string data is deserialized into object data, the technical problem that intensive deserialization operations will lead to reduced server carrying capacity is overcome. The embodiment of the present invention first performs filtering and then deserialization operations, which reduces the density of deserialization operations, thereby reducing CPU occupancy, reducing the performance pressure on the CPU, and improving the server carrying capacity; moreover, for existing systems, there is no need to change the upstream data storage logic and the downstream client display logic, so the present invention can be used for read optimization at a lower cost; in addition, the implementation of the invention is not limited by programming languages, and the existing java, javascript, php and other languages can all use the present invention.
[0045] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0047] Figure 1 is a schematic diagram of the main process of a method for reading data according to an embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of JSON data of a store according to an embodiment of the present invention;
[0049] Figure 3 is a schematic diagram of a process of reading target character string data according to an embodiment of the present invention;
[0050] Figure 4 is a schematic diagram of target character string data according to an embodiment of the present invention;
[0051] Figure 5 is a schematic diagram of a flow chart of separating target character string data according to an embodiment of the present invention;
[0052] Figure 6is a schematic diagram of a string array according to an embodiment of the present invention;
[0053] Figure 7 is a schematic diagram of the filtering and deserialization process according to an embodiment of the present invention;
[0054] Figure 8 is a schematic diagram of object data according to an embodiment of the present invention;
[0055] Fig. 9 is a schematic diagram of the main process of a method for reading data according to a reference embodiment of the present invention;
[0056] Fig.10 is a schematic diagram of main modules of a device for reading data according to an embodiment of the present invention;
[0057] Fig.11 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0058] Fig.12 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0060] Figure 1 Schematic diagram of the main process of the method for reading data according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for reading data may include:
[0061] Step 101, read target character string data from a data source.
[0062] First, read the target string data from the data source (such as a cache or database). Promotional activities and stores are generally formatted in JSON and organized by store. Therefore, after the JSON object is serialized into a string, the string is stored as a string content in a cache or database field. In the string content, the string is organized by floor. Optionally, the target string data can be the string data of a store. Figure 2As shown, the JSON data of the store includes the JSON data of the header information floor, the carousel floor, the product floor, etc., and the target string data includes the JSON string data of the header information floor, the carousel floor, the product floor, etc. Therefore, what is read in step 101 is the string data of the header information floor, the carousel floor, the product floor, etc., that is, the string data of the entire store. Moreover, the JSON data of each store may include multiple floors of JSON data, and may also include JSON data of other floors, not limited to Figure 2 The JSON data format is a lightweight data exchange format based on a subset of ECMAScript (js specification developed by the European Computer Association) and uses a text format that is completely independent of the programming language to store and represent data.
[0063] Generally speaking, the data source will also contain additional information such as store information, so it is also necessary to filter out this additional information. Optionally, step 101 includes: reading stored string data from the data source; extracting target string data from the stored string data through the start string index and end string index of the target string data; wherein the stored string data includes the target string data and additional information. In this embodiment, the stored string data (including the string data of the entire store and the additional information of the store) is first read from a data source (such as redis or mysql, etc.), as shown in FIG. Figure 3 As shown, the starting string position and the ending string position are then obtained through the starting string index and the ending string index, so as to extract the target string data (ie, the string data of the entire store) from the stored string data.
[0064] In general systems, the store data in the data source often includes other content besides the JSON string data of the store, which needs to be filtered out through this step. Since the start string index and end string index of the store data are set when the store is decorated, the string data of the entire store can be easily intercepted through the start string index and end string index, such as Figure 4 shown.
[0065] Step 102, separate the target character string data, and add the floor character string data of each floor into the same array, thereby generating a character string array.
[0066] After the target string data is obtained, the target string data is separated, and the floor string data of each floor is added to the same array, thereby generating a string array. In an embodiment of the present invention, the target string data includes floor string data corresponding to each floor.
[0067] Optionally, step 102 may specifically include: using the first attribute name in each floor string as a separator to separate the target string data to obtain the floor string data of each floor; adding the floor string data of each floor to the same array in order, thereby generating a string array. In an embodiment of the present invention, an array element in the string array represents a floor string data. The floor strings of each floor can be conveniently cut by separating the fields, and organizing the strings in an array manner is conducive to subsequent filtering steps, with good convenience and compatibility, and less CPU consumption.
[0068] Specifically, Figure 5 As shown, first you need to get the split field (splitKey). For example, the floor string is {"a":"xxx"...},{"a":"xxx"...},{"a":"xxx"...}. Since a is the first field, {"a is the available splitKey, which is used as a separator to separate the location of the strings of different floors. Then use the splitKey to separate the target string data to obtain the floor string data corresponding to each floor; finally, add the floor string data of each floor to the same array in storage order to obtain a string array. Use the first field as a separator to Figure 4 The target string data shown in the figure is separated to obtain the floor string data of the three floors. The floor string data of the three floors are added to the same array in sequence, and the following is obtained: Figure 6 The array of strings shown.
[0069] Optionally, the separator is used as the first attribute name of each floor JSON data, which can be a floor name, floor identifier, etc. The first attribute name can be obtained by string search: the characters between the first {" and the first subsequent " in the current json are the first attribute name. Among them, each floor identifier can be distinguished by an ID, which can be a non-repeating string or a unique identifier (GUID).
[0070] Step 103, filtering the floor character string data in the character string array, and deserializing the filtered floor character string data into object data.
[0071] In step 103, the floor string data in the string array obtained in step 102 can be filtered based on a preset filtering condition, and then the filtered floor string data can be deserialized into object data. In the present invention, deserialization refers to converting the string format of JSON into an object format. Optionally, the floor string data in the string array can be filtered based on a preset maximum number of floors and / or at least one floor identifier. By adopting the method of filtering first and then deserializing, the intensity of the deserialization operation can be reduced, thereby reducing the CPU occupancy rate.
[0072] Specifically, there are two ways to filter, one is the maximum number of floors, and the other is the floor ID: 1. The maximum number of floors is limited by defining the max input parameter, and the maximum value condition is defined through the for loop for filtering; 2. Define a single or multiple floor IDs to be filtered, traverse through for, and match the filter floor ID value through IndexOf, such as the ID field name is uniqueId. IndexOf is a method in javscript that returns the first position of a specified string value in a string, and the same implementation is also available in other languages. In the for statement, once the condition is hit, the deserialization interface is called to deserialize the filtered floor string in the string array into a JSON object; if it is not hit, no operation is performed and it is discarded, indicating that it is not required for the current client's business scenario.
[0073] like Figure 7 As shown, taking the floor string data of a certain store as an example, the floor string data in the string array (such as the floor string data of the header information floor, the carousel floor, the product floor, etc.) can be filtered based on the preset filtering conditions (such as the number of floors, ID, etc.), and then the filtered floor string data (such as the string data of the header information floor, the carousel floor, and the product floor) can be deserialized into object data (i.e., the header information floor JSON object, the carousel floor JSON object, and the product floor JSON object). For example, Figure 8 For Figure 6 The floor string data in the JSON object after deserialization.
[0074] Take a store with 10 floors as an example. If the existing technology is used to read data, the strings of the 10 floors need to be deserialized into JSON objects. However, if the method provided by the embodiment of the present invention is used to read data (assuming the filtering condition is: the maximum number of floors is 5), the string data of the first 5 floors are filtered out, and then the string data of these 5 floors are deserialized into JSON objects. It can be seen that compared with the existing technology, the method provided by the embodiment of the present invention can improve the CPU performance of the server by 30%, especially in the case of large traffic access to e-commerce web applications, the CPU occupancy rate can be reduced by 9%, thereby avoiding the deterioration of key system indicators such as CPU occupancy rate, TPS, and TP99.
[0075] According to the various embodiments described above, it can be seen that the present invention solves the problem that intensive deserialization operations will lead to reduced server carrying capacity by first reading the target string data from the data source, then separating and filtering the target string data, and finally deserializing the filtered string data into object data. The embodiment of the present invention first performs filtering and then deserialization operations, which reduces the density of deserialization operations, thereby reducing CPU occupancy, reducing the performance pressure on the CPU, and improving the server carrying capacity; moreover, for existing systems, there is no need to change the upstream data storage logic and the downstream client display logic, so the present invention can be used for read optimization at a lower cost; in addition, the implementation of the invention is not limited by the programming language, and the existing java, javascript, php and other languages can all use the present invention.
[0076] Fig. 9 1 is a schematic diagram of the main process of a method for reading data according to a reference embodiment of the present invention. The method for reading data may specifically include:
[0077] Step 901, read the stored string data from the data source.
[0078] First, the stored string data is read from a data source such as redis or mysql, wherein the stored string data includes the JSON string data of the store and the auxiliary information of the store.
[0079] Step 902: extract the target string data from the stored string data according to the start string index and the end string index of the target string data.
[0080] Since the start string index and the end string index of the store data are set when the store is decorated, the JSON string data of the entire store (ie, the target string data) can be conveniently intercepted through the start string index and the end string index.
[0081] Step 903: Use the first attribute name in each floor character string as a separator to separate the target character string data to obtain the floor character string data of each floor.
[0082] Use the first field as a separator to separate the JSON string data of the store and obtain the floor string data corresponding to each floor in the store.
[0083] Step 904, adding the floor character string data of each floor to the same array in sequence, thereby generating a character string array.
[0084] The floor character string data of each floor are added to the same array according to the storage order, thereby obtaining a character string array, wherein one array element in the character string array represents one floor character string data.
[0085] Step 905: filter the floor character string data in the character string array.
[0086] The floor character string data in the character string array is filtered based on preset filtering conditions (such as the maximum number of floors and / or floor identifications, etc.).
[0087] Step 906, deserialize the filtered floor string data into object data, thereby reducing the intensity of the deserialization operation.
[0088] Step 907: Filter the object data based on business requirements.
[0089] In order to ensure the system's carrying capacity and client performance, the distributed floor data will be paged, and screened to see if it is expired or valid.
[0090] Step 908, serialize the filtered object data into string data to be sent down, so that it meets the cross-platform requirements and can be easily read by the web page, APP, various APP embedded mini-programs, etc. In the embodiment of the present invention, serialization refers to converting the JSON object format into a string format.
[0091] Step 909: Send the sent string data to the client.
[0092] In addition, the specific implementation content of the method for reading data in a reference embodiment of the present invention has been described in detail in the method for reading data described above, so the repeated content will not be described again here.
[0093] Fig.10 is a schematic diagram of main modules of a device for reading data according to an embodiment of the present invention, such as Fig.10As shown, the device 1000 for reading data includes an interception module 1001, a separation module 1002 and a deserialization module 1003. The interception module 1001 is used to read target string data from a data source; the separation module 1002 is used to separate the target string data, add the floor string data of each floor to the same array, thereby generating a string array; the deserialization module 1003 is used to filter the floor string data in the string array, and deserialize the filtered floor string data into object data. Wherein, the target string data includes floor string data.
[0094] Optionally, the interception module 1001 is further used for:
[0095] Read stored string data from the data source;
[0096] Extracting target string data from the stored string data according to the start string index and the end string index of the target string data;
[0097] The stored character string data includes the target character string data and auxiliary information.
[0098] Optionally, the separation module 1002 is further used for:
[0099] Using the first attribute name in each floor character string as a separator, the target character string data is separated to obtain the floor character string data of each floor;
[0100] Add the floor string data of each floor to the same array in sequence to generate a string array;
[0101] Among them, one array element in the string array represents a floor string data.
[0102] Optionally, filtering the floor character string data in the character string array includes:
[0103] The floor character string data in the character string array is filtered based on a preset maximum number of floors and / or at least one floor identifier.
[0104] Optionally, the device also includes a serialization module, which is used to deserialize the filtered floor string data into object data, filter the object data based on business needs, and serialize the filtered object data into sent string data, and send the sent string data to the client.
[0105] According to the various embodiments described above, it can be seen that the present invention solves the problem that intensive deserialization operations will lead to reduced server carrying capacity by first reading the target string data from the data source, then separating and filtering the target string data, and finally deserializing the filtered string data into object data. The embodiment of the present invention first performs filtering and then deserialization operations, which reduces the density of deserialization operations, thereby reducing CPU occupancy, reducing the performance pressure on the CPU, and improving the server carrying capacity; moreover, for existing systems, there is no need to change the upstream data storage logic and the downstream client display logic, so the present invention can be used for read optimization at a lower cost; in addition, the implementation of the invention is not limited by the programming language, and the existing java, javascript, php and other languages can all use the present invention.
[0106] It should be noted that the specific implementation content of the device for reading data in the present invention has been described in detail in the method for reading data described above, so the repeated content will not be described again here.
[0107] Fig.11 An exemplary system architecture 1100 is shown to which the method for reading data or the apparatus for reading data according to the embodiments of the present invention can be applied.
[0108] like Fig.11 As shown, system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105. Network 1104 is used to provide a medium for communication links between terminal devices 1101, 1102, 1103 and server 1105. Network 1104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0109] Users can use terminal devices 1101, 1102, 1103 to interact with server 1104 through network 1104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1101, 1102, 1103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0110] The terminal devices 1101 , 1102 , and 1103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0111] The server 1105 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 1101, 1102, and 1103. The backend management server may analyze and process the received product information query request and other data, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0112] It should be noted that the method for reading data provided in the embodiment of the present invention is generally executed on the terminal devices 1101, 1102, 1103 in a public place, and can also be executed by the server 1105. Accordingly, the device for reading data is generally set on the terminal devices 1101, 1102, 1103 in a public place, and can also be set in the server 1105.
[0113] It should be understood that Fig.11 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0114] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 1200 of a terminal device suitable for implementing an embodiment of the present invention. Fig.12 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0115] like Fig.12 As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the system 1200 are also stored. The CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0116] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.
[0117] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present invention are executed.
[0118] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0119] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an interception module, a separation module and a deserialization module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0121] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: reading target string data from a data source; separating the target string data, adding the floor string data of each floor to the same array, thereby generating a string array; wherein the target string data includes floor string data; filtering the floor string data in the string array, and deserializing the filtered floor string data into object data.
[0122] According to the technical solution of the embodiment of the present invention, because the technical means of first reading the target string data from the data source, then separating and filtering the target string data, and finally deserializing the filtered string data into object data is adopted, the technical problem that intensive deserialization operations will lead to reduced server carrying capacity is overcome. The embodiment of the present invention first performs filtering and then deserialization operations, which reduces the density of deserialization operations, thereby reducing CPU occupancy, reducing the performance pressure on the CPU, and improving the server carrying capacity; moreover, for existing systems, there is no need to change the upstream data storage logic and the downstream client display logic, so the present invention can be used for read optimization at a lower cost; in addition, the implementation of the invention is not limited by the programming language, and the existing java, javascript, php and other languages can all use the present invention.
[0123] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for reading data, characterized in that: include: Read the target string data from the data source; Using the first attribute name in each floor string as a separator, the target string data is separated to obtain the floor string data of each floor; the floor string data of each floor is added to the same array in sequence to generate a string array; wherein the target string data includes the floor string data, and one array element in the string array represents one floor string data; The floor character string data in the character string array is filtered, and the filtered floor character string data is deserialized into object data.
2. The method according to claim 1, characterized in that Read the target string data from the data source, including: Read stored string data from the data source; Extracting target string data from the stored string data according to the start string index and the end string index of the target string data; The stored character string data includes the target character string data and auxiliary information.
3. The method according to claim 1, characterized in that Filtering the floor string data in the string array includes: The floor character string data in the character string array is filtered based on a preset maximum number of floors and / or at least one floor identifier.
4. The method according to claim 1, characterized in that After deserializing the filtered floor string data into object data, it also includes: Filtering the object data based on business requirements; The filtered object data is serialized into sent string data, and the sent string data is sent to the client.
5. A device for reading data, characterized in that: include: The interception module is used to read the target string data from the data source; A separation module is used to separate the target string data using the first attribute name in each floor string as a separation identifier to obtain the floor string data of each floor; the floor string data of each floor is added to the same array in sequence to generate a string array; wherein the target string data includes the floor string data, and one array element in the string array represents one floor string data; The deserialization module is used to filter the floor string data in the string array and deserialize the filtered floor string data into object data.
6. The device according to claim 5, characterized in that The interception module is also used for: Read stored string data from the data source; Extracting target string data from the stored string data according to the start string index and the end string index of the target string data; The stored character string data includes the target character string data and auxiliary information.
7. The device according to claim 5, characterized in that Filtering the floor string data in the string array includes: The floor character string data in the character string array is filtered based on a preset maximum number of floors and / or at least one floor identifier.
8. The device according to claim 5, characterized in that Also includes: The serialization module is used to deserialize the filtered floor string data into object data, filter the object data based on business needs, serialize the filtered object data into sent string data, and send the sent string data to the client.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Information access method and apparatus, and server
CN106302829A
Process configuration method of service system, storage medium and server
CN109408035A