# US 2021/0286790 A1 · Fast in-memory technique to build a reverse csr graph index in an rdbms

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0286790 A1
- Document ID: US20210286790A1
- Status: Published application
- Kind: A1
- Application number: 16/816,686
- Filed: 2020-03-12
- Published: 2021-09-16
- Earliest claimed: 2020-03-12
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Jean-Pierre Lozi; Marco Arnaboldi; Laurent Phillipe Daynes; Vlad Ioan Haprian; Hugo Kapp
- Web page: https://patentgrep.com/patent/US20210286790A1

## CPC

- G06F 16/2237: {Vectors, bitmaps or matrices}
- G06F 16/9024: {Graphs; Linked lists (G06F16/9027 takes precedence)}
- G06F 16/212: {with details for data modelling support}
- G06F 17/10: Complex mathematical operations {(function generation by table look-up G06F1/03; evaluation of elementary functions by calculation G06F7/544)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In an embodiment, a computer obtains a mapping of a relational schema of a database to a graph data model. The relational schema identifies vertex table(s) that correspond to vertex type(s) in the graph data model and edge table(s) that correspond to edge type(s) in the graph data model. Each edge type is associated with a source vertex type and a target vertex type. Based on that mapping, a forward compressed sparse row (CSR) representation is populated for forward traversal of edges of a same edge type. Each edge originates at a source vertex and terminates at a target vertex. Based on the forward CSR representation, a reverse CSR representation of the edge type is populated for reverse traversal of the edges of the edge type. Acceleration occurs in two ways. Values calculated for the forward CSR are reused for the reverse CSR. Elastic and inelastic scaling may occur.

## Claims

### Claim 1

A method comprising:
obtaining a mapping of a relational schema of a database to a graph data model, wherein:
the relational schema identifies one or more vertex tables that correspond to one or more respective vertex types in the graph data model and one or more edge tables that correspond to one or more respective edge types in the graph data model, and
each edge type in the one or more edge types is associated with a respective source vertex type of the one or more vertex types and a respective target vertex type of the one or more vertex types;
populating, based on said mapping, a forward compressed sparse row (CSR) representation for forward traversal of edges of an edge type of the one or more edge types, wherein each edge of the edge type:
originates at a source vertex of the source vertex type of the edge type, and terminates at a target vertex of the target vertex type of the edge type;
populating, based on the forward CSR representation, a reverse CSR representation of the edge type for reverse traversal of the edges of the edge type.

### Claim 2 (depends on 1)

The method of claim 1 wherein:
said populating the forward CSR representation is further based on:
the vertex table that corresponds to the source vertex type of the edge type,
the vertex table that corresponds to the target vertex type of the edge type, and
the edge table that corresponds to the edge type;
said populating the reverse CSR representation does not comprise:
input/output (I/O), nor
accessing:
the vertex table that corresponds to the source vertex type of the edge type,
the vertex table that corresponds to the target vertex type of the edge type, nor
the edge table that corresponds to the edge type.

### Claim 3 (depends on 1)

The method of claim 1 wherein:
the forward CSR representation comprises:
a forward destination array that indicates which vertices of the target vertex type of the edge type terminate which respective edges of the edge type, and
a forward source array that indicates a respective forward range of offsets into the forward destination array for each vertex of the source vertex type of the edge type;
the reverse CSR representation comprises:
a reverse source array that indicates which vertices of the source vertex type of the edge type originate which respective edges of the edge type, and
a reverse destination array that indicates a respective reverse range of offsets into the reverse source array for each vertex of the target vertex type of the edge type.

### Claim 4 (depends on 3)

The method of claim 3 wherein:
said populating the reverse CSR representation comprises counting respective edges of the edge type that terminate at each vertex of the target vertex type of the edge type;
said counting edges of the edge type that terminate at each vertex of the target vertex type of the edge type comprises either of:
scanning the forward destination array, or
while populating the forward destination array for each edge of the edge type,
incrementing a respective counter for the target vertex that terminates the edge.

### Claim 5 (depends on 4)

The method of claim 4 wherein:
the reverse destination array is initially filled with zeros;
said counter for the vertex that terminates the edge comprises a respective element of the reverse destination array for the vertex.

### Claim 6 (depends on 5)

The method of claim 5 wherein said counting edges that terminate at each vertex comprises concurrently processing at least two edges.

### Claim 7 (depends on 6)

The method of claim 6 wherein:
said at least two edges terminate at a same target vertex;
said concurrently processing said at least two edges comprises an atomic operation that increments said counter for said same target vertex.

### Claim 8 (depends on 5)

The method of claim 5 wherein:
one or more arrays are processed as multiple chunks;
each chunk of the multiple chunks contains multiple elements;
the one or more arrays comprise: the forward destination array, the forward source array, the reverse destination array, and/or the reverse source array.

### Claim 9 (depends on 8)

The method of claim 8 wherein:
the method further comprises replacing a respective old value of each element of each chunk of the reverse destination array with a respective new value;
when said element is the first element in the chunk, the new value is zero;
otherwise, the new value is a sum of the old value of the preceding element of the chunk plus the new value of said preceding element.

### Claim 10 (depends on 9)

The method of claim 9 wherein said replacing the old value of each element of each chunk comprises concurrently processing at least two chunks.

### Claim 11 (depends on 9)

The method of claim 9 wherein each chunk of the reverse destination array is associated with:
a last value that is a sum of said old values of the multiple elements of the chunk, and
a chunk offset that is:
zero when the chunk is the first chunk of the reverse destination array,
said last value of said first chunk when the chunk is the second chunk of the reverse destination array,
otherwise, a sum of said last value of the previous chunk plus said chunk offset of the previous chunk.

### Claim 12 (depends on 11)

The method of claim 11 further comprising concurrently:
calculating said sum of said last value of the previous chunk plus said chunk offset of the previous chunk, and
said replacing the old value of each element of said chunk.

### Claim 13 (depends on 11)

The method of claim 11 further comprising incrementing each element of said chunk by the chunk offset of said chunk.

### Claim 14 (depends on 13)

The method of claim 13 wherein said incrementing each element of said chunk comprises concurrently incrementing multiple elements of said chunk.

### Claim 15 (depends on 14)

The method of claim 14 wherein said concurrently incrementing multiple elements of said chunk comprises single instruction multiple data (SIMD).

### Claim 16 (depends on 3)

The method of claim 3 wherein said populating the reverse CSR representation comprises for each edge of the edge type:
calculating an offset into the reverse source array by summing a value of an element of the reverse destination array that corresponds to the target vertex of the edge plus a value of a respective counter for the target vertex;
based on said offset, storing, into an element of the reverse source array:
an identifier of the edge, and/or
the offset, into the forward source array, of the source vertex of the edge.

### Claim 17 (depends on 16)

The method of claim 16 wherein the identifier of the edge is copied from the forward destination array.

### Claim 18 (depends on 16)

The method of claim 16 wherein said for each edge of the edge type comprises concurrently for at least two edges of the edge type.

### Claim 19 (depends on 18)

The method of claim 18 wherein:
said at least two edges terminate at a same vertex;
said concurrently processing said at least two edges comprises an atomic operation that increments said counter for said same vertex.

### Claim 20 (depends on 1)

The method of claim 1 further comprising populating, based on a second forward CSR representation of a second edge type of the one or more edge types, a second reverse CSR representation of the second edge type for reverse traversal of edges of the second edge type.

### Claim 21 (depends on 20)

The method of claim 20 wherein:
the forward CSR representation is a first forward CSR representation;
the reverse CSR representation is a first reverse CSR representation;
the second forward CSR representation comprises a forward destination array that contains a sparse identifier or a persistent dense identifier for each vertex of a second source vertex type of the second edge type that corresponds to a vertex table of the one or more vertex tables, and/or
the first reverse CSR representation comprises a reverse source array that contains a sparse identifier or a persistent dense identifier for each vertex of a second destination vertex type of the second edge type.

### Claim 22 (depends on 1)

The method of claim 1 wherein:
the forward CSR representation comprises a forward destination array that contains a sparse identifier or a persistent dense identifier for each vertex of the destination vertex type of the edge type, and/or
the reverse CSR representation comprises a reverse source array that contains a sparse identifier or a persistent dense identifier for each vertex of the source vertex type of the edge type.

### Claim 23

One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause:
obtaining a mapping of a relational schema of a database to a graph data model, wherein:
the relational schema identifies one or more vertex tables that correspond to one or more respective vertex types in the graph data model and one or more edge tables that correspond to one or more respective edge types in the graph data model, and
each edge type in the one or more edge types is associated with a respective source vertex type of the one or more vertex types and a respective target vertex type of the one or more vertex types;
populating, based on said mapping, a forward compressed sparse row (CSR) representation for forward traversal of edges of an edge type of the one or more edge types, wherein each edge of the edge type:
originates at a source vertex of the source vertex type of the edge type, and
terminates at a target vertex of the target vertex type of the edge type;
populating, based on the forward CSR representation, a reverse CSR representation of the edge type for reverse traversal of the edges of the edge type.
