# US 12,117,996 B2 · Schema-free static query template

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

- Number: US 12,117,996 B2
- Document ID: US12117996B2
- Status: Granted
- Kind: B2
- Application number: 18/053,832
- Filed: 2022-11-09
- Published: 2024-05-09
- Granted: 2024-10-15
- Earliest claimed: 2022-11-09
- Assignees: TigerGraph, Inc.
- Applicants: TigerGraph, Inc.
- Inventors: Yiming Pan; Mingxi Wu
- Web page: https://patentgrep.com/patent/US12117996B2

## CPC

- G06F 16/242: Query formulation
- G06F 16/213: {with details for schema evolution support}
- G06F 16/2455: Query execution
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A schema-free static query template improves schema-free graph query performance and runtime stability. A user can customize a generated graph query while detecting a query tampering state. Schema-free query templates, which have been compile-time type/syntax/semantic checked by a dummy schema, are installed. The templates are called as if they are functions with their selected graph schema vertex types and edge types. The invocation generates a static query which uses input metadata to instantiate a static query, and goes through type/syntax/semantic checks to capture any input errors at compile time. If there is no error found during compile time, a query binary is generated only containing the metadata related to the parameters and sent to a query engine for execution. If a user later invokes the same query with the same metadata, the compiler matches the generated previous query, bypasses compilation, and goes directly to the existing binary code.

## Claims

### Claim 1

A method comprising:
creating, by a query template generator executed on a computer system, a query template using a dynamic query syntax for a graph algorithm, wherein the query template is schema-free and without a query binary code;
generating at runtime, by a static query generator executed on the computer system, a static query using the query template and input metadata;
generating, by a binary code generator based on a type check or a semantic check, binary code for the static query;
generating, by a calculator executed on the computer system, a signature for the binary code of the static query, wherein the signature is representative of the input metadata and a name of the static query;
storing, by the static query generator, the query template, the signature and the binary code in a computer memory;
invoking, by a template engine executed on the computer system, the query template, wherein the invoking the query template is performed at runtime, wherein the invoking the query template comprises receiving a call from a device for creating the static query;
determining when the received call is a first time call for the creating of the static query, if the received call is the first time call, then creating the static query, and otherwise retrieving the static query from a storage by matching the signature, in response to the call, to name of the static query and input metadata; and
running, by a query engine executed on the computer system, the binary code of the static query represented by the signature to output a query result.

### Claim 2 (depends on 1)

The method of claim 1, wherein the query template uses parameters for all vertex/edge type pattern positions.

### Claim 3 (depends on 1)

The method of claim 1, further comprising using a dummy schema to check correctness of type, semantic, and syntax of the query template.

### Claim 4 (depends on 3)

The method of claim 3, wherein the dummy graph schema has the minimum information that the graph algorithm uses.

### Claim 5 (depends on 3)

The method of claim 3, further comprising validating a topology traversal, validating a read attribute of a graph element, and validating a write attribute of the graph element.

### Claim 6 (depends on 1)

The method of claim 1, further comprising sending the static query to a compiler to do the type check and the semantic check.

### Claim 7 (depends on 1)

The method of claim 1, further comprising:
generating the binary code for the query template;
calculating a hash value encoding a query name, a metadata parameter, and a query text; and
storing the hash value in a storage.

### Claim 8 (depends on 7)

The method of claim 7, further comprising:
providing a query based on the query template to a query engine; and
outputting the query result from the query engine.

### Claim 9

A system comprising:
a query template generator configured to create a query template using a dynamic query syntax for a graph algorithm, wherein the query template is schema-free and without a query binary code;
static query generator configured to generate, at runtime, a static query using the query template and input metadata;
a binary code generator configured to generate binary code for the static query based on a type check or a semantic check;
a calculator to generate a signature for the binary code of the static query, wherein the signature is representative of the input metadata and a name of the static query;
a computer memory configured to store the query template, the signature and the binary code; and
a query engine configured to:
invoke the query template, wherein the invoking the query template is performed at runtime, wherein the invoking the query template comprises receiving a call from a device for creating the static query;
determine when the received call is a first time call for the creating of the static query, and if the received call is the first time call, then creating the static query, and otherwise retrieving the static query from a storage by matching the signature, in response to the received call, to name of the static query and input metadata; and
run the binary code of the static query represented by the signature to output a query result.

### Claim 10 (depends on 9)

The system of claim 9, further comprising a query template invocation engine configured to invoke the query template.

### Claim 11 (depends on 10)

The system of claim 10, wherein invoking the query template is performed at runtime and further comprises a static query generator configured to receive a call for generating a static query and creating the static query.

### Claim 12 (depends on 11)

The system of claim 11, further comprising a compiler configured to do a type check and a semantic check on the static query.

### Claim 13 (depends on 12)

The system of claim 12, further comprising:
a binary code generator configured to generate the binary code for the query template;
a hash value calculator configured to calculate a hash value of query template name and query metadata, and static query text; and
the query engine configured to receive a query based on the query template and output the query result.

### Claim 14

A system comprising:
at least one processor; and
a non-transitory computer readable medium comprising instructions that, when executed by the at least one processor, cause the system to:
create, by a query template generator, a query template using a dynamic query syntax for a graph algorithm, wherein the query template is schema-free and without a query binary code;
generate, by a static query generator at runtime, a static query using the query template and input metadata;
generate, by a binary code generator based on a type check or a semantic check, binary code for the static query;
generate, by a calculator executed on the computer system, a signature for the binary code of the static query, wherein the signature is representative of the input metadata and a name of the static query;
store the query template, the signature and the binary code in a computer memory;
invoke, by a template engine, the query template, wherein the invoking the query template is performed at runtime, wherein the invoking the query template comprises receiving a call from a device for creating the static query;
determine when the received call is a first time call for the creating of the static query, and if the received call is the first time call, then creating the static query, and otherwise retrieving the static query from a storage by matching the signature, in response to the call, to name of the static query and input metadata; and
run, by a query engine executed on the computer system, the binary code of the static query represented by the signature to output a query result.

### Claim 15 (depends on 14)

The system of claim 14, further comprising instructions that, when executed by the at least one processor, cause the system to:
send the static query to a compiler to do the type check and the semantic check;
generate the binary code for the query template;
calculate a hash value for the query template invocation parameters;
store the hash value in a storage; and
generate and output the query result based on a query and based on the query template.
