Method for optimizing query throughput of a graph database based on client-side reuse objects
By reusing objects in the graph database client and optimizing the deserialization process, the issues of memory and garbage collection pressure in high-concurrency scenarios are resolved, thereby improving the query throughput of the graph database.
Patent Information
- Application Number
- CN202511280044.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-09-09
AI Technical Summary
In high-concurrency query scenarios, the frequent object creation and destruction during the deserialization process of graph database clients leads to increased memory overhead, intensified garbage collection pressure, and accumulated redundant parsing overhead, becoming a system performance bottleneck and limiting throughput.
By adopting a client-side object reuse approach, the system receives serialized response data, parses metadata, creates an object list, caches data structure information, reuses existing object lists to populate the parsing results, reduces dynamic memory allocation and garbage collection, and optimizes the deserialization process.
It significantly reduces the number of memory allocations, reduces system overhead, and improves the throughput of query response processing, especially in high-concurrency and large-data-volume scenarios, where it significantly improves performance.
Smart Images

Figure CN120763351B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of graph database query optimization, and particularly relates to a graph database query throughput optimization method based on client-side reuse of objects. BACKGROUND
[0002] As a database system specially used for storing and processing graph-structured data, graph databases have been widely applied in many fields such as social network analysis, knowledge graph construction, recommendation system, financial risk control, network security, etc. due to their natural advantage in expressing complex relationships between entities. With the continuous expansion of application scenarios and the continuous growth of data size, users have higher requirements for the performance of graph databases in high-concurrency and low-latency environments. Among them, the concurrent processing capability is one of the key indicators to measure the overall performance of the graph database system, and the request throughput, as a core parameter reflecting the system's ability to process query requests in unit time, directly determines the availability and scalability of the graph database in actual production environments.
[0003] The factors affecting the request throughput of graph databases not only include the query execution efficiency, index mechanism, distributed architecture of the server, etc., but also are closely related to the processing capability of the client for query results. In the typical architecture of a graph database system, the client is responsible for sending query requests and receiving and parsing the result data returned by the server. Taking the open-source distributed graph database NebulaGraph as an example, its query results are transmitted in a specific serialization format (such as the Thrift protocol), and the deserialization and semantic parsing of the result data are completed in the client. Although this design helps to reduce the burden on the server and improve communication efficiency, in the high-concurrency and large-data query scenario, the parsing logic of the client may become a bottleneck of system performance.
[0004] Specifically, the query results of a graph database usually contain a large amount of structured data, and each record may involve multiple data types, including basic types (such as String, Int, Double, Boolean) and complex composite types (such as Node, Edge, Path, List, etc.). These complex types often have multiple substructures and attribute sets nested inside, which need to be parsed and object constructed layer by layer in the client. For example, when parsing a Node object, the client not only needs to construct the Node instance itself, but also needs to create corresponding objects for its Node ID, Tag, Property, etc. sub-elements. When a Node contains 10 properties, the parsing process of a single Node may trigger 13 or more object memory allocation and initialization operations.
[0005] In a high-concurrency query scenario, especially when thousands of records containing complex types are returned by the query, the above parsing mechanism can cause a series of performance problems:
[0006] 1. Significant increase in memory overhead: Frequent object creation leads to a large number of dynamic memory allocations, occupying a large amount of heap space, especially in long-running client applications, which can easily cause memory pressure and even memory overflow (OOM).
[0007] 2. Increased garbage collection (GC) pressure: Since the query result objects are mostly short-lived, a large number of objects to be recycled are generated during frequent queries, causing the JVM and other runtime environments to frequently trigger garbage collection operations, significantly increasing CPU occupancy, and thus affecting the overall processing efficiency and response delay of the client.
[0008] 3. Cumulative overhead of redundant parsing: For Node, Edge, Path, and other complex types, their metadata structures (such as attribute names and type information) often remain unchanged in multiple queries, but the existing parsing mechanism still repeatedly performs the same structure parsing logic for each returned result, resulting in waste of computing resources. When tens of thousands or even more complex type instances need to be parsed, the cumulative time of such redundant operations cannot be ignored.
[0009] The above problems collectively cause the client to become a performance bottleneck under certain query loads, despite the fact that the graph database server resources (such as CPU and I / O) are far from being saturated. For example, during a single-client stress test on a 6-node deployment of a NebulaGraph cluster, it was observed that the client CPU utilization was close to the upper limit, while the average CPU utilization of the server cluster was less than 10%. The overall system throughput was limited by the client processing capacity, and the computing potential of the server could not be fully utilized.
[0010] Therefore, there is a lack of an effective client optimization mechanism in the prior art to reduce the parsing overhead of graph database query results, improve deserialization efficiency, reduce memory and computing resource consumption, and thus improve the throughput of graph database query requests. SUMMARY
[0011] The purpose of the present application is to provide a graph database query throughput optimization method based on client reuse of objects, to solve the problem in the existing deserialization process that a new value object is created for each field when each row of data is parsed, and when the number of rows in the result set is huge, a large amount of object creation and destruction overhead is generated, which seriously affects the throughput performance and increases the garbage collection burden.
[0012] To achieve the above purpose, the following technical solutions are used in the present application:
[0013] The application discloses a method for optimizing query throughput of a graph database based on a client multiplexing object, which is applied to a deserialization process of serialized response data returned by a graph database service, and comprises the following steps.
[0014] Receiving serialized response data from the graph database service, wherein the serialized response data comprises a result set and metadata;
[0015] Analyzing the number of columns of the result set from the metadata, and creating an object list comprising a corresponding number of value objects based on the number of columns;
[0016] Analyzing first row data in the result set, including analyzing and caching data structure information from the metadata, wherein the data structure information is used to describe the structure of data types in the result set, and filling the analyzed first row data into the corresponding value objects in the object list;
[0017] Analyzing second row and subsequent row data in the result set, and multiplexing the cached data structure information and the created object list, and filling the analyzed current row data in each column into the corresponding value objects in the object list.
[0018] Preferably, the data types comprise basic data types and composite data types, and the composite data types comprise local time types, local date and time types, list collection types, node types, edge types, record types or path types.
[0019] The data structure information comprises at least one of the following: a type name, an attribute name set, an attribute type set and a mapping relationship between an attribute name and a data storage index.
[0020] Preferably, when analyzing the data structure information, if it is identified that a field is a composite data type with attributes, the method further comprises:
[0021] creating a nested value object set according to the attributes, wherein the attributes and the value objects are one-to-one corresponding, and filling the analyzed attribute data into the corresponding value objects in the set;
[0022] When analyzing the second row and subsequent row data, the created nested value object set is multiplexed, and the analyzed attribute data is directly filled into the corresponding value objects in the set.
[0023] Preferably, when analyzing the data structure information, if it is identified that a field has a constant characteristic, besides caching the data structure information of the field, the constant data value of the field is further analyzed and cached; when analyzing the second row and subsequent row data, the cached constant data value of the field is directly used as the analysis result of the field.
[0024] As preferred, when parsing the data structure information, if an unknown data type is identified, the corresponding value object in the object list is set to a null value state.
[0025] As preferred, filling the parsed data into the corresponding value object in the object list is achieved by calling a decoder, which receives the index of the target value object as an input parameter and directly writes the parsed data into the memory space pointed by the index.
[0026] As preferred, by multiplexing the object list, the memory space of the value object is maintained from being recycled and reallocated during the entire life cycle of the deserialization process.
[0027] A device for optimizing query throughput of a graph database based on client multiplexed objects, comprising:
[0028] A receiving module configured to receive serialized response data from a graph database service, the serialized response data including a result set and metadata;
[0029] A constructing module configured to parse the number of columns of the result set from the metadata and create an object list including a corresponding number of value objects based on the number of columns;
[0030] A first parsing module configured to parse the first row of data in the result set, including parsing data structure information from the metadata and caching the data structure information, the data structure information being used to describe the structure of the data types in the result set, and filling the parsed first row of data into the corresponding value object in the object list;
[0031] A second parsing module configured to parse the second row and subsequent rows of data in the result set and multiplex the cached data structure information and the created object list, and directly fill the parsed current row of data into the corresponding value object in the object list.
[0032] An electronic device comprising a memory and a processor, the memory being configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement a method for optimizing query throughput of a graph database based on client multiplexed objects according to any one of the above.
[0033] A computer-readable storage medium storing a computer program, the computer program causing a computer to execute a method for optimizing query throughput of a graph database based on client multiplexed objects according to any one of the above.
[0034] The present application has the following beneficial effects:
[0035] The application makes the subsequent parsing of the specific field value of each row of data no longer create a new value object for each field, but directly reuse the empty value object initially created for the column, and only update the value in the memory space of the empty value object to the parsing result of the current row, thereby significantly reducing the number of dynamic memory allocations in the deserialization process, effectively reducing the system overhead, and improving the processing throughput of query response. BRIEF DESCRIPTION OF DRAWINGS
[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0037] Figure 1 is a flowchart of a graph database query throughput optimization method based on client-side object reuse provided by an embodiment of the present application;
[0038] Figure 2 is a flowchart of a method for parsing a composite data type field provided by an embodiment of the present application;
[0039] Figure 3 is a structural schematic diagram of a graph database query throughput optimization device based on client-side object reuse provided by an embodiment of the present application;
[0040] Figure 4 is a schematic diagram of an electronic device for implementing a graph database query throughput optimization method based on client-side object reuse provided by an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the technical solutions of the present application more clear, the present application will be further described in detail below in combination with the drawings and specific embodiments. The terms "first", "second", etc. in the claims and description of the present application are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged as appropriate, which is only a distinguishing way used in the description of the embodiments of the present application to describe the same attribute objects. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the processes, methods, systems, products or devices containing a series of units do not have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or devices.
[0042] Embodiment 1
[0043] As Figure 1As shown, a client multiplex object-based graph database query throughput optimization method is applied to the deserialization process of the serialized response data returned by the client to the graph database service, and includes the following steps:
[0044] S110, receiving serialized response data from the graph database service, the serialized response data containing a result set and metadata;
[0045] S120, parsing the number of columns of the result set from the metadata, and creating an object list containing a corresponding number of value objects based on the number of columns;
[0046] S130, parsing the first row of data in the result set, including parsing data structure information from the metadata and caching, the data structure information being used to describe the structure of the data types in the result set, and filling the parsed first row of data into the corresponding value object in the object list;
[0047] S140, parsing the second row and subsequent rows of data in the result set, and reusing the cached data structure information and the created object list, and filling the parsed current row of data into the corresponding value object in the object list.
[0048] After the client receives the serialized response data returned by the graph database service, the serialized response data needs to be deserialized to convert it into a memory object that can be directly processed by the client application. The throughput optimization method involved in this application mainly improves this deserialization process.
[0049] In this embodiment, the NebulaGraph graph database Golang client is taken as an example for illustration, but the method is also applicable to other graph database systems that conform to similar response structures, and can be adapted according to the actual application scenario.
[0050] The serialized response data usually includes two parts: the result set and the metadata describing the structure of the result set. After receiving the serialized response data, the client first parses the number of columns of the result set from the metadata, and after obtaining the number of columns, it will construct a value object list of the corresponding length in advance. Each value (NebulaValue) object in the list represents a container for a column in the result set, i.e. the number of columns of the result set is equal to the number of NebulaValue objects in the list. In the initialization stage, these value objects are all empty objects without actual data filled in.
[0051] Suppose the result set contains 1000 rows of data, each row of data consists of three fields, i.e. 3 columns, including two Node fields and an Edge field, in order Node1 field, Edge field and Node2 field, and each Node field contains 3 attributes and each Edge field contains 1 attribute. In this embodiment, after obtaining the column number 3, an object list containing 3 NebulaValue objects is constructed, and the index position of each NebulaValue object in the object list is exactly the same as the column index of its corresponding column in the result set. At the same time, the object list is used to deserialize all 1000 rows of data.
[0052] When parsing the specific field values of each row of data subsequently, instead of creating a new value object for each field, the created empty value object is directly reused, and only the value in the memory space of the empty value object is updated to the parsing result of the current row. This mechanism significantly reduces the number of dynamic memory allocations in the deserialization process, thereby effectively reducing the system overhead and improving the processing throughput of query response.
[0053] It should be noted that in the Golang client of the NebulaGraph graph database, all data is encapsulated in a NebulaValue object, and the NebulaValue object is a composite structure that internally stores both the actual data value (Value) and the data type information (Type) corresponding to the value. The client can obtain the actual data value (Value) encapsulated in the NebulaValue object by calling the GetValue method of the NebulaValue object, thereby displaying the specific query result value to the user.
[0054] Then, the client scans and parses the result set through the Scan interface, first processes the first row of data, which includes parsing and caching data structure information from the metadata of the response data, wherein the data structure information is used to describe the composition and structure of the data types of each column in the result set, including but not limited to type name, attribute name set, attribute type set, and mapping relationship between attribute name and its index position in data storage, etc. In this embodiment, the data types include not only basic data types such as boolean, integer, float, string, etc., but also various composite data types, such as DateTime type, Date type, List collection type in graph database, Node type, Edge type, Record type and Path type, etc., and each composite type usually contains internal attribute structure. These cached structure information provides a unified type for the subsequent parsing of all data rows, avoiding repeated parsing of metadata and improving parsing efficiency.
[0055] Specifically, integer types include signed integers and unsigned integers, signed integers can represent negative numbers, zero and positive numbers, including 8-bit integers (int8), 16-bit integers (int16), 32-bit integers (int32) and 64-bit integers (int64); unsigned integers can only represent non-negative numbers, including 8-bit unsigned integers (uint8), 16-bit unsigned integers (uint16), 32-bit unsigned integers (uint32) and 64-bit unsigned integers (uint64).
[0056] Floating point types include single-precision floating point numbers (float32) and double-precision floating point numbers (float64).
[0057] Local time type is used to represent a specific time of day, containing information such as hour (Hour), minute (Minute), second (Sec) and microsecond (Microsec), wherein Hour, Minute and Sec are stored using int8 data type, and Microsec, which requires higher precision, is stored using int32 data type.
[0058] Local date and time type is used to represent a complete date and time point, containing information such as year (Year), month (Month), day (Day), hour (Hour), minute (Minute), second (Sec) and microsecond (Microsec), wherein Year is stored using int16 data type, Month and Day are stored using int8 data type, and the type specifications of Hour, Minute, Sec and Microsec are consistent with those of local time type.
[0059] List collection type is a dynamic array structure that can store any number of mixed type value object elements, suitable for storing ordered data sequences, wherein each element is an independent value object and supports dynamic expansion and index access.
[0060] Record type adopts a key-value pair structure, requires all values to be value objects of the same type, and realizes associated storage and fast retrieval of data through a unique identifier (key).
[0061] The Node type is used to represent an entity object in the graph, and contains information such as a point unique identifier (NodeId), a graph space (Graph) to which the point belongs, a node type (Type), a label group (Labels), a list of attribute names (PropNames), and a list of attribute values (PropValues). The NodeId is stored using an int64 data type, the Graph, Type, Labels, and PropNames are stored using a string data type, and the PropValues correspond to a NebulaValue collection.
[0062] The Edge type is used to completely describe the relationship between nodes in the graph, and contains information such as a starting point unique identifier (SrcId), a terminal point unique identifier (DstId), a direction of the edge (Direction), a graph space (Graph) to which the edge belongs, a node type (Type), a label group (Labels), an edge weight (Rank), a list of attribute names (PropNames), and a list of attribute values (PropValues). The SrcId, DstId, and Rank are stored using an int64 data type, the Direction is an enumeration type (forward / reverse / bidirectional), and the types of the Graph, Type, Labels, PropNames, and PropValues are consistent with those of the Node type.
[0063] The Path type represents a sequence structure of vertices and edges, and is used to describe a path in the graph data. This structure strictly follows the alternating pattern of "vertex-edge-vertex-edge..." and completely records the connection track between nodes in the graph.
[0064] In some embodiments, as shown in FIG. 13, when parsing the data structure information, if it is identified that a certain field is a composite data type with attributes, the method further includes: Figure 2
[0065] S210, creating a set of nested value objects according to the attributes, wherein the attributes and the value objects are one-to-one corresponding, and filling the parsed attribute data into the corresponding value objects in the set;
[0066] S220, when parsing the second row and subsequent rows of data, reusing the set of nested value objects that have been created, and directly filling the parsed attribute data into the corresponding value objects in the set.
[0067] When the client identifies from the metadata that a certain field belongs to a composite data type with internal attributes (such as Node, Edge or Path, etc.), an efficient object reuse mechanism will be started. Specifically, the client dynamically creates a set of nested value objects according to the attribute structure defined by the composite data type, and each value object in the set corresponds to an attribute one by one, which together constitute a reusable memory template. When processing the second row and subsequent rows of data, the client no longer creates a new set of value objects for the composite field in each row, but directly reuses the set of nested value objects that has been created. During the parsing process, the attribute data obtained by parsing each row is directly written into the original memory space of the corresponding value object in the set, and only the value is updated without re-allocating memory.
[0068] This mechanism significantly reduces the pressure on memory allocation and garbage collector by avoiding the overhead of repeatedly allocating and releasing a large number of small objects, thereby effectively improving the throughput and overall client performance in the large-scale result set deserialization phase.
[0069] In some embodiments, when parsing the data structure information, if it is identified that a certain field has a constant characteristic, in addition to caching its data structure information, the constant data value of the field is further parsed and cached; when parsing each row of data subsequently, for the constant field, the cached constant data value is directly used as the parsing result of the field.
[0070] When it is identified that a certain field has a constant characteristic, i.e., its data value remains unchanged throughout the result set, in addition to caching the data structure information of the field, its constant value is also parsed and stored in the cache. During the subsequent row-by-row parsing process, for this constant field, the client will skip repeated parsing calculations and directly use the pre-cached constant data value as the parsing result of the field. This method can avoid the parsing overhead of a large amount of repeated data and significantly improve the data processing throughput.
[0071] In some embodiments, when parsing the data structure information, if an unknown data type is identified, the value object corresponding to the object list is set to a null value state.
[0072] During the metadata parsing phase, if the data type of a certain field cannot be identified, the client sets a specific null value (null) for the value object of the object list corresponding to the field. This method ensures that the deserialization process continues to execute, thereby safely processing subsequent data streams and effectively enhancing the fault tolerance and forward compatibility of the client when dealing with different graph data versions or extended data types.
[0073] After the first row of data is parsed, the client fills the values of each field of the row into the memory space of the corresponding value object in the constructed object list. Through first-row parsing and caching mechanisms, the client establishes a reusable template for the deserialization of subsequent large amounts of data rows, significantly improving the overall query response processing throughput.
[0074] In some embodiments, filling the parsed data into the corresponding value object in the object list is implemented by calling a decoder that receives the index of the target value object as an input parameter and directly writes the parsed data into the memory space pointed to by the index.
[0075] Efficiently filling the parsed serialized data into the pre-constructed object list is implemented by calling a specific decoder component. The core function of the decoder is to act as a high-speed conversion channel between binary data and memory objects. The specific workflow is as follows: when parsing each row of data, the client determines the index position of the value object corresponding to the current field in the pre-created object list, and passes this index as a key input parameter to the decoder. The decoder accurately locates the exact position of the target value object in memory based on the index, and then directly writes the current parsed raw data into the existing memory space pointed to by the index.
[0076] This method completely avoids the overhead of repeatedly creating new objects or producing any intermediate representations for the field by using precise memory address operations. It turns the data filling process into pure memory write operations, greatly improving the execution efficiency of data deserialization, and is a key underlying optimization mechanism for reducing latency and improving overall query throughput.
[0077] In some embodiments, by reusing the object list, the memory space of the value object is maintained throughout the entire life cycle of the deserialization process and is not recycled and reallocated.
[0078] During the initialization phase of the deserialization process, the client pre-creates a fixed-size object list based on the column structure of the result set. Each value object in the list is allocated a specific memory space. Throughout the deserialization life cycle, the system will always maintain and reuse this object list and all value objects within it.
[0079] For each row of data in the result set, the system no longer creates a new value object for each field, but directly fills the parsed serialized data into the memory space of the existing value object corresponding to the index in the list. Through this mechanism, the performance loss caused by frequent creation and destruction of a large number of short-term objects in the traditional way is successfully avoided.
[0080] This method not only greatly reduces the number of memory allocation and garbage collection triggers, but also effectively improves cache locality and reduces memory access delay due to continuous reuse of object memory space, thereby ensuring high throughput and low latency of deserialization operations, especially suitable for processing large-scale, streaming returned graph query result sets.
[0081] Taking the above result set as an example, when parsing the first row of data, the metadata in the serialized response data of the first row of data is first parsed to obtain data structure information of three fields Node1, Edge and Node2, such as data type and attribute type set, and a value object set nodeProperties1 for storing attributes is created according to the attribute number of Node1, nodeProperties1 contains 3 value objects, and the attribute values parsed are filled into the memory space of the corresponding value object in nodeProperties1, and then the parsed data and the filled nodeProperties1 are filled into the memory space of the first value object in the object list; a value object set edgeProperties for storing attributes is created according to the attribute number of Edge, edgeProperties contains 1 value object, and the attribute values parsed are filled into the memory space of the corresponding value object in edgeProperties, and then the parsed data and the filled edgeProperties are filled into the memory space of the second value object in the object list; a value object set nodeProperties2 for storing attributes is created according to the attribute number of Node2, nodeProperties2 contains 3 value objects, and the attribute values parsed are filled into the memory space of the corresponding value object in nodeProperties2, and then the parsed data and the filled nodeProperties2 are filled into the memory space of the third value object in the object list.
[0082] When parsing the second row, the data structure information parsed, the object list constructed and the nodeProperties1, edgeProperties and nodeProperties2 constructed for the attributes of each field in the first row are reused, and after parsing, the attribute values of each field are filled into nodeProperties1, edgeProperties and nodeProperties2, respectively, and other data and the filled object sets are filled into the constructed object list, and the repeated calling of the Scan interface is repeated until the data acquisition is completed. After the request is completed, all NebulaValue objects are recycled, and there is no significant fluctuation of GC.
[0083] Taking the above result set as an example, before the throughput optimization method involved in the embodiment is executed, the number of NebulaValue objects that need to be created is 1000 rows * 3 fields per row + 1000 * (6 attributes for each Node and 1 attribute for each Edge) = 10000, and the number of times of parsing point edge metadata is 1000 * 3 = 3000, the CPU occupancy of the client is 77.3%, the CPU occupancy of the server is 5.9%, the bottleneck of the stress test is the CPU of the client, the CPU consumption of GC is relatively high, and the stress test throughput is only 5520.48 requests per second; after the throughput optimization method involved in the embodiment is executed, the number of NebulaValue objects that need to be created is 3 fields per row + (6 attributes for each Node and 1 attribute for each Edge) = 10, and the number of times of parsing point edge metadata is only 3, the CPU occupancy of the client is 42.8%, the CPU occupancy of the server is 62.6%, the CPU utilization of the server has reached the upper limit of the CPU used by the server configured, and the stress test throughput reaches 16624.27 requests per second.
[0084] The embodiment reduces more than 80% of memory allocation and GC time through object reuse, metadata cache reuse and lazy loading optimization, and the CPU load of the client also decreases by 50%+, at the same time, the single-client stress test cluster throughput is increased by 3-5 times, which is suitable for high-concurrency scenarios and supports larger-scale graph data stress testing.
[0085] Embodiment 2
[0086] As shown in Figure 3 , a graph database query throughput optimization device based on client object reuse comprises:
[0087] A receiving module is configured to receive serialized response data from a graph database service, and the serialized response data comprises a result set and metadata.
[0088] A construction module is configured to parse the number of columns of the result set from the metadata, and create an object list comprising a corresponding number of value objects based on the number of columns.
[0089] A first parsing module is configured to parse the first row of data in the result set, including parsing data structure information from the metadata and caching the data structure information, the data structure information being used to describe the structure of the data types in the result set, and filling the parsed first row of data into the corresponding value object in the object list.
[0090] A second parsing module is configured to parse the second row and subsequent rows of data in the result set, and reuse the cached data structure information and the created object list, and directly fill the parsed current row of data into the corresponding value object in the object list.
[0091] The embodiment is used to implement the method provided in the above embodiment, and has the corresponding beneficial effects of the method. Technical details not described in the embodiment can be found in the method provided in the foregoing all embodiments.
[0092] Embodiment 3
[0093] As shown in Figure 4 An electronic device includes a memory 401 and a processor 402, the memory 401 is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 402 to implement the above-mentioned method for optimizing query throughput of a graph database based on client multiplexing objects.
[0094] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the electronic device described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0095] A computer readable storage medium storing a computer program, the computer program enables a computer to execute the method for optimizing query throughput of a graph database based on client multiplexing objects as described above.
[0096] For example, the computer program can be divided into one or more modules / units, one or more modules / units are stored in the memory 401 and executed by the processor 402, and the input and output of data is completed by the input and output interface 405 and the output interface 406, in order to complete the present application, one or more modules / units can be a series of computer program instruction segments that can complete a specific function, which is used to describe the execution process of the computer program in the computer device.
[0097] The computer device can be a desktop computer, a notebook, a palm computer, and a cloud server, etc. The computer device can include, but is not limited to, the memory 401, the processor 402, and those skilled in the art can understand that the embodiment is only an example of the computer device, and does not constitute a limitation on the computer device, and can include more or fewer components, or combine certain components, or different components, for example, the computer device can also include an input device 407, a network access device, a bus, etc.
[0098] The processor 402 can be a central processing unit (CPU), and can also be other general-purpose processors 402, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor 402 can be a microprocessor or the processor 402 can also be any conventional processor.
[0099] The memory 401 can be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The memory 401 can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 401 can include both the internal storage unit and the external storage device of the computer device. The memory 401 is used to store computer programs and other programs and data required by the computer device, and can also be used to temporarily store data in the output device 408. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM) 403, a random access memory (RAM) 404, a disk or an optical disk, and various storage medium capable of storing program codes.
[0100] The above embodiments only express several embodiments of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the present application. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A method for optimizing the query throughput of a graph database based on client-side reusable objects, characterized in that, The deserialization process applied to serialized response data returned by a graph database service from a client includes the following steps: Receive serialized response data from a graph database service, the serialized response data containing a result set and metadata; Parse the number of columns in the result set from the metadata, and create an object list containing the corresponding number of value objects based on the number of columns; Parsing the first row of data in the result set includes parsing data structure information from the metadata and caching it. The data structure information is used to describe the structure of the data types in the result set. The parsed first row of data is then filled into the corresponding value object in the object list. Parse the second row and subsequent rows of data in the result set, and reuse the cached data structure information and the created object list to directly populate the corresponding value objects in the object list with the parsed data of each column of the current row.
2. The graph database query throughput optimization method based on client-side reusable objects according to claim 1, characterized in that, The data types include basic data types and composite data types. The composite data types include local time type, local date and time type, list collection type, node type, edge type, record type, or path type. The data structure information includes at least one of the following: type name, set of attribute names, set of attribute types, and mapping relationship between attribute names and data storage index.
3. The graph database query throughput optimization method based on client-side reusable objects according to claim 2, characterized in that, When parsing the data structure information, if a field is identified as a composite data type with attributes, the method further includes: A nested collection of value objects is created based on its attributes, where each attribute corresponds to a value object, and the parsed attribute data is then filled into the corresponding value objects in the collection. When parsing the second row and subsequent rows of data, the previously created set of nested value objects is reused, and the parsed attribute data is directly filled into the corresponding value objects in the set.
4. The graph database query throughput optimization method based on client-side reusable objects according to claim 2, characterized in that, When parsing the data structure information, if a field is identified as having constant characteristics, in addition to caching its data structure information, the constant data value of the field is further parsed and cached; when parsing the second row and subsequent rows of data, for the constant field, the cached constant data value is directly used as the parsing result of the field.
5. The graph database query throughput optimization method based on client-side reusable objects according to claim 1, characterized in that, When parsing the data structure information, if an unknown data type is identified, the corresponding value object in the object list is set to an empty state.
6. The graph database query throughput optimization method based on client-side reusable objects according to claim 1, characterized in that, The parsed data is filled into the corresponding value object in the object list by calling the decoder. The decoder receives the index of the target value object as input parameter and writes the parsed data directly into the memory space pointed to by the index.
7. The graph database query throughput optimization method based on client-side reusable objects according to claim 1, characterized in that, By reusing the list of objects, the memory space of the value objects is kept from being reclaimed and reallocated throughout the entire lifecycle of the deserialization process.
8. A graph database query throughput optimization device based on client-side reusable objects, characterized in that, include: A receiving module is used to receive serialized response data from a graph database service, wherein the serialized response data includes a result set and metadata; A construction module is used to parse the number of columns of the result set from the metadata and create an object list containing a corresponding number of value objects based on the number of columns; The first parsing module is used to parse the first row of data in the result set, including parsing data structure information from the metadata and caching it, wherein the data structure information is used to describe the structure of the data type in the result set, and filling the parsed first row of data into the corresponding value object in the object list; The second parsing module is used to parse the second row and subsequent rows of data in the result set, and reuse the cached data structure information and the created object list to directly fill the parsed data of each column of the current row into the corresponding value object in the object list.
9. An electronic device, characterized in that, The system includes a memory and a processor, wherein the memory stores one or more computer instructions, which are executed by the processor to implement a graph database query throughput optimization method based on client-reusable objects as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, The computer program enables the computer to implement, when executed, a graph database query throughput optimization method based on client-side reusable objects as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data query method and device of graph database and electronic equipment
CN117271840A
Serialization method and deserialization method of data object and electronic equipment
CN119513155A
