CN117271840B - Data query method and device of graph database and electronic equipment - Google Patents

Data query method and device of graph database and electronic equipment Download PDF

Info

Publication number
CN117271840B
CN117271840B CN202311234817.0A CN202311234817A CN117271840B CN 117271840 B CN117271840 B CN 117271840B CN 202311234817 A CN202311234817 A CN 202311234817A CN 117271840 B CN117271840 B CN 117271840B
Authority
CN
China
Prior art keywords
attribute
information
attribute information
graph
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311234817.0A
Other languages
Chinese (zh)
Other versions
CN117271840A (en
Inventor
杨娟
徐毅
杨珂
沈游人
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Haizhi Xingtu Technology Co ltd
Original Assignee
Beijing Haizhi Xingtu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Haizhi Xingtu Technology Co ltd filed Critical Beijing Haizhi Xingtu Technology Co ltd
Priority to CN202311234817.0A priority Critical patent/CN117271840B/en
Publication of CN117271840A publication Critical patent/CN117271840A/en
Application granted granted Critical
Publication of CN117271840B publication Critical patent/CN117271840B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a data query method, a device and electronic equipment of a graph database, relating to the technical field of graph database query, comprising the following steps: responding to the query request, and acquiring graph data to be queried from a graph database; the map data comprises map elements, attribute information of the map elements and map configuration information; serializing attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation; storing the byte array, the graph elements and the graph configuration information into a preset cache space; and according to the graph configuration information, carrying out data query on the preset cache space, and returning a query result. The method provided by the invention reduces the waste of the cache space resources to a certain extent, improves the utilization rate of the cache space, and further improves the query efficiency of the graph data to a certain extent.

Description

Data query method and device of graph database and electronic equipment
Technical Field
The present invention relates to the field of graph database query technologies, and in particular, to a method and an apparatus for querying data of a graph database, and an electronic device.
Background
At present, with the rapid development of social, financial and other fields, the data analysis business has greatly increased, the data volume has increased dramatically, the data association has become more complex, and the changes promote the transformation and innovation of the database. The graph database is in a rapidly evolving stage because it provides the most direct expression of the associated data.
Because the query of the graph data is usually IO intensive and the accessed data is random and scattered, the graph data can be firstly extracted from the graph database and stored into the cache space of the memory, then the data is queried in the cache space, and the query result is returned, so that the query speed is increased. In order to maximize the effect of the buffer space, it is necessary to store as much map data as possible in a limited buffer space. In the related art, when loading graph data into a cache space, a graph database generally abstracts attribute types of attribute information of points and edges in the graph data into one attribute type, and encapsulates all actual attribute types (integer, floating point number, character string, etc.) to which the attribute information may correspond. Taking the Rust programming language on a 64-bit machine as an example, 24 bytes of space is required to occupy the cache space, regardless of the actual attribute type of the attribute information. Even if only one 32-bit integer (4 bytes) needs to be stored, 24 bytes are required, of which 20 bytes are wasted.
Therefore, the above manner is easy to cause waste of cache space resources, so that the cache space utilization rate needs to be further improved, and further, the query efficiency of the graph data needs to be further improved.
Disclosure of Invention
The invention provides a data query method, a data query device and electronic equipment of a graph database, which are used for solving the problem that the cache space utilization rate is required to be further improved and the query efficiency of graph data is required to be further improved due to the fact that cache space resources are wasted easily in the related technology.
According to an aspect of the present invention, there is provided a data query method of a graph database, including:
responding to the query request, and acquiring graph data to be queried from a graph database; wherein the graph data comprises graph elements, attribute information of the graph elements and graph configuration information;
serializing the attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation;
storing the byte array, the graph elements and the graph configuration information into a preset cache space;
and according to the graph configuration information, carrying out data query on the preset cache space, and returning a query result.
According to another aspect of the present invention, there is provided a data query apparatus of a graph database, including:
the acquisition unit is used for responding to the query request and acquiring the graph data to be queried from the graph database; wherein the graph data comprises graph elements, attribute information of the graph elements and graph configuration information;
the attribute information processing unit is used for serializing the attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation;
the caching unit is used for storing the byte array, the picture elements and the picture configuration information into a preset caching space;
and the feedback unit is used for carrying out data query on the preset cache space according to the graph configuration information and returning a query result.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of querying the graph database according to any of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement a data query method of a graph database according to any embodiment of the present invention when executed.
According to the technical scheme, when the attribute information of the picture element is loaded into the preset cache space, the attribute information can be serialized to obtain the serialization representation of the attribute information, then a byte array is generated according to the attribute information and the serialization representation of the attribute information, and then the byte array is loaded into the preset cache space. Each byte in the byte array is necessary, so that the waste of cache space resources is reduced to a certain extent, the cache space utilization rate is improved, and the query efficiency of the graph data is improved to a certain extent.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for querying data in a graph database according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method for querying data in a graph database according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of an attribute information store provided in accordance with a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a data query device of a graph database according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device implementing a data query method of a graph database according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a data query method for a graph database according to an embodiment of the present invention, where the method may be applied to respond to a query request from a user for querying the graph database by using a client, and the method may be performed by an electronic device. As shown in fig. 1, the method includes:
step 101, responding to a query request, and acquiring graph data to be queried from a graph database; wherein the graph data includes graph elements, attribute information of the graph elements, and graph configuration information.
Specifically, the query request is used for performing data query on the graph database.
The user may send a query request to the electronic device using the client, and the electronic device may receive and respond to the query request to obtain the graph data to be queried from the graph database.
Wherein the graph data includes graph elements, attribute information of the graph elements, and graph configuration information. Wherein the graph elements include vertices and edges. The attribute information of the graph element includes attribute information of vertices and attribute information of edges. The attribute information of the vertex includes characteristic information of the vertex. The attribute information of the edge includes feature information of the edge. The graph configuration information includes configuration information of vertices and edges, for example, the graph configuration information may include information such as the number of vertices and the number of edges.
Step 102, serializing the attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation.
Specifically, the attribute information of the map element may be subjected to serialization processing to obtain a serialized representation corresponding to the attribute information, so as to facilitate storage of the attribute information.
Then, according to the characteristics of the attribute information of the picture element, the serialization representations corresponding to the attribute information can be combined together to generate a byte array.
Step 103, storing the byte array, the graph element and the graph configuration information into a preset cache space.
The preset cache space is a block of cache space divided in the memory in advance.
Specifically, the byte array generated according to the attribute information of the map element, the map element and the map configuration information may be loaded into a preset cache space.
Step 104, according to the graph configuration information, carrying out data query on the preset cache space, and returning a query result.
Specifically, the byte array, the map element and the map configuration information in the preset cache space may be acquired first.
The attribute information of the map element may then be parsed using the map configuration information and the byte array. The graph elements and attribute information for the graph elements may then be determined as query results.
The query results may then be fed back to the client for viewing and use by the user.
Further, a long-time and large-batch query request can be responded by means of the preset cache space. Specifically, the byte array, the graph elements and the graph configuration information stored in the preset cache space can be stored in the preset cache space for a long time, so that the next time the same graph data is queried, the query can be directly performed in the preset cache space, and the data does not need to be read from the graph database.
According to the data query method of the graph data, when the attribute information of the graph element is loaded into the preset cache space, the attribute information can be serialized to obtain the serialized representation of the attribute information, then the byte array is generated according to the attribute information and the serialized representation of the attribute information, and then the byte array is loaded into the preset cache space. Each byte in the byte array is necessary, so that the waste of cache space resources is reduced to a certain extent, the cache space utilization rate is improved, and the query efficiency of the graph data is improved to a certain extent.
Example two
Fig. 2 is a flowchart of a data query method of a graph database according to a second embodiment of the present invention, where steps 102 and 104 of the first embodiment are refined in this embodiment. As shown in fig. 2, the method includes:
Step 201, in response to a query request, obtaining graph data to be queried from a graph database; wherein the graph data includes graph elements, attribute information of the graph elements, and graph configuration information.
Specifically, the implementation and principle of step 201 are similar to those of step 101, and will not be described again.
Step 202, for each attribute information, acquiring a serialization function associated with an attribute type in the attribute information, and serializing the attribute data in the attribute information by adopting the serialization function to obtain a serialization representation corresponding to the attribute information; the attribute information includes attribute data, attribute names and attribute types; the attribute types include integers, floating point numbers, or strings.
Wherein the attribute information of the graph element may include an attribute name, attribute data, and an attribute type. Wherein the attribute data may be an integer, a floating point number, or a character string. Each attribute information corresponds to a unique attribute name.
Specifically, a serialization function associated with each attribute type may be preset. Different attribute types correspond to different serialization functions.
Further, for each attribute information, a serialization function associated with the attribute type in the attribute information may be obtained first, and then the attribute data in the attribute information may be serialized using the serialization function, so as to obtain a serialized representation corresponding to the attribute information (i.e., a serialized representation of the attribute data in the attribute information).
Step 203, using attribute information with an attribute type of an integer or a floating point number as first attribute information, and obtaining a sequencing result of each attribute name in each first attribute information as a first sequence.
Specifically, since the integer or floating point number is a fixed length, attribute information whose attribute type is an integer or floating point number may be used as the first attribute information for the convenience of data processing.
Specifically, the attribute names in the first attribute information may be ordered in advance to obtain the first order. The specific sorting order may be determined according to actual requirements, and the embodiment is not limited.
For example, each attribute name in each first attribute information is: e. f, j, k. The first order set in advance may be: k. f, e, j.
Step 204, using the attribute information with the attribute type of character string as the second attribute information, and obtaining the sorting result of each attribute name in each second attribute information as the second order.
Specifically, since the length of the character string is not fixed, attribute information whose attribute type is the character string may be used as the second attribute information for the convenience of data processing.
Specifically, the attribute names in the second attribute information may be ordered in advance to obtain the second order. The specific sorting order may be determined according to actual requirements, and the embodiment is not limited.
Step 205, determining array position information of the serialized representation corresponding to the second attribute information according to the serialized representation corresponding to each attribute information and the second order.
The array position information is used for representing the position of the serialized representation stored in the byte array corresponding to the second attribute information. The serialized representations corresponding to the second attribute information are in one-to-one correspondence with the array position information.
Specifically, since the attribute type of the second attribute information is a character string, the size of the character string is not fixed, the position of the serialized representation corresponding to the second attribute information in the byte array can be positioned by using the array position information, so that the serialized representation corresponding to the second attribute information can be conveniently analyzed from the byte array in the later stage.
Specifically, the serialized representations corresponding to the first attribute information may be stored in the byte array next to each other according to the first serialized result; storing the serialization representation corresponding to each piece of second attribute information in a byte array next to each other according to a second serialization result; the array position information is stored next to the byte array in a second order. The storage order of the serialized representations corresponding to the first attribute information, the serialized representations corresponding to the second attribute information and the array position information in the byte array can be preset according to actual requirements, and the embodiment is not limited. For example, the serialized representations corresponding to the first attribute information may be stored first, then the array position information may be stored next to each other, and then the serialized representations corresponding to the second attribute information may be stored next to each other. And if the data storage sequence of the byte array is determined, array position information of the serialized representation corresponding to each second attribute information can be obtained according to the serialized representation corresponding to each attribute information and the second sequence.
Step 206, ordering the serialized representations corresponding to the first attribute information by adopting a first order to obtain a first serialized result, ordering the serialized representations corresponding to the second attribute information by adopting array position information to obtain a second serialized result, and determining a byte array according to the array position information, the first serialized result and the second serialized result.
Specifically, the first order may be adopted to sort the serialized representations corresponding to the first attribute information, so as to obtain a first serialized result, so that the serialized representations corresponding to the first attribute information are arranged in order.
Specifically, the positions of the serialized representations corresponding to the second attribute information represented in the array position information in the byte array may be adopted, and the serialized representations corresponding to the second attribute information may be ordered to obtain a second serialized result.
Specifically, the serialized representations corresponding to the second attribute information correspond to the array position information one by one. The number of the second attribute information is the same as the number of the array position information. Each array of location information may occupy a fixed amount of space (e.g., unsigned 32-bit integers).
Specifically, a byte array may be generated according to the serialized representation corresponding to each attribute information and the size of the space occupied by each array position information. Then, the byte array is filled with the serialized representation corresponding to each attribute information and each array position information. For example, the serialized representations corresponding to the first attribute information may be stored next to each other according to the first serialization result; storing the serialization representation corresponding to each piece of second attribute information next to each other according to the second serialization result; and storing the array position information next to each other in a second order.
In one implementation, the method further includes: and acquiring first position information which corresponds to the first attribute information and is expressed in the byte array in a serialization manner, and storing the first position information into the graph configuration information so as to update the graph configuration information.
The first position information is used for representing the position of the serialized representation corresponding to the first attribute information in the byte array. The serialized representations corresponding to the first attribute information are in one-to-one correspondence with the first location information.
Specifically, first position information corresponding to the serialized representation corresponding to the first attribute information may be obtained, and the first position information may be stored in the map configuration information, so as to update the map configuration information.
In one implementation, the method further includes: and acquiring second position information of the array position information in the byte array, and storing the second position information in the map configuration information to update the map configuration information.
Wherein the second position information is used to characterize the position of the array position information in the byte array. The array position information corresponds to the second position information one by one.
Specifically, second location information corresponding to the array location information may be obtained, and the second location information may be stored in the map configuration information, so as to update the map configuration information.
Example III
Fig. 3 is a schematic diagram of an attribute information storage according to a third embodiment of the present invention.
The attribute information of the diagram element is assumed to be: { a: 32-bit integer (data a), b: character string (data b), c: 64-bit integer (data c), d: string (data d). Taking the first attribute information as an example, a is the attribute name of the first attribute information, a 32-bit integer is the attribute type of the first attribute information, and data a is used for representing the attribute data of the first attribute information. Other attribute information and so on are not described in detail. Assume in this example that the first order is: a. c, performing operation; the second sequence is: b. d, the step d. The resulting byte array may be as shown in fig. 3. Wherein, data a in fig. 3 is used for representing the serialization representation corresponding to the attribute information with the attribute name a, data C is used for representing the serialization representation corresponding to the attribute information with the attribute name C, data B is used for representing the serialization representation corresponding to the attribute information with the attribute name B, data D is used for representing the serialization representation corresponding to the attribute information with the attribute name D, data E is used for representing the position information of data B in the byte array, and data F is used for representing the position information of data D in the byte array.
Wherein, the array refers to a continuous space, which is divided into several segments, and each segment stores one same unit. Byte arrays are arrays in which one byte (binary 8 bits) is stored per segment. Thus, the position information of data A in the byte array can be noted 0, the position information of data C in the byte array can be noted 4, the position information of data E in the byte array can be noted 12, and the position information of data F in the byte array can be noted 16.
Step 207, storing the byte array, the map element and the map configuration information into a predetermined cache space.
Specifically, the principle and implementation of step 207 are similar to those of step 103, and will not be described again.
Step 208, obtaining a byte array in the preset cache space, and analyzing attribute data of the graph element from the byte array by utilizing the graph configuration information.
Specifically, a byte array may be obtained from a preset cache space, and then, according to the graph configuration information, a serialization representation corresponding to the attribute information of each graph element may be read from the byte array, and then, each serialization representation is analyzed, so as to obtain the attribute data of the graph element.
In one implementation, first location information is obtained from the graph configuration information, and a serialized representation corresponding to the first attribute information is read from the byte array according to the first location information.
Specifically, for the first attribute information, the first position information may be first obtained from the map configuration information, and the first position information is used to locate the serialized representation corresponding to the first attribute information in the byte array, so as to obtain the serialized representation corresponding to the first attribute information.
Then, an inverse serialization function associated with the attribute type in the first attribute information is obtained, and the serialization representation corresponding to the first attribute information is subjected to inverse serialization by adopting the inverse serialization function, so that attribute data of the first attribute information is obtained.
Specifically, an inverse serialization function associated with each attribute type in the attribute information of each drawing element may be preset. Different attribute types correspond to different anti-serialization functions. The anti-serialization function is used for carrying out anti-serialization on the serialization representation corresponding to the attribute information to obtain the attribute data of the attribute information.
Specifically, an inverse serialization function associated with the attribute type in the first attribute information may be first obtained, and the deserialization function is used to deserialize the serialized representation corresponding to the first attribute information, so as to obtain attribute data of the first attribute information.
In one implementation, the second position information and the adjacent second position information are acquired from the graph configuration information, and the corresponding array position information and the adjacent array position information are read from the byte array according to the second position information and the adjacent second position information.
Specifically, for the second attribute information, the second position information and the adjacent second position information may be acquired from the map configuration information (the adjacent second position information may be the adjacent next second position information of the second position information), and then, according to the second position information and the adjacent second position information, the corresponding array position information and the adjacent array position information (the adjacent array position information may be the adjacent next array position information of the array position information) are read from the byte array.
And then, reading the serialization representation corresponding to the second attribute information from the byte array according to the corresponding array position information and the adjacent array position information.
Specifically, the serialized representation corresponding to the second attribute information corresponding to the corresponding array position information may be located in the byte array according to the corresponding array position information and the adjacent array position information, and the serialized representation corresponding to the second attribute information may be read.
Wherein the serialization representation corresponding to the second attribute information corresponding to the corresponding array position information may be between the corresponding array position information and the adjacent array position information in the byte array.
Specifically, since the attribute type of the second attribute information is a character string, the size of the attribute data of the second attribute information is not fixed, and thus the corresponding array position information and the adjacent array position information can be utilized to quickly locate the serialized representation corresponding to the second attribute information in the byte array.
And then, acquiring an inverse serialization function associated with the attribute type in the second attribute information, and performing deserialization on the serialization representation corresponding to the second attribute information by adopting the inverse serialization function to obtain attribute data of the second attribute information.
Specifically, an inverse sequence function associated with the attribute type in the second attribute information may be obtained, and then the inverse sequence function is used to perform inverse sequence on the serialized representation corresponding to the second attribute information, so as to obtain attribute data of the second attribute information.
For example, for the byte array shown in fig. 3. If the attribute data of the attribute information with the attribute name of c is to be read, the recorded position information 4 can be found from the graph configuration information, then the serialization representation corresponding to the attribute information with the attribute name of c is read from the position 4 of the byte array, and then the attribute data of the attribute information with the attribute name of c can be obtained by calling the anti-serialization function corresponding to the 64-bit integer. If the attribute data of the attribute information with the attribute name b is to be read, the position information 12 corresponding to the attribute information with the attribute name b and the position information 16 corresponding to the attribute information with the attribute name d can be found from the map configuration information, then the position of the serialized representation of the attribute information with the attribute name b and the position of the serialized representation of the attribute information with the attribute name d in the byte array are respectively read from the positions 12 and 16 of the byte array, then the serialized representation corresponding to the attribute information with the attribute name b is read from the byte array, and finally the attribute data with the attribute name b can be obtained by calling the anti-serialization function of the character string.
Step 209, obtaining the attribute name and attribute type of the drawing element from the drawing configuration information, and determining the attribute information of the drawing element according to the attribute data, attribute name and attribute type of the drawing element.
Specifically, the attribute name and attribute type of the drawing element may also be included in the drawing configuration information. Further, the attribute name and the attribute type of the map element can be obtained from the map configuration information, and the attribute information of the map element is determined according to the attribute data, the attribute name and the attribute type of the map element.
Step 210, obtaining the graph elements in the preset cache space, determining the graph elements and attribute information of the graph elements as query results, and returning the query results.
Specifically, a graph element in a preset cache space may be obtained, and the graph element and attribute information of the graph element are determined as a query result. Further, the query results may be fed back to the client for viewing and use by the user.
Example IV
Fig. 4 is a schematic structural diagram of a data query device of a graph database according to a fourth embodiment of the present invention. As shown in fig. 4, the apparatus 400 includes:
an obtaining unit 410, configured to obtain, in response to a query request, graph data to be queried from a graph database; the map data comprises map elements, attribute information of the map elements and map configuration information;
The attribute information processing unit 420 is configured to serialize attribute information of the map element to obtain a serialized representation corresponding to the attribute information, and generate a byte array according to the attribute information and the serialized representation;
a buffer unit 430, configured to store the byte array, the map element, and the map configuration information into a preset buffer space;
the feedback unit 440 is configured to perform data query on the preset cache space according to the graph configuration information, and return a query result.
In one implementation manner, the attribute information processing unit 420 is specifically configured to obtain, for each attribute information, a serialization function associated with an attribute type in the attribute information, and serialize attribute data in the attribute information by using the serialization function, so as to obtain a serialized representation corresponding to the attribute information; wherein the attribute information comprises attribute data, attribute names and attribute types; attribute types include integers, floating point numbers, or strings;
taking attribute information with the attribute type of an integer or a floating point number as first attribute information, and acquiring a sequencing result of each attribute name in each first attribute information as a first sequence;
taking attribute information with the attribute type of a character string as second attribute information, and acquiring a sequencing result of each attribute name in each second attribute information as a second sequence;
Determining array position information of the serialized representation corresponding to the second attribute information according to the serialized representation corresponding to each attribute information and the second order;
and sequencing the serialized representations corresponding to the first attribute information by adopting a first sequence to obtain a first serialized result, sequencing the serialized representations corresponding to the second attribute information by adopting array position information to obtain a second serialized result, and determining a byte array according to the array position information, the first serialized result and the second serialized result.
The attribute information processing unit 420 is further configured to obtain first position information, which corresponds to the first attribute information and is represented in the byte array in a serialization manner, and store the first position information in the graph configuration information to update the graph configuration information;
and acquiring second position information of the array position information in the byte array, and storing the second position information in the map configuration information to update the map configuration information.
In one implementation manner, the feedback unit 440 is specifically configured to obtain a byte array in a preset cache space, and parse attribute data of the graph element from the byte array by using the graph configuration information;
acquiring attribute names and attribute types of the picture elements from the picture configuration information, and determining attribute information of the picture elements according to the attribute data, the attribute names and the attribute types of the picture elements;
And acquiring the graph elements in the preset cache space, and determining the graph elements and attribute information of the graph elements as query results.
Optionally, the feedback unit 440 is specifically configured to obtain the first location information from the map configuration information, and read the serialized representation corresponding to the first attribute information from the byte array according to the first location information;
and acquiring an inverse serialization function associated with the attribute type in the first attribute information, and performing inverse serialization on the serialization representation corresponding to the first attribute information by adopting the inverse serialization function to obtain attribute data of the first attribute information.
Optionally, the feedback unit 440 is specifically configured to obtain second location information and adjacent second location information from the map configuration information, and read corresponding array location information and adjacent array location information from the byte array according to the second location information and the adjacent second location information;
reading the serialization representation corresponding to the second attribute information from the byte array according to the corresponding array position information and the adjacent array position information;
and acquiring an inverse serialization function associated with the attribute type in the second attribute information, and performing inverse serialization on the serialization representation corresponding to the second attribute information by adopting the inverse serialization function to obtain attribute data of the second attribute information.
The data query device of the graph database provided by the embodiment of the invention can execute the data query method of the graph database provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 5 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as any of the graph database data querying methods described above.
In some embodiments, the data query method of any of the graph databases described above may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of a data query method of any of the above-described graph databases may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform any of the graph database data query methods described above in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (8)

1. A method for querying data in a graph database, comprising:
responding to the query request, and acquiring graph data to be queried from a graph database; wherein the graph data comprises graph elements, attribute information of the graph elements and graph configuration information; wherein the map configuration information at least comprises the number and the position information of the map elements; the attribute information comprises attribute data, attribute names and attribute types; the attribute type comprises an integer, a floating point number or a character string;
Serializing the attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation;
storing the byte array, the graph elements and the graph configuration information into a preset cache space;
analyzing attribute information of the graph element by utilizing the graph configuration information and the byte array; determining the graph elements and attribute information of the graph elements as query results, and returning the query results;
the serializing the attribute information of the map element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation, including:
for each attribute information, acquiring a serialization function associated with an attribute type in the attribute information, and serializing the attribute data in the attribute information by adopting the serialization function to obtain a serialization representation corresponding to the attribute information;
taking attribute information with the attribute type of an integer or a floating point number as first attribute information, and acquiring a sequencing result of each attribute name in each first attribute information as a first sequence;
Taking attribute information with the attribute type of a character string as second attribute information, and acquiring a sequencing result of each attribute name in each second attribute information as a second sequence;
determining array position information of the serialized representation corresponding to the second attribute information according to the serialized representation corresponding to each attribute information and the second order;
and sequencing the serialized representations corresponding to the first attribute information by adopting a first sequence to obtain a first serialized result, sequencing the serialized representations corresponding to the second attribute information by adopting the array position information to obtain a second serialized result, and determining the byte array according to the array position information, the first serialized result and the second serialized result.
2. The method as recited in claim 1, further comprising:
acquiring first position information which corresponds to the first attribute information and is expressed in the byte array in a serialization manner, and storing the first position information into the graph configuration information so as to update the graph configuration information;
and acquiring second position information of the array position information in the byte array, and storing the second position information into the map configuration information to update the map configuration information.
3. The method of claim 2, wherein the parsing the attribute information of the map element using the map configuration information and the byte array; determining the graph element and the attribute information of the graph element as query results, and returning the query results, wherein the method comprises the following steps:
acquiring the byte array in the preset cache space, and analyzing attribute data of a graph element from the byte array by utilizing the graph configuration information;
acquiring attribute names and attribute types of the map elements from the map configuration information, and determining attribute information of the map elements according to the attribute data, the attribute names and the attribute types of the map elements;
and acquiring the graph elements in the preset cache space, and determining the graph elements and attribute information of the graph elements as the query result.
4. A method according to claim 3, wherein parsing attribute data of a graph element from the byte array using the graph configuration information comprises:
acquiring the first position information from the map configuration information, and reading a serialization representation corresponding to the first attribute information from the byte array according to the first position information;
And acquiring an inverse serialization function associated with the attribute type in the first attribute information, and performing inverse serialization on the serialization representation corresponding to the first attribute information by adopting the inverse serialization function to obtain the attribute data of the first attribute information.
5. A method according to claim 3, wherein parsing attribute data of a graph element from the byte array using the graph configuration information comprises:
acquiring second position information and adjacent second position information from the map configuration information, and reading corresponding array position information and adjacent array position information from the byte array according to the second position information and the adjacent second position information;
reading the serialization representation corresponding to the second attribute information from the byte array according to the corresponding array position information and the adjacent array position information;
and acquiring an inverse serialization function associated with the attribute type in the second attribute information, and performing inverse serialization on the serialization representation corresponding to the second attribute information by adopting the inverse serialization function to obtain attribute data of the second attribute information.
6. A data query device for a graph database, comprising:
The acquisition unit is used for responding to the query request and acquiring the graph data to be queried from the graph database; wherein the graph data comprises graph elements, attribute information of the graph elements and graph configuration information; wherein the map configuration information at least comprises the number and the position information of the map elements; the attribute information comprises attribute data, attribute names and attribute types; the attribute type comprises an integer, a floating point number or a character string;
the attribute information processing unit is used for serializing the attribute information of the picture element to obtain a serialization representation corresponding to the attribute information, and generating a byte array according to the attribute information and the serialization representation;
the caching unit is used for storing the byte array, the picture elements and the picture configuration information into a preset caching space;
the feedback unit is used for analyzing attribute information of the graph element by utilizing the graph configuration information and the byte array; determining the graph elements and attribute information of the graph elements as query results, and returning the query results;
the attribute information processing unit is specifically used for acquiring a serialization function associated with an attribute type in the attribute information aiming at each attribute information, and serializing the attribute data in the attribute information by adopting the serialization function to obtain a serialization representation corresponding to the attribute information;
Taking attribute information with the attribute type of an integer or a floating point number as first attribute information, and acquiring a sequencing result of each attribute name in each first attribute information as a first sequence;
taking attribute information with the attribute type of a character string as second attribute information, and acquiring a sequencing result of each attribute name in each second attribute information as a second sequence;
determining array position information of the serialized representation corresponding to the second attribute information according to the serialized representation corresponding to each attribute information and the second order;
and sequencing the serialized representations corresponding to the first attribute information by adopting a first sequence to obtain a first serialized result, sequencing the serialized representations corresponding to the second attribute information by adopting the array position information to obtain a second serialized result, and determining the byte array according to the array position information, the first serialized result and the second serialized result.
7. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of querying data of the graph database of any of claims 1-5.
8. A computer readable storage medium storing computer instructions for causing a processor to perform the method of querying data of a graph database according to any one of claims 1-5.
CN202311234817.0A 2023-09-22 2023-09-22 Data query method and device of graph database and electronic equipment Active CN117271840B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311234817.0A CN117271840B (en) 2023-09-22 2023-09-22 Data query method and device of graph database and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311234817.0A CN117271840B (en) 2023-09-22 2023-09-22 Data query method and device of graph database and electronic equipment

Publications (2)

Publication Number Publication Date
CN117271840A CN117271840A (en) 2023-12-22
CN117271840B true CN117271840B (en) 2024-02-13

Family

ID=89215522

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311234817.0A Active CN117271840B (en) 2023-09-22 2023-09-22 Data query method and device of graph database and electronic equipment

Country Status (1)

Country Link
CN (1) CN117271840B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981884A (en) * 2012-11-22 2013-03-20 用友软件股份有限公司 Serializing device and serializing method
CN103488581A (en) * 2013-09-04 2014-01-01 用友软件股份有限公司 Data caching system and data caching method
CN104616354A (en) * 2015-01-23 2015-05-13 克拉玛依红有软件有限责任公司 Method for quickly loading space data through three-dimensional GIS (global information system)
CN106445944A (en) * 2015-08-06 2017-02-22 阿里巴巴集团控股有限公司 Data query request processing method and apparatus, and electronic device
CN111984849A (en) * 2019-05-24 2020-11-24 北京京东尚科信息技术有限公司 Information query method, device, equipment and medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11500934B2 (en) * 2020-06-30 2022-11-15 Vesoft. Inc POI recommendation method and device based on graph database, and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102981884A (en) * 2012-11-22 2013-03-20 用友软件股份有限公司 Serializing device and serializing method
CN103488581A (en) * 2013-09-04 2014-01-01 用友软件股份有限公司 Data caching system and data caching method
CN104616354A (en) * 2015-01-23 2015-05-13 克拉玛依红有软件有限责任公司 Method for quickly loading space data through three-dimensional GIS (global information system)
CN106445944A (en) * 2015-08-06 2017-02-22 阿里巴巴集团控股有限公司 Data query request processing method and apparatus, and electronic device
CN111984849A (en) * 2019-05-24 2020-11-24 北京京东尚科信息技术有限公司 Information query method, device, equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
海量RDF数据存储查询研究;肖佳;肖诗斌;王洪俊;;北京信息科技大学学报(自然科学版)(03);全文 *

Also Published As

Publication number Publication date
CN117271840A (en) 2023-12-22

Similar Documents

Publication Publication Date Title
CN112540806A (en) Applet page rendering method and device, electronic equipment and storage medium
CN113760839A (en) Log data compression processing method and device, electronic equipment and storage medium
CN117236236B (en) Chip design data management method and device, electronic equipment and storage medium
CN112784102B (en) Video retrieval method and device and electronic equipment
CN116955856A (en) Information display method, device, electronic equipment and storage medium
CN117271840B (en) Data query method and device of graph database and electronic equipment
CN116594709A (en) Method, apparatus and computer program product for acquiring data
CN115904240A (en) Data processing method and device, electronic equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN116340518A (en) Text association matrix establishment method and device, electronic equipment and storage medium
CN107291923B (en) Information processing method and device
CN115454971A (en) Data migration method and device, electronic equipment and storage medium
CN115577689A (en) Table component generation method, device, equipment and medium
CN115168358A (en) Database access method and device, electronic equipment and storage medium
CN110704481A (en) Method and device for displaying data
CN114816578A (en) Method, device and equipment for generating program configuration file based on configuration table
CN112861504A (en) Text interaction method, device, equipment, storage medium and program product
CN113434508B (en) Method and apparatus for storing information
CN116579914B (en) Execution method and device of graphic processor engine, electronic equipment and storage medium
US20220405792A1 (en) Method and apparatus for processing commodity information, device and storage medium
CN114625863A (en) Article searching method and related equipment thereof
CN115033823A (en) Method, apparatus, device, medium and product for processing data
CN117742686A (en) Program source code file generation method and device, electronic equipment and storage medium
CN117370397A (en) Database compatible method, device, equipment and storage medium
CN116204441A (en) Performance test method, device, equipment and storage medium of index data structure

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant