Efficient in-memory relation representation for heterogeneous graphs
By separating the vertices and edges of the graph by type and using the CSR format to store heterogeneous graphs, the problem of low efficiency of heterogeneous graph storage and query in the existing technology is solved, and efficient storage and query performance is achieved.
Patent Information
- Application Number
- CN201980033319.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-04-18
- Filing Date
- 2019-03-13
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2039-03-13
AI Technical Summary
Existing graph analysis systems are inefficient when processing heterogeneous graphs, resulting in insufficient memory utilization and low memory access efficiency, and cannot effectively support mixed graphs of directed edges and undirected arcs.
By separating the vertices and edges of the graph by type and using Compressed Sparse Row (CSR) format to store directed or undirected edges of the same type, generating globally unique identifiers and optimized edge offsets, efficient vertices and edges are achieved Storage and query.
It improves the storage efficiency and query performance of the graph, reduces data access and virtual memory exchange, increases hardware cache locality, and improves the efficient use of the graph.
Smart Images

Figure CN112166425B_ABST
Abstract
Description
[0001] Related Cases
[0002] U.S. Patent No. 9,201,944, filed on June 12, 2013, entitled “Techniques For Maintaining Column Vectors Of Relational Data Within Volatile Memory,” is incorporated herein by reference. Technical Field
[0003] The present disclosure relates to in-memory graph formats. Presented herein are techniques for encoding heterogeneous graphs for efficient use. Background Art
[0004] Property graphs are becoming an increasingly important tool in data analysis due to their explicit and fine-grained representation of relationships between entities. Property graphs consist of vertices that represent entities and relationships that connect the vertices and can be directed (i.e., edges) or undirected (i.e., arcs). Vertices, edges, and arcs can have properties or attributes that describe them. In some techniques, for property graphs, vertices and edges are untyped and have the same set of general properties, which can be empty (NULL) or have default and / or invalid values for some vertices or edges.
[0005] In this way, property graphs are well suited for handling completely unstructured data. However, in the real world, graphs, vertices, and edges often have a natural notion of type, i.e., a specific set of properties defined for each of them (e.g., a vertex type representing people, with properties "name", "date of birth", and "address", and another vertex type representing books, with properties "title", "author", and "ISBN"). Such graphs are heterogeneous, containing more than one kind of vertex and / or edge.
[0006] The problem we solve with the present invention is how to represent heterogeneous graphs in memory in an efficient way suitable for supporting graph analysis algorithms and queries. Current graph analysis systems typically implement a property graph model, that is, they treat vertices, edges and arcs as untyped. However, this approach leads to two inefficiencies when processing heterogeneous graphs. The first is inefficient memory utilization, because all properties that are not part of a vertex or edge type will still have a default or NULL value for that element, consuming additional memory.
[0007] The second aspect is inefficient memory access when performing computations that access only a subset of types, since the vertices (or edges) of the entire graph are integrated into the same set of all vertices (or edges) regardless of their semantic differences. Furthermore, commercial systems generally do not support mixed graphs with both directed edges and undirected arcs. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In the attached picture:
[0009] Figure 1 is a block diagram depicting an example computer for efficiently storing vertices of a heterogeneous graph in memory in an embodiment;
[0010] Figure 2 is a flow chart depicting an example process for efficiently storing and using vertices of a heterogeneous graph in memory in an embodiment;
[0011] Figure 3 is a flow chart depicting an example process for efficiently executing queries of heterogeneous graphs in memory in an embodiment;
[0012] Figure 4 is a block diagram depicting an example random access memory (RAM) of a computer in an embodiment that generates a compact and globally unique identifier for each vertex in a graph (regardless of type);
[0013] Figure 5 is a block diagram depicting an example computer in an embodiment that encodes directed edges of a heterogeneous graph in a compressed sparse row (CSR) format for space efficiency and accelerated access;
[0014] Figure 6 is a flow chart depicting an example process for encoding directed edges of a graph in CSR format for space efficiency and accelerated access in an embodiment;
[0015] Figure 7 is a block diagram of an example computer depicting edge feature vectors populated for space efficiency and accelerated access in an embodiment;
[0016] Figure 8 is a flow chart depicting an example process for populating an edge attribute vector for space efficiency and accelerated access in an embodiment;
[0017] Fig. 9 is a block diagram depicting an example RAM in an embodiment that contains edge endpoint vectors optimized for accessing directed edges based on their source vertices, such as when the edges are naturally traversed in the direction of each edge;
[0018] Fig.10is a flow chart depicting an example process for encoding directed edges of a graph in CSR format for backward (i.e., opposite to the natural direction of the directed edges) traversal for space efficiency and acceleration in an embodiment;
[0019] Fig.11 is a block diagram depicting an example RAM in an embodiment that contains endpoint vectors for undirected arcs that are not directed edges.
[0020] Fig.12 is a flowchart depicting an example process for bidirectionally encoding undirected arcs with homogeneous endpoints in an embodiment;
[0021] Fig.13 is a block diagram illustrating a computer system upon which embodiments of the present invention may be implemented;
[0022] Fig.14 is a block diagram illustrating a basic software system that may be used to control the operation of a computing system. DETAILED DESCRIPTION
[0023] In the following description, for the purpose of explanation, many specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent that the present invention can be practiced without these specific details. In other cases, well-known structures and devices are shown in block diagram form to avoid unnecessarily obscuring the present invention.
[0024] This article describes various embodiments according to the following outline:
[0025] 1.0 General Overview
[0026] 2.0 Sample Computer
[0027] 2.1 Data Source
[0028] 2.2 Heterogeneous Graphs
[0029] 2.3 Random Access Memory
[0030] 2.4 Vertex Properties
[0031] 2.5 Vertex Encoding
[0032] 3.0 Example Vertex Loading Process
[0033] 4.0 Example Query Processing
[0034] 4.1 Query Acceleration
[0035] 4.2 Improved Performance
[0036] 5.0 Globally Unique Identifiers
[0037] 5.1 Ram Content
[0038] 5.2 Identification
[0039] 6.0 Topological Coding
[0040] 6.1 Relationship
[0041] 6.2 Foreign Keys
[0042] 6.3 Endpoint Vector
[0043] 7.0 Example Topology Encoding Processing
[0044] 7.1 Destination Vector
[0045] 7.2 Source Vector
[0046] 7.3 Performance Improvements
[0047] 8.0 Edge Feature Storage
[0048] 9.0 Fill Edge Features
[0049] 10.0 Bidirectional traversal
[0050] 10.1 Reverse endpoint vector
[0051] 11.0 Example Reverse Encoding Processing
[0052] 11.1 Reverse Destination Vector
[0053] 11.2 Reverse Source Vector
[0054] 11.3 Edge Offset Translation
[0055] 12.0 Undirected Arc
[0056] 12.1 Arcs with Homogeneous Endpoints
[0057] 13.0 Bidirectional Encoding of Arcs with Homogeneous Endpoints
[0058] 13.1 Forward Coding
[0059] 13.2 Backward Coding
[0060] 14.0 Hardware Overview
[0061] 15.0 Software Overview
[0062] 16.0 Cloud Computing
[0063] 1.0 General Overview
[0064] Provided herein is a technique for efficiently representing heterogeneous graphs in memory. In an embodiment, the vertices and edges of a graph are separated by type. Each property of the type of a vertex or edge has a value stored in a corresponding vector. Directed or undirected edges of the same type are stored in a compressed sparse row (CSR) format. The CSR format is more or less repeated for edge traversals performed in a forward or reverse direction. Edge mapping transforms the edge offsets obtained from the reverse direction traversal to be used with a data structure for the expected edge offsets in the forward direction. Subsequent filtering and / or traversals by type or property of a vertex or edge require minimal data access and maximum data locality, thereby increasing the efficient use of the graph.
[0065] In an embodiment, a computer associates each vertex of a graph residing in a memory with a unique offset. For each of a plurality of relationships in a data source, the following occurs. The relationship becomes associated with the following objects residing in the memory: a unique (distinct) edge type, a sorted unique source vector, and a sorted unique destination vector for connecting a source vertex of a specific source vertex type with a destination vertex of a specific destination vertex type in the graph. For each instance of a relationship, a directed edge representing an instance of the relationship is created in the graph as an instance of the unique edge type of the relationship. The directed edge includes a source vertex of the graph and a destination vertex of the graph. For each vertex of a specific source vertex type, the following occurs. For each directed edge of a unique edge type having the vertex as its source vertex, the computer stores the unique offset of the destination vertex of the directed edge in a unique destination vector. The last position containing the unique offset in the unique destination vector is stored at the unique offset of the vertex in the unique source vector. Subsequently, the reading of the graph is accelerated by accessing the unique source vector of the relationship of the unique edge type and / or the unique destination vector of the relationship.
[0066] 2.0 Sample Computer
[0067] Figure 1 1 is a block diagram depicting an example computer 100 in an embodiment. Computer 100 efficiently stores vertices of a heterogeneous graph in memory. Computer 100 may be one or more computers, such as an embedded computer, a personal computer, a rack server (such as a blade, a mainframe, a virtual machine), or any computing device that uses temporary memory during symbolic processing.
[0068] Computer 100 may load and process graph 160, such as for querying, mutation, or analysis. Graph 160 is a logical graph of interconnected vertices, such as vertices 181-182. Vertices 181-182 may have properties, such as 186-187, and graph 160 may be a property graph.
[0069] 2.1 Data Source
[0070] Diagram 160 is a logical view of the underlying data provided by (one or more) data sources such as 110. Data source 110 may be a persistent data repository, such as a relational database, a columnar database, a property repository, a Resource Description Framework (RDF) triple store, a spreadsheet, a Hadoop File System (HDFS) file, or a data file. Data source 110 may generate data autonomously, such as when data source 110 is a computer program, a web service, or a data feed (such as a stream).
[0071] Data source 110 contains records (such as 141-142), which may be tuples, rows, or other structural units. Records 141-142 may aggregate data fields (such as 131-132) that store more or less atomic values. Data source 110 may have records (such as 141-142) of different types (such as 121-122) or of the same type (such as 122). Record type 122 may have data fields 131-132, while record type 121 may have other data fields. In an embodiment, data source 110 is a relational database; record types 121-122 are tables in the relational database; records 141-142 are rows in the database table; and data fields 131-132 are columns in the database table.
[0072] As shown, the graph 160 and the data source 110 reside in the same computer 100. However, the data source 110 may be located remotely (i.e., external to the computer 100), such as residing in a cross-mounted file system, a network attached storage device (NAS), a storage area network (SAN), or a remote service such as a relational database management system (RDBMS) accessed through open database connectivity (ODBC) according to the simple object access protocol (SOAP), the common gateway interface (CGI) and / or the representational state transfer (REST) or a web service accessed through the hypertext transfer protocol (HTTP). The data source 110 may serialize the records 141-142 for consumption by the computer 100 according to an encoding format such as the extensible markup language (XML), JavaScript object notation (JSON), comma separated values (CSV), Java object serialization, or a proprietary / native binary format.
[0073] 2.2 Heterogeneous Graphs
[0074] Graph 160 is heterogeneous, meaning that vertices (such as 181-182) can be of the same type (such as 172) or different types (such as 171-172). Computer 100 can have a mapping, such as marshaling or data binding logic, that causes a subset of vertex types 171-172 to be generated from a subset of record types 121-122. For example, one record type (such as 122) can be mapped to one vertex type 172. Other mappings are possible, such as one record type mapping to many vertex types, many record types mapping to one vertex type, or many-to-many mappings.
[0075] 2.3 Random Access Memory
[0076] Fast access to graph 160 may require low latency storage, such as random access memory (RAM), which may be volatile (such as 105), such as inexpensive and dense dynamic RAM (DRAM) or fast static RAM (SRAM). In an embodiment not shown, memory 105 is non-volatile (NVRAM), such as flash memory. Because RAM 105 typically has less capacity than disk storage due to capital costs, computer 100 uses a dense (i.e., space-efficient) storage format for vertices 181-182.
[0077] 2.4 Vertex Properties
[0078] The vertex storage format is column-wise for vertex properties such as 186-187, and the vertex properties are sliced (i.e., separated by properties) so that each property is stored in a unique property vector (such as 191-192). As shown, fields 131-132 correspond to properties 186-187, respectively. Each of vertices 181-182 can have its own value for properties 186-187. For example, vertex 181 may have been generated from record 141 (the value of field 131 of record 141 is red). Therefore, for vertex 181, the value of color property 187 can be red. Similarly, the color 187 value of vertex 182 can be blue because the value of field 131 of record 142 is blue. Therefore, records of the same type have the same set of fields, and vertices of the same type have the same set of properties.
[0079] All values of color properties 187 (e.g., red, blue) for vertices 181-182 of vertex type 172 are stored in property vector 191. Similarly, all values of property 186 are stored in vector 192. Some embodiments may have various ways of compressing vector 191, such as bit or byte packing (i.e., no padding for alignment), dictionary encoding, or run-length encoding. Property vector storage may also speed up processing, such as by reducing virtual memory swaps or by facilitating burst mode processing, such as by utilizing single instruction multiple data (SIMD) and / or (one or more) slice registers (i.e., packing multiple values from vector 191 into the same central processing unit (CPU) register). Techniques for property vectors (also called column vectors) are described in detail in U.S. Patent No. 9,201,944, entitled "Techniques For Maintaining Column Vectors Of Relational Data Within Volatile Memory," which is incorporated herein by reference.
[0080] 2.5 Vertex Encoding
[0081] Each vertex of vertex type 172 can have a (e.g., zero-based) unique sequence number. The sequence of sequence numbers can be reused for different vertex types, as long as each sequence number is unique within a given vertex type. For example, two vertex types 171-172 can each have their own vertex with the same sequence number (such as zero). Although not shown, each of vertex types 171-172 can have an array of vertices of that type. The offset of a given vertex within the array can be used as the (e.g., implicit) sequence number of the vertex. For example, vertices 181-182 both have vertex type 172 and can reside in the same vertex array with different offsets (such as zero and one, respectively).
[0082] For purposes of illustration, property vector 191 is shown as having two columns: an offset and a value. However, as long as the property values are stored in property vectors 191-192 for vertices 181-182 in the same order as vertices 181-182 are stored in a vertex array (not shown) of vertex type 172, the offset (e.g., a sequence number) of vertex 182 in the vertex array can be used to randomly access property vectors 191-192 for vertex 182. Thus, the offset column of vector 191 shown may be an implicit column that is not actually stored. Thus, in an embodiment, the only data contained in vector 191 is the values red and blue.
[0083] 3.0 Example Vertex Loading Process
[0084] Figure 2is a flow chart depicting how computer 100 efficiently stores and uses vertices of a heterogeneous graph in memory in an embodiment. Figure 1 Let's discuss Figure 2 .
[0085] The depicted process is performed by computer 100 in two phases, loading and using. During loading, a graph is created in memory based on data from (one or more) data sources. Loading occurs during steps 201-205 and is repeated for each record type provided by (one or more) data sources of the graph. Loading can be parallelized by data source or by record type.
[0086] Loading occurs in two phases, preparation and encoding. Preparation occurs during steps 201-202, during which empty data structures are created and linked in memory. Step 201 associates each record type with a unique vertex type in the graph constructed in memory.
[0087] In an embodiment, a static data binding map is consulted, which indicates that record types 121-122 are mapped to vertex types 171-172, respectively. In an embodiment without static data binding, data source 110 can be queried, and record types 121-122 can be discovered. From metadata about record types 121-122, vertex types 171-172 can be generated.
[0088] In an embodiment, the mapping of record types to vertex types need not be one-to-one. For example, rows can be separated, such as when record type 122 is mapped to two vertex types 171-172, so that red records (such as 141) are mapped to vertex type 171, and blue records (such as 142) are mapped to vertex type 172. In another example, fields can be separated, such as when field 131, color 187, and vertex type 172 are bound as shown, and although otherwise shown, field 132 and property 186 can be bound to vertex type 171. In another example, record types 121-122 are all mapped to vertex type 172.
[0089] Step 202 associates each data field in the record type with a vertex attribute vector residing in memory. For example, binding or inference may determine that data fields 131-132 map to vertex attributes 186-187, as shown. Based on this information, empty vertex attribute vectors 191-192 are created.
[0090] Vertex encoding occurs during steps 203-205, which is repeated for each record of the record type. A vertex or a subset of vertices may be the unit of parallelization during encoding. Each repetition of steps 203-205 populates one vertex. In an embodiment, an empty graph 160 is created in steps 201 or 202, and vertices may be added to the graph 160 as each vertex is initialized. In an embodiment, the empty graph 160 is not created until slightly later, but not later than after step 205, and vertices are not added to the graph 160 until all vertices are initialized.
[0091] Step 203 creates a vertex with the vertex type from a record with a record type corresponding to the vertex type. For example, vertex 181 is created from record 141.
[0092] Step 204 assigns a unique offset integer to the vertex. For example, vertex 181 may be stored in a vertex array (not shown) in memory at a unique offset within the array. The offset may be used to identify the vertex as unique within that vertex type, but not necessarily unique across multiple vertex types. Globally unique identifiers are discussed later in this document.
[0093] Step 205 stores the vertex properties. The value from each data field of the record is stored in a unique vertex property vector associated with that field. The value is stored in the property vector at the same offset as assigned to the vertex in step 204. For example, the value blue is copied from field 131 of record 142 to color property 187 of vertex 182, which is stored at offset 1 within vector 191.
[0094] After step 205, the map loading is complete and the map 160 is ready for use. In an embodiment, after step 205, the map 160 is made read-only.
[0095] Graph usage occurs during step 206. For example, properties of vertices may be read. As described above, reads are accelerated due to the simplified storage format. Random access to properties of one vertex or scans of properties of many vertices are accelerated. For example, computer 100 may receive and execute queries on graph 160 to find individual vertices or multi-vertex paths or subgraphs based on vertex properties. Query processing is performed at Figure 3 Further discussion in.
[0096] 4.0 Example Query Processing
[0097] Figure 3 is a flowchart depicting how the computer 100 efficiently executes queries on heterogeneous graphs in memory in an embodiment. Figure 1-2 Let's discuss Figure 3 .
[0098] In this example, query execution requires graph navigation that requires repeated traversal along edges from one vertex to another. Like vertices, edges can have a type. Each edge connects two vertices together or connects a vertex to itself. Like vertices, edges can have a type, properties, and a property vector, with the offset of the property vector aligned to the edge vector of the edge type. Edge storage and use is discussed later in this article.
[0099] Step 301 is preparatory. Step 301 assumes that Figure 1-2 The graph is loaded into memory. Step 301 facilitates Figure 2 The graph of steps 201-202 is loaded.
[0100] Step 301 associates vertex types with edge types and loads edges. Graph traversal depends on the graph topology, as graph traversal occurs outward through the edges of the vertices. Therefore, step 301 establishes which edge types (and edges) are available when traversing from a given vertex.
[0101] Steps 302-306 can be Figure 2 160 occurs during step 206 of . In step 302, a graph query is received. The query may be expressed in a graph language such as Sparql or another language such as Standard Query Language (SQL), Extensible Markup Language Path (XPath), Query by Example (QBE), regular expressions, or a domain-specific (e.g., graph) language (DSL). The query may mention types and properties of vertices and edges of the graph 160, constants (i.e., literals), and operators. The query may specify filtering, navigation, and projection.
[0102] 4.1 Query Acceleration
[0103] Efficient execution of the query occurs during steps 303-306. Step 303 detects which types and properties of vertices (and edges) are relevant to the query. Step 303 may construct an AST of the query and semantically analyze the parse tree of the query. At a minimum, the types and properties of vertices and edges are relevant if stated in the query (and / or appear in the AST).
[0104] Steps 304-306 are repeated for each vertex type. Step 304 detects whether the vertex type participates in the query. Steps 303-304 can help formulate a query execution plan.
[0105] According to step 304, irrelevant vertex types are skipped, which is efficient. In embodiments where vertices and / or vertex types are loaded slowly, skipping may mean postponing or avoiding loading some vertices. Similarly, vertex properties may each be irrelevant, skipped, and not loaded. For example, a first query of a cold (i.e., not fully loaded) graph may cause vertex property vector 191 to be loaded, but vector 192 not to be loaded, because the query only accesses color 187, but not property 186.
[0106] Step 305 accesses the relevant property vector for the vertex type. Step 305 may require random access to the properties of a particular vertex or scanning the properties of many vertices. For example, multiple values stored consecutively in vertex property vector 191 may be loaded (e.g., packed) into the same CPU register simultaneously and / or processed together via single instruction multiple data (SIMD) or other vector hardware acceleration (such as using a graphics processing unit (GPU)).
[0107] 4.2 Improved Performance
[0108] Thus, the space savings and speedup efficiencies occur at two levels. First, the heterogeneity of vertex types helps minimize the number of vertices accessed or even loaded by queries. Second, the separation and storage of columns (i.e., features) in separate vectors helps: a) minimize the number of feature values accessed or even loaded by queries, b) compression of feature vectors, such as by dictionary or run-length encoding, which may occur during or after loading feature vectors; and c) vector data parallelism, such as by SIMD or GPU.
[0109] Many of these efficiencies are more or less unavailable to graph loading techniques that treat vertices and edges as homogeneous or generalized. Various space savings (e.g., load avoidance, read avoidance, vector packing, and / or other vector compression) may result in various levels of speedup, such as reduced virtual memory thrashing, increased hardware cache locality, reduced bus saturation or wait states, and hardware data parallelism.
[0110] Edge traversal occurs during step 306, which examines the edges of the vertex(s) to turn or prune the subgraph along the path. Because edge traversal facilitates iteration of adjacent vertices, step 306 can facilitate exploration algorithms such as breadth-first search (BFS) or depth-first search (DFS). Edge storage and access techniques are discussed later in this document.
[0111] 5.0 Globally Unique Identifiers
[0112] Figure 4 is a block diagram depicting an example random access memory (RAM) 405 of a computer (not shown) in an embodiment. Figure 1As discussed, vertices of the same type may be identified by offsetting them into an array of vertices of that type, and for other vertex types, the offset sequence may conflict (i.e., be reused). The computer generates an identifier for each vertex in the graph (regardless of type) that is compact and globally unique. The computer may be an embodiment of computer 100.
[0113] 5.1 RAM Contents
[0114] RAM 405 stores a heterogeneous graph (not shown) that includes vertex type 470 (which may have vertices such as 480) and various vertex properties that may be stored in property vectors such as 491-492, respectively. Each of vectors 491-492 stores property values for a plurality of vertices. The contents of vectors 491-492 have the same ordering as the vertex array (not shown) of vertex type 470 by vertex. For example, vertex 480 may be the first vertex in the vertex array (i.e., offset zero). Therefore, the top row of vectors 491-492 (i.e., offset zero) has the property values for vertex 480.
[0115] 5.2 Identification
[0116] Therefore, zero is recorded in the offset field within identification pair 420. Identification pair 420 uniquely and globally identifies vertex 480. However, the vertex offset is not enough to uniquely and globally identify the vertex. Therefore, identification pair 420 also has an additional field to ensure global uniqueness. The additional field should identify which type is vertex 480. In an embodiment, the additional field records the name of vertex type 470. In an embodiment, the additional field is a serial number that uniquely identifies vertex type 470. Vertex type 470 has a serial number 410, whose value is 5, which is recorded in the identification pair of a vertex (such as 480).
[0117] The sequence number and offset fields of the identification pair 420 can be integers. The sequence number does not have to have the same width (i.e., storage size) as the offset, and they can be byte packed or bit packed together so that the width of the identification pair 420 includes the sum of the widths of the sequence number and offset fields. For speed, the width of the identification pair 420 should not exceed a machine word (e.g., CPU register width), which is typically 64 bits. A graph with too many vertices may require up to 128 bits (i.e., double words) for the identification pair 420.
[0118] More or less the same technique can be used to globally identify edges connecting vertices. RAM storage of edges is discussed later in this article. Figure 4 In addition, other figures in this document also depict techniques designed for vertex and edge identifiers that are unique only within a vertex type or edge type. Figure 4, the globally unique identifier may facilitate filtering by type, since the type of vertex or edge is encoded (eg, a sequence number) into the identification pair 420. The globally unique identifier may also be of interest to client applications or ad hoc clients.
[0119] 6.0 Topological Coding
[0120] Figure 5 is a block diagram depicting an example computer 500 in an embodiment. Computer 500 encodes directed edges of a heterogeneous graph in a compressed sparse row (CSR) format for space efficiency and accelerated access. Computer 500 may be an implementation of computer 100.
[0121] 6.1 Relationship
[0122] Computer 500 loads graph 560 into RAM 505 based on data from data source 510 as follows. In addition to providing records for vertex 0-2 (not shown), data source 510 also provides relationship 520 for creating edge 0-4. Each instance 0-4 of relationship 520 provides data for corresponding edge 0-4. For example, as shown, edge 1 is generated from instance 1.
[0123] For illustration, relationship 520 is depicted as a table. Each row represents an instance of relationship 520. Relation 520 has columns 530 and 540 that identify the directed endpoint vertices of each instance. For example, instance 1-2 is an edge in opposite directions between the same two vertices. Instance 4 is reflexive (i.e., connects a vertex to itself).
[0124] In an embodiment, data source 520 is a relational database. Relationship 520 can be encoded in relational database tables in various ways based on one or two foreign keys in one or three tables as follows. Each of instances 0-4 connects (ie, joins) two tables.
[0125] 6.2 Foreign key
[0126] For example, columns 530 and 540 can identify rows of corresponding source and destination tables (not shown). Source 530 can be a primary key column within the source table. Destination 540 can be replicated as two columns: a) the primary key column in the destination table, and b) the foreign key column in the source table. This can achieve a one-to-one or one-to-many relationship. In another example, source 530 can instead be a replicated column, and the destination table can store the foreign key column. When the source and destination tables are the same table, reflexivity (such as for Example 4) is possible.
[0127] Another example may involve a third table as an association table. For example, relationship 520 may be an association table separate from the source and destination tables. As such, columns 530 and 540 are both foreign keys that cross-reference the source and destination tables, respectively. This may implement a one-to-one, one-to-many, or many-to-many relationship. Regardless of how many tables and keys are used for relationship 520, instance columns may be implicit (i.e., illustrative and not actually stored).
[0128] 6.3 Endpoint Vector
[0129] Edges 0-4 are created from instances 0-4 by filling edge endpoint vectors 570 and 580 and a set of property vectors (not shown). As described above, edge property vectors are encoded in a manner similar to vertex property vectors. For example, for each type of edge, there may be an array of edges (not shown). The contents of the edge property vectors may share the edge ordering of the edge array.
[0130] The edge endpoint vectors 570 and 580 are encoded based on the special ordering of the edges as follows. The special ordering of edges 0-4 depends on the ordering of vertices 0-2 in the vertex array (not shown). Figure 5-6 The discussion of describes how edge endpoint vectors 570 and 580 are populated according to a special ordering of edges 0-4.
[0131] 7.0 Example Topology Encoding Processing
[0132] Figure 6 is a flowchart depicting an embodiment of computer 100 encoding directed edges of a graph in a compressed sparse row (CSR) format for space efficiency and accelerated access. Figure 5 Let's discuss Figure 6 .
[0133] The depicted process is performed by computer 500 in two phases, loading and using. During loading, a graph is created in memory based on data from (one or more) data sources. Loading occurs during steps 601-605, and is repeated for each relationship provided by (one or more) data sources of the graph. Loading can be parallelized by data source or by relationship.
[0134] Loading occurs in two phases: preparation and encoding. Preparation occurs during steps 601-602, during which an empty data structure is created and linked in memory. Step 601 associates each vertex of the graph with an offset that is unique to the type of vertex (but not necessarily globally unique). In an embodiment, RAM 505 is Figure 1 Embodiment of the memory 105, wherein the Figure 2 Vertices are loaded. In an embodiment, vertices of the same type may be stored with their unique offsets in a vertex array (not shown).
[0135] Steps 602-605 are repeated for each relationship in the (one or more) data sources. For relationships, step 602 associates a unique edge type that connects the source vertex type to the destination vertex type, and the source vertex type and the destination vertex type do not have to be the same vertex type. Just as for relationships, step 602 associates a source vector and a destination vector. For example, for the edge type associated with relationship 520, endpoint vectors 570 and 580 are created. Vectors 570 and 580 are initially empty. Subsequent steps fill vectors 570-580 according to a special ordering. In this sense, the contents of vectors 570 and 580 are effectively ordered without actually calling a sorting algorithm.
[0136] Edge encoding occurs during steps 603-605. Step 603 is repeated for each instance of a relationship. Each repetition of step 603 may populate the properties of one edge in an edge property vector (not shown). In an embodiment, an empty graph 560 is created in step 601, and edges may be added to the graph 560 as each edge is initialized. In an embodiment, the empty graph 560 is not created until slightly later but not later than after step 605, and edges are not added to the graph 560 until all edges are initialized.
[0137] Step 603 creates an edge with the edge type from an instance of a relation corresponding to the edge type. For example, edge 1 is created from instance 1. In an embodiment, the edges are stored in an array for the edge type.
[0138] 7.1 Destination Vector
[0139] The edge encoding and special ordering within vectors 570 and 580 is accomplished as follows by steps 604-605. Steps 604-605 are repeated for each vertex of the source vertex type. Step 604 is repeated for each edge of the edge type that has the vertex as a source vertex. In other words, step 604 is repeated for each edge of the edge type that originates from the vertex.
[0140] For example, vertex 0 is the source vertex of edge 0-1, which has the same edge type. Although edge 2 has the same edge type and is also connected to vertex 0, the source vertex of edge 2 is not vertex 0. Edge 0 connects source vertex 0 to destination vertex 1.
[0141] In the next sequential (i.e., vacant) position within the destination vector of the edge type, step 604 stores the value of the offset assigned to the destination vertex in step 601. For example, vertex 1 is stored at zero-based offset one of the vertex array (not shown) of the vertex type. For edge 0, step 604 appends one to the empty destination vector 580. Because destination vector 580 is empty, one is appended (i.e., stored) at position zero of destination vector 580. Also coming from the same source vertex 0 as edge 0, which has vertex 2 as its destination vertex, two is appended to the next position of destination vector 580, which is at zero-based offset one.
[0142] Thus, edges of the edge type from the same source vertex are recorded consecutively in the destination vector 580, after which step 604 is repeated for the next vertex of the same source vertex type. The next source vertex may appear during a sequential iteration of the vertex array (not shown) of that vertex type. Thus, the contents of the destination vector 580 are implicitly ordered by source vertex.
[0143] 7.2 Source Vector
[0144] Step 605 stores the following into the source vector of the edge type at the same offset as the offset assigned to the source vertex in step 601: the last position in the destination vector that contains a unique offset of the destination vertex for the directed edge with that vertex as the source vertex. This last position should be the last position written in step 604. For example, for source vertex 0, positions 0-1 are written into destination vector 580, where the last position written is 1. Therefore, step 605 stores 1 into source vector 570 at the same offset (offset 0) as assigned to vertex 0.
[0145] And the next vertex 1 of the source vertex type is not a source vertex for any edge of the edge type. In other words, none of the edges of the edge type originate from vertex 1. Therefore, step 604 does not record anything into the destination vector 580 of vertex 1. Therefore, the last write position within the destination vector 580 is the same for vertices 0-1. Therefore, step 605 writes the same value 1 into the source vector 570, but at the offset assigned to vertex 1 (which is 1).
[0146] After step 605, the filling of endpoint vectors 570 and 580 is completed. Source vector 570 has as many values as vertices of the source vertex type of the edge type. By design and without further sorting, the values in source vector 570 are sorted by source vertex and monotonically increasing.
[0147] 7.3 Performance Improvements
[0148] Destination vector 580 has as many values as there are edges of edge type. By design and without further sorting, the values in destination vector 580 are also sorted according to the source vertex. However, these values (e.g., 1, 2, 0, 1, 2 as shown) are obviously not in natural order. As shown, the edges are recorded in destination vector 580 with their natural ordering 0-4. The efficiency of these special orderings of the contents of endpoint vectors 570 and 580 is shown in step 606 as follows.
[0149] Graph usage occurs during step 606. For example, edges may be traversed. As described above, traversal is accelerated due to the simplified storage format. Random access for traversing an edge (such as for probing during a depth-first search) or traversing many edges (such as for reaching adjacent vertices during a breadth-first search) is accelerated. For example, computer 500 may receive and execute a query for graph 560 to find a multi-edge path or subgraph based on the types and properties of the edges and adjacent vertices.
[0150] For example, source vertex 2 generates edges 2-4. Endpoint vectors 570 and 580 can be used for fast traversal of these edges during step 606 as follows. The offset assigned to vertex 2 during step 601 is 2. The value at offset 2 in source vector 570 is 4, where the previous value at offset 1 in source vector 570 is 1. Four minus one equals three. Therefore, vertex 2 generates three directed edges, which are recorded in destination vector 580 after (i.e., excluding) offset 1 and up to (i.e., including) offset 4, because values 1 and 4 are stored continuously in source vector 570. Excluding one to including four is the same as including two to four. Therefore, the three edges originating from vertex 2 are recorded at offsets 2-4 in destination vector 580, and offsets 2-4 store values 0, 1, 2, which are the identification offsets assigned to destination vertex 0-2 in step 601. Therefore, destination vertex 0-2 becomes a direct neighbor of source vertex 2 through an edge of a given edge type.
[0151] Because each edge type has its own source vector and destination vector, filtering and / or traversal by edge type requires minimal data access and maximum data locality, thereby improving efficient reading of graph 560. If the property vector has an edge ordering that matches the ordering of destination vector 580, then edge properties stored in the property vector can be efficiently accessed randomly or sequentially during edge traversal or iteration.
[0152] Endpoint vectors 570 and 580 together implement a compressed sparse row (CSR) encoding of the topology (i.e., edges) of graph 560, which is efficient in space and time for traversal and filtering of edges. In an embodiment, the vertex offsets recorded in endpoint vectors 570 and / or 580 are packed bitwise or bytewise (i.e., without byte alignment or word alignment, respectively, to increase density). However, CSR adjustments may be inefficient, such as in cases where the topology of graph 560 evolves by adding or removing edges. Therefore, in an embodiment, endpoint vectors 570 and 580 may be made read-only. While read-only endpoint vectors may more or less prevent topology mutations, edge property vectors are still writable so that edge property values may be changed. For example, even if the edge cannot be removed, the value of the edge's weight property may be changed. For example, the removal of an edge may be approximated by setting the edge's weight property to zero or its delete flag property to true. The edge property vectors are written to the edge property vectors in the form of a read-only byte vector. Figure 7 Further discussion in.
[0153] 8.0 Edge Feature Storage
[0154] Figure 7 is a block diagram depicting an example computer 700 in an embodiment. Computer 700 fills edge property vectors for space efficiency and accelerated access. Computer 700 may be an implementation of computer 100.
[0155] Computer 700 populates edge property vector 790 within RAM 705 based on data from instance 0-1 from data source 710 as follows. Data source 710 provides relation 720 including data fields 751-752. A separate edge of type 770 may be created for each of instances 0-1 to populate an edge table (not shown) of edge type 770. The value within field 751 of instance 0-1 is copied to offset 0-1 in vector 790 according to the same edge ordering as the edge table, which facilitates random access to vector 790 for a given edge. The offset column of vector 790 may be implicit (i.e., illustrative but not stored). Thus, edge property vector 790 need only store the values red and blue, without storing any metadata. Edges are loaded at Figure 8 Further discussion in.
[0156] 9.0 Fill Edge Features
[0157] Figure 8 is a flow chart depicting how computer 700 fills edge feature vectors for space efficiency and accelerated access in one embodiment. Figure 7 Let's discuss Figure 8 Steps 802, 804, and 806 load one property of one edge type into a property vector. This process may be repeated for other property vectors of additional properties of the edge type and for additional edge types (eg, concurrently).
[0158] Step 802 associates the data field of the relationship of the data source with the edge type and the property vector. For example, edge type 770 may become associated with an empty property vector 790 and data field 751.
[0159] For each instance of a relation (such as Figure 7 0-1) repeat steps 804 and 806. The prerequisite for step 804 is to complete at least Figure 6 Step 603. In an embodiment, Figure 5-6 The loading of all graphs (i.e., vertices and edges) of occurs before step 804. Thus, before step 804, edges (not shown) are loaded from instance 0-1 (e.g., into an edge array of edge type).
[0160] Step 804 associates the edge with an offset that is unique to the edge type, but not necessarily across all edge types. For example, the edge is stored with its offset into an edge array (not shown).
[0161] Step 806 copies the value of the data field of the relationship instance to the offset assigned to the edge in the property vector associated with the data field. For example, the red value is copied from data field 751 of instance 0 to offset 0 in edge property vector 790, because 0 is the offset assigned to the edge (not shown) generated from instance 0. For example, this edge is the first edge in the zero-based edge array of edge type 770.
[0162] 10.0 Bidirectional traversal
[0163] Fig. 9 The embodiment is described again Figure 5 1 is a block diagram of an example RAM 505. Figure 5 Edge endpoint vectors 570 and 580 are depicted, such as being optimized to access directed edges 0-4 according to their source vertices as the edges are naturally traversed in the direction of each edge. Access to a directed edge starting from its destination vertex is in the opposite direction of the edge, and additional data structures 910, 970, and 980 are required to efficiently access edges in the opposite (i.e., reverse) direction. Figure 5 and 9 The combination of enables seamless (i.e., efficient) edge access regardless of the edge direction. Fig. 9 Assuming that Figure 5 RAM 505 is filled. Figure 560 is similar to Figure 5 Compared to no change.
[0164] 10.1 Reverse endpoint vector
[0165] Reverse endpoint vectors 970 and 980 are identical to direct endpoint vectors 570 and 580, except that the semantics of the endpoints are reversed just like the edges. Fig. 9 For example, the identifier of the source vertex is recorded in the reverse destination vector 980, while the direct destination vector 580 records the identifier of the destination vertex. Similarly, the offset of the reverse source vector 970 corresponds to the destination vertex, while the offset of the direct source vector 570 corresponds to the source vertex.
[0166] The filling of the reverse data structures 910, 970 and 980 is described below for Figure 9-10 980 has an edge ordering that is incompatible with the edge array and the edge property vector. Therefore, accessing edges (e.g., edge properties) through reverse destination vector 980 may require converting edge offsets from the reverse ordering to the direct ordering. Mapping 910 implements this conversion and is described below with respect to Figure 9-10 Have a discussion.
[0167] 11.0 Example Reverse Encoding Processing
[0168] Fig.10 is a flowchart depicting an embodiment in which computer 500 encodes directed edges of a graph in a compressed sparse row (CSR) format for space efficiency and accelerated backward (ie, opposite to the natural direction of the directed edges) traversal. Figure 5 and Fig. 9 Let's discuss Fig.10 . Fig.10 The process depicted in reverse encodes edges of one edge type and can be repeated for each additional edge type.
[0169] Step 1002 associates the edge type with a unique reverse source vector and a unique reverse destination vector. For example, empty reverse endpoint vectors 970 and 980 are created in RAM 505.
[0170] Repeat steps 1004 and 1006 for each vertex of the source vertex type of the edge type (such as 0-2). The prerequisite for step 1004 is to complete at least Figure 6 Step 603. In an embodiment, Figure 5-6 All graph (i.e., vertices and edges) loading of occurs before step 1004. Thus, edges 0-4 are loaded before step 1004 (e.g., loaded into an edge array of the edge type).
[0171] The reverse encoding and special ordering of the edges within vectors 970 and 980 is accomplished as follows by steps 1004 and 1006. Steps 1004 and 1006 are repeated for each vertex of the destination vertex type of the edge type. Step 1004 is repeated for each edge of the edge type that has the vertex as a source vertex. In other words, step 1004 is repeated for each edge of the edge type that terminates at the vertex.
[0172] For example, vertex 0 is the destination vertex of edge 2. Although edge 0-1 has the same edge type and is also connected to vertex 0, the destination vertex of edge 0-1 is not vertex 0. Edge 2 connects destination vertex 0 to source vertex 2.
[0173] 11.1 Reverse Destination Vector
[0174] In the next sequential (ie, empty) position in the reverse destination vector for the edge type, step 1004 stores Figure 6 601 of the source vertex. For example, vertex 2 is stored at zero-based offset 2 of a vertex array (not shown) of type vertex. For edge 4, step 1004 appends two to the empty reverse destination vector 980. Because reverse destination vector 980 is empty, the value 2 is appended (i.e., stored) at position zero of reverse destination vector 980.
[0175] Edges of the same destination vertex of the edge type are recorded consecutively in the reverse destination vector 980, after which step 1004 is repeated for the next vertex of the same destination vertex type. The next destination vertex may appear during a sequential iteration of the vertex array (not shown) of the vertex type. Therefore, the contents of the reverse destination vector 980 are implicitly ordered by the destination vertex.
[0176] 11.2 Reverse Source Vector
[0177] Step 1006 stores the following into the reverse source vector of the edge type Figure 6 The last position in the reverse destination vector that contains a unique offset of the source vertex of the directed edge with that vertex as the destination vertex is written at the same offset assigned to the destination vertex in step 601 of 1004. This last position should be the last position written in step 1004. For example, for destination vertex 0, only position 0 is written into reverse destination vector 980, and the last position written is 0. Therefore, step 1006 stores 0 into reverse source vector 970 at the same offset (offset 0) as assigned to vertex 0.
[0178] After step 1006, the population of reverse endpoint vectors 970 and 980 is complete. Reverse source vector 970 has as many values as vertices of the edge type destination vertex type. By design and without further sorting, the values in reverse source vector 570 are sorted by destination vertex and monotonically increasing.
[0179] 11.3 Edge Offset Conversion
[0180] As for Figure 6 As explained, edge iteration and edge property filtering can share the same edge index and occur in a single pass, thereby speeding up queries that traverse the edges in their natural direction just as for the direct destination vector 580. However, the edge ordering 950 is different from the edge ordering of the direct destination vector 680 and the edge property array of the edge type. The offset conversion map 910 is needed to take the offset positions 0-4 of the reverse destination vector 980 and convert them into the assigned edge index for use with the edge array and edge property vector for the edge type.
[0181] In an embodiment lacking mapping 910, step 1008 is not performed. Step 1008 creates and populates offset conversion mapping 910. For each edge of the edge type, step 1008 stores the position of the edge within the direct destination vector into the edge mapping array in the same edge order as the reverse destination vector. For example, edge 2 is the first / only edge of the edge type, and its vertex 0 is the destination vertex. Edge 2 has vertex 2 as its source vertex. Therefore, two is recorded in offset 0 of reverse destination vector 980. Each implicit (i.e., illustrative but not actually stored) column 920 can use offset 0 as an index into mapping 910. Therefore, the first row of actual data in mapping 910 is for edge 2, as indicated by column 930, which is the only column that needs to be actually stored for mapping 910.
[0182] 12.0 Undirected Arc
[0183] Fig.11 1 is a block diagram depicting an example RAM 1105 in an embodiment. RAM 1105 contains endpoint vectors for undirected arcs, which are not directed edges. Like directed edges, undirected arcs have types and connect vertices of one type to vertices of another type. However, because arcs lack direction, none of the vertex types are considered sources or destinations. The computer of RAM 1105 may be an embodiment of computer 100.
[0184] The heterogeneous graph 1160 contains various types of undirected arcs and directed edges, including driving edge types, collaboration arc types, and co-location arc types. The driving directed edge E-0 indicates that person P-0 is the driver of car C-0. A person can drive a car, but cannot drive a person. Therefore, due to the semantics (e.g., schema) of the graph 1160, it is necessary to direct the driving edge type.
[0185] Collaboration arc A-0 indicates that persons P-1 and P-2 are collaborating with each other. Collaboration has no concept of direction. Therefore, due to the semantics of graph 1160, the collaboration arc type must be undirected. Co-location arc L-0 is also undirected and indicates that person P-1 and car C-0 are at the same spatial location (not shown).
[0186] Each instance of a connection (i.e., edge or arc) type of the graph 1160 has enough endpoint vectors to enable bidirectional (e.g., direct and reverse) access. For example, the driving edge type has a direct source vector and destination vector (not shown) and a reverse source vector and destination vector (not shown), for a total of four endpoint vectors for bidirectional access.
[0187] Similarly, the co-located arc type has a similar set of four endpoint vectors 1171-1172 and 1181-1182 for bidirectional access, but because arcs are naturally undirected, the concept of comparative semantics of source and destination is missing. Therefore, while vectors 1171 and 1181 work together as a pair, and vectors 1172 and 1182 work together as another pair, it is not logically defined which pair is direct and which pair is reverse. However, in practice, one of the vector pairs may have the same arc ordering as the arc array (not shown) of the co-located arc type. The vector pair may be direct vectors, while the other pair may be reverse vectors. Although not shown, the co-located arc type may have a conversion mapping for use with reverse pairs, such as for Fig. 9 as described.
[0188] 12.1 Arcs with Homogeneous Endpoints
[0189] When the two endpoint vertices of the undirected arc type have the same vertex type, bidirectional arc access can be achieved using only a pair of endpoint vectors and without using a conversion map as follows. For example, the collaboration arc type connects two people, such as people P-0 and P-1 connected by collaboration arc A-0. In this case, endpoint vectors 1175 and 1185 are sufficient for bidirectional access to the collaboration arc. Different from endpoint vectors 1171-1172 and 1181-1182, each of which has one value (shown as dark) for each undirected arc, each of the endpoint vectors in endpoint vectors 1175 and 1185 has two values (shown as dark) for each undirected arc.
[0190] Legend 1110 indicates that only the dark values of endpoint vectors 1171-1172, 1175, 1181-1182, and 1185 have actual data. The bright values in the endpoint vectors indicate implicit data that is not actually stored, but is offset into these endpoint vectors. For collaboration arc A-0, bidirectional access occurs as follows. If exploring from person P-0, then the dark columns on the left of collaboration source vector 1175 are used. If exploring from person P-1, then the dark columns on the right are used. Figure 11-12 To describe the filling of endpoint vectors 1171-1172 and 1181-1182.
[0191] 13.0 Bidirectional encoding of arcs with homogeneous endpoints
[0192] Fig.12 is a flow chart depicting an example process for bidirectionally encoding undirected arcs with homogeneous endpoints in accordance with an embodiment. Fig.11 Let's discuss Fig.12 . Fig.11 The process depicted in encodes arcs of the same arc type and may be repeated for each additional type of undirected arc with homogeneous endpoints.
[0193] 13.1 Forward Coding
[0194] Step 1202 more or less loads edges, vertices and features, such as Figure 5-6 For example, RAM 1105 may be loaded as an embodiment of RAM 505. Step 1202 also loads undirected arcs (such as co-located arcs) connecting two different vertex types into vector endpoint vectors 1171-1172 and 1181-1182. Loading undirected arcs connecting two different vertex types may require filling in reverse endpoint vectors (such as Figure 9-10 As shown, including mapping 910).
[0195] However, undirected arcs with homogeneous endpoints (i.e., arc types with the same vertex type for both endpoints) require special loading as follows. In step 1202, no undirected arcs with homogeneous endpoints are created. Figure 9-10 1175-1185. The reverse endpoint vectors and mapping 910 in . Instead, step 1202 loads the endpoint vectors in only one direction for undirected arcs with homogeneous endpoints, and later fills in the other direction in steps 1204 and 1206. For example, step 1202 fills in the left (i.e., offset 0) column of endpoint vectors 1175-1185. Support for bidirectional traversal of arc types with homogeneous endpoints (such as collaboration arcs) is performed as follows during steps 1204 and 1206.
[0196] 13.2 Backward Coding
[0197] In step 1204, for each arc of a given arc type, a unique offset of the source vertex is stored into the destination vector of the arc type. For this arc, during step 1202, the offset of the destination vertex was already stored into the destination vector. For example, collaboration arc A-0 is stored as a traversal from person P-1 to person P-0. Step 1204 instead records the source vertex into the destination vector. For example, during step 1204, the second column (i.e., offset 1) of collaboration destination vector 1185 stores a value of 1 to indicate that collaboration arc A-0 can be traversed in the reverse direction from person P-0 to person P-1.
[0198] In step 1206, for each vertex with a particular source vertex type, the computer stores the following at the unique offset of the vertex in the source vector: the last position in the destination vector that contains the unique offset of the source vertex of an undirected arc with that vertex as the destination vertex. For example, the last position in the collaboration destination vector 1185 that was written (during step 1204) was offset 1. Therefore, step 1206 stores 1 in the value of the second column of the collaboration source vector 1175. Therefore, the endpoint vectors 1175 and 1185 shown in the figure support traversal of the collaboration arc A-0 in either direction. After step 1206, the bidirectional storage of undirected arcs with homogeneous endpoint types is completed, at which time the endpoint vectors 1175 and 1185 can optionally become read-only.
[0199] 14.0 Hardware Overview
[0200] According to one embodiment, the technology described herein is implemented by one or more special-purpose computing devices. The special-purpose computing device can be hard-wired to perform these technologies, or can include digital electronic devices (such as one or more application-specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs) that are permanently programmed to perform these technologies), or can include one or more general-purpose hardware processors that are programmed to perform these technologies according to program instructions in firmware, memory, other storage devices, or combinations. Such special-purpose computing devices can also combine customized hard-wired logic, ASICs, or FPGAs with customized programming to implement these technologies. The special-purpose computing device can be a desktop computer system, a portable computer system, a handheld device, a networking device, or any other device that combines hard-wiring and / or program logic to implement these technologies.
[0201] For example, Fig.13 1 is a block diagram illustrating a computer system 1300 upon which embodiments of the present invention may be implemented. Computer system 1300 includes a bus 1302 or other communication mechanism for communicating information, and a hardware processor 1304 coupled to bus 1302 for processing information. Hardware processor 1304 may be, for example, a general purpose microprocessor.
[0202] The computer system 1300 also includes a main memory 1306, such as a random access memory (RAM) or other dynamic storage device, coupled to the bus 1302 for storing information and instructions to be executed by the processor 1304. The main memory 1306 may also be used to store temporary variables or other intermediate information during the execution of instructions executed by the processor 1304. When stored in a non-transitory storage medium accessible to the processor 1304, these instructions cause the computer system 1300 to become a special-purpose machine customized to perform the operations specified in the instructions.
[0203] Computer system 1300 also includes a read only memory (ROM) 1308 or other static storage device coupled to bus 1302 for storing static information and instructions for processor 1304. A storage device 136, such as a magnetic or optical disk, is provided and coupled to bus 1302 for storing information and instructions.
[0204] The computer system 1300 may be coupled via the bus 1302 to a display 1312, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 1314, including alphanumeric and other keys, is coupled to the bus 1302 for communicating information and command selections to the processor 1304. Another type of user input device is a cursor control 1316, such as a mouse, trackball, or cursor direction keys, for communicating direction information and command selections to the processor 1304 and for controlling cursor movement on the display 1312. Such input devices typically have two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), which allows the device to specify a position in a plane.
[0205] Computer system 1300 may implement the techniques described herein using custom hardwired logic, one or more ASICs or FPGAs, firmware, and / or program logic that is combined with a computer system to make or program computer system 1300 into a special purpose machine. According to one embodiment, computer system 1300 performs the techniques described herein in response to processor 1304 executing one or more sequences of one or more instructions contained in main memory 1306. These instructions may be read into main memory 1306 from another storage medium, such as storage device 136. Execution of the sequences of instructions contained in main memory 1306 causes processor 1304 to perform the process steps described herein. In alternative embodiments, hardwired circuitry may be used in place of or in combination with software instructions.
[0206] The term "storage medium" as used herein refers to any non-transient medium that stores data and / or instructions that cause a machine to operate in a particular manner. Such storage media may include non-volatile media and / or volatile media. Non-volatile media include, for example, optical or magnetic disks, such as storage device 136. Volatile media include dynamic memory, such as main memory 1306. Common forms of storage media include, for example, floppy disks, flexible disks, hard disks, solid-state drives, magnetic tapes or any other magnetic data storage media, CD-ROMs, any other optical data storage media, any physical media with a pattern of holes, RAM, PROMs and EPROMs, FLASH-EPROMs, NVRAMs, any other memory chips, or cassette tapes.
[0207] Storage media are distinct from but can be used in conjunction with transmission media. Transmission media participate in the transfer of information between storage media. For example, transmission media include coaxial cables, copper wire, and optical fiber, including the wires that comprise bus 1302. Transmission media can also take the form of acoustic or light waves, such as those generated during radio wave and infrared data communications.
[0208] Various forms of media may be involved in carrying one or more sequences of one or more instructions to processor 1304 for execution. For example, the instructions may initially be carried on a disk or solid-state drive of a remote computer. The remote computer may load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 1300 may receive the data on the telephone line and use an infrared transmitter to convert the data to an infrared signal. An infrared detector may receive the data carried in the infrared signal and appropriate circuitry may place the data on bus 1302. Bus 1302 carries the data to main memory 1306, from which processor 1304 retrieves and executes the instructions. The instructions received by main memory 1306 may optionally be stored on storage device 136 before or after execution by processor 1304.
[0209] The computer system 1300 also includes a communication interface 1318 coupled to the bus 1302. The communication interface 1318 provides a two-way data communication coupled to a network link 1320, wherein the network link 1320 is connected to a local network 1322. For example, the communication interface 1318 can be an integrated services digital network (ISDN) card, a cable modem, a satellite modem, or a modem that provides a data communication connection with a corresponding type of telephone line. As another example, the communication interface 1318 can be a local area network (LAN) card to provide a data communication connection with a compatible LAN. A wireless link can also be implemented. In any such implementation, the communication interface 1318 sends and receives electrical signals, electromagnetic signals, or optical signals that carry digital data streams representing various types of information.
[0210] The network link 1320 typically provides data communication to other data devices through one or more networks. For example, the network link 1320 can provide a connection through the local network 1322 to a host computer 1324 or to data equipment operated by an Internet Service Provider (ISP) 1326. The ISP 1326 in turn provides data communication services through the global packet data communication network, now commonly referred to as the "Internet" 1328. Both the local network 1322 and the Internet 1328 use electrical, electromagnetic, or optical signals that carry digital data streams. The signals through the various networks and the signals on the network link 1320 and through the communication interface 1318, which carry the digital data to and from the computer system 1300, are example forms of transmission media.
[0211] Computer system 1300 can send messages and receive data, including program code, through the network(s), network link 1320, and communication interface 1318. In the Internet example, server 1330 can send the requested code for an application program through Internet 1328, ISP 1326, local network 1322, and communication interface 1318.
[0212] The received code may be executed by processor 1304 as it is received, and / or stored in storage device 136 or other non-volatile storage for later execution.
[0213] 15.0 Software Overview
[0214] Fig.14 1 is a block diagram of a basic software system 1400 that may be used to control the operation of computer system 1300. Software system 1400 and its components (including their connections, relationships, and functions) are meant to be exemplary only and are not meant to limit implementation of the example embodiment(s). Other software systems suitable for implementing the example embodiment(s) may have different components, including components with different connections, relationships, and functions.
[0215] Software system 1400 is provided for directing the operation of computer system 1300. Software system 1400, which may be stored on system memory (RAM) 1306 and fixed storage (eg, hard disk or flash memory) 136, includes a kernel or operating system (OS) 1410.
[0216] The OS 1410 manages low-level aspects of computer operation, including managing the execution of processes, memory allocation, file input and output (I / O), and device I / O. One or more applications, represented as 1402A, 1402B, 1402C ... 1402N, may be "loaded" (e.g., transferred from fixed storage 136 into memory 1306) for execution by the system 1400. Applications or other software intended for use on the computer system 1300 may also be stored as a downloadable set of computer-executable instructions, for example, for downloading and installation from an Internet location (e.g., a Web server, application (app) store, or other online service).
[0217] The software system 1400 includes a graphical user interface (GUI) 1415 for receiving user commands and data in a graphical (e.g., "click" or "touch gesture") manner. In turn, these inputs can be operated by the system 1400 according to instructions from the operating system 1410 and / or (one or more) applications 1402. The GUI 1415 is also used to display the results of operations from the OS 1410 and (one or more) applications 1402, so that the user can provide additional input or terminate the session (e.g., log off).
[0218] The OS 1410 may execute directly on the bare hardware 1420 (e.g., processor(s) 1304) of the computer system 1300. Alternatively, a hypervisor or virtual machine monitor (VMM) 1430 may be inserted between the bare hardware 1420 and the OS 1410. In this configuration, the VMM 1430 acts as a software "buffer" or virtualization layer between the OS 1410 and the bare hardware 1420 of the computer system 1300.
[0219] VMM 1430 instantiates and runs one or more virtual machine instances ("clients"). Each client includes a "client" operating system (such as OS 1410), and one or more applications (such as (one or more) applications 1402) designed to execute on the client operating system. VMM 1430 presents a virtual operating platform to the client operating system and manages the execution of the client operating system.
[0220] In some instances, VMM 1430 can allow a guest operating system to run as if it were running directly on bare hardware 1420 of computer system 1300. In these instances, the same version of a guest operating system that is configured to execute directly on bare hardware 1420 can also execute on VMM 1430 without modification or reconfiguration. In other words, VMM 1430 can provide full hardware and CPU virtualization to guest operating systems in some cases.
[0221] In other instances, the guest operating system may be specially designed or configured to execute on VMM 1430 to improve efficiency. In these instances, the guest operating system is "aware" that it is executing on a virtual machine monitor. In other words, VMM 1430 may provide paravirtualization to the guest operating system in some cases.
[0222] A computer system process includes an allocation of hardware processor time and an allocation of memory (physical and / or virtual) for storing instructions executed by the hardware processor, for storing data generated by the execution of instructions by the hardware processor, and / or for storing hardware processor state (e.g., contents of registers) between allocations of hardware processor time when the computer system process is not running. A computer system process runs under the control of an operating system and may run under the control of other programs executing on the computer system.
[0223] 16.0 Cloud Computing
[0224] The term "cloud computing" is used generally herein to describe a computing model that enables on-demand access to a shared pool of computing resources, such as computer networks, servers, software applications, and services, and allows resources to be rapidly provisioned and released with minimal management effort or service provider interaction.
[0225] A cloud computing environment (sometimes referred to as a cloud environment or just a cloud) can be implemented in a variety of different ways to best suit different requirements. For example, in a public cloud environment, the underlying computing infrastructure is owned by an organization that makes its cloud services available to other organizations or the public. In contrast, a private cloud environment is generally intended for use by or within a single organization. A community cloud is intended to be shared by several organizations within a community; while a hybrid cloud includes two or more types of clouds (e.g., private, community, or public) bound together by data and application portability.
[0226] In general, the cloud computing model enables some of those responsibilities that might previously have been provided by an organization's own information technology department to instead be delivered as a service layer within a cloud environment for use by consumers (either internally or externally to the organization, depending on the public / private nature of the cloud). Depending on the specific implementation, the precise definition of the components or features provided by or within each cloud service layer may vary, but common examples include: Software as a Service (SaaS), where consumers use software applications running on a cloud infrastructure, while the SaaS provider manages or controls the underlying cloud infrastructure and applications. Platform as a Service (PaaS), where consumers can use software programming languages and development tools supported by the PaaS provider to develop, deploy, and otherwise control their own applications, while the PaaS provider manages or controls other aspects of the cloud environment (i.e., everything in the runtime execution environment). Infrastructure as a Service (IaaS), where consumers can deploy and run arbitrary software applications and / or provision processes, storage, networks, and other basic computing resources, while the IaaS provider manages or controls the underlying physical cloud infrastructure (i.e., everything below the operating system layer). Database as a Service (DBaaS), where the consumer uses a database server or database management system running on a cloud infrastructure, while the DbaaS provider manages or controls the underlying cloud infrastructure and applications.
[0227] The above basic computer hardware and software and cloud computing environment are presented to illustrate the basic underlying computer components that can be used to implement the example embodiment(s). However, the example embodiment(s) are not necessarily limited to any particular computing environment or computing device configuration. Instead, the example embodiment(s) can be implemented in any type of system architecture or processing environment that a person skilled in the art would understand in light of the present disclosure as being capable of supporting the features and functions of the example embodiment(s) presented herein.
[0228] In the foregoing specification, embodiments of the present invention have been described with reference to many specific details, which may vary from implementation to implementation. Therefore, the description and drawings should be viewed in an illustrative rather than a restrictive sense. The sole and exclusive indicator of the scope of the invention and what the applicant intends to be the scope of the invention is the literal and equivalent range of the resulting claims in the specific form of the set of claims issued from this application, including any subsequent corrections.
Claims
1. A method executed by one or more computers for providing and using an in-memory representation of a graph, the method comprising: creating the in-memory representation of the graph based on data from one or more data sources, wherein the data provides records for vertices and a plurality of relationships in the graph; wherein creating the in-memory representation of the graph comprises: associating each vertex provided by the record with an offset unique to the type of each vertex; For each relationship in the plurality of relationships, wherein the relationship includes a plurality of instances providing data for a corresponding plurality of directed edges having a unique edge type in the plurality of edge types and connecting a source vertex of a particular source vertex type to a destination vertex of a particular destination vertex type: associating each of the relationships with: a unique edge type, a unique source vector, and a unique destination vertex vector corresponding to each of the relationships; For each of the plurality of instances of the each relationship, creating a directed edge of a unique edge type corresponding to the each relationship, wherein the directed edge includes a source vertex and a destination vertex; and For each vertex of a specific source vertex type: for each undirected edge of a unique edge type having each source vertex as its source vertex, storing an offset associated with a destination vertex of each directed edge in a unique destination vector; and storing a last position within the unique destination vector into the unique source vector at an offset associated with the each source vertex, the last position comprising an offset associated with a destination vertex of a directed edge having the each source vertex as its source vertex; The graph is read by accessing a unique source vector for a relationship of a unique edge type and / or a unique destination vector for the relationship.
2. The method of claim 1, further comprising: Associating data fields of a relationship of a data source with: a specific edge type and an edge property vector; For each instance of a relation: Associating a unique directed edge with an offset that is unique to the particular edge type; as well as The value of the data field from the instance is stored at the offset of the unique directed edge in the edge property vector.
3. The method of claim 1, wherein the contents of the unique source vector or the unique destination vector are not word aligned.
4. The method of claim 1, wherein the contents of the unique source vector or the unique destination vector are bit packed.
5. The method of claim 1 further comprising, for each unique edge type of the graph: associating the unique edge type with: a unique reverse source vector and a unique reverse destination vector; For each destination vertex of a specific destination vertex type: for each directed edge of the unique edge type having the each destination vertex as its destination vertex, storing in the unique reverse destination vector a value of an offset associated with a source vertex of the each directed edge; as well as A last position within the unique reverse destination vector that contains an offset of a source vertex having each destination vertex as its destination vertex is stored in the unique reverse source vector at the offset associated with each destination vertex.
6. The method of claim 5 further comprising, for each edge type of the graph: associating the edge type with an array of unique edge mappings; For each edge of the edge type, the position of the directed edge within the unique destination vector is stored in the unique edge mapping array in the same edge ordering as the unique reverse destination vector.
7. A method executed by one or more computers for providing and using an in-memory representation of a graph, the method comprising: creating the in-memory representation of the graph based on data from one or more data sources, wherein the data provides records for vertices and a plurality of relationships in the graph; wherein creating the in-memory representation of the graph comprises: associating each vertex provided by the record with an offset unique to the type of each vertex; For each relationship in the plurality of relationships, wherein the relationship includes a plurality of instances that provide data for a corresponding plurality of undirected arcs having a unique arc type in a plurality of arc types and connecting a first vertex of a particular first vertex type to a second vertex of a particular second vertex type: associating each of the relations with the following objects: a unique arc type, a unique first vector, and a unique second vector corresponding to each of the relations; For each of the plurality of instances of the each relationship, creating an undirected arc of a unique arc type corresponding to the each relationship, wherein the undirected arc includes a first vertex and a second vertex; and For each vertex of a specific first vertex type: For each undirected arc of a unique arc type having each vertex as its first vertex, storing an offset associated with a second vertex of the undirected arc in a unique second vector; and storing a last position within the unique second vector into the unique first vector at an offset associated with the each vertex, the last position comprising an offset associated with a second vertex of an undirected arc having the each vertex as its first vertex; The graph is read by accessing a unique first vector of a relationship of a unique arc type and / or a unique second vector of the relationship.
8. The method of claim 7, wherein: The specific first vertex type is the specific second vertex type; The method further comprises: For each undirected arc of the unique arc type, storing a value of an offset associated with the first vertex in the unique second vector; and For each vertex of the particular first vertex type of the graph, at the offset associated with the each vertex, the last position within the unique second vector containing the offset associated with the first vertex of an undirected arc having the each vertex as its second vertex is stored in the unique first vector.
9. The method of claim 7, wherein creating the in-memory representation of the graph further comprises: For each record type in a plurality of record types from the one or more data sources: Associating the record type with a corresponding unique vertex type; for each data field in a plurality of data fields in the record type, associating the data field with: a corresponding unique vertex type and a corresponding vertex property vector; and For each of the multiple records of the record type: creating vertices representing said records as instances of said unique vertex type for each said record type; as well as for each data field of the plurality of data fields, storing a value of the data field from the record in a vertex property vector associated with the data field at a unique offset for the unique vertex; Wherein reading the graph further comprises accessing vertex property vectors of unique vertex types.
10. The method of claim 9, wherein the reading comprises performing a query on the graph by: detecting one or more vertex types relevant to the query; and Unless a particular record type is associated with a vertex type in the one or more vertex types, a vertex property vector of a data field of the particular record type is not accessed.
11. The method of claim 9, wherein: The method further includes associating the unique vertex type with a plurality of unique edge types; Reading the graph includes reading at least one instance of at least one edge type of the plurality of unique edge types.
12. The method of claim 9, further comprising: assigning a unique serial number to the unique vertex type; A particular vertex that is an instance of a particular vertex type is identified by an identification pair comprising: a unique serial number of the particular vertex type, and the unique offset of the particular vertex.
13. The method of claim 12, wherein the identification pair comprises a maximum of 128 bits.
14. The method of claim 12, wherein the identification pair comprises a maximum of 64 bits.
15. The method of claim 12, wherein a unique serial number for a particular vertex type and the unique offset for a particular vertex are bit packed within the identification pair.
16. The method of claim 9, wherein: The one or more data sources include a relational database; Record types include tables in a relational database; Records consist of rows in a table; Data fields comprise the columns in a table.
17. One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to perform the method of any one of claims 1-8.
18. One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to perform the method of any one of claims 9-16.
19. A system for providing and using an in-memory representation of a graph, comprising: processor; as well as A memory coupled to the processor and having instructions stored thereon, which, when executed by the processor, cause the processor to perform the method of any one of claims 1-8.
20. A system for providing and using an in-memory representation of a graph, comprising: processor; as well as A memory coupled to the processor and having instructions stored thereon, which, when executed by the processor, cause the processor to perform the method of any one of claims 9-16.
21. An apparatus comprising means for performing the method of any one of claims 1-8.
22. An apparatus comprising means for performing the method of any one of claims 9 to 16.
